renmingwang
2026-03-25 6d56bf4daf08c4c7c6d193d98ed0b547dc473451
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -80,7 +80,7 @@
            _roadwayInforepository = roadwayInforepository;
            _dt_ApiInfoService = dt_ApiInfoService;
            _locationStatusChangeRecordService = locationStatusChangeRecordService;
            _stationMangerService=stationMangerService;
            _stationMangerService = stationMangerService;
        }
        public int GetTaskNum(string sequenceName)
        {
@@ -127,7 +127,7 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
@@ -158,11 +158,11 @@
                //获取到深库位编号
                Dt_LocationInfo DeepLocation = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == Locatask);
                if(DeepLocation == null) return content.Error($"未找到该货位信息,货位编号:{Locatask}");
                if (DeepLocation == null) return content.Error($"未找到该货位信息,货位编号:{Locatask}");
                //进行获取浅库位编号
                int locrow = DeepLocation.Row == 1 ? 2 : 3;
                Dt_LocationInfo ShallowLocation = _basicService.LocationInfoService.Repository.QueryFirst(x =>x.Row== locrow && x.Layer== DeepLocation.Layer && x.Column== DeepLocation.Column && x.RoadwayNo== DeepLocation.RoadwayNo);
                Dt_LocationInfo ShallowLocation = _basicService.LocationInfoService.Repository.QueryFirst(x => x.Row == locrow && x.Layer == DeepLocation.Layer && x.Column == DeepLocation.Column && x.RoadwayNo == DeepLocation.RoadwayNo);
                if (ShallowLocation == null) return content.Error($"未找到货位编号:{Locatask}的浅货位");
                if (ShallowLocation.LocationStatus == (int)LocationStatusEnum.Free)
@@ -294,7 +294,7 @@
                return webResponse.Error($"移库任务完成失败,任务id:{task.TaskNum}");
                throw;
            }
        }
        /// <summary>
@@ -371,9 +371,9 @@
                stockInfo.StockStatus = StockStatusEmun.出库完成.ObjToInt();
                int beforeStatus = locationInfo.LocationStatus;
                locationInfo.LocationStatus =(int)LocationStatusEnum.Free;
                locationInfo.LocationStatus = (int)LocationStatusEnum.Free;
                task.TaskStatus = TaskOutStatusEnum.OutFinish.ObjToInt();
                _unitOfWorkManage.BeginTran();
@@ -401,7 +401,7 @@
                return webResponse.Error($"出库任务完成失败,任务id:{task.TaskNum},错误原因:{ex.Message}");
                throw;
            }
        }
@@ -449,24 +449,24 @@
                string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName;
                if (WCSReceiveTaskAPI == null)
                {
                   return webResponse.Error($"出库失败,未配置MES移库完成反馈接口");
                    return webResponse.Error($"出库失败,未配置MES移库完成反馈接口");
                }
                var respon = HttpHelper.Post(WCSReceiveTaskAPI, JsonConvert.SerializeObject(transferRequest));
                if (respon != null)
                {
                   var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
                   if (response.Success)
                   {
                       return webResponse.OK();
                   }
                   else
                   {
                       return webResponse.Error($"调取接口失败,反馈参数原因:{response.Message}");
                   }
                    var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
                    if (response.Success)
                    {
                        return webResponse.OK();
                    }
                    else
                    {
                        return webResponse.Error($"调取接口失败,反馈参数原因:{response.Message}");
                    }
                }
                else
                {
                   return webResponse.Error($"调取接口失败,反馈参数为空");
                    return webResponse.Error($"调取接口失败,反馈参数为空");
                }
                return webResponse.OK();
@@ -500,16 +500,16 @@
                    locationCode = dt_Task.TargetAddress;
                }
                TaskNotification transferRequest = new TaskNotification()
                    {
                        //业务id,任务id后续进行更改
                        taskId = dt_Task.MEStaskId,   //任务id
                        businessId = dt_Task.MESbusinessId,   //业务id
                        palletCode = dt_Task.PalletCode,
                        subPalletCode = dt_Task.MESsubPalletCode,//子托盘编码
                        locationCode = locationCode,
                        errorStatus = "NORMAL",
                        errorInfo = "",
                    };
                {
                    //业务id,任务id后续进行更改
                    taskId = dt_Task.MEStaskId,   //任务id
                    businessId = dt_Task.MESbusinessId,   //业务id
                    palletCode = dt_Task.PalletCode,
                    subPalletCode = dt_Task.MESsubPalletCode,//子托盘编码
                    locationCode = locationCode,
                    errorStatus = "NORMAL",
                    errorInfo = "",
                };
                //获取接口进行调取
                var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESTaskFeedback);      //获取到wcs全部类型的接口
@@ -518,12 +518,12 @@
                {
                    return webResponse.Error($"任务反馈MES失败,未配置MES任务完成反馈接口");
                }
                // æ·»åŠ è°ƒè¯•ä¿¡æ¯
                string requestJson = JsonConvert.SerializeObject(transferRequest);
                //Console.WriteLine($"MES反馈接口URL: {WCSReceiveTaskAPI}");
                //Console.WriteLine($"MES反馈请求数据: {requestJson}");
                // ä½¿ç”¨ä¿®å¤åŽçš„PostSync方法(已在PostSync中设置默认请求头)
                var respon = HttpHelper.Post(WCSReceiveTaskAPI, requestJson);
                if (respon != null)
@@ -550,7 +550,7 @@
            }
        }
        public ApiResponse<object> MESresponse(string Message, bool Success,int  Code)
        public ApiResponse<object> MESresponse(string Message, bool Success, int Code)
        {
            ApiResponse<object> apiResponse = new ApiResponse<object>();
            apiResponse.Message = Message;
@@ -570,7 +570,7 @@
            try
            {
                // æŸ¥æ‰¾ä»»åŠ¡
                Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletTaskDTO && (x.TaskStatus == TaskOutStatusEnum.OutNew.ObjToInt()|| x.TaskStatus == TaskRelocationStatusEnum.RelocationNew.ObjToInt()|| x.TaskStatus == TaskInStatusEnum.Line_InExecuting.ObjToInt()));
                Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletTaskDTO && (x.TaskStatus == TaskOutStatusEnum.OutNew.ObjToInt() || x.TaskStatus == TaskRelocationStatusEnum.RelocationNew.ObjToInt() || x.TaskStatus == TaskInStatusEnum.Line_InExecuting.ObjToInt()));
                if (task == null)
                {
                    return MESresponse($"未找到货位信息,条码:{palletTaskDTO}", false, 0);
@@ -607,7 +607,7 @@
                  .SetColumns(x => x.StockStatus == StockStatusEmun.入库完成.ObjToInt())
                  .Where(x => x.PalletCode == task.PalletCode)
                  .ExecuteCommand();
                    if (stockmsseg<=0)
                    if (stockmsseg <= 0)
                    {
                        return MESresponse($"无库存信息", false, 0);
                    }
@@ -634,7 +634,7 @@
                    stockmsseg = _stockRepository.DeleteData(stockInfo).ObjToInt();
                    taskmsseg = BaseDal.DeleteData(task);
                }
                BaseDal.DeleteAndMoveIntoHty(task,OperateTypeEnum.人工删除);
                BaseDal.DeleteAndMoveIntoHty(task, OperateTypeEnum.人工删除);
                //获取接口进行调取
                var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_WCS_IPAddress, SysConfigConst.WCSCancelinventory);      //获取到wcs全部类型的接口
                string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName;
@@ -660,10 +660,10 @@
                    return MESresponse($"WCS调取接口失败,反馈参数原因:{response.Message}", false, 0);
                }
                if (stockmsseg <= 0 && locationmsseg <= 0 && taskmsseg)
                    {
                {
                    _unitOfWorkManage.RollbackTran();
                    return MESresponse($"任务取消失败", false, 0);
                    }
                }
@@ -702,7 +702,7 @@
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return  MESresponse($"取消任务失败,原因:{ex.Message}", false, 0);
                return MESresponse($"取消任务失败,原因:{ex.Message}", false, 0);
            }
        }
@@ -738,7 +738,7 @@
            int res = _locationInfoRepository.AddData(dt_LocationInfoList);
            if (res <= 0)
            {
                return MESresponse($"创建货位失败",false);
                return MESresponse($"创建货位失败", false);
            }
            return MESresponse($"", true);
        }
@@ -771,7 +771,7 @@
    .ExecuteCommand() > 0;
            if (!res)
            {
                return MESresponse($"修改货位失败",false);
                return MESresponse($"修改货位失败", false);
            }
            return MESresponse($"", true);
        }
@@ -788,7 +788,7 @@
            int res = _locationInfoRepository.Db.Deleteable<Dt_LocationInfo>().Where(x => locationCode.Contains(x.LocationCode)).ExecuteCommand();
            if (res <= 0)
            {
                return MESresponse($"删除货位失败",false);
                return MESresponse($"删除货位失败", false);
            }
            return MESresponse($"", true);
        }
@@ -812,7 +812,7 @@
            try
            {
                Dt_StockInfo dt_StockInfo =  _stockRepository.QueryFirst(x => x.LocationCode.StartsWith("SC01") && x.StockStatus == 6);
                Dt_StockInfo dt_StockInfo = _stockRepository.QueryFirst(x => x.LocationCode.StartsWith("SC01") && x.StockStatus == 6);
                int result = GetLastPart(dt_StockInfo.LocationCode).ObjToInt(); // è¿”回 "C03"
                List<Dt_Task> dt_s = new List<Dt_Task>();
@@ -896,7 +896,7 @@
            {
                // æŸ¥æ‰¾ä»»åŠ¡
                Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletTaskDTO);
                if (task == null)
                {
                    return webResponse.Error($"未找到托盘编码为【{palletTaskDTO}】的任务信息");
@@ -939,7 +939,7 @@
                //        if (locationmsseg1 == null) { webResponse.Error("未找到货位信息"); }
                //        locationmsseg1.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                //        location1 = _locationInfoRepository.UpdateData(locationmsseg1);
                //    }
                //}
                //else
@@ -1031,7 +1031,7 @@
        //手动下发任务到WCS
        public WebResponseContent WCSTask(int task)
        {
           List<Dt_Task> AddtaskList =  BaseDal.QueryData(x=>x.TaskNum == task);
            List<Dt_Task> AddtaskList = BaseDal.QueryData(x => x.TaskNum == task);
            if (!AddtaskList.Any())
            {