| | |
| | | using WIDESEA_DTO.ERP; |
| | | using WIDESEA_Common.MaterielEnum; |
| | | using WIDESEA_Common.WareHouseEnum; |
| | | using WIDESEA_DTO.MES; |
| | | using WIDESEA_DTO.Outbound; |
| | | using Microsoft.IdentityModel.Tokens; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åWMSç³è¯·åºåºAGVç»ç¹ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AssignOutTargetAddress(int taskNum) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); |
| | | } |
| | | if (_agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.TargetAddress) != null) |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | Dt_AGVStationInfo? aGVStationInfo = _agvStationInfoRepository.QueryData(x => x.StationArea == nameof(AGVStationAreaEnum.䏿¥¼æå°ç 头) && x.IsOccupied == WhetherEnum.False.ObjToInt()).OrderByDescending(x => x.Depth).FirstOrDefault(); |
| | | if (aGVStationInfo==null) |
| | | { |
| | | return content.Error("æªæ¾å°å¯åé
çåºåºç«ç¹"); |
| | | } |
| | | aGVStationInfo.IsOccupied = WhetherEnum.True.ObjToInt(); |
| | | _agvStationInfoRepository.UpdateData(aGVStationInfo); |
| | | content.OK("æå",data: aGVStationInfo.AGVStationCode); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åºåºä»»å¡å®æ |
| | | /// </summary> |
| | | public WebResponseContent OutboundTaskCompleted(Dt_Task task) |
| | |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | if (task.TaskType == TaskTypeEnum.OldYLOutbound.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | stockInfo.WarehouseId = WarehouseEnum.LLDOldCache.ObjToInt(); |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | MaterielCode = stockInfo.MaterielCode, |
| | | RfidCode = stockInfo.RfidCode, |
| | | Quantity = stockInfo.StockLength, |
| | | }; |
| | | if (stockInfo.MaterielWide>0) |
| | |
| | | /// æååºåº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestCPWMSTaskOut(string materialCode,int Count, int targetId) |
| | | public WebResponseContent RequestCPWMSTaskOut(string materialCode,int Count, string targetId) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x=>x.StationArea == targetId && x.IsOccupied==WhetherEnum.False.ObjToInt()); |
| | | if (aGVStationInfos.Count< Count) |
| | | int useCount=aGVStationInfos.Count; |
| | | if (targetId == nameof(AGVStationAreaEnum.䏿¥¼æå°ç 头)) |
| | | { |
| | | |
| | | //è·åæææå°åºåºä»»å¡ |
| | | List<Dt_Task> _TasksOut = BaseDal.QueryData(x => x.TaskType == TaskTypeEnum.OutProduct.ObjToInt() && x.TargetAddress == nameof(AGVStationAreaEnum.䏿¥¼æå°ç 头)); |
| | | useCount -= _TasksOut.Count; |
| | | } |
| | | if (useCount < Count) |
| | | { |
| | | return content.Error($"å¯ç¨ç¼åæ°ä¸è¶³"); |
| | | } |
| | | //è·åè´§ä½ |
| | | List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()); |
| | | |
| | | //è·åå¯ç¨åºå |
| | | List<Dt_ProStockInfo> stockInfos = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Select(x => x.LocationCode).Contains(x.LocationCode) && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt()).Includes(x => x.proStockInfoDetails) |
| | | .Where(x => x.proStockInfoDetails |
| | | .Any(v => |
| | | v.ProductCode == materialCode) |
| | | ).Take(Count).ToList(); |
| | | List<Dt_ProStockInfo> stockInfos = new List<Dt_ProStockInfo>(); |
| | | if (materialCode=="1") |
| | | { |
| | | stockInfos = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Select(x => x.LocationCode).Contains(x.LocationCode) && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.ProStockAttribute==ProStockAttributeEnum.空æ.ObjToInt()).Take(Count).ToList(); |
| | | } |
| | | else |
| | | { |
| | | stockInfos = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Select(x => x.LocationCode).Contains(x.LocationCode) && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt()).Includes(x => x.proStockInfoDetails) |
| | | .Where(x => x.proStockInfoDetails |
| | | .Any(v => |
| | | v.ProductCode == materialCode) |
| | | ).Take(Count).ToList(); |
| | | } |
| | | |
| | | if (stockInfos.Count!=Count) |
| | | { |
| | |
| | | } |
| | | TaskTypeEnum typeEnum = targetId switch |
| | | { |
| | | (int)AGVStationAreaEnum.AreaA => TaskTypeEnum.OutProduct, |
| | | (int)AGVStationAreaEnum.AreaC => TaskTypeEnum.OutWFB, |
| | | nameof(AGVStationAreaEnum.䏿¥¼æå°ç 头) => TaskTypeEnum.OutProduct, |
| | | nameof(AGVStationAreaEnum.䏿¥¼æ 纺ç»å¸) => TaskTypeEnum.OutWFB, |
| | | nameof(AGVStationAreaEnum.䏿¥¼æ 纺æ·è) => TaskTypeEnum.OutWFBLM, |
| | | nameof(AGVStationAreaEnum.䏿¥¼çº¸å¼ æ·è) => TaskTypeEnum.OutPaperLM, |
| | | nameof(AGVStationAreaEnum.䏿¥¼åå) => TaskTypeEnum.OutFenQie, |
| | | nameof(AGVStationAreaEnum.䏿¥¼æ¨¡å) => TaskTypeEnum.OutMoQie, |
| | | nameof(AGVStationAreaEnum.䏿¥¼å²å) => TaskTypeEnum.OutChongQie, |
| | | nameof(AGVStationAreaEnum.äºæ¥¼çº¸è¢) => TaskTypeEnum.OutCarton, |
| | | _ => throw new Exception("æªæ¾å°å¯¹åºä»»å¡") |
| | | }; |
| | | if (materialCode == "1" && typeEnum!= TaskTypeEnum.OutCarton) |
| | | { |
| | | typeEnum = TaskTypeEnum.OutEmpty; |
| | | } |
| | | List<Dt_Task> tasks = GetTasks(stockInfos, typeEnum, AssignLocations); |
| | | if (tasks == null || tasks.Count <= 0) |
| | | { |
| | | return content.Error($"çæä»»å¡å¤±è´¥"); |
| | | } |
| | | for (int i = 0; i < tasks.Count; i++) |
| | | //æåä»»å¡ä¸ç´æ¥åé
ç»ç¹ |
| | | if (targetId != nameof(AGVStationAreaEnum.䏿¥¼æå°ç 头)) |
| | | { |
| | | aGVStationInfos[i].IsOccupied = WhetherEnum.True.ObjToInt(); |
| | | tasks[i].TargetAddress = aGVStationInfos[i].AGVStationCode; |
| | | for (int i = 0; i < tasks.Count; i++) |
| | | { |
| | | aGVStationInfos[i].IsOccupied = WhetherEnum.True.ObjToInt(); |
| | | tasks[i].TargetAddress = aGVStationInfos[i].AGVStationCode; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (int i = 0; i < tasks.Count; i++) |
| | | { |
| | | tasks[i].TargetAddress = nameof(AGVStationAreaEnum.䏿¥¼æå°ç 头); |
| | | } |
| | | } |
| | | //夿æ¯å¦æåºåºåä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | |
| | | /// <param name="materielWide">ç©æå¹
宽</param> |
| | | /// <param name="Count">å·æ°</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestYLWMSTaskOut(string materielCode, int materielWide, int Count, string address = "") |
| | | public WebResponseContent RequestYLWMSTaskOut(YLWMSTaskOutDTO yLWMSTaskOutDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | if (yLWMSTaskOutDTO==null) |
| | | { |
| | | return content.Error("请填å
¥åºåºä¿¡æ¯"); |
| | | } |
| | | //è·åè´§ä½ |
| | | List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => x.WarehouseId == WarehouseEnum.LLDYL.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()); |
| | | //è·å对åºåºå |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.QueryData(x=> locationInfos.Select(x=>x.LocationCode).Contains(x.LocationCode) && x.MaterielCode==materielCode && x.MaterielWide== materielWide && x.StockStatus==StockStatusEmun.å
¥åºå®æ.ObjToInt()).OrderBy(x=>x.CreateDate).Take(Count).ToList(); |
| | | if (stockInfos.Count< Count) |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.QueryData(x => locationInfos.Select(x => x.LocationCode).Contains(x.LocationCode) && x.MaterielCode == yLWMSTaskOutDTO.MaterialCode && x.MaterielWide == yLWMSTaskOutDTO.Wide && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.MaterielInvOrgId == MaterielInvOrgEnum.æ°å.ObjToInt()).OrderBy(x => x.CreateDate).Take(yLWMSTaskOutDTO.Count).ToList(); |
| | | if (stockInfos.Count< yLWMSTaskOutDTO.Count) |
| | | { |
| | | return content.Error($"åºå{materielCode}æ°éä¸è¶³"); |
| | | return content.Error($"åºå{yLWMSTaskOutDTO.MaterialCode}æ°éä¸è¶³"); |
| | | } |
| | | List<Dt_LocationInfo> AssignLocations =new List<Dt_LocationInfo>(); |
| | | foreach (var item in stockInfos) |
| | |
| | | item.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | } |
| | | } |
| | | //åºåä»»å¡ |
| | | TaskTypeEnum taskTypeEnum = new(); |
| | | if (stockInfos.FirstOrDefault()?.MaterielInvOrgId==MaterielInvOrgEnum.èå.ObjToInt()) |
| | | { |
| | | taskTypeEnum = TaskTypeEnum.OldYLOutbound; |
| | | } |
| | | else |
| | | { |
| | | taskTypeEnum = TaskTypeEnum.PrintYLOutbound; |
| | | } |
| | | List<Dt_Task> tasks = GetTasks(stockInfos, taskTypeEnum); |
| | | List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.PrintYLOutbound); |
| | | if (tasks == null || tasks.Count <= 0) |
| | | { |
| | | return content.Error($"çæä»»å¡å¤±è´¥"); |
| | | } |
| | | if (!string.IsNullOrEmpty(address)) |
| | | if (!string.IsNullOrEmpty(yLWMSTaskOutDTO.Address)) |
| | | { |
| | | tasks.ForEach(x => |
| | | { |
| | | x.TargetAddress= address; |
| | | x.TargetAddress= yLWMSTaskOutDTO.Address; |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("å°åä¿¡æ¯ä¸è½ä¸ºç©º"); |
| | | } |
| | | //夿æ¯å¦æåºåºåä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// å建å纸ç管æç¨åºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="keys"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateSGOutboundTasks(int[] keys) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | List<Dt_OutSGOrderDetail> outSGOrderDetails = new List<Dt_OutSGOrderDetail>(); |
| | | 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); |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | | stockInfos.AddRange(result.Item2); |
| | | } |
| | | if (result.Item3 != null && result.Item3.Count > 0) |
| | | { |
| | | outSGOrderDetails.AddRange(result.Item3); |
| | | } |
| | | if (result.Item4 != null && result.Item4.Count > 0) |
| | | { |
| | | outStockLockInfos.AddRange(result.Item4); |
| | | } |
| | | if (result.Item5 != null && result.Item5.Count > 0) |
| | | { |
| | | locationInfos.AddRange(result.Item5); |
| | | } |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks.AddRange(result.Item1); |
| | | } |
| | | //å¤çåºåºæ°æ® |
| | | return GenerateOutboundTaskDataUpdate(tasks, stockInfos, outSGOrderDetails, outStockLockInfos, locationInfos); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åºåºä»»å¡æ°æ®å¤ç |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |
| | | /// <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) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_OutSGOrderDetail> outSGOrderDetails = _outboundRepository.OutSGOrderDetailRepository.QueryData(x => keys.Contains(x.Id)); |
| | | |
| | | if (outSGOrderDetails == null || outSGOrderDetails.Count == 0) |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | Dt_OutSGOrderDetail? outBSTOrderDetail = outSGOrderDetails.FirstOrDefault(x => x.OutSGOrderDetailStatus != OutOrderStatusEnum.æªå¼å§.ObjToInt()); |
| | | if (outBSTOrderDetail != null) |
| | | { |
| | | throw new Exception($"åºåºæç»{nameof(Dt_OutSGOrderDetail.BoardMpsDetailId)}{outBSTOrderDetail.BoardMpsDetailId}ç©æ{outBSTOrderDetail.MaterialNo},åºåºä¸æå·²å®æ"); |
| | | } |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutSGOrderDetail>? orderDetails = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | |
| | | //åé
åºå |
| | | (List<Dt_StockInfo>, List<Dt_OutSGOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutSGOrderDetailService.AssignStockOutbound(outSGOrderDetails); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | //è·åä»»å¡ |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.OldYLOutbound); |
| | | |
| | | result.Item2.ForEach(x => |
| | | { |
| | | x.OutSGOrderDetailStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | orderDetails = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | |
| | | return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); |
| | | } |
| | | /// <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) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | if (outStockLockInfos != null && outStockLockInfos.Any()) |
| | | { |
| | | tasks.ForEach(x => |
| | | { |
| | | string orderNos = string.Join(",", outStockLockInfos.Where(x => x.PalletCode == x.PalletCode).Select(x => x.OrderNo).Distinct()); |
| | | x.OrderNo = orderNos; |
| | | }); |
| | | } |
| | | BaseDal.AddData(tasks); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | outboundOrderDetails.ForEach(x => |
| | | { |
| | | x.OutSGOrderDetailStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | List<Dt_OutSGOrder> outSGOrders = _outboundRepository.OutSGOrderRepository.QueryData(x => outboundOrderDetails.Select(x=>x.OutSGOrderId).Distinct().Contains(x.Id)); |
| | | if (outSGOrders.Count<=0) |
| | | { |
| | | throw new Exception("æªæ¾å°åæ®ä¿¡æ¯"); |
| | | } |
| | | outSGOrders.ForEach(x => |
| | | { |
| | | x.OutSGOrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | _outboundRepository.OutSGOrderRepository.UpdateData(outSGOrders); |
| | | WebResponseContent content = _outboundService.OutSGOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | List<string> GradeCodes = new List<string> |
| | | { |
| | | "001" |
| | | }; |
| | | /// <summary> |
| | | /// æ¥æ¶MESé¢æè®¡å |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent ReceiveOutBound(List<OutMESOrderDTO> outMESOrderDTOs) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (outMESOrderDTOs == null || outMESOrderDTOs.Count <= 0) |
| | | { |
| | | return content.Error("é¢æè®¡åä¼ å
¥ä¿¡æ¯ä¸ºç©º"); |
| | | } |
| | | outMESOrderDTOs.Select(x => x.OutDetailId); |
| | | List<Dt_Warehouse> warehouses = _basicRepository.WarehouseRepository.QueryData(); |
| | | OutMESOrderDTO? CheckGradeCode = outMESOrderDTOs.FirstOrDefault(x => !GradeCodes.Contains(x.GradeCode)); |
| | | if (CheckGradeCode != null) |
| | | { |
| | | return content.Error($"é¢æè®¡ååºåº{nameof(OutMESOrderDTO.GradeCode)}:{CheckGradeCode.GradeCode}ä¸åå¨"); |
| | | } |
| | | OutMESOrderDTO? CheckOutDetailId = outMESOrderDTOs.FirstOrDefault(x => x.OutDetailId <= 0); |
| | | if (CheckOutDetailId != null) |
| | | { |
| | | return content.Error($"é¢æè®¡å{nameof(OutMESOrderDTO.OutDetailId)}:{CheckOutDetailId.ProductOrderNo}éè¦å¤§äº0"); |
| | | } |
| | | OutMESOrderDTO? CheckReqQuantity = outMESOrderDTOs.FirstOrDefault(x => x.ReqQuantity <= 0); |
| | | if (CheckReqQuantity != null) |
| | | { |
| | | return content.Error($"é¢æè®¡å{nameof(OutMESOrderDTO.ReqQuantity)}:{CheckReqQuantity.ProductOrderNo}éè¦å¤§äº0"); |
| | | } |
| | | //è·åææç©æä¿¡æ¯ |
| | | List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData(x => x.MaterielInvOrgId == MaterielInvOrgEnum.æ°å.ObjToInt()); |
| | | //è·åææé¢æè®¡å |
| | | List<Dt_OutMESOrder> outMESOrders = _outboundRepository.OutMESOrderRepository.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}ä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | Dt_OutMESOrder? OldoutMESOrder = outMESOrders.FirstOrDefault(x => outMESOrderDTOs.Select(x => x.OutDetailId).Contains(x.OutDetailId)); |
| | | if (OldoutMESOrder != 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) |
| | | { |
| | | Dt_MaterielInfo materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode); |
| | | item.WarehouseId = materielInfo.WarehouseId; |
| | | } |
| | | |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | _outboundRepository.OutMESOrderRepository.AddData(AddoutMESOrders); |
| | | |
| | | 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(AddoutMESOrders); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | //åå»ºä»»å¡ |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.PrintYLOutbound); |
| | | result.Item2.ForEach(x => |
| | | { |
| | | OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | Orders = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | int id = BaseDal.AddData(tasks); |
| | | |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | 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("æ¥æ¶æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |