| | |
| | | public ApiResponse<Dt_InventoryInfo> OrderFeedback(EdiOrderCallbackRequest request) |
| | | { |
| | | try |
| | | { |
| | | { |
| | | // 1ï¸â£ æ ¡éªè¯·æ± |
| | | if (request == null || request.details == null || !request.details.Any()) |
| | | { |
| | | return new ApiResponse<Dt_InventoryInfo> { code = "500", msg = "请æ±åæ°æ æ" }; |
| | | } |
| | | |
| | | |
| | | //æ¥æ¾å°å
¨é¨ç |
| | | |
| | | foreach (var detail in request.details) |
| | | { |
| | | var goods = Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == detail.productCode).First(); |
| | | var goods = Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == detail.productCode).First(); |
| | | |
| | | // 3ï¸â£ 计ç®å
¥åºæ°éï¼åæ£ï¼ |
| | | // 3ï¸ è®¡ç®å
¥åºæ°éï¼åæ£ï¼éå orderDetails ä¸çæ¯ä¸ª EdiOrderBoxDto 对象 |
| | | decimal orderQty = detail.orderDetails? |
| | | .Sum(x => decimal.TryParse(x.quantity, out var q) ? Math.Abs(q) : 0) |
| | | ?? 0; |
| | | |
| | | // 5ï¸â£ æ¥è¯¢åºå详æ
|
| | | var entity = BaseDal.Db.Queryable<Dt_InventoryInfo>() |
| | | .First(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo&&x.LocationCode=="ç«åº"); |
| | | .First(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo && x.LocationCode == "ç«åº"); |
| | | //æ¥è¯¢ç©æè¡¨ |
| | | var Goods = BaseDal.Db.Queryable<Dt_MaterielInfo>().First(x => x.MaterielCode == detail.productCode); |
| | | |
| | |
| | | StockQuantity = 0, |
| | | OutboundQuantity = 0, |
| | | SupplyQuantity = 0, |
| | | AvailableQuantity = 0, |
| | | InDate = DateTime.Now, |
| | | ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"), |
| | | ShelfLife = 0, |
| | |
| | | BatchNo = detail.batchNo, |
| | | StockQuantity = 0, |
| | | OutboundQuantity = 0, |
| | | AvailableQuantity = 0, |
| | | SupplyQuantity = 0, |
| | | ERPStockQuantity = 0, |
| | | Status = false, |
| | |
| | | switch (request.orderType) |
| | | { |
| | | case "1": //å
¥åº |
| | | entity.StockQuantity += orderQty; |
| | | entity.StockQuantity = orderQty; //å®é
åºå |
| | | entity.AvailableQuantity = orderQty; |
| | | entity.InDate = DateTime.Now; |
| | | entity.Remark = "å
¥åºååä¼ "; |
| | | //Goods.Business_qty= |
| | | |
| | | batch.StockQuantity += orderQty; |
| | | |
| | | batch.StockQuantity = orderQty; |
| | | batch.AvailableQuantity = orderQty; |
| | | batch.Remark = "å
¥åºååä¼ "; |
| | | UpdateInboundOrderDetailStatus(detail.batchNo, detail.productCode); |
| | | break; |
| | | |
| | | case "2": // åºåº |
| | | entity.OutboundQuantity += orderQty; //åºåºæ°é |
| | | entity.StockQuantity -= orderQty; |
| | | case "2": // åºåº æ»100 åº20 |
| | | decimal actualOutQty = entity.StockQuantity - orderQty;// è®¡ç®æ¬æ¬¡å®é
åºåºæ°é 20 |
| | | entity.StockQuantity=orderQty; //å®é
åºåæ° 100 |
| | | entity.OutboundQuantity =Math.Max(0,entity.OutboundQuantity-actualOutQty); //å¾
åºåºæ°é |
| | | entity.AvailableQuantity = entity.StockQuantity - entity.OutboundQuantity;//å¯ç¨åºå |
| | | if (entity.StockQuantity < 0) entity.StockQuantity = 0; |
| | | entity.Remark = "åºåºååä¼ "; |
| | | |
| | | //CreateAllocatInOut() |
| | | batch.OutboundQuantity += orderQty; |
| | | batch.StockQuantity -= orderQty; |
| | | |
| | | batch.StockQuantity = orderQty; |
| | | batch.OutboundQuantity =Math.Max(0,batch.OutboundQuantity-actualOutQty);//å¾
åºåºæ°é |
| | | batch.AvailableQuantity = batch.StockQuantity - batch.OutboundQuantity; //å¯ç¨åºå |
| | | if (batch.StockQuantity < 0) batch.StockQuantity = 0; |
| | | batch.Remark = "åºåºååä¼ "; |
| | | UpdateOutboundOrderDetailStatus(detail.batchNo, detail.productCode); |
| | | //è°æ¨ä»»å¡ |
| | | _deliveryOrderServices.CreateAllocatInOut(goods); |
| | | |
| | | |
| | | break; |
| | | |
| | | case "3": // çç¹ |
| | | decimal diff = detail.ea ?? 0; // 差弿° |
| | | int flag = detail.isLossOrProfit ?? 3; // 1=çäº, 2=çç, 3=çä¸ |
| | | |
| | | if (flag == 1) // çäº |
| | | { |
| | | batch.SupplyQuantity = batch.StockQuantity - diff; |
| | | //åºåæ°-差弿°=çäº |
| | | batch.SupplyQuantity +=( batch.StockQuantity - diff); |
| | | batch.Remark = "çç¹ååä¼ - çäº"; |
| | | } |
| | | else if (flag == 2) // çç |
| | | { |
| | | batch.SupplyQuantity = batch.StockQuantity + diff; |
| | | //åºåæ°+差弿°=çç |
| | | batch.SupplyQuantity +=(batch.StockQuantity + diff); |
| | | batch.Remark = "çç¹ååä¼ - çç"; |
| | | } |
| | | else // çä¸ |
| | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ´æ°å
¥åºåè¯¦ç» |
| | | /// </summary> |
| | | /// <param name="batchNo">æ¹æ¬¡å·</param> |
| | | /// <param name="productCode">ç©æåç¼ç /param> |
| | | public void UpdateInboundOrderDetailStatus(string batchNo,string productCode) |
| | | { |
| | | try |
| | | { |
| | | //æ¥è¯¢è¯¦æ
|
| | | var detail = BaseDal.Db.Queryable<Dt_CabinOrderDetail>() |
| | | .First(x => x.Goods_no == productCode && x.Batch_num == batchNo && x.OrderDetailStatus == "å¼å§" && x.Status == 1); |
| | | //æ¥æ¾å°åæ ¹æ®ç©æç¶æï¼OrderDetailStatus==å¼å§ï¼ è¯¥ç¶æStatus=1ä¿®æ¹è¯¥æ¡è¯¦æ
çOrderDetailStatus==已宿 |
| | | detail.OrderDetailStatus = "已宿"; |
| | | BaseDal.Db.Updateable(detail).ExecuteCommand(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// //æ¥æ¾å°åæ ¹æ®ç©æç¶æï¼OrderDetailStatus==å¼å§ï¼ è¯¥ç¶æStatus=1ä¿®æ¹è¯¥æ¡è¯¦æ
çOrderDetailStatus==已宿 |
| | | /// </summary> |
| | | /// <param name="batchNo"></param> |
| | | /// <param name="productCode"></param> |
| | | public void UpdateOutboundOrderDetailStatus(string batchNo, string productCode) |
| | | { |
| | | try |
| | | { |
| | | //æ¥è¯¢è¯¦æ
|
| | | var detail = BaseDal.Db.Queryable<Dt_DeliveryOrderDetail>() |
| | | .First(x => x.Goods_no == productCode && x.Batch_num == batchNo && x.OotDetailStatus == "å¼å§" && x.Status == 1); |
| | | detail.OotDetailStatus = "已宿"; |
| | | BaseDal.Db.Updateable(detail).ExecuteCommand(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ¨éå¼å¸¸ä¿¡æ¯ç»ä¸æ¸¸ç³»ç»1.å
¥åºåæ¥å£ï¼2.å
¥åºåæ¥å®ææ¥å£ï¼3.åºåºåæ¥å£ï¼4.åºåºæ¥å®ææ¥å£ï¼5.è¯ååºç¡ä¿¡æ¯åæ¥æ¥å£ï¼6.ä¾åºåä¿¡æ¯æ¥å£ï¼7.客æ·ä¿¡æ¯æ¥å£ï¼8.åºå |