| | |
| | | return |
| | | } |
| | | |
| | | operationInfos := make([]purchaseRes.OperationInfo, 0) |
| | | var operationInfos purchaseRes.OperationInfo |
| | | productInfos := make([]purchaseRes.ProductInfo, 0) |
| | | inWarehouseInfos := make([]purchaseRes.InWarehouseInfo, 0) |
| | | productMap := make(map[string]*purchaseRes.ProductInfo) |
| | | if len(info.Operations) > 0 { |
| | | for _, operation := range info.Operations { |
| | | var oi purchaseRes.OperationInfo |
| | | oi.Number = operation.ProductId |
| | | oi.Name = operation.ProductName |
| | | oi.OperationNumber = operation.Number |
| | | oi.Status = operation.Status |
| | | oi.Principal = data.Principal |
| | | oi.WarehouseName = data.Warehouse |
| | | var pi purchaseRes.ProductInfo |
| | | var iwi purchaseRes.InWarehouseInfo |
| | | if p, ok := productMap[operation.ProductId]; ok { |
| | | pi = *p |
| | | } |
| | | pi.Number = operation.ProductId |
| | | pi.Name = operation.ProductName |
| | | iwi.Number = operation.ProductId |
| | | iwi.Name = operation.ProductName |
| | | iwi.OperationNumber = operation.Number |
| | | iwi.Status = operation.Status |
| | | iwi.Principal = data.Principal |
| | | iwi.WarehouseName = data.Warehouse |
| | | if operation.OverTime != "" { |
| | | oi.OverTime = operation.OverTime |
| | | oi.OverAmount = operation.Amount |
| | | iwi.OverTime = operation.OverTime |
| | | iwi.OverAmount = operation.Amount |
| | | pi.OverAmount = pi.OverAmount + operation.Amount |
| | | } |
| | | for _, products := range productList { |
| | | if products.Product.Number == operation.ProductId { |
| | | oi.Amount = products.Amount |
| | | oi.PurchasePrice = products.Price |
| | | oi.Total = products.Total |
| | | oi.Unit = products.Product.Unit |
| | | oi.Specifications = products.Product.Specifications |
| | | oi.ModelNumber = products.Product.ModelNumber |
| | | pi.Amount = products.Amount |
| | | pi.PurchasePrice = products.Price |
| | | pi.Total = products.Total |
| | | pi.Unit = products.Product.Unit |
| | | pi.Specifications = products.Product.Specifications |
| | | pi.ModelNumber = products.Product.ModelNumber |
| | | break |
| | | } |
| | | } |
| | | for _, confirm := range confirmInfo { |
| | | if operation.ProductId == confirm.ProductId { |
| | | oi.SendAmount = confirm.OverReceiveAmount.IntPart() |
| | | pi.SendAmount = confirm.OverReceiveAmount.IntPart() |
| | | break |
| | | } |
| | | } |
| | | operationInfos = append(operationInfos, oi) |
| | | inWarehouseInfos = append(inWarehouseInfos, iwi) |
| | | productMap[operation.ProductId] = &pi |
| | | } |
| | | } else { |
| | | for _, products := range productList { |
| | | var oi purchaseRes.OperationInfo |
| | | oi.Number = products.Product.Number |
| | | oi.Name = products.Product.Name |
| | | oi.Amount = products.Amount |
| | | oi.PurchasePrice = products.Price |
| | | oi.Total = products.Total |
| | | oi.Unit = products.Product.Unit |
| | | oi.Specifications = products.Product.Specifications |
| | | oi.ModelNumber = products.Product.ModelNumber |
| | | var pi purchaseRes.ProductInfo |
| | | pi.Number = products.Product.Number |
| | | pi.Name = products.Product.Name |
| | | pi.Amount = products.Amount |
| | | pi.PurchasePrice = products.Price |
| | | pi.Total = products.Total |
| | | pi.Unit = products.Product.Unit |
| | | pi.Specifications = products.Product.Specifications |
| | | pi.ModelNumber = products.Product.ModelNumber |
| | | for _, confirm := range confirmInfo { |
| | | if products.Product.Number == confirm.ProductId { |
| | | oi.SendAmount = confirm.OverReceiveAmount.IntPart() |
| | | pi.SendAmount = confirm.OverReceiveAmount.IntPart() |
| | | break |
| | | } |
| | | } |
| | | operationInfos = append(operationInfos, oi) |
| | | productMap[pi.Number] = &pi |
| | | } |
| | | } |
| | | for _, productInfo := range productMap { |
| | | productInfos = append(productInfos, *productInfo) |
| | | } |
| | | operationInfos.InWarehouseInfos = inWarehouseInfos |
| | | operationInfos.ProductInfos = productInfos |
| | | |
| | | response.OkWithData(operationInfos, c) |
| | | } |
| | |
| | | } |
| | | product := make([]*purchase_wms.PurchaseProduct, 0) |
| | | ids := make([]int, 0) |
| | | productMap := make(map[string]int64) |
| | | for _, inspection := range inspectionList { |
| | | var p purchase_wms.PurchaseProduct |
| | | p.Id = inspection.ProductId |
| | | p.Amount = inspection.Amount.IntPart() |
| | | product = append(product, &p) |
| | | productMap[inspection.ProductId] = inspection.Amount.IntPart() |
| | | ids = append(ids, int(inspection.ID)) |
| | | } |
| | | for k, v := range productMap { |
| | | var p purchase_wms.PurchaseProduct |
| | | p.Id = k |
| | | p.Amount = v |
| | | product = append(product, &p) |
| | | } |
| | | client := purchase_wms.NewPurchaseServiceClient(purchase_wms.PurchaseConn) |
| | | _, err = client.PurchaseToWms(context.Background(), &purchase_wms.PurchaseToWmsRequest{ |
| | | Number: purchaseData.Number, |
| | |
| | | "type": "string" |
| | | }, |
| | | "sourceOrder": { |
| | | "description": "来源单据", |
| | | "description": "来源单据 ,销售明细编码", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.OperationInfo": { |
| | | "response.InWarehouseInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "采购数", |
| | | "type": "number" |
| | | }, |
| | | "modelNumber": { |
| | | "description": "型号", |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "description": "产品名称", |
| | | "type": "string" |
| | |
| | | "description": "负责人", |
| | | "type": "string" |
| | | }, |
| | | "purchasePrice": { |
| | | "description": "单价", |
| | | "type": "number" |
| | | }, |
| | | "sendAmount": { |
| | | "description": "发货数", |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "description": "规格", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "type": "integer" |
| | | }, |
| | | "total": { |
| | | "description": "总价", |
| | | "type": "number" |
| | | }, |
| | | "unit": { |
| | | "description": "单位", |
| | | "type": "string" |
| | | }, |
| | | "warehouseName": { |
| | | "description": "仓库名", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.OperationInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "inWarehouseInfos": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/response.InWarehouseInfo" |
| | | } |
| | | }, |
| | | "productInfos": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/response.ProductInfo" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ProductInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "采购数", |
| | | "type": "number" |
| | | }, |
| | | "modelNumber": { |
| | | "description": "型号", |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "description": "产品名称", |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "description": "产品编码", |
| | | "type": "string" |
| | | }, |
| | | "overAmount": { |
| | | "description": "入库数", |
| | | "type": "integer" |
| | | }, |
| | | "purchasePrice": { |
| | | "description": "单价", |
| | | "type": "number" |
| | | }, |
| | | "sendAmount": { |
| | | "description": "收货数", |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "description": "规格", |
| | | "type": "string" |
| | | }, |
| | | "total": { |
| | | "description": "总价", |
| | | "type": "number" |
| | | }, |
| | | "unit": { |
| | | "description": "单位", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.PurchaseProducts": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "string" |
| | | }, |
| | | "sourceOrder": { |
| | | "description": "来源单据", |
| | | "description": "来源单据 ,销售明细编码", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.OperationInfo": { |
| | | "response.InWarehouseInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "采购数", |
| | | "type": "number" |
| | | }, |
| | | "modelNumber": { |
| | | "description": "型号", |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "description": "产品名称", |
| | | "type": "string" |
| | |
| | | "description": "负责人", |
| | | "type": "string" |
| | | }, |
| | | "purchasePrice": { |
| | | "description": "单价", |
| | | "type": "number" |
| | | }, |
| | | "sendAmount": { |
| | | "description": "发货数", |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "description": "规格", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "type": "integer" |
| | | }, |
| | | "total": { |
| | | "description": "总价", |
| | | "type": "number" |
| | | }, |
| | | "unit": { |
| | | "description": "单位", |
| | | "type": "string" |
| | | }, |
| | | "warehouseName": { |
| | | "description": "仓库名", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.OperationInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "inWarehouseInfos": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/response.InWarehouseInfo" |
| | | } |
| | | }, |
| | | "productInfos": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/response.ProductInfo" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ProductInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "采购数", |
| | | "type": "number" |
| | | }, |
| | | "modelNumber": { |
| | | "description": "型号", |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "description": "产品名称", |
| | | "type": "string" |
| | | }, |
| | | "number": { |
| | | "description": "产品编码", |
| | | "type": "string" |
| | | }, |
| | | "overAmount": { |
| | | "description": "入库数", |
| | | "type": "integer" |
| | | }, |
| | | "purchasePrice": { |
| | | "description": "单价", |
| | | "type": "number" |
| | | }, |
| | | "sendAmount": { |
| | | "description": "收货数", |
| | | "type": "integer" |
| | | }, |
| | | "specifications": { |
| | | "description": "规格", |
| | | "type": "string" |
| | | }, |
| | | "total": { |
| | | "description": "总价", |
| | | "type": "number" |
| | | }, |
| | | "unit": { |
| | | "description": "单位", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.PurchaseProducts": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | description: 签约日期 |
| | | type: string |
| | | sourceOrder: |
| | | description: 来源单据 |
| | | description: 来源单据 ,销售明细编码 |
| | | type: string |
| | | status: |
| | | allOf: |
| | |
| | | $ref: '#/definitions/test.SupplierType' |
| | | type: array |
| | | type: object |
| | | response.OperationInfo: |
| | | response.InWarehouseInfo: |
| | | properties: |
| | | amount: |
| | | description: 采购数 |
| | | type: number |
| | | modelNumber: |
| | | description: 型号 |
| | | type: string |
| | | name: |
| | | description: 产品名称 |
| | | type: string |
| | |
| | | principal: |
| | | description: 负责人 |
| | | type: string |
| | | purchasePrice: |
| | | description: 单价 |
| | | type: number |
| | | sendAmount: |
| | | description: 发货数 |
| | | type: integer |
| | | specifications: |
| | | description: 规格 |
| | | type: string |
| | | status: |
| | | type: integer |
| | | total: |
| | | description: 总价 |
| | | type: number |
| | | unit: |
| | | description: 单位 |
| | | type: string |
| | | warehouseName: |
| | | description: 仓库名 |
| | | type: string |
| | | type: object |
| | | response.OperationInfo: |
| | | properties: |
| | | inWarehouseInfos: |
| | | items: |
| | | $ref: '#/definitions/response.InWarehouseInfo' |
| | | type: array |
| | | productInfos: |
| | | items: |
| | | $ref: '#/definitions/response.ProductInfo' |
| | | type: array |
| | | type: object |
| | | response.PageResult: |
| | | properties: |
| | |
| | | total: |
| | | type: integer |
| | | type: object |
| | | response.ProductInfo: |
| | | properties: |
| | | amount: |
| | | description: 采购数 |
| | | type: number |
| | | modelNumber: |
| | | description: 型号 |
| | | type: string |
| | | name: |
| | | description: 产品名称 |
| | | type: string |
| | | number: |
| | | description: 产品编码 |
| | | type: string |
| | | overAmount: |
| | | description: 入库数 |
| | | type: integer |
| | | purchasePrice: |
| | | description: 单价 |
| | | type: number |
| | | sendAmount: |
| | | description: 收货数 |
| | | type: integer |
| | | specifications: |
| | | description: 规格 |
| | | type: string |
| | | total: |
| | | description: 总价 |
| | | type: number |
| | | unit: |
| | | description: 单位 |
| | | type: string |
| | | type: object |
| | | response.PurchaseProducts: |
| | | properties: |
| | | amount: |
| | |
| | | } |
| | | |
| | | type OperationInfo struct { |
| | | Number string `json:"number"` //产品编码 |
| | | Name string `json:"name"` //产品名称 |
| | | Specifications string `json:"specifications"` //规格 |
| | | ModelNumber string `json:"modelNumber"` //型号 |
| | | Amount decimal.Decimal `json:"amount"` //采购数 |
| | | SendAmount int64 `json:"sendAmount"` //收货数 |
| | | OverAmount int64 `json:"overAmount"` //入库数 |
| | | Unit string `json:"unit"` //单位 |
| | | PurchasePrice decimal.Decimal `json:"purchasePrice"` //单价 |
| | | Total decimal.Decimal `json:"total"` //总价 |
| | | OperationNumber string `json:"operationNumber"` //入库单号 |
| | | WarehouseName string `json:"warehouseName"` //仓库名 |
| | | OverTime string `json:"overTime"` //入库时间 |
| | | Status int64 `json:"status"` |
| | | Principal string `json:"principal"` //负责人 |
| | | ProductInfos []ProductInfo `json:"productInfos"` |
| | | InWarehouseInfos []InWarehouseInfo `json:"inWarehouseInfos"` |
| | | } |
| | | |
| | | type ProductInfo struct { |
| | | Number string `json:"number"` //产品编码 |
| | | Name string `json:"name"` //产品名称 |
| | | Specifications string `json:"specifications"` //规格 |
| | | ModelNumber string `json:"modelNumber"` //型号 |
| | | Amount decimal.Decimal `json:"amount"` //采购数 |
| | | SendAmount int64 `json:"sendAmount"` //收货数 |
| | | OverAmount int64 `json:"overAmount"` //入库数 |
| | | Unit string `json:"unit"` //单位 |
| | | PurchasePrice decimal.Decimal `json:"purchasePrice"` //单价 |
| | | Total decimal.Decimal `json:"total"` //总价 |
| | | } |
| | | |
| | | type InWarehouseInfo struct { |
| | | Number string `json:"number"` //产品编码 |
| | | Name string `json:"name"` //产品名称 |
| | | OperationNumber string `json:"operationNumber"` //入库单号 |
| | | WarehouseName string `json:"warehouseName"` //仓库名 |
| | | OverTime string `json:"overTime"` //入库时间 |
| | | Status int64 `json:"status"` |
| | | Principal string `json:"principal"` //负责人 |
| | | OverAmount int64 `json:"overAmount"` //入库数 |
| | | } |
| | |
| | | |
| | | func (slf *PurchaseService) UpdatePurchaseStatus(number string, status int) error { |
| | | var total int64 |
| | | err := global.GVA_DB.Model(&purchase.PurchaseQualityInspection{}).Where("purchase_number = ?", number).Where("status = ?", status).Count(&total).Error |
| | | err := global.GVA_DB.Model(&purchase.Purchase{}).Where("number = ?", number).Where("status = ?", purchase.OrderStatusWaitQuality).Count(&total).Error |
| | | if err != nil { |
| | | return err |
| | | } |
| | | if total == 0 { |
| | | err = global.GVA_DB.Model(&purchase.Purchase{}).Where("number = ?", number).Updates(map[string]interface{}{"status": purchase.OrderStatusReceived}).Error |
| | | if total > 0 { |
| | | err = global.GVA_DB.Model(&purchase.PurchaseQualityInspection{}).Where("purchase_number = ?", number).Where("status = ?", status).Count(&total).Error |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | if total == 0 { |
| | | err = global.GVA_DB.Model(&purchase.Purchase{}).Where("number = ?", number).Updates(map[string]interface{}{"status": purchase.OrderStatusReceived}).Error |
| | | if err != nil { |
| | | return err |
| | | } |
| | | } |
| | | } |
| | | return nil |
| | | } |