Admin
2026-01-16 d5fe80c5cb7dc0b209d8fea9faa84c7ca5b20324
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MESTaskService.cs
@@ -45,28 +45,41 @@
                if (string.IsNullOrWhiteSpace(mES_In.endPosition)) return apiResponse.Error("目标位置不能为空");
                if (string.IsNullOrWhiteSpace(mES_In.containerType)) return apiResponse.Error("载具类型不能为空");  //载具类型,布料-1,松布卷-2,成品-1
                Dt_Warehouse dt_Warehouse = _warehouseService.QueryWarehouse(mES_In.warehouseNo);
                if (dt_Warehouse == null) return apiResponse.Error($"WMS未能查询道对应仓库,仓库编码:{mES_In.warehouseNo}");
                int LocationType = 1;
                if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMYL)
                {
                    if (mES_In.containerType == "2") LocationType = 2;
                }
                else if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMCP)
                {
                    LocationType = 3;
                }
                string Roadway = _locationInfoService.AccessingTunnel(dt_Warehouse.WarehouseId, LocationType);
                if (Roadway == "") return apiResponse.Error($"WMS未能查询道对应巷道编号,仓库编码:{mES_In.warehouseNo}");
                //获取对应PLC站台信息
                Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(Roadway);
                Dt_Task setask = BaseDal.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault();
                if (setask != null) return apiResponse.Error($"WMS已有当前任务,不可重复下发,托盘编号:{mES_In.containerNo}");
                Dt_Warehouse dt_Warehouse = _warehouseService.QueryWarehouse(mES_In.warehouseNo);
                int LocationType = 1;
                string Roadway = "0";
                string SourceAddress = mES_In.startPosition;
                string TargetAddress = "";
                string CurrentAddress = mES_In.startPosition;
                string NextAddress = "";
                int WarehouseId = 0;
                if (dt_Warehouse != null)
                {
                    if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMYL)
                    {
                        if (mES_In.containerType == "2") LocationType = 2;
                    }
                    else if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMCP)
                    {
                        LocationType = 3;
                    }
                    Roadway = _locationInfoService.AccessingTunnel(dt_Warehouse.WarehouseId, LocationType);
                    if (Roadway == "0") return apiResponse.Error($"WMS未能查询道对应巷道编号,仓库编码:{mES_In.warehouseNo}");
                    //获取对应PLC站台信息
                    Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(Roadway);
                    NextAddress = _Roadwayinfo.InStationCode;
                    WarehouseId = dt_Warehouse.WarehouseId;
                }
                else
                {
                    TargetAddress = mES_In.endPosition;
                    NextAddress = mES_In.endPosition;
                }
                Dt_Task task = new Dt_Task();
                task.TaskNum = mES_In.transNo;
                task.PalletCode = mES_In.containerNo;
@@ -74,27 +87,27 @@
                task.Roadway = Roadway;
                task.TaskType = (int)TaskTypeEnum.Inbound;
                task.TaskStatus = (int)InTaskStatusEnum.InNew;
                task.SourceAddress = mES_In.startPosition;
                task.TargetAddress = "";
                task.CurrentAddress = mES_In.startPosition;
                task.NextAddress = _Roadwayinfo.InStationCode;
                task.WarehouseId = dt_Warehouse.WarehouseId;
                task.SourceAddress = SourceAddress;
                task.TargetAddress = TargetAddress;
                task.CurrentAddress = CurrentAddress;
                task.NextAddress = NextAddress;
                task.WarehouseId = WarehouseId;
                task.OrderNo = mES_In.transDate.ToString();
                task.Grade = 1;
                task.Creater = "MES";
                task.CreateDate = DateTime.Now;
                Dt_StockInfo dt_StockInfo = new Dt_StockInfo();
                /*Dt_StockInfo dt_StockInfo = new Dt_StockInfo();
                dt_StockInfo.PalletCode = task.PalletCode;
                dt_StockInfo.PalletType = task.PalletType;
                dt_StockInfo.WarehouseId = task.WarehouseId;
                dt_StockInfo.StockStatus = (int)StockStatusEmun.入库中;
                dt_StockInfo.Creater = "MWS";
                dt_StockInfo.CreateDate = DateTime.Now;
                dt_StockInfo.CreateDate = DateTime.Now;*/
                _unitOfWorkManage.BeginTran();
                BaseDal.AddData(task);
                _stockInfoService.Repository.AddData(dt_StockInfo);
                //_stockInfoService.Repository.AddData(dt_StockInfo);
                _unitOfWorkManage.CommitTran();
                WriteLog.GetLog("接收MES入库任务下发").Write($"参数:{mES_In.containerNo}", $"入库任务添加成功");
                return apiResponse.OK();
@@ -300,6 +313,7 @@
                mesInResult.ContainerNo = ContainerNo;
                mesInResult.LocationCode = LocationCode;
                mES_Parame = HttpHelper.Post<MES_parameter>(MES_InReporttask, mesInResult, "入库任务汇报");
                WriteLog.GetLog("入库任务反馈接口").Write($"订单编号:{TransNo},执行结果:{Result},执行结果描述:{ResultMsg},托盘条码:{ContainerNo},库位编号:{LocationCode},接收到的回参:{mesInResult.ToJson()}", $"任务上报信息");
                return mES_Parame;
            }
            catch (Exception ex)
@@ -321,6 +335,7 @@
                mesInResult.Result = Result;
                mesInResult.ResultMsg = ResultMsg;
                mES_Parame = HttpHelper.Post<MES_parameter>(MES_OutReporttask, mesInResult, "出库任务汇报");
                WriteLog.GetLog("出库任务反馈接口").Write($"订单编号:{TransNo},执行结果:{Result},执行结果描述:{ResultMsg},接收到的回参:{mesInResult.ToJson()}", $"任务上报信息");
                return mES_Parame;
            }
            catch (Exception ex)