| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private static object _requestZH = new object(); |
| | | public WebResponseContent RequestZHInboundTask(string agvTaskCode, string palletCode, string palletType, string materialLot) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | lock (_requestZH) |
| | | { |
| | | //è·åé»çåºåä¿¡æ¯ |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString()); |
| | | //è·ååºåè®°å½ |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => |
| | | x.WarehouseId == warehouse.WarehouseId && x.PalletCode== palletCode).Includes(x => x.Details).ToList(); |
| | | if (stockInfos.Count > 0) |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | return content.Error($"è½½å
·æçå·²åå¨"); |
| | | } |
| | | Dt_StockInfo? stockInfoOld = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == materialLot)); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return content.Error($"åºåä¿¡æ¯å·²åå¨"); |
| | | } |
| | | //è·åé»çåºåä¿¡æ¯ |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString()); |
| | | //è·ååºåè®°å½ |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => |
| | | x.WarehouseId == warehouse.WarehouseId && x.PalletCode == palletCode).Includes(x => x.Details).ToList(); |
| | | if (stockInfos.Count > 0) |
| | | { |
| | | return content.Error($"è½½å
·æçå·²åå¨"); |
| | | } |
| | | Dt_StockInfo? stockInfoOld = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == materialLot)); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return content.Error($"åºåä¿¡æ¯å·²åå¨"); |
| | | } |
| | | |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletCode); |
| | | if(task != null) |
| | | { |
| | | return content.Error($"æç{palletCode}å·²ç»åå¨ä»»å¡ï¼è¯·å¿éå¤ä¸è¾¾"); |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | return content.Error($"æç{palletCode}å·²ç»åå¨ä»»å¡ï¼è¯·å¿éå¤ä¸è¾¾"); |
| | | } |
| | | Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletType); |
| | | if (palletTypeInfo == null) |
| | | { |
| | | return content.Error($"æçç±»åä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | //è·åé»çæ¹æ¬¡ |
| | | WebResponseContent requestLotInfo = GetZHMesMaterialLot(materialLot); |
| | | if (!requestLotInfo.Status) |
| | | { |
| | | return content.Error($"请æ±é»çæ¹æ¬¡ä¿¡æ¯å¤±è´¥,{requestLotInfo.Message}"); |
| | | } |
| | | MesLotInfoModel mesLotInfo = JsonConvert.DeserializeObject<MesLotInfoModel>(requestLotInfo.Data.ToString()); |
| | | //MesLotInfoModel mesLotInfo = new MesLotInfoModel() |
| | | //{ |
| | | // Product="FH001", |
| | | // ProductVersion="A1", |
| | | // Qty=20, |
| | | // LotNo= materialLot, |
| | | // IsFullNumber=true |
| | | //}; |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | MaterielSpec = mesLotInfo.ProductVersion, |
| | | BatchNo = materialLot, |
| | | EffectiveDate = mesLotInfo.DateCode ?? " ", |
| | | MaterielCode = mesLotInfo.Product, |
| | | InboundOrderRowNo = 0, |
| | | MaterielName = mesLotInfo.Product, |
| | | ProductionDate = mesLotInfo.DateCode ?? " ", |
| | | OrderNo = "", |
| | | OutboundQuantity = 0, |
| | | SerialNumber = materialLot, |
| | | StockQuantity = (float)mesLotInfo.Qty, |
| | | Status = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | Unit = "Lot", |
| | | Remark = mesLotInfo.IsFullNumber ? "满Lot" : "䏿»¡Lot" |
| | | }; |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = palletCode, |
| | | PalletType = palletTypeInfo.PalletType, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | Details = new List<Dt_StockInfoDetail> { stockInfoDetail } |
| | | }; |
| | | |
| | | //çæéåºä»»å¡ |
| | | Dt_Task taskIn = new() |
| | | { |
| | | CurrentAddress = "AGV_ZH", |
| | | Grade = 0, |
| | | PalletCode = palletCode, |
| | | NextAddress = "", |
| | | Roadway = "SC01_ZH", |
| | | SourceAddress = "AGV_ZH", |
| | | TargetAddress = "", |
| | | TaskStatus = (int)TaskStatusEnum.New, |
| | | TaskType = palletTypeInfo.LocaitonCount == 2 ? (int)TaskTypeEnum.InZHProductLarge : (int)TaskTypeEnum.InZHProductSmall, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | PalletType = palletTypeInfo.PalletType, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | MaterielCode = mesLotInfo.Product, |
| | | Quantity = (float)mesLotInfo.Qty, |
| | | BatchNo = mesLotInfo.LotNo |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); |
| | | BaseDal.AddData(taskIn); |
| | | //BaseDal.AddData(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //å°ä»»å¡æ¨éå°WCS |
| | | PushTasksToWCS(new List<Dt_Task>() { taskIn }, "AGV_ZH", agvTaskCode); |
| | | content.OK(data: taskIn); |
| | | } |
| | | Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x=>x.CodeStartStr== palletType); |
| | | if (palletTypeInfo == null) |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error($"æçç±»åä¿¡æ¯ä¸åå¨"); |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | //è·åé»çæ¹æ¬¡ |
| | | WebResponseContent requestLotInfo = GetZHMesMaterialLot(materialLot); |
| | | if (!requestLotInfo.Status) |
| | | { |
| | | return content.Error($"请æ±é»çæ¹æ¬¡ä¿¡æ¯å¤±è´¥,{requestLotInfo.Message}"); |
| | | } |
| | | MesLotInfoModel mesLotInfo = JsonConvert.DeserializeObject<MesLotInfoModel>(requestLotInfo.Data.ToString()); |
| | | //MesLotInfoModel mesLotInfo = new MesLotInfoModel() |
| | | //{ |
| | | // Product="FH001", |
| | | // ProductVersion="A1", |
| | | // Qty=20, |
| | | // LotNo= materialLot, |
| | | // IsFullNumber=true |
| | | //}; |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | MaterielSpec = mesLotInfo.ProductVersion, |
| | | BatchNo = materialLot, |
| | | EffectiveDate = mesLotInfo.DateCode ?? " ", |
| | | MaterielCode = mesLotInfo.Product, |
| | | InboundOrderRowNo = 0, |
| | | MaterielName = mesLotInfo.Product, |
| | | ProductionDate = mesLotInfo.DateCode ?? " ", |
| | | OrderNo = "", |
| | | OutboundQuantity = 0, |
| | | SerialNumber = materialLot, |
| | | StockQuantity = (float)mesLotInfo.Qty, |
| | | Status = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | Unit = "Lot", |
| | | Remark= mesLotInfo.IsFullNumber?"满Lot":"䏿»¡Lot" |
| | | }; |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = palletCode, |
| | | PalletType = palletTypeInfo.PalletType, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | Details = new List<Dt_StockInfoDetail> { stockInfoDetail } |
| | | }; |
| | | |
| | | //çæéåºä»»å¡ |
| | | Dt_Task taskIn = new() |
| | | { |
| | | CurrentAddress = "AGV_ZH", |
| | | Grade = 0, |
| | | PalletCode = palletCode, |
| | | NextAddress = "", |
| | | Roadway = "SC01_ZH", |
| | | SourceAddress = "AGV_ZH", |
| | | TargetAddress = "", |
| | | TaskStatus = (int)TaskStatusEnum.New, |
| | | TaskType = palletTypeInfo.LocaitonCount==2? (int)TaskTypeEnum.InZHProductLarge : (int)TaskTypeEnum.InZHProductSmall, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | PalletType = palletTypeInfo.PalletType, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | MaterielCode = mesLotInfo.Product, |
| | | Quantity = (float)mesLotInfo.Qty, |
| | | BatchNo = mesLotInfo.LotNo |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); |
| | | BaseDal.AddData(taskIn); |
| | | //BaseDal.AddData(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //å°ä»»å¡æ¨éå°WCS |
| | | PushTasksToWCS(new List<Dt_Task>() { taskIn }, "AGV_ZH", agvTaskCode); |
| | | content.OK(data: taskIn); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | |
| | | } |
| | | |
| | | public readonly string[] OutStartPonits = { "5230", "5237", "5244" }; |