Admin
2026-01-15 7d6194cf002b8f54d41cdc50b7f1b1843c1da636
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MESTaskService.cs
@@ -52,12 +52,19 @@
                {
                    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_Task task = new Dt_Task();
@@ -126,6 +133,9 @@
                Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(dt_LocationInfo.RoadwayNo);
                Dt_Task setask = BaseDal.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault();
                if (setask != null) return apiResponse.Error($"WMS已有当前任务,不可重复下发,托盘编号:{mES_In.containerNo}");
                Dt_Task task = new Dt_Task();
                task.TaskNum = mES_In.transNo;
                task.PalletCode = dt_Stock.PalletCode;
@@ -166,11 +176,12 @@
        //储位查询接口
        public ApiResponse GetLocationByContainer(MES_InTask mES_In)
        {
            WriteLog.GetLog("储位查询接口").Write($"参数:{mES_In.ToJson()}", $"任务接收参数");
            ApiResponse apiResponse = new ApiResponse();
            try
            {
                if (string.IsNullOrWhiteSpace(mES_In.containerNo)) return apiResponse.Error("托盘码不能为空");
                Dt_StockInfo dt_Stock = _stockInfoService.Repository.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault();
                Dt_StockInfo dt_Stock = _stockInfoService.Repository.QueryData(x => x.PalletCode == mES_In.containerNo &&x.StockStatus==(int)StockStatusEmun.已入库).FirstOrDefault();
                if (dt_Stock == null) return apiResponse.Error($"WMS未能查找道该托盘条码的库存货位信息,条码:{mES_In.containerNo}");
                Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stock.LocationCode).FirstOrDefault();
                if (dt_LocationInfo == null) return apiResponse.Error($"WMS未能查找道该托盘条码的库存货位信息,条码:{mES_In.containerNo},未找到货位号:{dt_Stock.LocationCode}");
@@ -244,8 +255,22 @@
                if (string.IsNullOrWhiteSpace(mES_In.transNo)) return apiResponse.Error("单据编号不能为空");
                Dt_Task dt_Task = BaseDal.QueryData(x => x.TaskNum == mES_In.transNo).FirstOrDefault();
                if (dt_Task == null) return apiResponse.Error($"WMS未能查找道对应单据任务,条码:{mES_In.transNo}");
                if(dt_Task.TaskStatus== (int)InTaskStatusEnum.InNew || dt_Task.TaskStatus == (int)OutTaskStatusEnum.OutNew)
                if(dt_Task.TaskStatus== (int)InTaskStatusEnum.InNew)
                {
                    Dt_StockInfo dt_StockInfo=_stockInfoService.Repository.QueryData(x=>x.PalletCode==dt_Task.PalletCode).FirstOrDefault();
                    if (dt_StockInfo == null) return apiResponse.Error("取消失败,WMS记录的托盘库存查找失败");
                    _stockInfoService.Repository.DeleteData(dt_StockInfo);
                    BaseDal.DeleteData(dt_Task);
                    return apiResponse.OK();
                }else if(dt_Task.TaskStatus == (int)OutTaskStatusEnum.OutNew)
                {
                    Dt_StockInfo dt_StockInfo = _stockInfoService.Repository.QueryData(x => x.PalletCode == dt_Task.PalletCode).FirstOrDefault();
                    Dt_LocationInfo dt_LocationInfo= _locationInfoService.Repository.QueryData(x=>x.LocationCode== dt_StockInfo.LocationCode).FirstOrDefault();
                    dt_StockInfo.StockStatus = (int)StockStatusEmun.已入库;
                    dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.InStock;
                    _stockInfoService.Repository.UpdateData(dt_StockInfo);
                    _locationInfoService.Repository.UpdateData(dt_LocationInfo);
                    BaseDal.DeleteData(dt_Task);
                    return apiResponse.OK();
                }
@@ -261,5 +286,131 @@
                return apiResponse.Error($"WMS任务取消接口错误,原因:{ex.Message}");
            }
        }
        //入库任务反馈接口
        public MES_parameter InStoreDocCallback(string TransNo, string Result, string ResultMsg, string ContainerNo, string LocationCode)
        {
            MES_parameter mES_Parame= new MES_parameter();
            try
            {
                MesInResultResponse mesInResult = new MesInResultResponse();
                mesInResult.TransNo = TransNo;
                mesInResult.Result = Result;
                mesInResult.ResultMsg = ResultMsg;
                mesInResult.ContainerNo = ContainerNo;
                mesInResult.LocationCode = LocationCode;
                mES_Parame = HttpHelper.Post<MES_parameter>(MES_InReporttask, mesInResult, "入库任务汇报");
                return mES_Parame;
            }
            catch (Exception ex)
            {
                mES_Parame.Result = "N";
                mES_Parame.ResultMsg= $"入库:WMS系统上传失败,原因:{ex.Message}";
                return mES_Parame;
            }
        }
        //出库任务反馈接口
        public MES_parameter OutStoreDocCallback(string TransNo,string Result,string ResultMsg)
        {
            MES_parameter mES_Parame = new MES_parameter();
            try
            {
                MesOutResultResponse mesInResult = new MesOutResultResponse();
                mesInResult.TransNo = TransNo;
                mesInResult.Result = Result;
                mesInResult.ResultMsg = ResultMsg;
                mES_Parame = HttpHelper.Post<MES_parameter>(MES_OutReporttask, mesInResult, "出库任务汇报");
                return mES_Parame;
            }
            catch (Exception ex)
            {
                mES_Parame.Result = "N";
                mES_Parame.ResultMsg = $"出库:WMS系统上传失败,原因:{ex.Message}";
                return mES_Parame;
            }
        }
        /// <summary>
        /// å‚¨ä½å¼‚动申请
        /// </summary>
        /// <param name="ContainerNo">托盘条码</param>
        /// <param name="OriginalLocationCode">原储位</param>
        /// <param name="NewLocationCode">新储位</param>
        /// <returns></returns>
        public MES_parameter ApplicationChangeStorageLocation(string ContainerNo,string OriginalLocationCode,string NewLocationCode)
        {
            MES_parameter mES_Parame = new MES_parameter();
            try
            {
                MES_Storagelocation Storagelocation = new MES_Storagelocation();
                Storagelocation.ContainerNo = ContainerNo;
                Storagelocation.OriginalLocationCode = OriginalLocationCode;
                Storagelocation.NewLocationCode = NewLocationCode;
                mES_Parame = HttpHelper.Post<MES_parameter>(MES_InventoryUpdateApply, Storagelocation, "储位异动申请");
                return mES_Parame;
            }
            catch (Exception ex)
            {
                mES_Parame.Result = "N";
                mES_Parame.ResultMsg = $"储位异动申请:WMS系统调取失败,原因:{ex.Message}";
                return mES_Parame;
            }
        }
        /// <summary>
        /// å‚¨ä½å¼‚动
        /// </summary>
        /// <param name="ContainerNo">托盘条码</param>
        /// <param name="OriginalLocationCode">原储位</param>
        /// <param name="NewLocationCode">新储位</param>
        /// <returns></returns>
        public MES_parameter AbnormalStorageLocation(string ContainerNo, string OriginalLocationCode, string NewLocationCode)
        {
            MES_parameter mES_Parame = new MES_parameter();
            try
            {
                MES_Storagelocation Storagelocation = new MES_Storagelocation();
                Storagelocation.ContainerNo = ContainerNo;
                Storagelocation.OriginalLocationCode = OriginalLocationCode;
                Storagelocation.NewLocationCode = NewLocationCode;
                mES_Parame = HttpHelper.Post<MES_parameter>(MES_InventoryUpdateCallback, Storagelocation, "储位异动");
                return mES_Parame;
            }
            catch (Exception ex)
            {
                mES_Parame.Result = "N";
                mES_Parame.ResultMsg = $"储位异动:WMS系统调取失败,原因:{ex.Message}";
                return mES_Parame;
            }
        }
        /// <summary>
        /// ä»»åС异叏
        /// </summary>
        /// <param name="TransNo">单据编号</param>
        /// <param name="EquipmentType">设备类型</param>
        /// <param name="EquipmentNumber">设备编码</param>
        /// <param name="ErrorInfo">异常报文</param>MES_TaskErrorInfoCallback
        /// <returns></returns>
        public MES_parameter ToMES_TaskException(string TransNo,string EquipmentType,string EquipmentNumber,string ErrorInfo)
        {
            MES_parameter mES_Parame = new MES_parameter();
            try
            {
                MES_TaskException Storagelocation = new MES_TaskException();
                Storagelocation.TransNo = TransNo;
                Storagelocation.EquipmentType = EquipmentType;
                Storagelocation.EquipmentNumber = EquipmentNumber;
                Storagelocation.ErrorInfo = ErrorInfo;
                mES_Parame = HttpHelper.Post<MES_parameter>(MES_TaskErrorInfoCallback, Storagelocation, "任务异常");
                return mES_Parame;
            }
            catch (Exception ex)
            {
                mES_Parame.Result = "N";
                mES_Parame.ResultMsg = $"任务异常:WMS系统调取失败,原因:{ex.Message}";
                return mES_Parame;
            }
        }
    }
}