|  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ç³è¯·å
¥åºä»»å¡(PDA使ç¨ï¼ä»
æçç»å®å
¥åºç«å°ï¼ä¸åé
è´§ä½) | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="palletCode">æçå·</param> | 
|---|
|  |  |  | /// <param name="stationCode">ç«å°å·</param> | 
|---|
|  |  |  | /// <param name="saveModel"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent RequestInboundTask(SaveModel saveModel) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°åºåº"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode && x.WarehouseId == warehouseId); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该æçå·²çæä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) | 
|---|
|  |  |  | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null && warehouse.WarehouseCode != WarehouseEnum.HA60.ToString()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt()) | 
|---|
|  |  |  | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | Roadway = "", | 
|---|
|  |  |  | SourceAddress = stationCode, | 
|---|
|  |  |  | TargetAddress = "", | 
|---|
|  |  |  | TaskType = TaskTypeEnum.Inbound.ObjToInt(), | 
|---|
|  |  |  | TaskType = stockInfo.StockStatus == StockStatusEmun.æ£é宿.ObjToInt() ? TaskTypeEnum.InPick.ObjToInt() : TaskTypeEnum.Inbound.ObjToInt(), | 
|---|
|  |  |  | TaskStatus = TaskStatusEnum.New.ObjToInt(), | 
|---|
|  |  |  | WarehouseId = stockInfo.WarehouseId, | 
|---|
|  |  |  | PalletType = stockInfo.PalletType | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | int taskId = BaseDal.AddData(newTask); | 
|---|
|  |  |  | newTask.TaskId = taskId; | 
|---|
|  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// å
¥ç©ºç®± | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="barcode"></param> | 
|---|
|  |  |  | /// <param name="address"></param> | 
|---|
|  |  |  | /// <param name="WarehouseId"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent InEmpty(string barcode, string address, int WarehouseId) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | WarehouseId = stockInfo.WarehouseId, | 
|---|
|  |  |  | PalletType = stockInfo.PalletType | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | int taskId = BaseDal.AddData(newTask); | 
|---|
|  |  |  | newTask.TaskId = taskId; | 
|---|
|  |  |  | _basicRepository.LocationInfoRepository.UpdateData(locationInfo); | 
|---|
|  |  |  | _stockRepository.StockInfoRepository.AddData(stockInfo); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | PushTasksToWCS(new List<Dt_Task> { newTask }); | 
|---|
|  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public WebResponseContent OutEmpty(int qty, string address, int WarehouseId) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="qty"></param> | 
|---|
|  |  |  | /// <param name="address"></param> | 
|---|
|  |  |  | /// <param name="WarehouseId"></param> | 
|---|
|  |  |  | /// <param name="barcode"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent OutEmpty(int qty, string address, int WarehouseId, string barcode) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°åºåº"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | var stockInfos = _stockRepository.StockInfoRepository.QueryData(x => x.WarehouseId == WarehouseId && x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt(), qty, nameof(Dt_StockInfo.CreateDate)); | 
|---|
|  |  |  | if (stockInfos == null) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}æªæ¾å°ç©ºç®±åºå"); | 
|---|
|  |  |  | List<Dt_StockInfo> stockInfos = null; | 
|---|
|  |  |  | if (string.IsNullOrEmpty(barcode)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfos = _stockRepository.StockInfoRepository.QueryData(x => x.WarehouseId == WarehouseId && x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt(), qty, nameof(Dt_StockInfo.CreateDate)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfos = _stockRepository.StockInfoRepository.QueryData(x => x.WarehouseId == WarehouseId && x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.PalletCode == barcode); | 
|---|
|  |  |  | if (stockInfos.Count == 0) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}æªæ¾å°ç©ºç®±ã{barcode}ã"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (stockInfos.Count < qty) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}空箱åºåä¸è¶³,åºåæ°ã{stockInfos.Count}ã"); | 
|---|
|  |  |  | List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutEmpty); | 
|---|
|  |  |  | stockInfos.ForEach(x => | 
|---|
|  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="stationCode"></param> | 
|---|
|  |  |  | /// <param name="roadwayNo"></param> | 
|---|
|  |  |  | /// <param name="palletCode"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | 
|---|
|  |  |  | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | PushTasksToWCS(new List<Dt_Task> { task }); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) | 
|---|
|  |  |  | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null && stationCode != "8005")//è¾
æä»ä¸éå¶å
¥åºä»»å¡ | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt()) | 
|---|
|  |  |  | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | PalletType = stockInfo.PalletType | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (stockInfo.StockStatus == StockStatusEmun.æ£é宿.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.æ£é宿.ObjToInt(); | 
|---|
|  |  |  | newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PushTasksToWCS(new List<Dt_Task> { newTask }); | 
|---|
|  |  |  | if (newTask.WarehouseId == 5) PutFinish(stationCode); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(data: wMSTaskDTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä»
ç³è¯·ä»»å¡ï¼è®©WCSæ ¹æ®è·¯ç±ç¡®å®ä¸ä¸å°å | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="stationCode"></param> | 
|---|
|  |  |  | /// <param name="palletCode"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent DeviceRequestInboundTaskSimple(string stationCode, string palletCode) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | PushTasksToWCS(new List<Dt_Task> { task }); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); | 
|---|
|  |  |  | if (stockInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_Task newTask = new Dt_Task() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | CurrentAddress = stationCode, | 
|---|
|  |  |  | Grade = 0, | 
|---|
|  |  |  | NextAddress = "", | 
|---|
|  |  |  | PalletCode = palletCode, | 
|---|
|  |  |  | Roadway = "", | 
|---|
|  |  |  | SourceAddress = stationCode, | 
|---|
|  |  |  | TargetAddress = "", | 
|---|
|  |  |  | TaskType = TaskTypeEnum.Inbound.ObjToInt(), | 
|---|
|  |  |  | TaskStatus = TaskStatusEnum.New.ObjToInt(), | 
|---|
|  |  |  | WarehouseId = stockInfo.WarehouseId, | 
|---|
|  |  |  | PalletType = stockInfo.PalletType | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | int taskId = BaseDal.AddData(newTask); | 
|---|
|  |  |  | newTask.TaskId = taskId; | 
|---|
|  |  |  | _stockRepository.StockInfoRepository.UpdateData(stockInfo); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PushTasksToWCS(new List<Dt_Task> { newTask }); | 
|---|
|  |  |  | if (newTask.WarehouseId == 5) PutFinish(stationCode); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(data: wMSTaskDTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="stationCode"></param> | 
|---|
|  |  |  | /// <param name="palletCode"></param> | 
|---|
|  |  |  | /// <param name="staions"></param> | 
|---|
|  |  |  | /// <param name="heightType"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent DeviceRequestInboundTaskByRoadways(string stationCode, string palletCode, List<string> staions, int heightType) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | PushTasksToWCS(new List<Dt_Task> { task }); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string roadwayNo = AssignRoadwayNo(staions, palletCode, heightType); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); | 
|---|
|  |  |  | if (stockInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_Task newTask = new Dt_Task() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | CurrentAddress = stationCode, | 
|---|
|  |  |  | Grade = 0, | 
|---|
|  |  |  | NextAddress = "", | 
|---|
|  |  |  | PalletCode = palletCode, | 
|---|
|  |  |  | Roadway = roadwayNo, | 
|---|
|  |  |  | SourceAddress = stationCode, | 
|---|
|  |  |  | TargetAddress = roadwayNo, | 
|---|
|  |  |  | TaskType = TaskTypeEnum.Inbound.ObjToInt(), | 
|---|
|  |  |  | TaskStatus = TaskStatusEnum.New.ObjToInt(), | 
|---|
|  |  |  | WarehouseId = stockInfo.WarehouseId, | 
|---|
|  |  |  | PalletType = stockInfo.PalletType | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | int taskId = BaseDal.AddData(newTask); | 
|---|
|  |  |  | newTask.TaskId = taskId; | 
|---|
|  |  |  | _stockRepository.StockInfoRepository.UpdateData(stockInfo); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PushTasksToWCS(new List<Dt_Task> { newTask }); | 
|---|
|  |  |  | //if (newTask.WarehouseId == 5) PutFinish(stationCode); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(data: wMSTaskDTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="taskNum"></param> | 
|---|
|  |  |  | /// <param name="roadwayNo"></param> | 
|---|
|  |  |  | /// <param name="heightType"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent AssignInboundTaskLocationByHeight(int taskNum, string roadwayNo, int heightType) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); | 
|---|
|  |  |  | if (task == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(data: task.TargetAddress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, heightType: heightType); | 
|---|
|  |  |  | if (locationInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | task.Roadway = roadwayNo; | 
|---|
|  |  |  | task.TargetAddress = locationInfo.LocationCode; | 
|---|
|  |  |  | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); | 
|---|
|  |  |  | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId); | 
|---|
|  |  |  | BaseDal.UpdateData(task); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(data: locationInfo.LocationCode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|