| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); |
| | | } |
| | | if (_agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.TargetAddress) != null) |
| | | if (_basicRepository.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(); |
| | | Dt_AGVStationInfo? aGVStationInfo = _basicRepository.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); |
| | | _basicRepository.AGVStationInfoRepository.UpdateData(aGVStationInfo); |
| | | content.OK("æå",data: aGVStationInfo.AGVStationCode); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | //å¤çåºåæ°æ® |
| | | if (task.TaskType == TaskTypeEnum.OldYLOutbound.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | stockInfo.WarehouseId = WarehouseEnum.LLDOldCache.ObjToInt(); |
| | | stockInfo.LocationCode = ""; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | } |
| | | else |
| | |
| | | Dt_LocationInfo locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == stockInfo.LocationCode); |
| | | if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode)) |
| | | { |
| | | Dt_Task task = new() |
| | | Dt_Task task = new () |
| | | { |
| | | CurrentAddress = stockInfo.LocationCode, |
| | | Grade = 0, |
| | |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | MaterielCode= stockInfo.proStockInfoDetails?.FirstOrDefault().ProductCode ?? "" , |
| | | Quantity = 0, |
| | | }; |
| | | tasks.Add(task); |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x=>x.StationArea == targetId && x.IsOccupied==WhetherEnum.False.ObjToInt()); |
| | | List<Dt_AGVStationInfo> aGVStationInfos = _basicRepository.AGVStationInfoRepository.QueryData(x=>x.StationArea == targetId && x.IsOccupied==WhetherEnum.False.ObjToInt()); |
| | | 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 (_TasksOut.Count>0) |
| | | { |
| | | useCount -= _TasksOut.Count; |
| | | } |
| | | } |
| | | if (useCount < Count) |
| | | { |
| | |
| | | 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(); |
| | | 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).OrderBy(x => x.CreateDate).ToList(); |
| | | } |
| | | else |
| | | { |
| | |
| | | .Where(x => x.proStockInfoDetails |
| | | .Any(v => |
| | | v.ProductCode == materialCode) |
| | | ).Take(Count).ToList(); |
| | | ).Take(Count).OrderBy(x=>x.CreateDate).ToList(); |
| | | } |
| | | |
| | | if (stockInfos.Count!=Count) |
| | |
| | | nameof(AGVStationAreaEnum.䏿¥¼åå) => TaskTypeEnum.OutFenQie, |
| | | nameof(AGVStationAreaEnum.䏿¥¼æ¨¡å) => TaskTypeEnum.OutMoQie, |
| | | nameof(AGVStationAreaEnum.䏿¥¼å²å) => TaskTypeEnum.OutChongQie, |
| | | nameof(AGVStationAreaEnum.äºæ¥¼çº¸è¢) => TaskTypeEnum.OutCarton, |
| | | nameof(AGVStationAreaEnum.äºæ¥¼çº¸è¢) or |
| | | nameof(AGVStationAreaEnum.äºæ¥¼æ 纺å¸è¢) or |
| | | nameof(AGVStationAreaEnum.äºæ¥¼çº¸æ¯) => TaskTypeEnum.OutCarton, |
| | | _ => throw new Exception("æªæ¾å°å¯¹åºä»»å¡") |
| | | }; |
| | | if (materialCode == "1" && typeEnum!= TaskTypeEnum.OutCarton) |
| | |
| | | { |
| | | return content.Error($"çæä»»å¡å¤±è´¥"); |
| | | } |
| | | //æåä»»å¡ä¸ç´æ¥åé
ç»ç¹ |
| | | //æå°ä»»å¡ä¸ç´æ¥åé
ç»ç¹ |
| | | if (targetId != nameof(AGVStationAreaEnum.䏿¥¼æå°ç 头)) |
| | | { |
| | | for (int i = 0; i < tasks.Count; i++) |
| | |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ´æ°åºåç¶æ |
| | | _stockRepository.ProStockInfoRepository.UpdateData(stockInfos); |
| | | _agvStationInfoRepository.UpdateData(aGVStationInfos); |
| | | _basicRepository.AGVStationInfoRepository.UpdateData(aGVStationInfos); |
| | | //æ´æ°è´§ä½ç¶æ |
| | | _basicRepository.LocationInfoRepository.UpdateLocationStatus(AssignLocations, LocationStatusEnum.Lock); |
| | | //å å
¥è´§ä½åå¨è®°å½ |
| | |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// å建å纸ç产æç¨åºåºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="keys"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CreateBSTOutboundTasks(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_OutBSTOrderDetail> outBSTOrderDetails = new List<Dt_OutBSTOrderDetail>(); |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | //çæä»»å¡ãåºåçä¿¡æ¯ |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutBSTOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys); |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | | stockInfos.AddRange(result.Item2); |
| | | } |
| | | if (result.Item3 != null && result.Item3.Count > 0) |
| | | { |
| | | outBSTOrderDetails.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, outBSTOrderDetails, 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_OutBSTOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int[] keys) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_OutBSTOrderDetail> outboundOrderDetails = _outBSTOrderDetailRepository.QueryData(x => keys.Contains(x.Id)); |
| | | |
| | | if (outboundOrderDetails == null || outboundOrderDetails.Count == 0) |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | Dt_OutBSTOrderDetail? outBSTOrderDetail = outboundOrderDetails.FirstOrDefault(x => x.OutBSTOrderDetailStatus != OutOrderStatusEnum.æªå¼å§.ObjToInt()); |
| | | if (outBSTOrderDetail!=null) |
| | | { |
| | | throw new Exception($"åºåºæç»ç©æ{outBSTOrderDetail.MaterialNo},åºåºä¸æå·²å®æ"); |
| | | } |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutBSTOrderDetail>? orderDetails = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | |
| | | //åé
åºå |
| | | (List<Dt_StockInfo>, List<Dt_OutBSTOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outBSTOrderDetailService.AssignStockOutbound(outboundOrderDetails); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | Dt_OutBSTOrder outBSTOrder = _outBSTOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OutBSTOrderId); |
| | | //è·åä»»å¡ |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.OldYLOutbound); |
| | | tasks.ForEach(x => |
| | | { |
| | | x.OrderNo = outBSTOrder.BoardMpsNo; |
| | | }); |
| | | result.Item2.ForEach(x => |
| | | { |
| | | x.OutBSTOrderDetailStatus = 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> |
| | | public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutBSTOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | 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.OutBSTOrderDetailStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | Dt_OutBSTOrder outBSTOrder = _outBSTOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OutBSTOrderId); |
| | | if (outBSTOrder.OutBSTOrderStatus == OutOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | outBSTOrder.OutBSTOrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | _outBSTOrderRepository.UpdateData(outBSTOrder); |
| | | } |
| | | WebResponseContent content = _outBSTOrderDetailService.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); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å建å纸ç管æç¨åºåºä»»å¡ |
| | | /// </summary> |
| | |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// BSTé¢æä¿¡æ¯åæ¥ |
| | | /// </summary> |
| | | /// <param name="bSTPickInfoDTO"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ReceivePicking(BSTPickInfoDTO bSTPickInfoDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | List<string> GradeCodes = new List<string> |
| | | { |
| | | "001" |
| | |
| | | List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData(x => x.MaterielInvOrgId == MaterielInvOrgEnum.æ°å.ObjToInt()); |
| | | //è·åææé¢æè®¡å |
| | | List<Dt_OutMESOrder> outMESOrders = _outboundRepository.OutMESOrderRepository.QueryData(); |
| | | //è·åææå å·¥ä¸å¿ |
| | | 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? CheckMakeCenterCode = outMESOrderDTOs.FirstOrDefault(x => !makeCenterInfos.Select(x => x.MakeCode).Contains(x.MakeCode)); |
| | | if (CheckMakeCenterCode!=null) |
| | | { |
| | | return content.Error($"å å·¥ä¸å¿{nameof(OutMESOrderDTO.MakeCode)}:{CheckMakeCenterCode.MakeCode}ä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | Dt_OutMESOrder? OldoutMESOrder = outMESOrders.FirstOrDefault(x => outMESOrderDTOs.Select(x => x.OutDetailId).Contains(x.OutDetailId)); |
| | | if (OldoutMESOrder != null) |
| | |
| | | |
| | | _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(); |
| | | }); |
| | | //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); |
| | | // 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 (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); |
| | | } |
| | | } |
| | | // if (!contentResponse.Status) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return content.Error(contentResponse.Message); |
| | | // } |
| | | //} |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |