| | |
| | | |
| | | import ( |
| | | "context" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "go.uber.org/zap" |
| | | "gorm.io/gorm" |
| | | "srm/global" |
| | | "srm/model/common/request" |
| | | "srm/model/common/response" |
| | | "srm/model/purchase" |
| | | purchaserequest "srm/model/purchase/request" |
| | | "srm/proto/purchase_wms" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | | |
| | | //"srm/model/purchase" |
| | | |
| | | //"srm/model/purchase" |
| | |
| | | purchaseRecord.Status = purchase.OrderStatusConfirmed |
| | | purchaseRecord.HandledBy = "admin" |
| | | purchaseRecord.Creator = "admin" |
| | | purchaseRecord.Number = fmt.Sprintf("CG%v", time.Now().Unix()) |
| | | purchaseRecord.Principal = "admin" |
| | | purchaseRecord.OrderType = "采购订单" |
| | | |
| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data query request.PageInfo true "页码, 每页大小" |
| | | // @Param data query purchaserequest.PurchaseSearch true "参数" |
| | | // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页获取采购单列表,返回包括列表,总数,页码,每页数量" |
| | | // @Router /purchase/purchaseList [get] |
| | | func (e *PurchaseApi) GetPurchaseList(c *gin.Context) { |
| | | var pageInfo request.PageInfo |
| | | var pageInfo purchaserequest.PurchaseSearch |
| | | err := c.ShouldBindQuery(&pageInfo) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | warehouse := "" |
| | | if params.Status == purchase.OrderStatusReceived { |
| | | data, err := service.NewPurchaseService().GetPurchase(uint(params.Id)) |
| | | if err != nil { |
| | |
| | | product = append(product, &p) |
| | | } |
| | | client := purchase_wms.NewPurchaseServiceClient(purchase_wms.PurchaseConn) |
| | | _, err = client.PurchaseToWms(context.Background(), &purchase_wms.PurchaseToWmsRequest{ |
| | | resp, err := client.PurchaseToWms(context.Background(), &purchase_wms.PurchaseToWmsRequest{ |
| | | Number: data.Number, |
| | | SupplierName: data.Supplier.Name, |
| | | Product: product, |
| | | Source: "SRM_PURCHASE", |
| | | }) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("grpc调用失败!", zap.Error(err)) |
| | | response.FailWithMessage("grpc调用失败", c) |
| | | return |
| | | } |
| | | warehouse = resp.Warehouse |
| | | } |
| | | |
| | | err = service.NewPurchaseService().Submit(params.Id, params.Status) |
| | | err = service.NewPurchaseService().Submit(params.Id, params.Status, warehouse) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("更新失败!", zap.Error(err)) |
| | | response.FailWithMessage("更新失败", c) |