| | |
| | | using HslCommunication; |
| | | using MailKit.Search; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.OrderEnum; |
| | | 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("åºåä¿¡æ¯åæ¥å®æ"); |
| | |
| | | return responseContent.Error("åæ¥å¤±è´¥: " + ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | return new ApiResponse<Dt_InventoryInfo> { code = "500", msg = "请æ±åæ°æ æ" }; |
| | | } |
| | | |
| | | var reslut = WarehouseEnum.ç«åº.ObjToInt().ToString("000"); |
| | | // 2ï¸â£ å¼å¯äºå¡ |
| | | BaseDal.Db.Ado.BeginTran(); |
| | | |
| | | foreach (var detail in request.details) |
| | | { |
| | | // 3ï¸â£ 计ç®å
¥åºæ°éï¼åæ£ï¼ |
| | | #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; |
| | | |
| | | // 5ï¸â£ æ¥è¯¢åºå详æ
|
| | | 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 ?? "", |
| | | WarehouseCode = "001", |
| | | LocationCode = "", |
| | | StockStatus = 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åä¼ å建" |
| | | }; |
| | | } |
| | | |
| | | // 6ï¸â£ æ¥è¯¢åºåæ¹æ¬¡ä¿¡æ¯ |
| | | 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 = "èªå¨å建" |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | // 7ï¸â£ æè®¢åç±»åæ§è¡ä¸åé»è¾ |
| | | switch (request.orderType) |
| | | { |
| | | case "1": //å
¥åº |
| | | entity.StockQuantity += orderQty; |
| | | entity.InDate = DateTime.Now; |
| | | entity.Remark = "å
¥åºååä¼ "; |
| | | { |
| | | #region å¤çå
¥åºè®¢å |
| | | |
| | | batch.StockQuantity += orderQty; |
| | | batch.Remark = "å
¥åºååä¼ "; |
| | | Dt_CabinOrder cabinOrder = Db.Queryable<Dt_CabinOrder>().Where(x => x.Order_no == request.externalOrderNo && x.Warehouse_no == reslut).Includes(x => x.Details).First(); |
| | | if (cabinOrder == null) throw new Exception($"æªæ¾å°å
¥åºåå·ã{request.externalOrderNo}ãçå
¥åºåä¿¡æ¯"); |
| | | #region 夿æ¯å¦ä¸ºççå
¥åºå |
| | | if (cabinOrder.Order_type == "5") |
| | | { |
| | | 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.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(); |
| | | } |
| | | 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) |
| | | { |
| | | inventoryInfo.StockQuantity += orderQty; |
| | | inventoryInfo.AvailableQuantity += orderQty; |
| | | inventoryInfo.InDate = DateTime.Now; |
| | | BaseDal.Db.Updateable(inventoryInfo).ExecuteCommand(); |
| | | } |
| | | 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 å建åºåæ¹æ¬¡ä¿¡æ¯ åªæä¸æ¯è°æ¨å
¥åºåï¼115ï¼æå¯¹æ¹æ¬¡ä¿¡æ¯è¿è¡ä¿®æ¹ |
| | | if (cabinOrder.Order_type != InOrderTypeEnum.Allocat.ObjToInt().ToString()) |
| | | { |
| | | // 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.ObjToDate(), |
| | | 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 = "å
¥åº" |
| | | }; |
| | | //è¿éè¿éçå
¥åºè°æ¨åç¶ææ¯115ï¼å°±å°è°æ¨ä»»å¡ç¶ææ¹ä¸º7 |
| | | if (cabinOrder.Order_type == InOrderTypeEnum.Allocat.ObjToInt().ToString()) supplyTask_Hty.TaskType = TaskTypeEnum.AllocatIn.ObjToInt(); |
| | | BaseDal.Db.Insertable(supplyTask_Hty).ExecuteCommand(); |
| | | #endregion |
| | | } |
| | | } |
| | | break; |
| | | case "2": |
| | | { |
| | | Dt_DeliveryOrder cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == request.externalOrderNo && x.Warehouse_no == reslut).Includes(x => x.Details).First(); |
| | | if (cabinOrder == null) throw new Exception($"æªæ¾å°åºåºåå·ã{request.externalOrderNo}ãçå
¥åºåä¿¡æ¯"); |
| | | |
| | | case "2": // åºåº |
| | | entity.OutboundQuantity += orderQty; |
| | | entity.StockQuantity -= orderQty; |
| | | if (entity.StockQuantity < 0) entity.StockQuantity = 0; |
| | | entity.Remark = "åºåºååä¼ "; |
| | | 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.externalOrderNo && x.WarehouseCode == reslut && x.TaskStatus == SupplyStatusEnum.NewOut.ObjToInt()).First(); |
| | | if (supplyTask == null) throw new Exception($"æªæ¾å°è®¢åå·ã{request.externalOrderNo}ãç©æç¼å·ã{detail.productCode}ãçåºåºä»»å¡"); |
| | | if (supplyTask.StockQuantity != orderQty) throw new Exception($"订åå·ã{request.orderNo}ãç©æç¼å·ã{detail.productCode}ãçåºåºæ°éä¸åºåºä»»å¡æ°éä¸ç¸ç"); |
| | | #endregion |
| | | |
| | | batch.OutboundQuantity += orderQty; |
| | | batch.StockQuantity -= orderQty; |
| | | if (batch.StockQuantity < 0) batch.StockQuantity = 0; |
| | | batch.Remark = "åºåºååä¼ "; |
| | | #region å¤çåºåºåãåºåä¿¡æ¯ãåºåºä»»å¡ãè°æ¨ä»»å¡ |
| | | var content = _deliveryOrderServices.OutTaskFinish(supplyTask); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | #endregion |
| | | } |
| | | } |
| | | 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.Remark = "çç¹ååä¼ - çäº"; |
| | | } |
| | | else if (flag == 2) // çç |
| | | { |
| | | batch.SupplyQuantity = batch.StockQuantity + diff; |
| | | batch.Remark = "çç¹ååä¼ - çç"; |
| | | } |
| | | else // çä¸ |
| | | { |
| | | batch.Remark = "çç¹ååä¼ - çä¸"; |
| | | 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.externalOrderNo && x.WarehouseCode == WarehouseLK && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).First(); |
| | | if (supplyTask == null) throw new Exception($"æªæ¾å°è®¢åå·ã{request.externalOrderNo}ãç©æç¼å·ã{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; |
| | | } |
| | | var content = _deliveryOrderServices.CheckTaskFinish(supplyTask); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | // 8ï¸â£ ä¿åæ°æ® |
| | | 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ï¸â£ æäº¤äºå¡ |
| | |
| | | } |
| | | |
| | | |
| | | /// <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.åºå |