Admin
2026-01-18 b593c2d4ada3244f4a256ca18a23c3fef609f234
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -18,6 +18,7 @@
using AutoMapper;
using Microsoft.Extensions.Logging;
using Org.BouncyCastle.Math.EC;
using SixLabors.ImageSharp;
using SqlSugar;
using System.ComponentModel;
using System.Net;
@@ -129,8 +130,8 @@
                switch (wcsTaskType)
                {
                    case 1:
                        if(task.TargetAddress == "")
                        if (string.IsNullOrEmpty(task.TargetAddress))
                        {
                            int loctype = 0;
                            if (task.Roadway == "1" || task.Roadway == "2")
@@ -149,8 +150,16 @@
                            if (ShallowCargoHold == null) return content.Error($"未找到该货位信息,货位编号:{dt_Location.LocationCode}的浅货位");
                            if (ShallowCargoHold.LocationStatus != (int)LocationStatusEnum.Free) return content.Error($"任务号:{task.TaskId},托盘编号:{task.PalletCode},查找的货位浅货位有货,货位编号:{ShallowCargoHold.LocationCode}");
                            if (task.PalletCode[0] == 1 && (dt_Location.RoadwayNo == "1" || dt_Location.RoadwayNo == "2") && dt_Location.Column < 4)
                            {
                                return content.Error($"条码为高托盘,但是查找的货位要入在低托盘下,故障,托盘条码:{task.PalletCode},货位编号:{dt_Location.LocationCode}");
                            }
                            Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(task.Roadway);
                            task.TargetAddress = dt_Location.LocationCode;
                            task.CurrentAddress = task.NextAddress;
                            task.CurrentAddress = _Roadwayinfo.InSCStationCode;
                            task.NextAddress = dt_Location.LocationCode;
                            task.TaskStatus = (int)InTaskStatusEnum.PLC_InFinish;
@@ -174,6 +183,8 @@
                        }
                        else
                        {
                            //判断是否有该站台
                            string Resultplc = MesInTaskStatusEnum.入库完成.GetDescription();
                            MES_parameter mES_PCLParameter = InStoreDocCallback(task.TaskNum, Resultplc, "操作成功", task.PalletCode, task.TargetAddress);
                            if (mES_PCLParameter.Result == "Y")
@@ -193,7 +204,7 @@
                        string Resultsc = MesInTaskStatusEnum.入库完成.GetDescription();
                        //上报MES任务完成
                        MES_parameter mES_Parameter = InStoreDocCallback(task.TaskNum, Resultsc, "操作成功", task.PalletCode, task.TargetAddress);
                        if (mES_Parameter.Result == "Y")
                        if (mES_Parameter.Result != "Y")
                        {
                            Dt_StockInfo dt_Stockowc = _stockInfoService.Repository.QueryData(x => x.PalletCode == task.PalletCode).FirstOrDefault();
                            Dt_LocationInfo dt_LocationInfo=_locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stockowc.LocationCode).FirstOrDefault();
@@ -235,7 +246,7 @@
                        string Resultplc = MesOutTaskStatusEnum.到达目的地.GetDescription();
                        //上报MES任务完成
                        MES_parameter mES_Parameter = OutStoreDocCallback(task.TaskNum, Resultplc, "操作成功");
                        if (mES_Parameter.Result == "Y")
                        if (mES_Parameter.Result != "Y")
                        {
                            task.TaskStatus = (int)OutTaskStatusEnum.PLC_OutFinish;
                            BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
@@ -254,15 +265,24 @@
                        Dt_StockInfo dt_Stockowc = _stockInfoService.Repository.QueryData(x => x.PalletCode == task.PalletCode).FirstOrDefault();
                        Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stockowc.LocationCode).FirstOrDefault();
                        dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.Free;
                        _unitOfWorkManage.BeginTran();
                        _stockInfoService.DeleteData(dt_Stockowc);
                        _locationInfoService.DeleteData(dt_LocationInfo);
                        BaseDal.UpdateData(task);
                        _unitOfWorkManage.CommitTran();
                        return content.OK($"已接收出库堆垛机完成信息,任务号:{task.TaskId},托盘编号:{task.PalletCode}");
                        string Result = MesOutTaskStatusEnum.出库完成.GetDescription();
                        //调取上游系统反馈开始任务
                        MES_parameter mES_SCParameter = OutStoreDocCallback(task.TaskNum, Result, "操作成功");
                        if (mES_SCParameter.Result != "Y")
                        {
                            _unitOfWorkManage.BeginTran();
                            _stockInfoService.DeleteData(dt_Stockowc);
                            _locationInfoService.UpdateData(dt_LocationInfo);
                            BaseDal.UpdateData(task);
                            _unitOfWorkManage.CommitTran();
                            return content.OK($"已接收出库堆垛机完成信息,任务号:{task.TaskId},托盘编号:{task.PalletCode}");
                        }
                        else
                        {
                            return content.Error("上传MES失败,原因:" + mES_SCParameter.ResultMsg);
                        }
                    default:
                        return content.Error($"WCS上报类型错误:{wcsTaskType}");
                }
@@ -277,24 +297,53 @@
        private WebResponseContent HandleRelocationTask(Dt_Task task, int wcsTaskType)
        {
            WebResponseContent responseContent = new WebResponseContent();
            if (wcsTaskType == 2)
            try
            {
                //上报MES堆垛机移库任务
                string Resultplc = MesOutTaskStatusEnum.到达目的地.GetDescription();
                //上报MES任务完成
                MES_parameter mES_Parameter = AbnormalStorageLocation(task.PalletCode, task.SourceAddress, task.TargetAddress);
                if (mES_Parameter.Result == "Y")
                if (wcsTaskType == 2)
                {
                    task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationFinish;
                    BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                    return WebResponseContent.Instance.OK($"已接收移库堆垛机完成信息,任务号:{task.TaskId},托盘编号:{task.PalletCode}");
                    //上报MES任务完成
                    MES_parameter mES_Parameter = AbnormalStorageLocation(task.PalletCode, task.SourceAddress, task.TargetAddress);
                    if (mES_Parameter.Result == "Y")
                    {
                        Dt_LocationInfo OriginalLocation = _locationInfoService.Repository.QueryData(x => x.LocationCode == task.SourceAddress).FirstOrDefault();
                        Dt_LocationInfo NewLocation = _locationInfoService.Repository.QueryData(x => x.LocationCode == task.TargetAddress).FirstOrDefault();
                        Dt_StockInfo dt_StockInfo = _stockInfoService.Repository.QueryData(x => x.LocationCode == task.TargetAddress).FirstOrDefault();
                        List<Dt_LocationInfo> dt_Locations = new List<Dt_LocationInfo>();
                        OriginalLocation.LocationStatus = (int)LocationStatusEnum.Free;
                        NewLocation.LocationStatus = (int)LocationStatusEnum.InStock;
                        dt_StockInfo.LocationCode = NewLocation.LocationCode;
                        dt_StockInfo.StockStatus = (int)StockStatusEmun.已入库;
                        task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationFinish;
                        dt_Locations.Add(OriginalLocation);
                        dt_Locations.Add(NewLocation);
                        _unitOfWorkManage.BeginTran();
                        _locationInfoService.UpdateData(dt_Locations);
                        _stockInfoService.UpdateData(dt_StockInfo);
                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                        _unitOfWorkManage.CommitTran();
                        return WebResponseContent.Instance.OK($"已接收移库堆垛机完成信息,任务号:{task.TaskId},托盘编号:{task.PalletCode}");
                    }
                    else
                    {
                        return responseContent.Error("上传MES失败,原因:" + mES_Parameter.ResultMsg);
                    }
                }
                else
                {
                    return responseContent.Error("上传MES失败,原因:" + mES_Parameter.ResultMsg);
                    return WebResponseContent.Instance.Error($"WCS上报类型错误:{wcsTaskType}");
                }
            }
            return WebResponseContent.Instance.Error($"WCS上报类型错误:{wcsTaskType}");
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return WebResponseContent.Instance.Error($"WMS系统错误,原因:{ex.Message}");
            }
        }