| | |
| | | using HslCommunication; |
| | | using MailKit.Search; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Common.WareHouseEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.SquareCabin; |
| | | using WIDESEA_ISquareCabinServices; |
| | | using WIDESEA_IWMsInfoServices; |
| | | using WIDESEA_Model.Models; |
| | | using static WIDESEA_DTO.SquareCabin.OrderDto; |
| | | using static WIDESEA_DTO.SquareCabin.TowcsDto; |
| | |
| | | { |
| | | public class InventoryServices : ServiceBase<Dt_Inventory, IRepository<Dt_Inventory>>, IInventoryServices |
| | | { |
| | | public InventoryServices(IRepository<Dt_Inventory> BaseDal) : base(BaseDal) |
| | | private readonly IDeliveryOrderServices _deliveryOrderServices; |
| | | public InventoryServices(IRepository<Dt_Inventory> BaseDal, IDeliveryOrderServices deliveryOrderServices) : base(BaseDal) |
| | | { |
| | | _deliveryOrderServices = deliveryOrderServices; |
| | | } |
| | | |
| | | |
| | |
| | | try |
| | | { |
| | | var url = "http://121.37.118.63/GYZ2/95fck/repositoryInfo"; |
| | | // åèµ·è¯·æ± |
| | | var result = HttpHelper.Post(url, new { goods_no,batch_num}.ToJsonString()); |
| | | var result = HttpHelper.Post(url, new { goods_no, batch_num }.ToJsonString()); |
| | | |
| | | // ååºåå |
| | | var response = JsonConvert.DeserializeObject<UpstreamResponse<InventoryInfo>>(result); |
| | | |
| | | if (response.resultCode!="0") |
| | | if (response.resultCode != "0") |
| | | { |
| | | // è°ç¨å¼å¸¸æ¥å£ |
| | | SendErrorToUpstream(8, "", response.resultMsg ?? "䏿¸¸æ¥å£è¿å失败", ""); |
| | | return responseContent.Error(response.resultMsg ?? "䏿¸¸æ¥å£è¿å失败"); |
| | | } |
| | | |
| | | if (response.data == null || !response.data.Any()) |
| | | { |
| | | return responseContent.OK("æ æ°åºåæ°æ®"); |
| | | } |
| | | |
| | | Db.Ado.BeginTran(); |
| | | foreach (var item in response.data) |
| | | { |
| | | var Inver = new Dt_Inventory |
| | | { |
| | | Goods_no = item.goods_no, |
| | | Batch_num = item.batch_num, |
| | | Exp_date=item.exp_date, |
| | | Business_qty = item.business_qty, |
| | | Actual_qty = item.actural_qty, |
| | | }; |
| | | AddData(Inver); |
| | | // ä½¿ç¨ FirstOrDefault é¿å
æ¾ä¸å°è®°å½æ¶æåºå¼å¸¸ |
| | | var Inver = Db.Queryable<Dt_Inventory_Batch>() |
| | | .First(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num); |
| | | |
| | | if (Inver != null) |
| | | { |
| | | Inver.ERPStockQuantity = item.business_qty; |
| | | Db.Updateable(Inver).ExecuteCommand(); |
| | | } |
| | | } |
| | | Db.Ado.CommitTran(); |
| | | return responseContent.OK("åºåä¿¡æ¯åæ¥å®æ"); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// wcsåä¼ ç»æè°ç¨æçæ¹æ³ |
| | | /// wcsåä¼ ç»æè°ç¨æçæ¹æ³ ä¸ç®¡æ¯å
¥åº åºåº çç¹é½ä¼è°ç¨è¿ä¸ªæ¥å£ |
| | | /// </summary> |
| | | /// <param name="request"></param> |
| | | /// <returns></returns> |
| | | //public ApiResponse<Dt_Inventory> OrderFeedback(EdiOrderCallbackRequest request) |
| | | //{ |
| | | // try |
| | | // { |
| | | // if (request == null || request.details == null || !request.details.Any()) |
| | | // { |
| | | // return new ApiResponse<Dt_Inventory> { code = "500", msg = "请æ±åæ°æ æ" }; |
| | | // } |
| | | // BaseDal.Db.Ado.BeginTran();//å¼å¯äºå¡ |
| | | // foreach (var detail in request.details) |
| | | // { |
| | | // // å
æ¥åºåæ¯å¦åå¨ï¼æç
§äº§åç¼å·åæ¹æ¬¡æ¥å¯»æ¾ï¼ |
| | | // var entity = BaseDal.Db.Queryable<Dt_Inventory>() |
| | | // .First(x => x.Goods_no == detail.productCode && x.Batch_num == detail.batchNo); |
| | | // //å°éåä¸çæ°éè¿è¡ç´¯å |
| | | // // å®å
¨è½¬æ¢ |
| | | |
| | | // //æ£å¸¸åºå
¥åº |
| | | // decimal orderQty = detail.orderDetails?.Sum(x => decimal.TryParse(x.quantity, out var q) ? q : 0) ?? 0; |
| | | // //çç¹çäº |
| | | // decimal diffQty = detail.stocktakingDetails?.Sum(x => Convert.ToDecimal(x.differenceQuantity)) ?? 0; |
| | | // if (entity == null) |
| | | // { |
| | | // // 妿ä¸åå¨ï¼æ°å»ºä¸æ¡ |
| | | // entity = new Dt_Inventory |
| | | // { |
| | | // Goods_no = detail.productCode ?? detail.productName, |
| | | // Reservoirarea = "é»è®¤åºåº", |
| | | // Batch_num = detail.batchNo, |
| | | // //ä¸å¡åºå |
| | | // Business_qty = 0, |
| | | // //å®é
åºå |
| | | // Actual_qty = 0 |
| | | // }; |
| | | // } |
| | | |
| | | // switch (request.orderType) |
| | | // { |
| | | // case "1": // å
¥åº |
| | | // entity.Business_qty += orderQty; |
| | | // entity.Actual_qty += orderQty; |
| | | // break; |
| | | |
| | | // case "2": // åºåº |
| | | // entity.Business_qty -= orderQty; |
| | | // entity.Actual_qty -= orderQty; |
| | | // if (entity.Business_qty < 0) entity.Business_qty = 0; // å¯éï¼é²æ¢è´æ° |
| | | // if (entity.Actual_qty < 0) entity.Actual_qty = 0; |
| | | // break; |
| | | |
| | | // case "3": // çç¹ |
| | | // if (detail.stocktakingDetails != null && detail.stocktakingDetails.Any()) |
| | | // { |
| | | // foreach (var stock in detail.stocktakingDetails) |
| | | // { |
| | | // //æ¯æ¬¡é½åªæ¿ä¸æ¡æç»ä¸çæ°é |
| | | // decimal diff = Convert.ToDecimal(stock.differenceQuantity); |
| | | // if (stock.IsProfit == "1") // çç |
| | | // { |
| | | // entity.Business_qty += diff;//妿ççäºå¤äºï¼å°±å°ä¸å¡æ°é+ï¼çäºåç¸å |
| | | // entity.PalletCode = stock.palletCode; |
| | | // } |
| | | // else // çäº |
| | | // { |
| | | // entity.Business_qty -= diff; |
| | | // entity.PalletCode = stock.palletCode; |
| | | // } |
| | | // } |
| | | // } |
| | | // break; |
| | | // } |
| | | |
| | | // // ä¿åæ°æ® |
| | | // if (entity.Id == 0) // æ°å»º |
| | | // BaseDal.Db.Insertable(entity).ExecuteCommand(); |
| | | // else // æ´æ° |
| | | // BaseDal.Db.Updateable(entity).ExecuteCommand(); |
| | | // } |
| | | // BaseDal.Db.Ado.CommitTran(); // æäº¤äºå¡ |
| | | // return new ApiResponse<Dt_Inventory> { code = "0", msg = "æå" }; |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // BaseDal.Db.Ado.RollbackTran();//åæ»äºå¡ |
| | | // return new ApiResponse<Dt_Inventory> { code = "500", msg = ex.Message }; |
| | | // } |
| | | //} |
| | | |
| | | |
| | | 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 = "请æ±åæ°æ æ" }; |
| | | } |
| | | |
| | | BaseDal.Db.Ado.BeginTran(); // å¼å¯äºå¡ |
| | | |
| | | var reslut = WarehouseEnum.ç«åº.ObjToInt().ToString("000"); |
| | | // 2ï¸â£ å¼å¯äºå¡ |
| | | BaseDal.Db.Ado.BeginTran(); |
| | | foreach (var detail in request.details) |
| | | { |
| | | // å
¥åºæ°éï¼èªå¨åæ£ï¼ |
| | | #region æ¥è¯¢ç©æä¿¡æ¯ãè®¡ç®æ»å |
| | | //æ¥è¯¢ç©æè¡¨ |
| | | var goods = Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == detail.productCode).First(); |
| | | if (goods == null) throw new Exception($"æªæ¾å°ç©æç¼ç ã{detail.productCode}ãçç©æä¿¡æ¯"); |
| | | // 3ï¸ è®¡ç®å
¥åºæ°éï¼åæ£ï¼éå orderDetails ä¸çæ¯ä¸ª EdiOrderBoxDto 对象 |
| | | decimal orderQty = detail.orderDetails? |
| | | .Sum(x => decimal.TryParse(x.quantity, out var q) ? Math.Abs(q) : 0) |
| | | ?? 0; |
| | | #endregion |
| | | |
| | | // çç¹å·®å¼æ° |
| | | decimal diffQty = detail.stocktakingDetails? |
| | | .Sum(x => Convert.ToDecimal(x.differenceQuantity)) |
| | | ?? 0; |
| | | |
| | | // æ¥è¯¢ç°æåºåæç» |
| | | var entity = BaseDal.Db.Queryable<Dt_InventoryInfo>() |
| | | .First(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo); |
| | | |
| | | if (entity == null) |
| | | { |
| | | //ä¸åå¨åæ°å»ºåºåæç»è®°å½ |
| | | entity = new Dt_InventoryInfo |
| | | { |
| | | PalletCode = detail.orderDetails?.FirstOrDefault()?.palletCode ?? "", |
| | | WarehouseId = 1, // é»è®¤åºæ¿ç¼å· |
| | | LocationCode = "", |
| | | StockStatus = 1, // ç«åºåºå®ä¸º 1 |
| | | MaterielCode = detail.productCode ?? detail.productName, |
| | | MaterielName = detail.productName ?? "", |
| | | MaterielSpec = detail.productSpecifications ?? "", |
| | | BatchNo = detail.batchNo, |
| | | StockQuantity = 0, |
| | | OutboundQuantity = 0, |
| | | SupplyQuantity = 0, |
| | | InDate = DateTime.Now, |
| | | ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"), |
| | | ShelfLife = 0, |
| | | ValidityPeriod = "", |
| | | Remark = "WCSåä¼ å建" |
| | | }; |
| | | } |
| | | |
| | | // æ¹æ¬¡è¡¨è®°å½ï¼ç¨äºæ±æ»ï¼ |
| | | var batch = BaseDal.Db.Queryable<Dt_Inventory_Batch>() |
| | | .First(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo); |
| | | |
| | | if (batch == null) |
| | | { |
| | | batch = new Dt_Inventory_Batch |
| | | { |
| | | MaterielCode = detail.productCode ?? detail.productName, |
| | | MaterielName = detail.productName ?? "", |
| | | MaterielSpec = detail.productSpecifications ?? "", |
| | | BatchNo = detail.batchNo, |
| | | StockQuantity = 0, |
| | | OutboundQuantity = 0, |
| | | SupplyQuantity = 0, |
| | | ERPStockQuantity = 0, |
| | | Status = false, |
| | | ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"), |
| | | ValidityPeriod = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd"), |
| | | Remark = "èªå¨å建" |
| | | }; |
| | | } |
| | | |
| | | // 7ï¸â£ æè®¢åç±»åæ§è¡ä¸åé»è¾ |
| | | switch (request.orderType) |
| | | { |
| | | case "1": // å
¥åº |
| | | entity.StockQuantity += (float)orderQty; |
| | | entity.InDate = DateTime.Now; |
| | | entity.Remark = "å
¥åºååä¼ "; |
| | | |
| | | batch.StockQuantity += (float)orderQty; |
| | | batch.Remark = "å
¥åºååä¼ "; |
| | | break; |
| | | |
| | | case "2": // åºåº |
| | | entity.OutboundQuantity += (float)orderQty; |
| | | entity.StockQuantity -= (float)orderQty; |
| | | if (entity.StockQuantity < 0) entity.StockQuantity = 0; |
| | | entity.Remark = "åºåºååä¼ "; |
| | | |
| | | batch.OutboundQuantity += (float)orderQty; |
| | | batch.StockQuantity -= (float)orderQty; |
| | | if (batch.StockQuantity < 0) batch.StockQuantity = 0; |
| | | batch.Remark = "åºåºååä¼ "; |
| | | break; |
| | | |
| | | case "3": //çç¹ |
| | | if (detail.stocktakingDetails != null && detail.stocktakingDetails.Any()) |
| | | case "1": //å
¥åº |
| | | { |
| | | foreach (var stock in detail.stocktakingDetails) |
| | | #region å¤çå
¥åºè®¢å |
| | | |
| | | Dt_CabinOrder cabinOrder = Db.Queryable<Dt_CabinOrder>().Where(x => x.Order_no == request.orderNo && x.Warehouse_no == reslut).Includes(x => x.Details).First(); |
| | | #region 夿æ¯å¦ä¸ºççå
¥åºå |
| | | if (cabinOrder.Order_type == "5") |
| | | { |
| | | decimal diff = Convert.ToDecimal(stock.differenceQuantity); |
| | | if (stock.IsProfit == "1") // çç |
| | | foreach (var item in cabinOrder.Details) |
| | | { |
| | | entity.SupplyQuantity += (float)Math.Abs(diff); |
| | | batch.SupplyQuantity += (float)Math.Abs(diff); |
| | | Dt_InventoryInfo inventoryInfo = BaseDal.Db.Queryable<Dt_InventoryInfo>() |
| | | .First(x => x.MaterielCode == item.Goods_no && x.BatchNo == item.Batch_num && x.LocationCode == reslut); |
| | | var qty = inventoryInfo.SupplyQuantity - inventoryInfo.StockQuantity; |
| | | if (orderQty != qty) |
| | | throw new Exception($"ççå
¥åºæ°éä¸ä¸è´,ä¸ä¼ æ°éã{orderQty}ã,åºåççæ°éã{qty}ã"); |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | #region æ·»å ççå
¥åºä»»å¡ |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.InFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.ChenckIn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = cabinOrder.Order_no, |
| | | StockQuantity = orderQty, |
| | | SupplyQuantity = 0, |
| | | Remark = "ççå
¥åº" |
| | | }; |
| | | #endregion |
| | | var inventory_Batch = BaseDal.Db.Queryable<Dt_Inventory_Batch>() |
| | | .First(x => x.MaterielCode == inventoryInfo.MaterielCode && x.BatchNo == inventoryInfo.BatchNo); |
| | | inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity; |
| | | inventory_Batch.SupplyQuantity = 0; |
| | | item.OrderDetailStatus = "已宿"; |
| | | BaseDal.Db.Updateable(item).ExecuteCommand(); |
| | | BaseDal.Db.Updateable(inventoryInfo).ExecuteCommand(); |
| | | BaseDal.Db.Updateable(inventory_Batch).ExecuteCommand(); |
| | | BaseDal.Db.Insertable(supplyTask_Hty).ExecuteCommand(); |
| | | } |
| | | else // çäº |
| | | var cabinOrder1 = BaseDal.Db.Queryable<Dt_CabinOrder>().Where(x => x.Id == cabinOrder.Id).Includes(x => x.Details).First(); |
| | | if (!cabinOrder1.Details.Where(x => x.OrderDetailStatus != "已宿").Any()) |
| | | cabinOrder.OdrderStatus = "已宿"; |
| | | BaseDal.Db.Updateable(cabinOrder).ExecuteCommand(); |
| | | } |
| | | #endregion |
| | | else |
| | | { |
| | | if (cabinOrder == null || cabinOrder.OdrderStatus == "已宿") |
| | | throw new Exception($"å
¥åºå已宿"); |
| | | Dt_CabinOrderDetail cabinOrderDetail = cabinOrder.Details.Where(x => x.Goods_no == detail.productCode && x.Batch_num == detail.batchNo && x.Status == 1).First(); |
| | | if (cabinOrderDetail == null || cabinOrderDetail.OrderDetailStatus == "已宿") |
| | | throw new Exception($"å
¥åºåæç»å·²å®æ"); |
| | | cabinOrderDetail.Order_Inqty += orderQty; |
| | | if (cabinOrderDetail.Order_Inqty > cabinOrderDetail.Order_qty) |
| | | throw new Exception($"å
¥åºæ°éä¸å¯è¶
åºåæ®æ°é"); |
| | | cabinOrder.OdrderStatus = "å¼å§"; |
| | | cabinOrderDetail.OrderDetailStatus = "å¼å§"; |
| | | if (cabinOrderDetail.Order_Inqty == cabinOrderDetail.Order_qty) |
| | | cabinOrderDetail.OrderDetailStatus = "已宿"; |
| | | BaseDal.Db.Updateable(cabinOrderDetail).ExecuteCommand(); |
| | | var cabinOrder1 = BaseDal.Db.Queryable<Dt_CabinOrder>().Where(x => x.Order_no == cabinOrder.Order_no && x.Warehouse_no == reslut).Includes(x => x.Details).First(); |
| | | if (!cabinOrder1.Details.Where(x => x.OrderDetailStatus != "已宿").Any()) |
| | | cabinOrder.OdrderStatus = "已宿"; |
| | | BaseDal.Db.Updateable(cabinOrder).ExecuteCommand(); |
| | | #endregion |
| | | |
| | | #region å建åºåä¿¡æ¯ |
| | | // 5ï¸â£ æ¥è¯¢åºå详æ
|
| | | var inventoryInfo = BaseDal.Db.Queryable<Dt_InventoryInfo>() |
| | | .First(x => x.MaterielCode == cabinOrderDetail.Goods_no && x.BatchNo == cabinOrderDetail.Batch_num && x.LocationCode == "ç«åº"); |
| | | if (inventoryInfo != null) |
| | | { |
| | | entity.SupplyQuantity -= (float)Math.Abs(diff); |
| | | batch.SupplyQuantity -= (float)Math.Abs(diff); |
| | | if (entity.SupplyQuantity < 0) entity.SupplyQuantity = 0; |
| | | if (batch.SupplyQuantity < 0) batch.SupplyQuantity = 0; |
| | | inventoryInfo.StockQuantity += orderQty; |
| | | inventoryInfo.AvailableQuantity += orderQty; |
| | | inventoryInfo.InDate = DateTime.Now; |
| | | BaseDal.Db.Updateable(inventoryInfo).ExecuteCommand(); |
| | | } |
| | | entity.PalletCode = stock.palletCode; |
| | | entity.Remark = "çç¹ååä¼ "; |
| | | batch.Remark = "çç¹ååä¼ "; |
| | | else |
| | | { |
| | | inventoryInfo = new Dt_InventoryInfo |
| | | { |
| | | PalletCode = detail.orderDetails?.FirstOrDefault()?.palletCode ?? "", |
| | | WarehouseCode = "001", |
| | | LocationCode = "ç«åº", |
| | | StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(), |
| | | MaterielCode = goods.MaterielCode, |
| | | MaterielName = goods.MaterielName, |
| | | MaterielSpec = goods.MaterielSpec, |
| | | BatchNo = detail.batchNo, |
| | | StockQuantity = orderQty, |
| | | OutboundQuantity = 0, |
| | | SupplyQuantity = 0, |
| | | AvailableQuantity = orderQty, |
| | | InDate = DateTime.Now, |
| | | ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"), |
| | | ShelfLife = 0, |
| | | ValidityPeriod = cabinOrderDetail.Exp_date, |
| | | Remark = "WCSåä¼ å建" |
| | | }; |
| | | BaseDal.Db.Insertable(inventoryInfo).ExecuteCommand(); |
| | | } |
| | | #endregion |
| | | |
| | | #region å建åºåæ¹æ¬¡ä¿¡æ¯ |
| | | // 6ï¸â£ æ¥è¯¢åºåæ¹æ¬¡ä¿¡æ¯ |
| | | var inventory_Batch = BaseDal.Db.Queryable<Dt_Inventory_Batch>() |
| | | .First(x => x.MaterielCode == inventoryInfo.MaterielCode && x.BatchNo == inventoryInfo.BatchNo); |
| | | |
| | | if (inventory_Batch != null) |
| | | { |
| | | inventory_Batch.StockQuantity += orderQty; |
| | | inventory_Batch.AvailableQuantity += orderQty; |
| | | BaseDal.Db.Updateable(inventory_Batch).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | inventory_Batch = new Dt_Inventory_Batch |
| | | { |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | StockQuantity = inventoryInfo.StockQuantity, |
| | | OutboundQuantity = inventoryInfo.OutboundQuantity, |
| | | AvailableQuantity = inventoryInfo.AvailableQuantity, |
| | | SupplyQuantity = inventoryInfo.SupplyQuantity, |
| | | ERPStockQuantity = 0, |
| | | Status = false, |
| | | ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"), |
| | | ValidityPeriod = inventoryInfo.ValidityPeriod, |
| | | Remark = "èªå¨å建" |
| | | }; |
| | | BaseDal.Db.Insertable(inventory_Batch).ExecuteCommand(); |
| | | } |
| | | #endregion |
| | | |
| | | #region æ·»å å
¥åºä»»å¡åå² |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | TaskNum = cabinOrderDetail.Id, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.InFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = cabinOrder.Order_type == "1" ? TaskTypeEnum.In.ObjToInt() : TaskTypeEnum.OutReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = cabinOrder.Order_no, |
| | | StockQuantity = orderQty, |
| | | SupplyQuantity = 0, |
| | | Remark = "å
¥åº" |
| | | }; |
| | | BaseDal.Db.Insertable(supplyTask_Hty).ExecuteCommand(); |
| | | #endregion |
| | | } |
| | | } |
| | | break; |
| | | case "2": |
| | | { |
| | | Dt_DeliveryOrder cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == request.orderNo && x.Warehouse_no == reslut).Includes(x => x.Details).First(); |
| | | if (cabinOrder.Out_type == "6") |
| | | { |
| | | foreach (var item in cabinOrder.Details) |
| | | { |
| | | Dt_InventoryInfo inventoryInfo = BaseDal.Db.Queryable<Dt_InventoryInfo>() |
| | | .First(x => x.MaterielCode == item.Goods_no && x.BatchNo == item.Batch_num && x.LocationCode == reslut); |
| | | var qty = inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity; |
| | | if (orderQty != qty) |
| | | throw new Exception($"çäºåºåºæ°éä¸ä¸è´,ä¸ä¼ æ°éã{orderQty}ã,åºåçäºæ°éã{qty}ã"); |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | #region æ·»å çäºåºåºä»»å¡ |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.ChenckOut.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = cabinOrder.Out_no, |
| | | StockQuantity = orderQty, |
| | | SupplyQuantity = 0, |
| | | Remark = "çäºåºåº" |
| | | }; |
| | | #endregion |
| | | var inventory_Batch = BaseDal.Db.Queryable<Dt_Inventory_Batch>() |
| | | .First(x => x.MaterielCode == inventoryInfo.MaterielCode && x.BatchNo == inventoryInfo.BatchNo); |
| | | inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity; |
| | | inventory_Batch.SupplyQuantity = 0; |
| | | item.OotDetailStatus = "已宿"; |
| | | BaseDal.Db.Updateable(item).ExecuteCommand(); |
| | | BaseDal.Db.Updateable(inventoryInfo).ExecuteCommand(); |
| | | BaseDal.Db.Updateable(inventory_Batch).ExecuteCommand(); |
| | | BaseDal.Db.Insertable(supplyTask_Hty).ExecuteCommand(); |
| | | } |
| | | var cabinOrder1 = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Id == cabinOrder.Id).Includes(x => x.Details).First(); |
| | | if (!cabinOrder1.Details.Where(x => x.OotDetailStatus != "已宿").Any()) |
| | | cabinOrder.OutStatus = "已宿"; |
| | | BaseDal.Db.Updateable(cabinOrder).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | #region æ¾åºåºä»»å¡ |
| | | Dt_SupplyTask supplyTask = Db.Queryable<Dt_SupplyTask>().Where(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo && x.OrderNo == request.orderNo && x.WarehouseCode == reslut && x.TaskStatus == SupplyStatusEnum.NewOut.ObjToInt()).First(); |
| | | if (supplyTask == null) throw new Exception($"æªæ¾å°è®¢åå·ã{request.orderNo}ãç©æç¼å·ã{detail.productCode}ãçåºåºä»»å¡"); |
| | | if (supplyTask.StockQuantity != orderQty) throw new Exception($"订åå·ã{request.orderNo}ãç©æç¼å·ã{detail.productCode}ãçåºåºæ°éä¸åºåºä»»å¡æ°éä¸ç¸ç"); |
| | | #endregion |
| | | |
| | | #region å¤çåºåºåãåºåä¿¡æ¯ãåºåºä»»å¡ãè°æ¨ä»»å¡ |
| | | _deliveryOrderServices.OutTaskFinish(supplyTask); |
| | | #endregion |
| | | } |
| | | } |
| | | break; |
| | | case "3": // çç¹ |
| | | { |
| | | var WarehouseLK = WarehouseEnum.ç«åº.ObjToInt().ToString("000"); |
| | | #region æ¾çç¹ä»»å¡ |
| | | Dt_SupplyTask supplyTask = Db.Queryable<Dt_SupplyTask>().Where(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo && x.OrderNo == request.orderNo && x.WarehouseCode == WarehouseLK && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).First(); |
| | | if (supplyTask == null) throw new Exception($"æªæ¾å°è®¢åå·ã{request.orderNo}ãç©æç¼å·ã{detail.productCode}ãççç¹ä»»å¡"); |
| | | #endregion |
| | | if (detail.isLossOrProfit == 1) // çäº |
| | | { |
| | | supplyTask.SupplyQuantity = supplyTask.StockQuantity - detail.ea; |
| | | } |
| | | else if (detail.isLossOrProfit == 2) // çç |
| | | { |
| | | supplyTask.SupplyQuantity = supplyTask.StockQuantity + detail.ea; |
| | | } |
| | | else // çä¸ |
| | | { |
| | | supplyTask.SupplyQuantity = supplyTask.StockQuantity; |
| | | } |
| | | _deliveryOrderServices.CheckTaskFinish(supplyTask); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | //ä¿åå°æ°æ®åº |
| | | if (entity.Id == 0) |
| | | BaseDal.Db.Insertable(entity).ExecuteCommand(); |
| | | else |
| | | BaseDal.Db.Updateable(entity).ExecuteCommand(); |
| | | |
| | | if (batch.Id == 0) |
| | | BaseDal.Db.Insertable(batch).ExecuteCommand(); |
| | | else |
| | | BaseDal.Db.Updateable(batch).ExecuteCommand(); |
| | | } |
| | | |
| | | // 9ï¸â£ æäº¤äºå¡ |
| | | BaseDal.Db.Ado.CommitTran(); |
| | | return new ApiResponse<Dt_InventoryInfo> { code = "0", msg = "æå" }; |
| | | |
| | | return new ApiResponse<Dt_InventoryInfo> |
| | | { |
| | | code = "0", |
| | | msg = "æå" |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // ð åæ»äºå¡ |
| | | BaseDal.Db.Ado.RollbackTran(); |
| | | return new ApiResponse<Dt_InventoryInfo> { code = "500", msg = ex.Message }; |
| | | |
| | | return new ApiResponse<Dt_InventoryInfo> |
| | | { |
| | | code = "500", |
| | | msg = $"å¤ç失败: {ex.Message}" |
| | | }; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ´æ°å
¥åºåè¯¦ç» |
| | | /// </summary> |
| | | /// <param name="batchNo">æ¹æ¬¡å·</param> |
| | | /// <param name="productCode">ç©æåç¼ç /param> |
| | | public void UpdateInboundOrderDetailStatus(string orderNo, 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.åºå |