|  |  |  | 
|---|
|  |  |  | x.AGVArea = agvDescription; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | string url = AppSettings.Get("WCS"); | 
|---|
|  |  |  | if(string.IsNullOrEmpty(url)) | 
|---|
|  |  |  | if (string.IsNullOrEmpty(url)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°WCSApiå°å,è¯·æ£æ¥é
ç½®æä»¶"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°WCSAApiå°å,è¯·æ£æ¥é
ç½®æä»¶"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string response = HttpHelper.Post($"{url}/api/CTU_AGV/PutFinish", code); | 
|---|
|  |  |  | string response = HttpHelper.Post($"{url}/api/CTU_AGV/PutFinish?code=" + code); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("è¿åé误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | stockInfo.LocationCode = locationInfo.LocationCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region ç©ºç®±å
¥åº | 
|---|
|  |  |  | if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt()) | 
|---|
|  |  |  | #region ç©ºç®±å
¥åº/æ£éååº/çäº§éæ | 
|---|
|  |  |  | if (task.TaskType == TaskTypeEnum.InEmpty.ObjToInt() || task.TaskType == TaskTypeEnum.InPick.ObjToInt() || task.TaskType==TaskTypeEnum.ProductionReturn.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); | 
|---|
|  |  |  | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); | 
|---|
|  |  |  | stockInfo.Details.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.Status = StockStatusEmun.å
¥åºå®æ.ObjToInt(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); | 
|---|
|  |  |  | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); | 
|---|
|  |  |  | _stockRepository.StockInfoRepository.UpdateData(stockInfo); | 
|---|
|  |  |  | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); | 
|---|
|  |  |  | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|
|  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_InboundOrder? inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First(); | 
|---|
|  |  |  | List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>(); | 
|---|
|  |  |  | List<ERPInboundDetailModel> detailModels = new List<ERPInboundDetailModel>(); | 
|---|
|  |  |  | if (stockInfo.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) | 
|---|
|  |  |  | Dt_InboundOrderDetail? inboundOrderDetail = null; | 
|---|
|  |  |  | //æ åå
¥åºæµç¨æ¥æ¾å
¥åºåæ® | 
|---|
|  |  |  | if (inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (inboundOrder == null) | 
|---|
|  |  |  | //æ¥è¯¢å宿çå
¥åºæç»æ°é | 
|---|
|  |  |  | int overCount = inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; | 
|---|
|  |  |  | if (stockInfo.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"对åºå
¥åºåä¸åå¨"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | foreach (var item in stockInfo.Details) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.RowNo == item.InboundOrderRowNo); | 
|---|
|  |  |  | if (inboundOrderDetail == null) | 
|---|
|  |  |  | inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.RowNo == stockInfo.Details.FirstOrDefault()?.InboundOrderRowNo); | 
|---|
|  |  |  | foreach (var item in stockInfo.Details) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | if (inboundOrderDetail == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ERPInboundDetailModel detailModel = new ERPInboundDetailModel() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ExpiryDate = item.EffectiveDate ?? "", | 
|---|
|  |  |  | LocationCode = warehouse.WarehouseCode, | 
|---|
|  |  |  | MaterialsCode = item.MaterielCode, | 
|---|
|  |  |  | MfgDate = item.ProductionDate ?? "", | 
|---|
|  |  |  | QtyCustoms = "0", | 
|---|
|  |  |  | Quantity = item.StockQuantity.ToString(), | 
|---|
|  |  |  | Rack = stockInfo.LocationCode, | 
|---|
|  |  |  | ReceiptCode = inboundOrder.UpperOrderNo, | 
|---|
|  |  |  | ReceiptSerNo = item.InboundOrderRowNo.ToString() | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | inboundOrderDetail.OverInQuantity += item.StockQuantity; | 
|---|
|  |  |  | if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); | 
|---|
|  |  |  | overCount += 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ERPInboundDetailModel detailModel = new ERPInboundDetailModel() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ExpiryDate = item.EffectiveDate ?? "", | 
|---|
|  |  |  | LocationCode = warehouse.WarehouseCode, | 
|---|
|  |  |  | MaterialsCode = item.MaterielCode, | 
|---|
|  |  |  | MfgDate = item.ProductionDate ?? "", | 
|---|
|  |  |  | QtyCustoms = "0", | 
|---|
|  |  |  | Quantity = item.StockQuantity.ToString(), | 
|---|
|  |  |  | Rack = stockInfo.LocationCode, | 
|---|
|  |  |  | ReceiptCode = inboundOrder.UpperOrderNo, | 
|---|
|  |  |  | ReceiptSerNo = item.InboundOrderRowNo.ToString() | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | inboundOrderDetail.OverInQuantity += detailModel.Quantity.ObjToInt(); | 
|---|
|  |  |  | if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | inboundOrderDetails.Add(inboundOrderDetail); | 
|---|
|  |  |  | detailModels.Add(detailModel); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //å
¥åºæç»æ°å¢å®ææ°é | 
|---|
|  |  |  | int newCount = inboundOrderDetails.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; | 
|---|
|  |  |  | //å
¥åºæç»å宿æ°é | 
|---|
|  |  |  | int oldCount = inboundOrder.Details.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; | 
|---|
|  |  |  | if (inboundOrder.Details.Count == (newCount + oldCount)) | 
|---|
|  |  |  | if (inboundOrder.Details.Count == overCount) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºå®æ.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (inboundOrder.OrderStatus == InOrderStatusEnum.æªå¼å§.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if ((stockInfo.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt() || stockInfo.StockStatus == StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt()) && warehouse.WarehouseCode == WarehouseEnum.HA64.ToString()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | foreach (var model in stockInfo.Details) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, /*MaterialName = model.MaterielName,*/ Life = int.TryParse(model.Remark, out int val) ? val : 1000 }); | 
|---|
|  |  |  | TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, MaterialName = model.MaterielName, Life = int.TryParse(model.Remark, out int val) ? val : 1000 }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //æµè¯æ¶å
¥åºåºåç¶æ | 
|---|
|  |  |  | if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt() && warehouse.WarehouseCode == WarehouseEnum.HA64.ToString() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | stockInfo.Details.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.Status = StockStatusEmun.å
¥åºå®æ.ObjToInt(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //æ´æ°ä»»å¡ç¶æ | 
|---|
|  |  |  | task.TaskStatus = (int)TaskStatusEnum.Finish; | 
|---|
|  |  |  | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); | 
|---|
|  |  |  | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); | 
|---|
|  |  |  | 
|---|
|  |  |  | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum); | 
|---|
|  |  |  | if (inboundOrder != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails); | 
|---|
|  |  |  | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); | 
|---|
|  |  |  | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | if (stockInfo.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder, detailModels); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //åå¨å
¥åºåå¹¶ç¶æä¸ºå®æç¶ææ¨éè³ERP | 
|---|
|  |  |  | if (inboundOrder != null && inboundOrder.OrderStatus == InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) | 
|---|
|  |  |  | _inboundOrderService.FeedbackInboundOrder(inboundOrder); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | 
|---|
|  |  |  | Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == item.OrderDetailId); | 
|---|
|  |  |  | if (outboundOrderDetail != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | outboundOrderDetail.OverOutQuantity = item.AssignQuantity; | 
|---|
|  |  |  | outboundOrderDetail.OverOutQuantity += item.AssignQuantity; | 
|---|
|  |  |  | if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); | 
|---|
|  |  |  | 
|---|
|  |  |  | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) | 
|---|
|  |  |  | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.MesHandPickOutbound.ObjToInt() || task.TaskType == TaskTypeEnum.MesHandOutbound.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (outboundOrderDetails.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, mesOutboundOrders.FirstOrDefault().OrderQuantity); | 
|---|
|  |  |  | MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, stockInfo.Details.Where(x => x.MaterielCode == mesOutboundOrders.FirstOrDefault().MaterialCode).Sum(x => x.StockQuantity)); | 
|---|
|  |  |  | UploadMesMaterialLotaAcept(model); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|