| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | { |
| | | return content.Error($"çæä»»å¡å¤±è´¥"); |
| | | } |
| | | tasks.ForEach(x => |
| | | { |
| | | x.Grade = 1; |
| | | }); |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | |
| | | if (proStockInfo != null && proStockInfo.StockStatus==StockStatusEmun.åºåºéå®.ObjToInt()) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | //è·åææåºåºè¯¦æ
æ°æ® |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = _outboundRepository.OutStockLockInfoRepository.QueryData(x => x.TaskNum == task.TaskNum); |
| | | _unitOfWorkManage.BeginTran(); |
| | | proStockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | _stockRepository.ProStockInfoRepository.DeleteAndMoveIntoHty(proStockInfo,App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | if (proStockInfo.proStockInfoDetails!=null && proStockInfo.proStockInfoDetails.Count>0) |
| | | { |
| | | _stockRepository.ProStockInfoDetailRepository.DeleteAndMoveIntoHty(proStockInfo.proStockInfoDetails, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | if (outStockLockInfos != null && outStockLockInfos.Count > 0) |
| | | { |
| | | outStockLockInfos.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºå®æ.ObjToInt(); |
| | | }); |
| | | List<Dt_OutStockLockInfo> outStockLockInfosMES = outStockLockInfos.Where(x => x.OrderType == OutOrderTypeEnum.OutMESPick.ObjToInt()).ToList(); |
| | | if (outStockLockInfosMES != null && outStockLockInfosMES.Count() > 0) |
| | | { |
| | | Dt_AGVStationInfo aGVStationInfo = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.TargetAddress); |
| | | MESDeliveryModel mESDeliveryModel = MESDeliveryUp(outStockLockInfosMES, aGVStationInfo.MESPointCode); |
| | | MESResponse response = _invokeMESService.MESDelivery(mESDeliveryModel).DeserializeObject<MESResponse>() ?? throw new Exception("æªè·åå°è¿åä¿¡æ¯"); |
| | | if (!response.Result) |
| | | { |
| | | throw new Exception($"MESé
éåºåæ¥å£è°ç¨æ¥é,MESè¿åä¿¡æ¯{DecodeUnicode(response.Msg)}"); |
| | | } |
| | | } |
| | | } |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, proStockInfo.PalletType, LocationStatusEnum.Free, proStockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | |
| | | return content.Error($"è´§ä½ç¶æä¸æ£ç¡®"); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == task.PalletCode); |
| | | int wareId=stockInfo.WarehouseId; |
| | | if (stockInfo != null && stockInfo.StockStatus == StockStatusEmun.åºåºéå®.ObjToInt()) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | |
| | | } |
| | | if (outStockLockInfosMES != null && outStockLockInfosMES.Count() > 0) |
| | | { |
| | | Dt_AGVStationInfo aGVStationInfo = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.AGVStationCode==task.TargetAddress); |
| | | Dt_AGVStationInfo aGVStationInfo = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.AGVStationCode==task.TargetAddress || x.MESPointCode == task.TargetAddress); |
| | | MESDeliveryModel mESDeliveryModel = MESDeliveryUp(outStockLockInfosMES, aGVStationInfo.MESPointCode); |
| | | MESResponse response = _invokeMESService.MESDelivery(mESDeliveryModel).DeserializeObject<MESResponse>() ?? throw new Exception("æªè·åå°è¿åä¿¡æ¯"); |
| | | if (!response.Result) |
| | |
| | | } |
| | | } |
| | | } |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, wareId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | |
| | | DispatchPlanMaterialId=item.OrderDetailId, |
| | | UnitCode=item.Unit, |
| | | GradeCode="001", |
| | | MainQuantity=item.AssignQuantity, |
| | | MainQuantity=item.OriginalQuantity, |
| | | AssistUnitCode=item.AssistUnit, |
| | | LocationCode= address, |
| | | LotNumber=item.BatchNo, |
| | |
| | | return tasks; |
| | | } |
| | | /// <summary> |
| | | /// åºåæ°æ®è½¬åºåºä»»å¡(MESå·¥å) |
| | | /// åºåæ°æ®è½¬åºåºä»»å¡(MESå·¥åæå) |
| | | /// </summary> |
| | | /// <param name="stockInfos"></param> |
| | | /// <returns></returns> |
| | | public List<Dt_Task> GetTasks(List<Dt_ProStockInfo> stockInfos, List<Dt_OutStockLockInfo> outStockLockInfos, TaskTypeEnum taskType = new TaskTypeEnum()) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | for (int i = 0; i < stockInfos.Count; i++) |
| | | { |
| | | Dt_ProStockInfo stockInfo = stockInfos[i]; |
| | | |
| | | if (stockInfo != null) |
| | | { |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode); |
| | | if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode)) |
| | | { |
| | | Dt_OutStockLockInfo outStockLockInfo = outStockLockInfos.FirstOrDefault(x => x.PalletCode == stockInfo.PalletCode); |
| | | taskType = outStockLockInfo.MachineName.ObjToInt() switch |
| | | { |
| | | (int)StationAreaEnum.äºæ¥¼çº¸è¢ or |
| | | (int)StationAreaEnum.äºæ¥¼æ 纺å¸è¢ or |
| | | (int)StationAreaEnum.äºæ¥¼çº¸æ¯ => TaskTypeEnum.OutCarton, |
| | | (int)StationAreaEnum.䏿¥¼æ 纺ç»å¸ => TaskTypeEnum.OutWFB, |
| | | _ => throw new Exception($"æªæ¾å°å å·¥ä¸å¿ä»»å¡ç±»ååé
") |
| | | }; |
| | | Dt_Task task = new() |
| | | { |
| | | CurrentAddress = stockInfo.LocationCode, |
| | | Grade = 0, |
| | | PalletCode = stockInfo.PalletCode, |
| | | NextAddress = "", |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = stockInfo.LocationCode, |
| | | TargetAddress = "", |
| | | TaskStatus = TaskStatusEnum.CallPending.ObjToInt(), |
| | | TaskType = taskType.ObjToInt(), |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | MaterielCode = stockInfo.proStockInfoDetails?.FirstOrDefault().ProductCode ??"", |
| | | Quantity = stockInfo.proStockInfoDetails?.Sum(x=>x.StockQty) ?? 0, |
| | | OrderNo = outStockLockInfo.OrderNo, |
| | | DispatchPlanId = outStockLockInfo.OrderDetailId, |
| | | WorkCentreCode = outStockLockInfo.MakeCode |
| | | }; |
| | | tasks.Add(task); |
| | | } |
| | | } |
| | | } |
| | | return tasks; |
| | | } |
| | | /// <summary> |
| | | /// åºåæ°æ®è½¬åºåºä»»å¡(MESå·¥ååæ) |
| | | /// </summary> |
| | | /// <param name="stockInfos"></param> |
| | | /// <returns></returns> |
| | |
| | | taskType = outStockLockInfo.MachineName.ObjToInt() switch |
| | | { |
| | | (int)StationAreaEnum.äºæ¥¼çº¸è¢ => TaskTypeEnum.PaperYLOutZDGL, |
| | | (int)StationAreaEnum.äºæ¥¼æ 纺å¸è¢ => TaskTypeEnum.OutWFBGL, |
| | | (int)StationAreaEnum.䏿¥¼æ 纺æ·è => TaskTypeEnum.OutWFBLM, |
| | | (int)StationAreaEnum.䏿¥¼å°å· => TaskTypeEnum.PrintYLOutbound, |
| | | (int)StationAreaEnum.䏿¥¼åå => TaskTypeEnum.OutFenQie, |
| | | (int)StationAreaEnum.䏿¥¼çº¸å¼ æ·è => TaskTypeEnum.OutPaperLM, |
| | | _ => throw new Exception($"æªæ¾å°å å·¥ä¸å¿ä»»å¡ç±»ååé
") |
| | | }; |
| | | Dt_Task task = new() |
| | |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | MaterielCode= stockInfo.proStockInfoDetails?.FirstOrDefault().ProductCode ?? "" , |
| | | Quantity = 0, |
| | | Quantity = stockInfo.proStockInfoDetails?.Sum(x=>x.StockQty) ?? 0, |
| | | }; |
| | | tasks.Add(task); |
| | | } |
| | |
| | | nameof(StationAreaEnum.䏿¥¼åå) => TaskTypeEnum.OutFenQie, |
| | | nameof(StationAreaEnum.䏿¥¼æ¨¡å) => TaskTypeEnum.OutMoQie, |
| | | nameof(StationAreaEnum.䏿¥¼å²å) => TaskTypeEnum.OutChongQie, |
| | | nameof(StationAreaEnum.䏿¥¼æå) => TaskTypeEnum.OutProduct, |
| | | nameof(StationAreaEnum.äºæ¥¼çº¸è¢) or |
| | | nameof(StationAreaEnum.äºæ¥¼æ 纺å¸è¢) or |
| | | nameof(StationAreaEnum.äºæ¥¼çº¸æ¯) => TaskTypeEnum.OutCarton, |
| | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | //çæä»»å¡ãåºåçä¿¡æ¯ |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutSGOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutSGTaskDataHandle(keys); |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutSGOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?,string) result = OutSGTaskDataHandle(keys); |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | | stockInfos.AddRange(result.Item2); |
| | |
| | | { |
| | | tasks.AddRange(result.Item1); |
| | | } |
| | | content.Message = result.Item6; |
| | | //å¤çåºåºæ°æ® |
| | | return GenerateOutboundTaskDataUpdate(tasks, stockInfos, outSGOrderDetails, outStockLockInfos, locationInfos); |
| | | return GenerateOutboundTaskDataUpdate(tasks, stockInfos, outSGOrderDetails, outStockLockInfos, locationInfos, result.Item6); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// <param name="stockSelectViews"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutSGOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutSGTaskDataHandle(int[] keys) |
| | | public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutSGOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?,string) OutSGTaskDataHandle(int[] keys) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_OutSGOrderDetail> outSGOrderDetails = _outboundRepository.OutSGOrderDetailRepository.QueryData(x => keys.Contains(x.Id)); |
| | |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | |
| | | //åé
åºå |
| | | (List<Dt_StockInfo>, List<Dt_OutSGOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutSGOrderDetailService.AssignStockOutbound(outSGOrderDetails); |
| | | (List<Dt_StockInfo>, List<Dt_OutSGOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>,string) result = _outboundService.OutSGOrderDetailService.AssignStockOutbound(outSGOrderDetails); |
| | | |
| | | //ä¿å缺æç¶æï¼æ 论æ¯å¦çæäºä»»å¡ |
| | | var shortageDetails = result.Item2.Where(x => x.OutSGOrderDetailStatus == OutOrderStatusEnum.缺æ.ObjToInt()).ToList(); |
| | | if (shortageDetails.Any()) |
| | | { |
| | | _outboundRepository.OutSGOrderDetailRepository.UpdateData(shortageDetails); |
| | | } |
| | | |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | //è·åä»»å¡ |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.OldYLOutbound); |
| | | tasks = GetTasks(result.Item1.Where(x=> !x.LocationCode.IsNullOrEmpty()).ToList(), TaskTypeEnum.OldYLOutbound); |
| | | result.Item2.ForEach(x => |
| | | { |
| | | if (result.Item3.FirstOrDefault(t=>t.OrderDetailId==x.Id)!=null) |
| | |
| | | }); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | if (x.LocationCode== "èåç¼ååº") |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºå®æ.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | } |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | //没æåºåï¼ä½å·²ç»å¨AssignStockOutboundæ¹æ³ä¸æ è®°äºç¼ºæç¶æï¼å¹¶ä¸å·²ç»ä¿å |
| | | orderDetails = result.Item2; |
| | | } |
| | | |
| | | return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); |
| | | return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos, result.Item5); |
| | | } |
| | | /// <summary> |
| | | /// å¤çåºåºæ°æ® |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutSGOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutSGOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null, string message = "") |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | tasks.ForEach(x => |
| | | { |
| | | string orderNos = string.Join(",", outStockLockInfos.Where(t => t.PalletCode == x.PalletCode).Select(x => x.OrderNo).Distinct()); |
| | | List<Dt_OutStockLockInfo> outStockNos = outStockLockInfos.Where(t => t.PalletCode == x.PalletCode).ToList(); |
| | | List<int> outDetailIds = outStockNos.Select(t => t.OrderDetailId).ToList(); |
| | | int numberNo = outboundOrderDetails.Where(t => outDetailIds.Contains(t.Id)).OrderBy(x => x.Number).FirstOrDefault().Number; |
| | | string orderNos = string.Join(",", outStockNos.Select(t => t.OrderNo).Distinct()); |
| | | x.OrderNo = orderNos; |
| | | x.Grade = numberNo; |
| | | }); |
| | | } |
| | | BaseDal.AddData(tasks); |
| | |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | return WebResponseContent.Instance.OK(); |
| | | return WebResponseContent.Instance.OK(message); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //æ°å¢ |
| | | List<BSTPickInfoDTO> bSTPickInfosAdd = bSTPickInfoDTOs.Where(x => x.Way == 1).ToList(); |
| | | //è·åæ°å¢æç»é¢æ |
| | | List<PaperMattakeDetailItem>? paperMattakeDetailItemsAdd = null; |
| | | //ä¿®æ¹ |
| | | List<BSTPickInfoDTO> bSTPickInfosUp = bSTPickInfoDTOs.Where(x => x.Way == 2).ToList(); |
| | | //è·åæ°å¢æç»é¢æ |
| | | List<PaperMattakeDetailItem>? paperMattakeDetailItemsUp = null; |
| | | if (bSTPickInfosAdd != null && bSTPickInfosAdd.Count > 0) |
| | | { |
| | | paperMattakeDetailItemsAdd = bSTPickInfosAdd.SelectMany(x => x.PaperMattakeDetails).ToList(); |
| | | } |
| | | if (bSTPickInfosUp != null && bSTPickInfosUp.Count > 0) |
| | | { |
| | | paperMattakeDetailItemsUp = bSTPickInfosUp.SelectMany(x => x.PaperMattakeDetails).ToList(); |
| | | } |
| | | //è·åææå¾
颿çåºåºè¯¦æ
|
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundRepository.OutStockLockInfoRepository.QueryData(x => x.OrderType == OutOrderTypeEnum.OutSGPick.ObjToInt() && x.Status==OutLockStockStatusEnum.åºåºå®æ.ObjToInt()); |
| | | #region 颿é»è¾ |
| | | if (paperMattakeDetailItemsAdd != null && paperMattakeDetailItemsAdd.Count > 0) |
| | | { |
| | | foreach (var item in paperMattakeDetailItemsAdd) |
| | | { |
| | | //è·å对åºç |
| | | } |
| | | } |
| | | |
| | | if (paperMattakeDetailItemsUp != null && paperMattakeDetailItemsUp.Count > 0) |
| | | //è·å颿æ¡ç ååºå |
| | | List<string> lockCodes = bSTPickInfoDTOs.SelectMany(x => x.PaperMattakeDetails).Select(x=>x.Barcode).Distinct().ToList(); |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.QueryData(x => lockCodes.Contains(x.PalletCode) && x.WarehouseId == WarehouseEnum.LLDOldCache.ObjToInt()); |
| | | List<string> ExistNoCodes = lockCodes.Where(x => !stockInfos.Select(x=>x.PalletCode).Contains(x)).ToList(); |
| | | //è·åå¾
颿çåºåºè¯¦æ
|
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundRepository.OutStockLockInfoRepository.QueryData(x => x.OrderType == OutOrderTypeEnum.OutSGPick.ObjToInt() && x.Status==OutLockStockStatusEnum.åºåºå®æ.ObjToInt() && lockCodes.Distinct().ToList().Contains(x.PalletCode)); |
| | | //åºåºè¯¦æ
ç¶ææ´æ° |
| | | if (outStockLockInfos.Count > 0) |
| | | { |
| | | foreach (var item in paperMattakeDetailItemsUp) |
| | | outStockLockInfos.ForEach(x => |
| | | { |
| | | |
| | | x.Status = OutLockStockStatusEnum.å
³é.ObjToInt(); |
| | | }); |
| | | } |
| | | List<int> BSTPickDetailsId = outStockLockInfos.Select(x => x.OrderDetailId).Distinct().ToList(); |
| | | //è·åå¯¹åºæç¨ |
| | | List<Dt_OutSGOrder> outSGOrders = BaseDal.Db.Queryable<Dt_OutSGOrder>().Where(x => x.OutSGOrderStatus < OutOrderStatusEnum.åºåºå®æ.ObjToInt()).Includes(x => x.Details) |
| | | .Where(x => x.Details |
| | | .Any(v => |
| | | BSTPickDetailsId.Contains(v.Id)) |
| | | ).OrderBy(x => x.CreateDate).ToList(); |
| | | List<Dt_OutSGOrderDetail> orderDetails = new List<Dt_OutSGOrderDetail>(); |
| | | //å¤çæç¨ |
| | | if (outSGOrders.Count>0) |
| | | { |
| | | orderDetails = outSGOrders.SelectMany(x=>x.Details).Where(x=> BSTPickDetailsId.Contains(x.Id)).ToList(); |
| | | orderDetails.ForEach(x => |
| | | { |
| | | x.OutSGOrderDetailStatus = OutOrderStatusEnum.åºåºå®æ.ObjToInt(); |
| | | }); |
| | | foreach (var item in outSGOrders) |
| | | { |
| | | int overCount = item.Details.Where(x=>x.OutSGOrderDetailStatus==OutLockStockStatusEnum.åºåºå®æ.ObjToInt()).Count(); |
| | | int thisCount = orderDetails.Where(x => x.OutSGOrderId == item.Id).Count(); |
| | | if ((overCount + thisCount) == item.Details.Count) |
| | | { |
| | | item.OutSGOrderStatus = OutOrderStatusEnum.åºåºå®æ.ObjToInt(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | //è·åææå¾
颿çåºå |
| | | #region 颿é»è¾ |
| | | foreach (var item in stockInfos) |
| | | { |
| | | if (item.StockStatus==StockStatusEmun.åºåºå®æ.ObjToInt() || item.StockStatus == StockStatusEmun.èåéææå.ObjToInt()) |
| | | { |
| | | item.StockLength = 0; |
| | | item.MaterielWeight = 0; |
| | | item.MaterielThickness = 0; |
| | | item.StockOutLength = 0; |
| | | item.IsFull = WhetherEnum.True.ObjToInt(); |
| | | item.IsPick = WhetherEnum.True.ObjToInt(); |
| | | } |
| | | } |
| | | #endregion |
| | | List<Dt_OutLineView> outLineViewsDel = _outboundRepository.OutLineViewRepository.QueryData(x => stockInfos.Select(x=>x.PalletCode).Contains(x.PalletCode)); |
| | | //æ°æ®åºæä½ |
| | | _unitOfWorkManage.BeginTran(); |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfos); |
| | | _outboundRepository.OutStockLockInfoRepository.UpdateData(outStockLockInfos); |
| | | _outboundRepository.OutSGOrderRepository.UpdateData(outSGOrders); |
| | | _outboundRepository.OutSGOrderDetailRepository.UpdateData(orderDetails); |
| | | _outboundRepository.OutLineViewRepository.DeleteData(outLineViewsDel); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(ExistNoCodes.Count>0 ? string.Join(",", ExistNoCodes)+"èå坿£åºåä¸åå¨" : ""); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// å建éå®åºåº |
| | | /// </summary> |
| | | /// <param name="ids"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateProDeliveryTasks(List<int> ids) |
| | | { |
| | | WebResponseContent content=new WebResponseContent(); |
| | | try |
| | | { |
| | | ////è·åéå®åºåºåæ® |
| | | //List<Dt_ProDeliveryOrder> deliveryOrders = BaseDal.Db.Queryable<Dt_ProDeliveryOrder>().Where(x=> ids.Contains(x.Id)).Includes(x=>x.Details).ToList(); |
| | | //Dt_ProDeliveryOrder? proDeliveryOrder = deliveryOrders.FirstOrDefault(x => x.ProDeliveryStatus != OutOrderStatusEnum.æªå¼å§.ObjToInt()); |
| | | //if (proDeliveryOrder != null) |
| | | //{ |
| | | // return content.Error($"åå·{proDeliveryOrder.DeliveryCode},订åç¶æ{(OutOrderStatusEnum)proDeliveryOrder.ProDeliveryStatus}"); |
| | | //} |
| | | //List<Dt_ProDeliveryOrderDetail> proDeliveryOrderDetails = deliveryOrders.SelectMany(x=>x.Details).ToList(); |
| | | //if (!proDeliveryOrderDetails.Any()) |
| | | //{ |
| | | // throw new Exception($"æªæ¾å°éåºåºçæç»ä¿¡æ¯"); |
| | | //} |
| | | //_unitOfWorkManage.BeginTran(); |
| | | //List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | //List<Dt_ProStockInfo>? stockInfos = null; |
| | | //List<Dt_ProDeliveryOrder>? Orders = null; |
| | | //List<Dt_ProDeliveryOrderDetail>? OrderDetails = null; |
| | | //List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | //List<Dt_LocationInfo>? locationInfos = null; |
| | | //{ |
| | | // //åé
åºå |
| | | // (List<Dt_ProStockInfo>, List<Dt_ProDeliveryOrder>, List<Dt_ProDeliveryOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.ProDeliveryOrderService.AssignProStockOutbound(deliveryOrders, proDeliveryOrderDetails); |
| | | // if (result.Item1 != null && result.Item1.Count > 0) |
| | | // { |
| | | // //åå»ºä»»å¡ |
| | | // tasks = GetTasks(result.Item1, result.Item3); |
| | | // result.Item3.ForEach(x => |
| | | // { |
| | | // x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | // }); |
| | | // stockInfos = result.Item1; |
| | | // Orders = result.Item2; |
| | | // outStockLockInfos = result.Item3; |
| | | // locationInfos = result.Item4; |
| | | // } |
| | | //} |
| | | //if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0 && tasks.Count > 0) |
| | | //{ |
| | | // BaseDal.AddData(tasks); |
| | | // stockInfos.ForEach(x => |
| | | // { |
| | | // x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | // }); |
| | | // WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | // if (!contentResponse.Status) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return content.Error(contentResponse.Message); |
| | | // } |
| | | //} |
| | | //_unitOfWorkManage.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | List<string> GradeCodes = new List<string> |
| | | { |
| | | "001" |
| | |
| | | public WebResponseContent ReceiveOutBound(List<OutMESOrderDTO> outMESOrderDTOs) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | string ErrorMsg = ""; |
| | | try |
| | | { |
| | | if (outMESOrderDTOs == null || outMESOrderDTOs.Count <= 0) |
| | |
| | | //è·åææå å·¥ä¸å¿ |
| | | List<Dt_MakeCenterInfo> makeCenterInfos = _basicRepository.MakeCenterInfoRepository.QueryData(); |
| | | |
| | | OutMESOrderDTO? CheckMaterialCode = outMESOrderDTOs.FirstOrDefault(x => !materielInfos.Select(x => x.MaterielCode).Contains(x.MaterialCode)); |
| | | if (CheckMaterialCode != null) |
| | | { |
| | | return content.Error($"ç©æç¼ç {nameof(OutMESOrderDTO.MaterialCode)}:{CheckMaterialCode.MaterialCode}ä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | //OutMESOrderDTO? CheckMaterialCode = outMESOrderDTOs.FirstOrDefault(x => !materielInfos.Select(x => x.MaterielCode).Contains(x.MaterialCode)); |
| | | //if (CheckMaterialCode != null) |
| | | //{ |
| | | // return content.Error($"ç©æç¼ç {nameof(OutMESOrderDTO.MaterialCode)}:{CheckMaterialCode.MaterialCode}ä¿¡æ¯ä¸åå¨"); |
| | | //} |
| | | OutMESOrderDTO? CheckMakeCenterCode = outMESOrderDTOs.FirstOrDefault(x => !makeCenterInfos.Select(x => x.MakeCode).Contains(x.MakeCode)); |
| | | if (CheckMakeCenterCode!=null) |
| | | { |
| | |
| | | { |
| | | return content.Error($"é¢æè®¡å{nameof(OutMESOrderDTO.OutDetailId)}:{OldoutMESOrder.OutDetailId}ä¿¡æ¯å·²åå¨"); |
| | | } |
| | | List<Dt_OutMESOrder> AddoutMESOrders = outMESOrderDTOs.Select(x => _mapper.Map<Dt_OutMESOrder>(x)).ToList(); |
| | | foreach (var item in AddoutMESOrders) |
| | | List<Dt_OutMESOrder> AddoutMESOrders = new List<Dt_OutMESOrder>(); |
| | | foreach (var item in outMESOrderDTOs) |
| | | { |
| | | Dt_MaterielInfo materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode); |
| | | Dt_MakeCenterInfo makeCenterInfo=makeCenterInfos.FirstOrDefault(x => x.MakeCode == item.MakeCode); |
| | | item.MakeArea = makeCenterInfo.MakeArea; |
| | | item.WarehouseId = materielInfo.WarehouseId; |
| | | item.MaterielUnit = materielInfo.MaterielUnit; |
| | | item.AssistUnitCode = materielInfo.AssistUnitCode; |
| | | Dt_MaterielInfo? materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode); |
| | | if (materielInfo==null) |
| | | { |
| | | ErrorMsg += $"ç©æç¼ç :{item.MaterialCode}ä¿¡æ¯ä¸åå¨;"; |
| | | continue; |
| | | } |
| | | Dt_MakeCenterInfo makeCenterInfo = makeCenterInfos.FirstOrDefault(x => x.MakeCode == item.MakeCode); |
| | | Dt_OutMESOrder outMESOrder = _mapper.Map<Dt_OutMESOrder>(item); |
| | | outMESOrder.MakeArea = makeCenterInfo.MakeArea; |
| | | outMESOrder.WarehouseId = materielInfo.WarehouseId; |
| | | outMESOrder.MaterielUnit = materielInfo.MaterielUnit; |
| | | outMESOrder.AssistUnitCode = materielInfo.AssistUnitCode; |
| | | AddoutMESOrders.Add(outMESOrder); |
| | | } |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æä½æ°æ®ï¼å¹¶åé
éæ±åºå |
| | | _outboundRepository.OutMESOrderRepository.AddData(AddoutMESOrders); |
| | | List<Dt_OutMESOrder> mESOrders = _outboundRepository.OutMESOrderRepository.QueryData(x => AddoutMESOrders.Select(x => x.OutDetailId).Contains(x.OutDetailId)); |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutMESOrder>? Orders = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | //åé
åºå |
| | | (List<Dt_StockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignStockOutbound(mESOrders); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_ProStockInfo>? stockInfos = null; |
| | | List<Dt_OutMESOrder>? Orders = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | //åå»ºä»»å¡ |
| | | tasks = GetTasks(result.Item1, result.Item3); |
| | | result.Item2.ForEach(x => |
| | | if (mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()).ToList().Count > 0) |
| | | { |
| | | OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | Orders = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | //åé
åºå |
| | | (List<Dt_ProStockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignProStockOutbound(mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()).ToList()); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | //åå»ºä»»å¡ |
| | | tasks = GetTasks(result.Item1, result.Item3); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | stockInfos = result.Item1; |
| | | Orders = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0 && tasks.Count > 0) |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | BaseDal.AddData(tasks); |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!contentResponse.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content.Error(contentResponse.Message); |
| | | } |
| | | } |
| | | } |
| | | int id = BaseDal.AddData(tasks); |
| | | |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | stockInfos.ForEach(x => |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutMESOrder>? Orders = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | x.StockStatus=StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!contentResponse.Status) |
| | | if (mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDYL.ObjToInt()).ToList().Count > 0) |
| | | { |
| | | //åé
åºå |
| | | (List<Dt_StockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignStockOutbound(mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDYL.ObjToInt()).ToList()); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | //åå»ºä»»å¡ |
| | | tasks = GetTasks(result.Item1, result.Item3); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | stockInfos = result.Item1; |
| | | Orders = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | } |
| | | } |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0 && tasks.Count > 0) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content.Error(contentResponse.Message); |
| | | BaseDal.AddData(tasks); |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks); |
| | | if (!contentResponse.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content.Error(contentResponse.Message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return content.OK("æ¥æ¶æå"); |
| | | return content.OK(ErrorMsg.IsNullOrEmpty()? "æ¥æ¶æå" : $"ä¿¡æ¯ï¼{ErrorMsg}"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// 空æå çåºåº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent PlateOutbound(string stationCode) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //è·åæææå°åºåºä»»å¡ |
| | | Dt_Task TasksOut = BaseDal.QueryFirst(x => x.TaskType == TaskTypeEnum.OutEmptyPlate.ObjToInt()); |
| | | if (TasksOut != null) |
| | | throw new Exception($"ä»»å¡å·²åå¨"); |
| | | //è·åè´§ä½ |
| | | List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()); |
| | | Dt_ProStockInfo? stockInfo = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Select(x => x.LocationCode).Contains(x.LocationCode) && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.ProStockAttribute == ProStockAttributeEnum.空æ.ObjToInt()).OrderBy(x => x.CreateDate).ToList().FirstOrDefault() ?? throw new Exception($"åºåç©ºææ°éä¸è¶³"); |
| | | |
| | | Dt_LocationInfo locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == stockInfo.LocationCode); |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | |
| | | TaskTypeEnum typeEnum = TaskTypeEnum.OutEmptyPlate; |
| | | |
| | | List<Dt_Task> tasks = GetTasks(new List<Dt_ProStockInfo>() { stockInfo }, typeEnum, new List<Dt_LocationInfo>() { locationInfo }); |
| | | if (tasks == null || tasks.Count <= 0) |
| | | { |
| | | return content.Error($"çæä»»å¡å¤±è´¥"); |
| | | } |
| | | tasks.ForEach(x => |
| | | { |
| | | x.TargetAddress = stationCode; |
| | | }); |
| | | //夿æ¯å¦æåºåºåä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ´æ°åºåç¶æ |
| | | _stockRepository.ProStockInfoRepository.UpdateData(stockInfo); |
| | | //æ´æ°è´§ä½ç¶æ |
| | | _basicRepository.LocationInfoRepository.UpdateLocationStatus(new List<Dt_LocationInfo>() { locationInfo }, LocationStatusEnum.Lock); |
| | | //å å
¥è´§ä½åå¨è®°å½ |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(new List<Dt_LocationInfo>() { locationInfo }, LocationStatusEnum.Lock, LocationChangeType.OutboundAssignLocation, taskNums: tasks.Select(x => x.TaskNum).ToList()); |
| | | //æ°å»ºä»»å¡ |
| | | BaseDal.AddData(tasks); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |