wangxinhui
2025-08-26 a23691d54a0142ba9a0668788d366638bd82349e
更新最新代码,码垛,伸缩货叉等
已添加10个文件
已修改32个文件
2242 ■■■■ 文件已修改
项目代码/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskStatusEnum.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_DTO/Agv/AgvSecureApplyDTO.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_DTO/Agv/AgvTaskSendDTO.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_ITaskInfoService/ITaskService.cs 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs 215 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineTaskCommand.cs 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/DBNames/CoveryorDBName.cs 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/DBNames/R_MDDBName.cs 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/DBNames/RetractDBName.cs 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/DBNames/W_MDDBName.cs 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/伸缩货叉/RetractYSJob.cs 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/原料库/ConveyorLineJob_YL1ndFloor.cs 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/原料库/StackerCraneJob_YLSC2.cs 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/AGV_CPExtend.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/ConveyorLineJob_CPA.cs 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/ConveyorLineJob_CPB.cs 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/ConveyorLineJob_CPC.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/ConveyorLineJob_CPH.cs 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/RGVJob_CP.cs 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/StackerCraneJob_CP.cs 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/接驳台/CoveryorJobYL.cs 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/码垛/MDJob_CP.cs 165 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_BasicService/Service/LocationInfoService_Common.cs 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskStatusEnum.cs 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_ITaskInfoService/ITaskService.cs 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_Model/Models/Stock/Dt_ProCache.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Completed.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs 413 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Reloaction.cs 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS/WMSServices/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/龙利得PDA/common/config.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/接口协议/一期BSTERP需求字段.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/通信协议/伸缩货叉接驳台IP分配表.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/通信协议/印智云数据字典.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/通信协议/原料库输送线通讯协议.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/通信协议/成品输送线通讯协议_20250707.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/通信协议/龙利得机器人IO通讯表20250712.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskStatusEnum.cs
@@ -48,10 +48,10 @@
        [Description("AGV待执行")]
        AGV_Execute = 300,
        /// <summary>
        /// AGV取货中
        /// AGV取货完成
        /// </summary>
        [Description("AGV取货中")]
        AGV_Takeing = 305,
        [Description("AGV取货完成")]
        AGV_TakeFinish = 305,
        /// <summary>
        /// AGV执行中
        /// </summary>
@@ -104,6 +104,12 @@
        RGV_Executing = 510,
        /// <summary>
        /// ç åž›æ‰§è¡Œä¸­
        /// </summary>
        [Description("码垛执行中")]
        MD_Executing = 520,
        /// <summary>
        /// ä»»åŠ¡å®Œæˆ
        /// </summary>
        [Description("任务完成")]
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs
@@ -80,6 +80,19 @@
        /// </summary>
        [Description("成品MES提库")]
        OutMesRworkProduct = 250,
        /// <summary>
        /// å°åˆ·å‡ºåº“
        /// </summary>
        [Description("印刷出库")]
        PrintOutbound = 310,
        /// <summary>
        /// æ— çººå¸ƒå‡ºåº“
        /// </summary>
        [Description("无纺布出库")]
        OutWFB = 320,
        /// <summary>
        /// é‡‡è´­å…¥åº“
        /// </summary>
@@ -155,6 +168,24 @@
        EmptyProductBack = 630,
        /// <summary>
        /// æˆå“ç åž›
        /// </summary>
        [Description("成品码垛")]
        ProductMD = 640,
        /// <summary>
        /// å°åˆ·åŠæˆå“å…¥åº“
        /// </summary>
        [Description("印刷半成品入库")]
        PrintInbound = 710,
        /// <summary>
        /// å°åˆ·åŽŸæ–™ä½™æ–™é€€åº“
        /// </summary>
        [Description("印刷原料余料退库")]
        PrintBackInbound = 720,
        /// <summary>
        /// å··é“内移库
        /// </summary>
        [Description("巷道内移库")]
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_DTO/Agv/AgvSecureApplyDTO.cs
@@ -13,7 +13,7 @@
        /// </summary>
        public string ReceiveTaskID { get; set; }
        /// <summary>
        /// æ‰¹æ¬¡
        /// åœ°å›¾å·
        /// </summary>
        public string WbCode { get; set; }
    }
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_DTO/Agv/AgvTaskSendDTO.cs
@@ -44,6 +44,6 @@
    public class PointDetail
    {
        public string Code { get; set; }
        public string Value { get; set; }
        public string? Value { get; set; }
    }
}
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_ITaskInfoService/ITaskService.cs
@@ -71,7 +71,15 @@
        /// <param name="palletCode">托盘</param>
        /// <param name="sourceAddress">起点</param>
        /// <returns></returns>
        WebResponseContent RequestYLWMSTaskSimple(string palletCode, string sourceAddress);
        WebResponseContent RequestYLWMSTaskSimple(string palletCode, string sourceAddress, int taskNum = 0);
        WebResponseContent AssignCPRoadwayNo();
        // <summary>
        /// è¯·æ±‚原料入库巷道
        /// </summary>
        /// <returns></returns>
        WebResponseContent AssignYLRoadwayNo(string palletCode);
        /// <summary>
        /// è¯·æ±‚入库任务
        /// </summary>
@@ -79,7 +87,7 @@
        /// <param name="sourceAddress">起始地址</param>
        /// /// <param name="roadWay">巷道</param>
        /// <returns></returns>
        WebResponseContent RequestWMSTaskSimple(string palletCode, string sourceAddress, string roadWay="", int taskType = 630);
        WebResponseContent RequestWMSTaskSimple(string palletCode, string sourceAddress, string roadWay="", int taskType = 630,int taskNum=0,string targetAddress="");
        /// <summary>
        /// å‘WMS申请任务
@@ -97,15 +105,6 @@
        /// <param name="roadwayNo">巷道号</param>
        /// <returns></returns>
        string? RequestAssignLocation(int taskNum, string roadwayNo);
        /// <summary>
        /// å‘WMS申请分配货位
        /// </summary>
        /// <param name="taskNum">任务号</param>
        /// <param name="roadwayNo">巷道号</param>
        /// <param name="heightType">高度</param>
        /// <returns></returns>
        string? RequestAssignLocationByHeight(int taskNum, string roadwayNo, int heightType);
        /// <summary>
        /// ä»»åŠ¡å®Œæˆ
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs
@@ -15,9 +15,12 @@
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_Tasks;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_Tasks.DBNames;
using static Dm.net.buffer.ByteArrayBuffer;
namespace WIDESEAWCS_Server.Controllers
{
@@ -28,12 +31,14 @@
        private readonly IStationMangerRepository _stationMangerRepository;
        private readonly ITaskService _taskService;
        private readonly ITaskRepository _taskRepository;
        private readonly IRouterRepository _routerRepository;
        public AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository)
        public AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository,IRouterRepository routerRepository)
        {
            _stationMangerRepository = stationMangerRepository;
            _taskService = taskService;
            _taskRepository = taskRepository;
            _routerRepository = routerRepository;
        }
        
@@ -53,22 +58,42 @@
                if (task == null) throw new Exception("未找到任务");
                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
                    var content = TakeRequest(task.CurrentAddress);
                    if (!content.Status)
                    if (task.TaskState==TaskStatusEnum.AGV_Executing.ObjToInt())//出库取货请求
                    {
                        throw new Exception(content.Message);
                        var content = TakeRequest(secureApplyModel.WbCode);
                        if (!content.Status)
                        {
                            throw new Exception(content.Message);
                        }
                    }
                    else//出库放货请求
                    {
                        var content = PutRequest(secureApplyModel.WbCode, task.PalletType);
                        if (!content.Status)
                        {
                            throw new Exception(content.Message);
                        }
                    }
                }
                else
                {
                    var content = PutRequest(task.NextAddress, task.PalletType);
                    if (!content.Status)
                    if (task.TaskState == TaskStatusEnum.AGV_Executing.ObjToInt())//入库取货请求
                    {
                        throw new Exception(content.Message);
                        var content = TakeRequest(secureApplyModel.WbCode);
                        if (!content.Status)
                        {
                            throw new Exception(content.Message);
                        }
                    }
                    else//入库放货请求
                    {
                        var content = PutRequest(secureApplyModel.WbCode, task.TaskNum);
                        if (!content.Status)
                        {
                            throw new Exception(content.Message);
                        }
                    }
                }
                task.TaskState = TaskStatusEnum.AGV_Puting.ObjToInt();
                var up = _taskRepository.UpdateData(task);
                agvResponse.OK("成功","0");
            }
            catch (Exception ex)
@@ -201,6 +226,9 @@
                switch (agvUpdateModel.GoodsState)
                {
                    case "1"://出库根据这个信号判断取货完成
                        //更新任务状态
                        _taskService.UpdateTask(task, TaskStatusEnum.AGV_TakeFinish);
                        if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                        {
                            var content = TakeFinish(task.CurrentAddress);
@@ -208,9 +236,19 @@
                            {
                                throw new Exception(content.Message);
                            };
                            return agvResponse.OK("成功", "0");
                        }
                        break;
                        else
                        {
                            if (task.TaskType == TaskTypeEnum.PrintInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintBackInbound.ObjToInt())
                            {
                                var content = TakeFinish(task.CurrentAddress);
                                if (!content.Status)
                                {
                                    throw new Exception(content.Message);
                                };
                            }
                        }
                        return agvResponse.OK("成功", "0");
                    case "2"://入库根据这个信号判断放货完成
                        if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                        {
@@ -219,19 +257,41 @@
                            {
                                throw new Exception($"{task.NextAddress}AGV站台未定义");
                            }
                            task.CurrentAddress = dt_Station.StationCode;
                            task.NextAddress = "";
                            task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
                            task.DeviceCode = dt_Station.StationDeviceCode;
                            var up = _taskRepository.UpdateData(task);
                            if (task.TaskType == TaskTypeEnum.PrintInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintBackInbound.ObjToInt())
                            {
                                List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.NextAddress == x.StartPosi);
                                Dt_Router router = routers.FirstOrDefault();
                                if (router == null)
                                {
                                    throw new Exception($"任务号:{task.TaskNum}未找到路由配置信息");
                                }
                                string oldAddress = task.NextAddress;
                                //更新任务状态
                                task.CurrentAddress = router.NextPosi;
                                task.NextAddress = "";
                                task.DeviceCode = router.ChildPosiDeviceCode;
                                _taskService.UpdateTask(task, TaskStatusEnum.AGV_Finish);
                                PutFinish(oldAddress, task.TaskNum);
                            }
                            else
                            {
                                task.CurrentAddress = dt_Station.StationCode;
                                task.NextAddress = "";
                                task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
                                task.DeviceCode = dt_Station.StationDeviceCode;
                                _taskRepository.UpdateData(task);
                            }
                            return agvResponse.OK("成功","0");
                        }
                        else if(task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                        else
                        {
                            _taskService.TaskCompleted(task.TaskNum);
                            if (task.TaskType==TaskTypeEnum.PrintOutbound.ObjToInt())
                            {
                                PutFinish(task.NextAddress);
                            }
                            return agvResponse.OK("成功", "0");
                        }
                        break;
                    default:
                        throw new Exception($"未定义方法名【{agvUpdateModel.TaskState}】");
                }
@@ -241,7 +301,6 @@
                agvResponse.Error(ex.Message);
            }
            return agvResponse;
            //return _taskService.AgvUpdateTask(agvUpdateModel);
        }
        /// <summary>
@@ -251,12 +310,12 @@
        /// <param name="palletType"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("PutRequest"), AllowAnonymous]
        public WebResponseContent PutRequest(string code, int palletType)
        public WebResponseContent PutRequest(string code, int taskNum)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == code);
                Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code);
                if (stationManger == null)
                {
                    return content.Error($"未找到站台配置");
@@ -269,15 +328,57 @@
                OtherDevice otherDevice = (OtherDevice)device;
                short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
                if (Command == 3)
                if (device.DeviceCode.Contains("CP"))//成品输送线
                {
                    content.OK("允许放料");
                    short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
                    if (Command == 3)
                    {
                        content.OK("允许放料");
                    }
                    else
                    {
                        return content.Error("禁止放料");
                    }
                }
                else
                else if (device.DeviceCode.Contains("Coveryor"))//接驳台
                {
                    return content.Error("禁止放料");
                    bool RequestPut = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_RequestPut, stationManger.StationDeviceCode);
                    if (!RequestPut)
                    {
                        otherDevice.SetValue(CoveryorDB.C_InTaskNum, taskNum, stationManger.StationDeviceCode);
                        otherDevice.SetValue(CoveryorDB.C_RequestPut, true, stationManger.StationDeviceCode);
                        Thread.Sleep(1000);
                    }
                    bool AllowFinish = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_AllowFinish, stationManger.StationDeviceCode);
                    if (AllowFinish)
                    {
                        content.OK("允许放料");
                    }
                    else
                    {
                        return content.Error("禁止放料");
                    }
                }
                else if (device.DeviceCode.Contains("Retract"))//伸缩货叉
                {
                    bool RequestPut = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_RequestPut, stationManger.StationDeviceCode);
                    if (!RequestPut)
                    {
                        otherDevice.SetValue(RetractDB.Ret_TargetAddress, Convert.ToInt16(stationManger.StationCode), stationManger.StationDeviceCode);
                        otherDevice.SetValue(RetractDB.Ret_RequestPut, true, stationManger.StationDeviceCode);
                        Thread.Sleep(1000);
                    }
                    bool AllowFinish = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_AllowFinish, stationManger.StationDeviceCode);
                    if (AllowFinish)
                    {
                        content.OK("允许放料");
                    }
                    else
                    {
                        return content.Error("禁止放料");
                    }
                }
                return content;
            }
            catch (Exception ex)
@@ -293,11 +394,11 @@
        /// <param name="code"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("PutFinish"), AllowAnonymous]
        public WebResponseContent PutFinish(string code)
        public WebResponseContent PutFinish(string code,int taskNum=0)
        {
            try
            {
                Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code);
                Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == code);
                if (stationManger == null)
                {
                    return WebResponseContent.Instance.Error($"未找到站台配置");
@@ -309,7 +410,14 @@
                }
                OtherDevice otherDevice = (OtherDevice)device;
                otherDevice.SetValue(GroundStationDBName.W_PutFinish, true, stationManger.StationCode);
                if (device.DeviceCode.Contains("Coveryor"))//接驳台
                {
                    otherDevice.SetValue(CoveryorDB.C_PutFinish, true, stationManger.StationDeviceCode);
                }
                else if (device.DeviceCode.Contains("Retract"))//伸缩货叉
                {
                    otherDevice.SetValue(RetractDB.Ret_PutFinish, true, stationManger.StationDeviceCode);
                }
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
@@ -330,7 +438,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == code);
                Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code);
                if (stationManger == null)
                {
                    return WebResponseContent.Instance.Error($"未找到站台配置{code}");
@@ -343,15 +451,43 @@
                OtherDevice otherDevice = (OtherDevice)device;
                short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
                if (Command == 2)
                if (otherDevice.DeviceCode.Contains("CP"))//成品输送线
                {
                    content.OK("允许取料");
                    short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
                    if (Command == 2)
                    {
                        content.OK("允许取料");
                    }
                    else
                    {
                        return content.Error("禁止取料");
                    }
                }
                else
                else if (device.DeviceCode.Contains("Coveryor"))//接驳台
                {
                    return content.Error("禁止取料");
                    bool AllowTake = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_AllowTake, stationManger.StationDeviceCode);
                    if (AllowTake)
                    {
                        content.OK("允许取料");
                    }
                    else
                    {
                        return content.Error("禁止取料");
                    }
                }
                else if (device.DeviceCode.Contains("Retract"))//伸缩货叉
                {
                    bool AllowTake = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_AllowTake, stationManger.StationDeviceCode);
                    if (AllowTake)
                    {
                        content.OK("允许取料");
                    }
                    else
                    {
                        return content.Error("禁止取料");
                    }
                }
                return content;
            }
            catch (Exception ex)
@@ -387,6 +523,15 @@
                {
                    otherDevice.SetValue(W_ConveyorLineCPDB.W_Command, 2, stationManger.StationCode);
                }
                else if (device.DeviceCode.Contains("Coveryor"))
                {
                    otherDevice.SetValue(CoveryorDB.C_TakeFinish, true, stationManger.StationDeviceCode);
                }
                else if (device.DeviceCode.Contains("Retract"))//伸缩货叉
                {
                    otherDevice.SetValue(RetractDB.Ret_TakeFinish, true, stationManger.StationDeviceCode);
                }
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs
@@ -102,6 +102,11 @@
            };
            return Service.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
        }
        [HttpPost, HttpGet, Route("AssignCPRoadwayNo"), AllowAnonymous]
        public WebResponseContent AssignCPRoadwayNo()
        {
            return Service.AssignCPRoadwayNo();
        }
        /// <summary>
        /// è¯·æ±‚入库任务
        /// </summary>
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -80,6 +80,8 @@
        public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList();
        public List<int> TaskRelocationTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 900 && x < 1000).ToList();
        public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository) : base(BaseDal)
        {
            _mapper = mapper;
@@ -206,6 +208,10 @@
                                task.CurrentAddress = router.StartPosi;
                                task.NextAddress = router.NextPosi;
                                task.DeviceCode = router.ChildPosiDeviceCode;
                                if (task.TaskType == TaskTypeEnum.ProductMD.ObjToInt())
                                {
                                    task.TaskState = TaskStatusEnum.Line_Executing.ObjToInt();
                                }
                            }
                            else //出库
                            {
@@ -312,7 +318,7 @@
        /// <param name="sourceAddress">起始地址</param>
        /// /// <param name="roadWay">巷道</param>
        /// <returns></returns>
        public WebResponseContent RequestYLWMSTaskSimple(string palletCode, string sourceAddress)
        public WebResponseContent RequestYLWMSTaskSimple(string palletCode, string sourceAddress,int taskNum=0)
        {
            WebResponseContent content = new WebResponseContent();
            try
@@ -322,7 +328,7 @@
                {
                    return WebResponseContent.Instance.Error($"未找到WMSApi地址");
                }
                string responseStr = HttpHelper.Get($"{address}/api/Task/RequestYLWMSTaskSimple?stationCode={sourceAddress}&palletCode={palletCode}");
                string responseStr = HttpHelper.Get($"{address}/api/Task/RequestYLWMSTaskSimple?stationCode={sourceAddress}&palletCode={palletCode}&taskNum{taskNum}");
                WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
                if (responseContent != null && responseContent.Status && responseContent.Data != null)
                {
@@ -340,6 +346,64 @@
            }
            return content;
        }
        // <summary>
        /// è¯·æ±‚成品入库巷道
        /// </summary>
        /// <returns></returns>
        public WebResponseContent AssignCPRoadwayNo()
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string address = AppSettings.Get("WMSApiAddress");
                if (string.IsNullOrEmpty(address))
                {
                    return WebResponseContent.Instance.Error($"未找到WMSApi地址");
                }
                string responseStr = HttpHelper.Get($"{address}/api/Task/AssignCPRoadwayNo");
                if (!responseStr.IsNullOrEmpty())
                {
                    content.OK("成功", responseStr);
                }
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
        // <summary>
        /// è¯·æ±‚原料入库巷道
        /// </summary>
        /// <returns></returns>
        public WebResponseContent AssignYLRoadwayNo(string palletCode)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string address = AppSettings.Get("WMSApiAddress");
                if (string.IsNullOrEmpty(address))
                {
                    return WebResponseContent.Instance.Error($"未找到WMSApi地址");
                }
                string responseStr = HttpHelper.Get($"{address}/api/Task/AssignYLRoadwayNo?palletCode={palletCode}");
                WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
                if (responseContent != null && responseContent.Status && responseContent.Data != null)
                {
                    content = responseContent;
                }
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
        // <summary>
        /// è¯·æ±‚入库任务
        /// </summary>
@@ -347,7 +411,7 @@
        /// <param name="sourceAddress">起始地址</param>
        /// /// <param name="roadWay">巷道</param>
        /// <returns></returns>
        public WebResponseContent RequestWMSTaskSimple(string palletCode, string sourceAddress, string roadWay="", int taskType=630)
        public WebResponseContent RequestWMSTaskSimple(string palletCode, string sourceAddress,string roadWay="", int taskType=630, int taskNum = 0, string targetAddress = "")
        {
            WebResponseContent content = new WebResponseContent();
            try
@@ -366,16 +430,15 @@
                //    {
                WMSTaskDTO? taskDTO = new WMSTaskDTO()
                {
                    Id = 1,
                    TaskNum = DateTime.Now.ToString("mmss").ObjToInt(),
                    TaskNum = taskNum ==0 ? DateTime.Now.ToString("mmss").ObjToInt(): taskNum,
                    PalletCode= palletCode,
                    RoadWay= roadWay ?? "",
                    RoadWay= roadWay,
                    TaskType= taskType,
                    PalletType=1,
                    TaskStatus=TaskStatusEnum.New.ObjToInt(),
                    TaskStatus= TaskStatusEnum.New.ObjToInt(),
                    SourceAddress= sourceAddress,
                    TargetAddress="",
                    WarehouseId=1,
                    TargetAddress= targetAddress,
                    WarehouseId=2,
                    Grade=0,
                };
                content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
@@ -574,29 +637,6 @@
        }
        /// <summary>
        /// å‘WMS申请分配货位
        /// </summary>
        /// <param name="taskNum"></param>
        /// <param name="roadwayNo"></param>
        /// <param name="heightType"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public string? RequestAssignLocationByHeight(int taskNum, string roadwayNo, int heightType)
        {
            string address = AppSettings.Get("WMSApiAddress");
            if (string.IsNullOrEmpty(address)) throw new Exception("未找到WMSApi地址");
            string responseStr = HttpHelper.Get($"{address}/api/Task/AssignInboundTaskLocationByHeight?taskNum={taskNum}&roadwayNo={roadwayNo}&heightType={heightType}");
            WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
            if (responseContent != null && responseContent.Status && responseContent.Data != null)
            {
                return responseContent.Data.ToString();
            }
            return "";
        }
        /// <summary>
        /// æ ¹æ®è®¾å¤‡ç¼–号、任务类型分组(可选)按照优先级以及创建时间排序查询任务池新增的任务
        /// </summary>
        /// <param name="deviceNo">设备编号</param>
@@ -610,6 +650,8 @@
                return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskStatusEnum.SC_Execute, TaskOrderBy);
            if (taskTypeGroup.Value == TaskTypeGroup.OutbondGroup)
                return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskStatusEnum.SC_Execute, TaskOrderBy);
            if (taskTypeGroup.Value == TaskTypeGroup.RelocationGroup)
                return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && TaskRelocationTypes.Contains(x.TaskType) && x.TaskState == (int)TaskStatusEnum.SC_Execute, TaskOrderBy);
            return null;
        }
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineTaskCommand.cs
@@ -62,7 +62,7 @@
        ///7:申请料框
        ///8:料框到位
        ///9:执行命令中
        ///11:异常
        ///11:满盘准备
        /// </summary>
        public short Command { get; set; }
        /// <summary>
@@ -261,7 +261,8 @@
        public short WR_Height { get; set; }
        /// <summary>
        /// ç”³è¯·
        /// ç”³è¯·<br/>
        /// 86为申请
        /// </summary>
        public short WR_Request { get; set; }
@@ -350,4 +351,70 @@
        /// </summary>
        public short TaskReceivedDone { get; set; }
    }
    /// <summary>
    /// æŽ¥é©³å°æœ‰æ— è´§
    /// </summary>
    public class C_RequestTakeStatus
    {
        /// <summary>
        /// æœªç”³è¯·å–æ–™
        /// </summary>
        [BoolIndex(0)]
        public bool NoTakeRequest { get; set; }
        /// <summary>
        /// å·²ç”³è¯·å–æ–™
        /// </summary>
        [BoolIndex(1)]
        public bool OkTakeRequest { get; set; }
    }
    public class CoveryorInfo : DeviceCommand
    {
        /// <summary>
        /// æœ‰æ— è´§çŠ¶æ€
        /// </summary>
        public byte C_GoodsStatus { get; set; }
        /// <summary>
        /// æ•…障状态
        /// </summary>
        public short C_Error { get; set; }
        /// <summary>
        /// å…¥åº“申请放货
        /// </summary>
        public byte C_RequestPut { get; set; }
        /// <summary>
        /// å…¥åº“放货完成
        /// </summary>
        public byte C_PutFinish { get; set; }
        /// <summary>
        /// å…¥åº“允许放货
        /// </summary>
        public byte C_AllowFinish { get; set; }
        /// <summary>
        /// å‡ºåº“申请取货
        /// </summary>
        public byte C_RequestTake { get; set; }
        /// <summary>
        /// å‡ºåº“允许取货
        /// </summary>
        public byte C_AllowTake { get; set; }
        /// <summary>
        /// å‡ºåº“任务号
        /// </summary>
        public int C_OutTaskNum { get; set; }
        /// <summary>
        /// å‡ºåº“申请回应
        /// </summary>
        public byte C_OutResponse { get; set; }
        /// <summary>
        /// å‡ºåº“取料完成
        /// </summary>
        public byte C_TakeFinish { get; set; }
        /// <summary>
        /// å…¥åº“任务号
        /// </summary>
        public int C_InTaskNum { get; set; }
    }
}
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/DBNames/CoveryorDBName.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEAWCS_Tasks.DBNames
{
    /// <summary>
    /// æŽ¥é©³å°ä¿¡å·
    /// </summary>
    public enum CoveryorDB
    {
        /// <summary>
        /// æœ‰æ— è´§çŠ¶æ€
        /// </summary>
        C_GoodsStatus,
        /// <summary>
        /// æ•…障状态
        /// </summary>
        C_Error,
        /// <summary>
        /// å…¥åº“申请放货
        /// </summary>
        C_RequestPut,
        /// <summary>
        /// å…¥åº“放货完成
        /// </summary>
        C_PutFinish,
        /// <summary>
        /// å…¥åº“允许放货
        /// </summary>
        C_AllowFinish,
        /// <summary>
        /// å‡ºåº“申请取货
        /// </summary>
        C_RequestTake,
        /// <summary>
        /// å‡ºåº“允许取货
        /// </summary>
        C_AllowTake,
        /// <summary>
        /// å‡ºåº“任务号
        /// </summary>
        C_OutTaskNum,
        /// <summary>
        /// å‡ºåº“申请回应
        /// </summary>
        C_OutResponse,
        /// <summary>
        /// å‡ºåº“取料完成
        /// </summary>
        C_TakeFinish,
        /// <summary>
        /// å…¥åº“任务号
        /// </summary>
        C_InTaskNum,
    }
}
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/DBNames/R_MDDBName.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEAWCS_Tasks.DBNames
{
    public enum R_MDDB
    {
        /// <summary>
        /// 1允许码垛
        /// </summary>
        R_MDAllow,
        /// <summary>
        /// ç åž›1状态<br/>
        /// 1码垛中<br/>
        /// 2码垛完成<br/>
        /// 4码垛清托<br/>
        /// </summary>
        R_MDStatus1,
        /// <summary>
        /// ç åž›2状态<br/>
        /// 1码垛中<br/>
        /// 2码垛完成<br/>
        /// 4码垛清托<br/>
        /// </summary>
        R_MDStatus2,
        /// <summary>
        /// ç åž›3状态<br/>
        /// 1码垛中<br/>
        /// 2码垛完成<br/>
        /// 4码垛清托<br/>
        /// </summary>
        R_MDStatus3,
        /// <summary>
        /// ç åž›4状态<br/>
        /// 1码垛中<br/>
        /// 2码垛完成<br/>
        /// 4码垛清托<br/>
        /// </summary>
        R_MDStatus4,
        /// <summary>
        /// ç åž›1数量
        /// </summary>
        R_MDQtys1,
        /// <summary>
        /// ç åž›2数量
        /// </summary>
        R_MDQtys2,
        /// <summary>
        /// ç åž›3数量
        /// </summary>
        R_MDQtys3,
        /// <summary>
        /// ç åž›4数量
        /// </summary>
        R_MDQtys4
    }
}
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/DBNames/RetractDBName.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEAWCS_Tasks.DBNames
{
    /// <summary>
    /// ä¼¸ç¼©è´§å‰ä¿¡å·
    /// </summary>
    public enum RetractDB
    {
        /// <summary>
        /// æœ‰æ— è´§çŠ¶æ€
        /// </summary>
        Ret_GoodsStatus,
        /// <summary>
        /// æ•…障状态
        /// </summary>
        Ret_Error,
        /// <summary>
        /// ä¸Šæ–™ç”³è¯·æ”¾è´§
        /// </summary>
        Ret_RequestPut,
        /// <summary>
        /// ä¸Šæ–™æ”¾è´§å®Œæˆ
        /// </summary>
        Ret_PutFinish,
        /// <summary>
        /// ä¸Šæ–™ç›®çš„站台
        /// </summary>
        Ret_TargetAddress,
        /// <summary>
        /// ä¸Šæ–™å…è®¸æ”¾è´§
        /// </summary>
        Ret_AllowFinish,
        /// <summary>
        /// ä¸‹æ–™ç”³è¯·å–è´§
        /// </summary>
        Ret_RequestTake,
        /// <summary>
        /// ä¸‹æ–™å…è®¸å–è´§
        /// </summary>
        Ret_AllowTake,
        /// <summary>
        /// ä¸‹æ–™æ¥æºç«™å°
        /// </summary>
        Ret_SourceAddress,
        /// <summary>
        /// ä¸‹æ–™ç”³è¯·å›žåº”
        /// </summary>
        Ret_OutResponse,
        /// <summary>
        /// ä¸‹æ–™å–料完成
        /// </summary>
        Ret_TakeFinish
    }
}
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/DBNames/W_MDDBName.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEAWCS_Tasks.DBNames
{
    public enum W_MDDB
    {
        /// <summary>
        /// ä»»åŠ¡ä¸‹å‘æ ‡è¯†
        /// </summary>
        W_MDReceiveDone,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½1
        /// </summary>
        W_MDSend1,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½2
        /// </summary>
        W_MDSend2,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½3
        /// </summary>
        W_MDSend3,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½4
        /// </summary>
        W_MDSend4,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½å·
        /// </summary>
        W_MDSendID,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½X
        /// </summary>
        W_MDX,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½Y
        /// </summary>
        W_MDY,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½Z
        /// </summary>
        W_MDZ,
        /// <summary>
        /// ä»»åŠ¡å·¥ä½A
        /// </summary>
        W_MDA
    }
}
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/ÉìËõ»õ²æ/RetractYSJob.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,114 @@
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.Helper;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Communicator;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.ConveyorLine.Enum;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_Tasks.DBNames;
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
namespace WIDESEAWCS_Tasks
{
    [DisallowConcurrentExecution]
    public class RetractYSJob : JobBase, IJob
    {
        private readonly ICacheService _cacheService;
        private readonly ITaskService _taskService;
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly ITaskRepository _taskRepository;
        private readonly IStationMangerRepository _stationMangerRepository;
        private readonly IRouterRepository _routerRepository;
        private readonly IRouterService _routerService;
        private readonly IRouterExtension _routerExtension;
        private readonly List<Dt_WarehouseDevice> warehouseDevices;
        public RetractYSJob(ICacheService cacheService, ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IRouterService routerService, IRouterExtension routerExtension)
        {
            _cacheService = cacheService;
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
            _taskRepository = taskRepository;
            _stationMangerRepository = stationMangerRepository;
            _routerRepository = routerRepository;
            _routerService = routerService;
            _routerExtension = routerExtension;
            string? warehouseDevicesStr = _cacheService.Get<string>(nameof(Dt_WarehouseDevice));
            if (!string.IsNullOrEmpty(warehouseDevicesStr))
            {
                warehouseDevices = JsonConvert.DeserializeObject<List<Dt_WarehouseDevice>>(warehouseDevicesStr) ?? new List<Dt_WarehouseDevice>();
            }
            else
            {
                warehouseDevices = new List<Dt_WarehouseDevice>();
            }
        }
        public Task Execute(IJobExecutionContext context)
        {
            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
            if (flag && value != null)
            {
                OtherDevice device = (OtherDevice)value;
                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                foreach (var item in stationMangers)
                {
                    //获取协议
                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationDeviceCode && x.DeviceProParamType == nameof(RetractDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    if (deviceProRead != null)
                    {
                        bool RequestTake = device.GetValue<RetractDB, bool>(RetractDB.Ret_RequestTake, item.StationDeviceCode);
                        short SourceAddress = device.GetValue<RetractDB, short>(RetractDB.Ret_SourceAddress, item.StationDeviceCode);
                        if (RequestTake && SourceAddress > 0) //一楼印刷下料申请
                        {
                            //获取当前任务
                            Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == SourceAddress.ToString() && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode== device.DeviceCode);
                            if (task != null)
                            {
                                //分配巷道 å­˜å…¥æ‰˜ç›˜æ•°æ®
                                List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.CurrentAddress == x.StartPosi && x.ChildPosi==device.DeviceCode);
                                Dt_Router router = routers.FirstOrDefault();
                                if (router == null)
                                {
                                    WriteError(item.StationName, $"任务号:{task.TaskNum}未找到路由配置信息");
                                    return Task.CompletedTask;
                                }
                                device.SetValue(RetractDB.Ret_OutResponse, true, item.StationDeviceCode);
                                //更新任务信息
                                task.DeviceCode = item.StackerCraneCode;
                                _taskService.UpdateTask(task, TaskStatusEnum.AGV_Execute);
                                WriteInfo(item.StationName, $"任务号{task.TaskNum}伸缩货叉下料");
                            }
                        }
                    }
                    else
                    {
                        WriteError(item.StationName, $"未找到设备子编号{item.StationCode}的协议信息");
                    }
                }
            }
            return Task.CompletedTask;
        }
    }
}
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/Ô­ÁÏ¿â/ConveyorLineJob_YL1ndFloor.cs
@@ -82,7 +82,7 @@
                            device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
                            WriteInfo(item.StationCode, $"请求入库条码:{conveyorLineInfoRead.WR_TMID}");
                        }
                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 86 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID)) //一楼分配站台入库分配目标点
                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 86 && conveyorLineInfoRead.WR_Task <= 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID)) //一楼分配站台入库分配目标点
                        {
                            Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == conveyorLineInfoRead.WR_TMID && x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            if (task == null)
@@ -99,7 +99,45 @@
                                device.SetValue(WR_CLineYLDB.WR_ToHode, task.NextAddress, item.StationCode);
                                device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
                                _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
                                WriteInfo(item.StationCode, conveyorLineInfoRead.Serialize());
                                WriteInfo(item.StationCode, $"{conveyorLineInfoRead.Serialize()}");
                            }
                        }
                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 86 && conveyorLineInfoRead.WR_Task > 0) //一楼分配站台入库分配目标点
                        {
                            Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.WR_Task && x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.AGV_Finish.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            //发送任务
                            if (task != null)
                            {
                                if (string.IsNullOrEmpty(task.Roadway) && string.IsNullOrEmpty(task.NextAddress))
                                {
                                    WebResponseContent content = _taskService.AssignYLRoadwayNo(task.PalletCode);
                                    if (!content.Status)
                                    {
                                        WriteError(item.StationCode, $"请求入库失败:{content.Message}");
                                    }
                                    string roadWay = content.Data.ToString();
                                    //获取路由配置
                                    List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.CurrentAddress == x.StartPosi && x.ChildPosiDeviceCode== roadWay);
                                    Dt_Router router = routers.FirstOrDefault();
                                    if (router == null)
                                    {
                                        WriteError(item.StationName, $"任务号:{task.TaskNum}未找到路由配置信息");
                                        return Task.CompletedTask;
                                    }
                                    task.Roadway = roadWay;
                                    task.NextAddress = router.NextPosi;
                                    _taskService.UpdateTask(task,TaskStatusEnum.AGV_Finish);
                                }
                                else
                                {
                                    device.SetValue(WR_CLineYLDB.WR_Task, task.TaskNum, item.StationCode);
                                    device.SetValue(WR_CLineYLDB.WR_ToHode, task.NextAddress, item.StationCode);
                                    device.SetValue(WR_CLineYLDB.WR_Width, task.TaskLength, item.StationCode);
                                    device.SetValue(WR_CLineYLDB.WR_TMID, task.PalletCode, item.StationCode);
                                    device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
                                    _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
                                    WriteInfo(item.StationCode, $"请求入库成功:{conveyorLineInfoRead.Serialize()}");
                                }
                            }
                        }
                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode > 0 && conveyorLineInfoRead.WR_Request == 86 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID) && conveyorLineInfoRead.WR_Task>0) //入库站台申请
@@ -137,7 +175,14 @@
                                device.SetValue(WR_CLineYLDB.WR_TMID, task.PalletCode, item.StationCode);
                                device.SetValue(WR_CLineYLDB.WR_ToHode, task.NextAddress, item.StationCode);
                                device.SetValue(WR_CLineYLDB.WR_Reresult, 86, item.StationCode);
                                if (task.TaskType==TaskTypeEnum.OutPick.ObjToInt())
                                {
                                    task.Roadway = task.TargetAddress;
                                    task.TargetAddress = "";
                                    task.TaskType=TaskTypeEnum.InPick.ObjToInt();
                                }
                                _taskService.UpdateTask(task,TaskStatusEnum.Line_Executing);
                                WriteInfo(item.StationCode, $"任务号:{task.TaskNum}出库至{task.NextAddress}");
                            }
                        }
                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_Task > 0 && conveyorLineInfoRead.WR_Request == 98) //一楼老厂出库口完成
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/Ô­ÁÏ¿â/StackerCraneJob_YLSC2.cs
@@ -60,22 +60,26 @@
                    commonStackerCrane.CheckStackerCraneTaskCompleted();//防止任务完成事件监测超时,再手动触发一次
                    if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                    {
                        Dt_Task? task = GetTask(commonStackerCrane);
                        if (task != null)
                        short stackerError = commonStackerCrane.Communicator.Read<short>("DB1000.54.0");
                        if (stackerError==0)
                        {
                            StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                            if (stackerCraneTaskCommand != null)
                            Dt_Task? task = GetTask(commonStackerCrane);
                            if (task != null)
                            {
                                bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                if (sendFlag)
                                StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                                if (stackerCraneTaskCommand != null)
                                {
                                    commonStackerCrane.LastTaskType = task.TaskType;
                                    task.Dispatchertime = DateTime.Now;
                                    task.ExceptionMessage = "";
                                    _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing);
                                    commonStackerCrane.Communicator.Write("DB1000.20.0", true);
                                    //延时1s
                                    Thread.Sleep(1000);
                                    bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                    if (sendFlag)
                                    {
                                        commonStackerCrane.LastTaskType = task.TaskType;
                                        task.Dispatchertime = DateTime.Now;
                                        task.ExceptionMessage = "";
                                        _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing);
                                        commonStackerCrane.Communicator.Write("DB1000.20.0", true);
                                        //延时1s
                                        Thread.Sleep(1000);
                                    }
                                }
                            }
                        }
@@ -112,7 +116,7 @@
        {
            try
            {
                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum && x.TaskState == TaskStatusEnum.SC_Executing.ObjToInt());
                if (task != null)
                {
                    if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
@@ -132,7 +136,7 @@
                            return WebResponseContent.Instance.Error($"未找到路由信息,{task.NextAddress}");
                        }
                        int oldStatus = task.TaskState;
                        //todo å †åž›æœºå®Œæˆå®Œæˆ
                        // å †åž›æœºå®Œæˆ
                        _taskService.UpdateTask(task, TaskStatusEnum.Line_Execute, deviceCode: stationManger.StationDeviceCode, currentAddress: stationManger.StationCode, nextAddress: router.NextPosi);
                        _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"系统自动流程,任务状态从【{oldStatus}】转到【{task.TaskState}】");
                        WriteInfo(deviceCode, $"堆垛机出库任务完成,任务号:{taskNum}");
@@ -172,7 +176,7 @@
        /// <returns></returns>
        private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
        {
            Dt_Task task;
            Dt_Task? task;
            if (commonStackerCrane.LastTaskType == null)
            {
                task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
@@ -181,6 +185,7 @@
            {
                if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
                    //上一个为出库则查是否存在入库任务 äº¤æ›¿æ‰§è¡Œ
                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
                    if (task == null)
                    {
@@ -189,6 +194,7 @@
                }
                else
                {
                    //上一个为入库则查是否存在出库任务 äº¤æ›¿æ‰§è¡Œ
                    task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
                    if (task == null)
                    {
@@ -199,6 +205,7 @@
            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            {
                //判断出库站台占用
                if (OutTaskStationIsOccupied(task) == null)
                {
                    bool flag = false;
@@ -218,7 +225,11 @@
                    }
                }
            }
            task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
            if (task == null)
            {
                task = _taskService.QuertStackerCraneTask(commonStackerCrane.DeviceCode, TaskTypeGroup.RelocationGroup);
            }
            return task;
        }
@@ -298,7 +309,7 @@
                    return null;
                }
            }
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)//判断是否是出库任务
            {
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 3)
@@ -327,7 +338,7 @@
                    return null;
                }
            }
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)//判断是否是移库任务
            {
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 5)
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/AGV_CPExtend.cs
@@ -22,7 +22,7 @@
        {
            try
            {
                var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()|| x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.DeviceCode=="AGV" && x.TaskType!=999).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
                var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()|| x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.DeviceCode=="AGV").ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
                if (newTasks.Count>0)
                {
@@ -48,6 +48,7 @@
                                    Code= "GoodPoint",
                                    Value=stationMangerStart.AGVStationCode
                                };
                                //判断是否有前置点
                                if (!string.IsNullOrEmpty(stationMangerStart.AGVFrontCode))
                                {
                                    PointDetail pointDetail2 = new PointDetail()
@@ -62,7 +63,8 @@
                                    Code = "PointB",
                                    Value = stationMangerEnd.AGVStationCode
                                };
                                if (!string.IsNullOrEmpty(stationMangerStart.AGVFrontCode))
                                //判断是否有前置点
                                if (!string.IsNullOrEmpty(stationMangerEnd.AGVFrontCode))
                                {
                                    PointDetail pointDetail4 = new PointDetail()
                                    {
@@ -90,17 +92,61 @@
                            {
                                throw new Exception("未找到AGV站点");
                            }
                            if (!stationMangerStart.StationCode.Contains("PNT") && stationMangerEnd.StationCode.Contains("PNT"))
                            //取放任务模版
                            if (stationMangerStart.StationCode.Contains("PNT") && !stationMangerEnd.StationCode.Contains("PNT"))//请求放
                            {
                                agvTaskSend.TaskCode = "DUIGAO1";
                                if (stationMangerStart.StationType == 998 || stationMangerEnd.StationType == 998)//潜伏顶升车
                                {
                                    agvTaskSend.TaskCode = "DUOLUN1";
                                }
                            }
                            else if (!stationMangerStart.StationCode.Contains("PNT") && stationMangerEnd.StationCode.Contains("PNT"))//请求取
                            {
                                agvTaskSend.TaskCode = "DUIGAO2";
                                if (stationMangerStart.StationType==998 || stationMangerEnd.StationType == 998)//潜伏顶升车
                                {
                                    agvTaskSend.TaskCode = "DUOLUN2";
                                }
                            }
                            else if (!stationMangerStart.StationCode.Contains("PNT") && !stationMangerEnd.StationCode.Contains("PNT"))//请求取放
                            {
                                agvTaskSend.TaskCode = "DUIGAO3";
                                if (stationMangerStart.StationType == 998 || stationMangerEnd.StationType == 998)//潜伏顶升车
                                {
                                    agvTaskSend.TaskCode = "DUOLUN3";
                                }
                            }
                            else if (stationMangerStart.StationCode.Contains("PNT") && stationMangerEnd.StationCode.Contains("PNT"))//无请求
                            {
                                agvTaskSend.TaskCode = "DUIGAO4";
                                if (stationMangerStart.StationType == 998 || stationMangerEnd.StationType == 998)//潜伏顶升车
                                {
                                    agvTaskSend.TaskCode = "DUOLUN4";
                                }
                            }
                            if (stationMangerStart.StationType == 998 || stationMangerEnd.StationType == 998)//潜伏顶升车
                            {
                                agvTaskSend.Variables.FirstOrDefault(x => x.Code == "FHMH").Value = "0";
                                agvTaskSend.Variables.FirstOrDefault(x => x.Code == "GoodPoint").Value = "";
                                //下发任务AGV任务集群
                                agvTaskSend.AgvGroupCode = "QianF";
                                PointDetail pointDetail2 = new PointDetail()
                                {
                                    Code = "CostPoint",
                                    Value = stationMangerStart.AGVStationCode
                                };
                                agvTaskSend.Variables.Add(pointDetail2);
                            }
                            //延时
                            Thread.Sleep(500);
                            //发送AGV任务
                            WebResponseContent content = _taskService.AgvSendTask(agvTaskSend, APIEnum.AgvSendTask);
                            if (!content.Status)
                                throw new Exception(content.Message);
                            task.Dispatchertime = DateTime.Now;
                            _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
                            Thread.Sleep(500);
                            Thread.Sleep(200);
                        }
                        catch (Exception ex)
                        {
@@ -108,6 +154,7 @@
                            task.ExceptionMessage = ex.Message;
                        }
                    }
                    //更新任务
                    if (newTasks.Count > 0)
                    {
                        _taskService.UpdateData(newTasks);
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/ConveyorLineJob_CPA.cs
@@ -67,9 +67,8 @@
            {
                OtherDevice device = (OtherDevice)value;
                List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList();
                //获取有协议的输送线-z
                //获取有协议的输送线
                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                //让每个输送线启动-z
                foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
                {
                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
@@ -83,22 +82,17 @@
                            Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNo && x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            if (task != null)
                            {
                                string local = "";
                                //分配货位
                                if (task.HeightType==1)
                                string? local = _taskService.RequestAssignLocation(task.TaskNum, task.Roadway);
                                if (!string.IsNullOrEmpty(local))
                                {
                                    local = "SC02_CP-001-064-001-01";
                                    task.CurrentAddress = item.StackerCraneStationCode;
                                    task.TargetAddress = local;
                                    task.NextAddress = local;
                                    task.DeviceCode = item.StackerCraneCode;
                                    _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute);
                                    WriteInfo(item.StationName, $"任务号:{task.TaskNum}进行堆垛机入库");
                                }
                                else if (task.HeightType == 2)
                                {
                                    local = "SC02_CP-001-063-001-01";
                                }
                                task.CurrentAddress = item.StackerCraneStationCode;
                                task.TargetAddress= local;
                                task.NextAddress = local;
                                task.DeviceCode = item.StackerCraneCode;
                                _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute);
                                WriteInfo(item.StationName, $"任务号:{task.TaskNum}进行堆垛机入库");
                            }
                        }
                        else if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 4 && conveyorLineInfoRead.TaskNo <= 0 && item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) //二楼线体出库站台
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/ConveyorLineJob_CPB.cs
@@ -77,36 +77,39 @@
                    {
                        R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress);
                        //二楼入库扫码请求工位
                        if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 5 && conveyorLineInfoRead.TaskNo > 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.PalletCode))
                        if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 5 && conveyorLineInfoRead.TaskNo > 0)//&& !string.IsNullOrEmpty(conveyorLineInfoRead.PalletCode) todo临时删除条件限制
                        {
                            //查找对应任务
                            Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNo && x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            if (task != null)
                            {
                                //分配巷道 å­˜å…¥æ‰˜ç›˜æ•°æ®
                                List<Dt_Router> routers = _routerService.QueryNextRoutes(item.StationCode, "SC02_CP", task.TaskType);
                                Dt_Router? router = routers.FirstOrDefault();
                                if (routers == null || routers.Count == 0 || router == null)
                                string roadWay = _taskService.AssignCPRoadwayNo().Data.ToString();
                                if (!string.IsNullOrEmpty(roadWay))
                                {
                                    WriteError(item.StationName, $"未找到对应路由信息,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                    continue;
                                    List<Dt_Router> routers = _routerService.QueryNextRoutes(item.StationCode, roadWay, task.TaskType);
                                    Dt_Router? router = routers.FirstOrDefault();
                                    if (routers == null || routers.Count == 0 || router == null)
                                    {
                                        WriteError(item.StationName, $"未找到对应路由信息,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                        continue;
                                    }
                                    if (routers.Count > 1)
                                    {
                                        WriteError(item.StationName, $"路由信息配置错误,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                        continue;
                                    }
                                    device.SetValue(W_ConveyorLineCPDB.W_TargetAddress, router.NextPosi, item.StationCode);
                                    device.SetValue(W_ConveyorLineCPDB.W_TaskNo, task.TaskNum, item.StationCode);
                                    device.SetValue(W_ConveyorLineCPDB.W_Command, 1, item.StationCode);
                                    task.CurrentAddress = item.StationCode;
                                    task.NextAddress = router.NextPosi;
                                    task.PalletCode = DateTime.Now.ToString("yyMMddHHmmss");//todo临时
                                    task.Roadway = roadWay;
                                    task.DeviceCode = router.ChildPosiDeviceCode;
                                    _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
                                    WriteInfo(item.StationName, $"任务号{conveyorLineInfoRead.TaskNo}下一步");
                                }
                                if (routers.Count > 1)
                                {
                                    WriteError(item.StationName, $"路由信息配置错误,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                    continue;
                                }
                                device.SetValue(W_ConveyorLineCPDB.W_TargetAddress, router.NextPosi, item.StationCode);
                                device.SetValue(W_ConveyorLineCPDB.W_TaskNo, task.TaskNum, item.StationCode);
                                device.SetValue(W_ConveyorLineCPDB.W_Command, 1, item.StationCode);
                                task.CurrentAddress = item.StationCode;
                                task.NextAddress = router.NextPosi;
                                task.PalletType = 1;
                                task.PalletCode = conveyorLineInfoRead.PalletCode;
                                task.Roadway = "SC02_CP";
                                task.DeviceCode = router.ChildPosiDeviceCode;
                                _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
                                WriteInfo(item.StationName, $"任务号{conveyorLineInfoRead.TaskNo}下一步");
                            }
                        }
                    }
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/ConveyorLineJob_CPC.cs
@@ -82,7 +82,7 @@
                            if (task == null)
                            {
                                //获取站台生成任务
                                WebResponseContent content = _taskService.RequestWMSTaskSimple("", item.StationCode);
                                WebResponseContent content = _taskService.RequestWMSTaskSimple("", item.StationCode,taskType:TaskTypeEnum.InProduct.ObjToInt());
                                if (content.Status)
                                {
                                    Dt_Task taskNew = _taskRepository.QueryFirst(x => x.SourceAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && (x.TaskState == TaskStatusEnum.New.ObjToInt()));
@@ -94,9 +94,18 @@
                                Thread.Sleep(1000);
                            }
                        }
                        if (conveyorLineInfoRead != null && conveyorLineInfoRead.StatusPV == 2 && conveyorLineInfoRead.Command == 10)
                        {
                            item.IsOccupied = 0;
                        }
                        else
                        {
                            item.IsOccupied = 1;
                        }
                    }
                    
                }
                _stationMangerRepository.UpdateData(stationMangers);
            }
            return Task.CompletedTask;
        }
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/ConveyorLineJob_CPH.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using Quartz;
using SqlSugar.Extensions;
using System;
@@ -80,11 +81,24 @@
                        //码垛环线请求任务 
                        if (conveyorLineInfoRead != null && (conveyorLineInfoRead.R_State == 2 || conveyorLineInfoRead.R_State == 3) && conveyorLineInfoRead.R_TaskNo <= 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.R_BoxCode) && conveyorLineInfoRead.R_Request==1)
                        {
                            WebResponseContent content = _taskService.RequestWMSTaskSimple(conveyorLineInfoRead.R_BoxCode, item.StationCode);
                            //向WMS请求任务
                            if (true)
                            {
                            //WebResponseContent content = _taskService.RequestWMSTaskSimple(conveyorLineInfoRead.R_BoxCode, item.StationCode);
                            ////向WMS请求任务
                            //if (true)
                            //{
                            //}
                            if (conveyorLineInfoRead.R_BoxCode=="1")
                            {
                                int taskNum = Convert.ToInt32(DateTime.Now.ToString("ddHHmmss"));
                                WebResponseContent content = _taskService.RequestWMSTaskSimple(taskNum.ToString(), item.StationCode,taskType:TaskTypeEnum.ProductMD.ObjToInt(),taskNum: taskNum, targetAddress:"2554");
                                //请求任务
                                if (content.Status)
                                {
                                    //写入出库线体地址
                                    device.SetValue(W_CLineCPHDB.W_TaskNo, 5, item.StationCode);
                                    device.SetValue(W_CLineCPHDB.W_TaskNo, taskNum, item.StationCode);
                                    device.SetValue(W_ConveyorLineCPDB.W_Command, 1, item.StationCode);
                                }
                            }
                        }
                    }
@@ -94,16 +108,14 @@
                        //获取码垛口任务更新任务状态
                        if (conveyorLineInfoRead != null && (conveyorLineInfoRead.R_State == 2 || conveyorLineInfoRead.R_State == 3) && conveyorLineInfoRead.R_TaskNo > 0)
                        {
                        }
                    }
                    else if (item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && deviceProRead != null)
                    {
                        R_CLineCPHInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_CLineCPHInfo>(deviceProRead.DeviceProAddress);
                        //码垛环线排出口请求取消任务
                        if (conveyorLineInfoRead != null && (conveyorLineInfoRead.R_State == 2 || conveyorLineInfoRead.R_State == 3) && conveyorLineInfoRead.R_TaskNo > 0 && conveyorLineInfoRead.R_Request == 2)
                        {
                            Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.R_TaskNo && x.NextAddress==item.StationCode && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt());
                            if (task != null)
                            {
                                task.CurrentAddress = item.StationCode;
                                task.NextAddress = task.TargetAddress;
                                task.DeviceCode = item.StackerCraneCode;
                                _taskService.UpdateTask(task, TaskStatusEnum.MD_Executing);
                            }
                        }
                    }
                    else
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/RGVJob_CP.cs
@@ -78,66 +78,88 @@
                    W_RGVCPInfo rgvInfoWrite = device.Communicator.ReadCustomer<W_RGVCPInfo>(deviceProWrite.DeviceProAddress);
                    if ((rgvInfoRead.Mode == 5 || rgvInfoRead.Mode == 4) && rgvInfoRead.State == 0 && rgvInfoRead.TaskDone==1)
                    {
                        //获取任务 æ˜¯å¦æœ‰RGV执行的任务
                        List<Dt_Task> tasks = _taskRepository.QueryData(x => _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState != TaskStatusEnum.RGV_Execute.ObjToInt() && x.DeviceCode == device.DeviceCode);
                        //获取任务
                        Dt_Task? task1 = tasks.FirstOrDefault(x => x.HeightType == 1);
                        Dt_Task? task2 = tasks.FirstOrDefault(x => x.HeightType == 2);
                        Dt_Task? task3 = tasks.FirstOrDefault(x => x.HeightType == 3);
                        List<Dt_Task> tasksDown = _taskRepository.QueryData(x => _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.RGV_Execute.ObjToInt() && x.DeviceCode == device.DeviceCode).OrderBy(x=>x.CreateDate).Take(3).ToList();
                        //分配RGV工位任务
                        if (tasksDown.Count>=2)
                        if (tasksDown.Count>0)
                        {
                            device.SetValue(W_RgvCPDB.TaskType, 4);
                            //占用两个工位
                            if (tasksDown.Count==2)
                            bool ReceivedDone = false;
                            //分配RGV工位任务占用一个工位
                            if (tasksDown.Count == 1)
                            {
                                device.SetValue(W_RgvCPDB.WorkStation, 4);
                                if (task1 == null)
                                {
                                    //下发执行工位
                                    device.SetValue(W_RgvCPDB.WorkStation, 1);
                                    device.SetValue(W_RgvCPDB.WcsTask1, tasksDown[0].TaskNum);
                                    device.SetValue(W_RgvCPDB.Qu1, tasksDown[0].CurrentAddress);
                                    device.SetValue(W_RgvCPDB.Fang1, tasksDown[0].NextAddress);
                                    tasksDown[0].HeightType = 1;
                                    _taskService.UpdateTask(tasksDown[0], TaskStatusEnum.RGV_Executing);
                                    Thread.Sleep(100);
                                    ReceivedDone=true;
                                }
                                if (task2 == null)
                            }
                            else if (tasksDown.Count == 2)//占用两个工位
                            {
                                if (task1 == null && task2 == null)
                                {
                                    //下发执行工位
                                    device.SetValue(W_RgvCPDB.WorkStation, 4);
                                    device.SetValue(W_RgvCPDB.WcsTask1, tasksDown[0].TaskNum);
                                    device.SetValue(W_RgvCPDB.Qu1, tasksDown[0].CurrentAddress);
                                    device.SetValue(W_RgvCPDB.Fang1, tasksDown[0].NextAddress);
                                    tasksDown[0].HeightType = 1;
                                    _taskService.UpdateTask(tasksDown[0], TaskStatusEnum.RGV_Executing);
                                    Thread.Sleep(100);
                                    device.SetValue(W_RgvCPDB.WcsTask2, tasksDown[1].TaskNum);
                                    device.SetValue(W_RgvCPDB.Qu2, tasksDown[1].CurrentAddress);
                                    device.SetValue(W_RgvCPDB.Fang2, tasksDown[1].NextAddress);
                                    tasksDown[1].HeightType = 2;
                                    _taskService.UpdateTask(tasksDown[1], TaskStatusEnum.RGV_Executing);
                                    Thread.Sleep(100);
                                    ReceivedDone = true;
                                }
                            }
                            else //占用三个工位
                            {
                                device.SetValue(W_RgvCPDB.WorkStation, 7);
                                if ( task1 == null)
                                if (task1 == null && task2 == null && task3 == null)
                                {
                                    //下发执行工位
                                    device.SetValue(W_RgvCPDB.WorkStation, 7);
                                    device.SetValue(W_RgvCPDB.WcsTask1, tasksDown[0].TaskNum);
                                    device.SetValue(W_RgvCPDB.Qu1, tasksDown[0].CurrentAddress);
                                    device.SetValue(W_RgvCPDB.Fang1, tasksDown[0].NextAddress);
                                    tasksDown[0].HeightType = 1;
                                    _taskService.UpdateTask(tasksDown[0], TaskStatusEnum.RGV_Executing);
                                }
                                if (task2 == null)
                                {
                                    Thread.Sleep(100);
                                    device.SetValue(W_RgvCPDB.WcsTask2, tasksDown[1].TaskNum);
                                    device.SetValue(W_RgvCPDB.Qu2, tasksDown[1].CurrentAddress);
                                    device.SetValue(W_RgvCPDB.Fang2, tasksDown[1].NextAddress);
                                    tasksDown[1].HeightType = 2;
                                    _taskService.UpdateTask(tasksDown[1], TaskStatusEnum.RGV_Executing);
                                }
                                if (task3 == null)
                                {
                                    Thread.Sleep(100);
                                    device.SetValue(W_RgvCPDB.WcsTask3, tasksDown[2].TaskNum);
                                    device.SetValue(W_RgvCPDB.Qu3, tasksDown[2].CurrentAddress);
                                    device.SetValue(W_RgvCPDB.Fang3, tasksDown[2].NextAddress);
                                    tasksDown[2].HeightType = 3;
                                    _taskService.UpdateTask(tasksDown[2], TaskStatusEnum.RGV_Executing);
                                    Thread.Sleep(100);
                                    ReceivedDone = true;
                                }
                            }
                            device.SetValue(W_RgvCPDB.TaskReceivedDone, 1);
                            if (ReceivedDone)
                            {
                                device.SetValue(W_RgvCPDB.TaskType, 4);
                                device.SetValue(W_RgvCPDB.TaskReceivedDone, 1);
                            }
                        }
                    }
                    else if((rgvInfoRead.Mode == 5 || rgvInfoRead.Mode == 4) && rgvInfoRead.TaskDone == 3)
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/StackerCraneJob_CP.cs
@@ -60,22 +60,26 @@
                    commonStackerCrane.CheckStackerCraneTaskCompleted();//防止任务完成事件监测超时,再手动触发一次
                    if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                    {
                        Dt_Task? task = GetTask(commonStackerCrane);
                        if (task != null)
                        short stackerError = commonStackerCrane.Communicator.Read<short>("DB1000.54.0");
                        if (stackerError == 0)
                        {
                            StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                            if (stackerCraneTaskCommand != null)
                            Dt_Task? task = GetTask(commonStackerCrane);
                            if (task != null)
                            {
                                bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                if (sendFlag)
                                StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                                if (stackerCraneTaskCommand != null)
                                {
                                    commonStackerCrane.LastTaskType = task.TaskType;
                                    task.Dispatchertime = DateTime.Now;
                                    task.ExceptionMessage = "";
                                    _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing);
                                    commonStackerCrane.Communicator.Write("DB1000.20.0", true);
                                    //延时1s
                                    Thread.Sleep(1000);
                                    bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                    if (sendFlag)
                                    {
                                        commonStackerCrane.LastTaskType = task.TaskType;
                                        task.Dispatchertime = DateTime.Now;
                                        task.ExceptionMessage = "";
                                        _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing);
                                        commonStackerCrane.Communicator.Write("DB1000.20.0", true);
                                        //延时1s
                                        Thread.Sleep(1000);
                                    }
                                }
                            }
                        }
@@ -112,7 +116,7 @@
        {
            try
            {
                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum && x.TaskState==TaskStatusEnum.SC_Executing.ObjToInt());
                if (task != null)
                {
                    if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
@@ -131,13 +135,14 @@
                            WriteError(deviceCode, $"未找到路由信息,{task.NextAddress}");
                            return WebResponseContent.Instance.Error($"未找到路由信息,{task.NextAddress}");
                        }
                        //堆垛机完成完成
                        int oldStatus = task.TaskState;
                        task.DeviceCode = stationManger.StationDeviceCode;
                        task.TaskState = TaskStatusEnum.Line_Execute.ObjToInt();
                        task.CurrentAddress = stationManger.StationCode;
                        task.NextAddress = router.NextPosi;
                        _taskService.UpdateTask(task, TaskStatusEnum.Line_Execute);
                        //todo å †åž›æœºå®Œæˆå®Œæˆ
                        //_taskService.UpdateTask(task, TaskStatusEnum.Line_Execute, deviceCode: stationManger.StationDeviceCode, currentAddress: stationManger.StationCode, nextAddress: router.NextPosi, targetAddress: router.NextPosi);
                        _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"系统自动流程,任务状态从【{oldStatus}】转到【{task.TaskState}】");
                        WriteInfo(deviceCode, $"堆垛机任务完成,任务号:{taskNum}");
@@ -186,6 +191,7 @@
            {
                if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
                    //上一个为出库则查是否存在入库任务 äº¤æ›¿æ‰§è¡Œ
                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
                    if (task == null)
                    {
@@ -194,6 +200,7 @@
                }
                else
                {
                    //上一个为入库则查是否存在出库任务 äº¤æ›¿æ‰§è¡Œ
                    task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
                    if (task == null)
                    {
@@ -204,6 +211,7 @@
            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            {
                //判断出库站台占用
                if (OutTaskStationIsOccupied(task) == null)
                {
                    bool flag = false;
@@ -234,7 +242,7 @@
        /// <returns>如果未被占用,返回传入的任务信息,否则,返回null</returns>
        private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task)
        {
            Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode == task.DeviceCode);
            Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => (x.StationCode == task.NextAddress) && x.StackerCraneCode == task.DeviceCode);
            if (stationManger != null)
            {
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
@@ -303,7 +311,7 @@
                    return null;
                }
            }
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)//判断是否是出库任务
            {
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 3)
@@ -332,7 +340,7 @@
                    return null;
                }
            }
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
            else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)//判断是否是移库任务
            {
                string[] targetCodes = task.NextAddress.Split("-");
                if (targetCodes.Length == 5)
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/½Ó²µÌ¨/CoveryorJobYL.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,116 @@
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.Helper;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Communicator;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.ConveyorLine.Enum;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_Tasks.DBNames;
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
namespace WIDESEAWCS_Tasks
{
    [DisallowConcurrentExecution]
    public class CoveryorJobYL : JobBase, IJob
    {
        private readonly ICacheService _cacheService;
        private readonly ITaskService _taskService;
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly ITaskRepository _taskRepository;
        private readonly IStationMangerRepository _stationMangerRepository;
        private readonly IRouterRepository _routerRepository;
        private readonly IRouterService _routerService;
        private readonly IRouterExtension _routerExtension;
        private readonly List<Dt_WarehouseDevice> warehouseDevices;
        public CoveryorJobYL(ICacheService cacheService, ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IRouterService routerService, IRouterExtension routerExtension)
        {
            _cacheService = cacheService;
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
            _taskRepository = taskRepository;
            _stationMangerRepository = stationMangerRepository;
            _routerRepository = routerRepository;
            _routerService = routerService;
            _routerExtension = routerExtension;
            string? warehouseDevicesStr = _cacheService.Get<string>(nameof(Dt_WarehouseDevice));
            if (!string.IsNullOrEmpty(warehouseDevicesStr))
            {
                warehouseDevices = JsonConvert.DeserializeObject<List<Dt_WarehouseDevice>>(warehouseDevicesStr) ?? new List<Dt_WarehouseDevice>();
            }
            else
            {
                warehouseDevices = new List<Dt_WarehouseDevice>();
            }
        }
        public Task Execute(IJobExecutionContext context)
        {
            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
            if (flag && value != null)
            {
                OtherDevice device = (OtherDevice)value;
                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                foreach (var item in stationMangers)
                {
                    //获取协议
                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationDeviceCode && x.DeviceProParamType == nameof(CoveryorDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    if (deviceProRead != null)
                    {
                        bool RequestTake = device.GetValue<CoveryorDB, bool>(CoveryorDB.C_RequestTake, item.StationDeviceCode);
                        int OutTaskNum = device.GetValue<CoveryorDB, int>(CoveryorDB.C_OutTaskNum, item.StationDeviceCode);
                        if (RequestTake && OutTaskNum>0) //一楼出库申请
                        {
                            //获取当前任务
                            Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum ==OutTaskNum && x.NextAddress == item.StationCode && _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt());
                            if (task != null)
                            {
                                //分配巷道 å­˜å…¥æ‰˜ç›˜æ•°æ®
                                List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.NextAddress == x.StartPosi);
                                Dt_Router router = routers.FirstOrDefault();
                                if (router == null)
                                {
                                    WriteError(item.StationName, $"任务号:{task.TaskNum}未找到路由配置信息");
                                    return Task.CompletedTask;
                                }
                                device.SetValue(CoveryorDB.C_OutResponse, true, item.StationDeviceCode);
                                //更新任务信息
                                task.CurrentAddress = router.StartPosi;
                                task.NextAddress = task.TargetAddress;
                                task.DeviceCode = router.NextPosi;
                                _taskService.UpdateTask(task, TaskStatusEnum.AGV_Execute);
                                WriteInfo(item.StationName, $"任务号{OutTaskNum}接驳台出库");
                            }
                        }
                    }
                    else
                    {
                        WriteError(item.StationName, $"未找到设备子编号{item.StationCode}的协议信息");
                    }
                }
            }
            return Task.CompletedTask;
        }
    }
}
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/Âë¶â/MDJob_CP.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,165 @@
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.Helper;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Communicator;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.ConveyorLine.Enum;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_Tasks.DBNames;
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
namespace WIDESEAWCS_Tasks
{
    [DisallowConcurrentExecution]
    public class MDJob_CP : JobBase, IJob
    {
        private readonly ICacheService _cacheService;
        private readonly ITaskService _taskService;
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly ITaskRepository _taskRepository;
        private readonly IStationMangerRepository _stationMangerRepository;
        private readonly IRouterRepository _routerRepository;
        private readonly IRouterService _routerService;
        private readonly IRouterExtension _routerExtension;
        private readonly List<Dt_WarehouseDevice> warehouseDevices;
        public MDJob_CP(ICacheService cacheService, ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IRouterService routerService, IRouterExtension routerExtension)
        {
            _cacheService = cacheService;
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
            _taskRepository = taskRepository;
            _stationMangerRepository = stationMangerRepository;
            _routerRepository = routerRepository;
            _routerService = routerService;
            _routerExtension = routerExtension;
            string? warehouseDevicesStr = _cacheService.Get<string>(nameof(Dt_WarehouseDevice));
            if (!string.IsNullOrEmpty(warehouseDevicesStr))
            {
                warehouseDevices = JsonConvert.DeserializeObject<List<Dt_WarehouseDevice>>(warehouseDevicesStr) ?? new List<Dt_WarehouseDevice>();
            }
            else
            {
                warehouseDevices = new List<Dt_WarehouseDevice>();
            }
        }
        public Task Execute(IJobExecutionContext context)
        {
            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
            if (flag && value != null)
            {
                OtherDevice device = (OtherDevice)value;
                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StackerCraneCode == device.DeviceCode);
                foreach (var item in stationMangers)
                {
                    //获取协议
                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StackerCraneCode && x.DeviceProParamType == nameof(R_MDDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StackerCraneCode && x.DeviceProParamType == nameof(W_MDDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    if (deviceProRead != null && deviceProWrite != null && item.IsOccupied==0)
                    {
                        short Allow = device.GetValue<R_MDDB, short>(R_MDDB.R_MDAllow, item.StackerCraneCode);
                        short R_MDStatus1 = device.GetValue<R_MDDB, short>(R_MDDB.R_MDStatus1, item.StackerCraneCode);
                        short R_MDStatus2 = device.GetValue<R_MDDB, short>(R_MDDB.R_MDStatus2, item.StackerCraneCode);
                        short R_MDStatus3 = device.GetValue<R_MDDB, short>(R_MDDB.R_MDStatus3, item.StackerCraneCode);
                        short R_MDStatus4 = device.GetValue<R_MDDB, short>(R_MDDB.R_MDStatus4, item.StackerCraneCode);
                        short R_MDQtys1 = device.GetValue<R_MDDB, short>(R_MDDB.R_MDQtys1, item.StackerCraneCode);
                        short R_MDQtys2 = device.GetValue<R_MDDB, short>(R_MDDB.R_MDQtys2, item.StackerCraneCode);
                        short R_MDQtys3 = device.GetValue<R_MDDB, short>(R_MDDB.R_MDQtys3, item.StackerCraneCode);
                        short R_MDQtys4 = device.GetValue<R_MDDB, short>(R_MDDB.R_MDQtys4, item.StackerCraneCode);
                        if (R_MDStatus1 == 1 || R_MDStatus2 == 1 || R_MDStatus3 == 1 || R_MDStatus4 == 1)
                        {
                            Thread.Sleep(500);
                            device.Communicator.Write<short>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDReceiveDone.ToString()).DeviceProDataBlock, 0);
                        }
                        //获取当前任务
                        Dt_Task task = _taskRepository.QueryData(x => x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.MD_Executing.ObjToInt() && x.DeviceCode == device.DeviceCode).OrderBy(x=>x.TaskNum).First();
                        if (task!=null) //码垛申请
                        {
                            if ((Allow==3 || Allow == 7)&& item.StackerCraneStationCode == "1")
                            {
                                if ( R_MDQtys1 / 6 ==1)
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDZ.ToString()).DeviceProDataBlock, 400);
                                }
                                else if (R_MDQtys1 / 6 == 2)
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDZ.ToString()).DeviceProDataBlock, 800);
                                }
                                else
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDZ.ToString()).DeviceProDataBlock, 0);
                                }
                                device.Communicator.Write<short>(device.DeviceProDTOs.FirstOrDefault(x=>x.DeviceProParamName== W_MDDB.W_MDSend1.ToString()).DeviceProDataBlock,1);
                                device.Communicator.Write<short>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDSendID.ToString()).DeviceProDataBlock, 1);
                                if (R_MDQtys1 % 6==0)
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDX.ToString()).DeviceProDataBlock, 1675);
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDY.ToString()).DeviceProDataBlock, 1137);
                                }
                                else if (R_MDQtys1 % 6 == 1)
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDX.ToString()).DeviceProDataBlock, 1675);
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDY.ToString()).DeviceProDataBlock, 1462);
                                }
                                else if (R_MDQtys1 % 6 == 2)
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDX.ToString()).DeviceProDataBlock, 1675);
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDY.ToString()).DeviceProDataBlock, 1787);
                                }
                                else if (R_MDQtys1 % 6 == 3)
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDX.ToString()).DeviceProDataBlock, 1250);
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDY.ToString()).DeviceProDataBlock, 1137);
                                }
                                else if (R_MDQtys1 % 6 == 4)
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDX.ToString()).DeviceProDataBlock, 1250);
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDY.ToString()).DeviceProDataBlock, 1462);
                                }
                                else if (R_MDQtys1 % 6 == 5)
                                {
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDX.ToString()).DeviceProDataBlock, 1250);
                                    device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDY.ToString()).DeviceProDataBlock, 1787);
                                }
                                device.Communicator.Write<float>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDA.ToString()).DeviceProDataBlock, 1);
                                device.Communicator.Write<short>(device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == W_MDDB.W_MDReceiveDone.ToString()).DeviceProDataBlock, 3);
                                //更新任务信息
                                //_taskService.TaskCompleted(task.TaskNum);
                                task.TaskState = TaskStatusEnum.Finish.ObjToInt();
                                _taskRepository.UpdateData(task);
                                Thread.Sleep(1500);
                                WriteInfo(item.StationName, $"任务号{task.TaskNum}码垛");
                            }
                        }
                    }
                    else
                    {
                        WriteError(item.StationName, $"未找到设备子编号{item.StationCode}的协议信息");
                    }
                }
            }
            return Task.CompletedTask;
        }
    }
}
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_BasicService/Service/LocationInfoService_Common.cs
@@ -25,7 +25,9 @@
{
    public partial class LocationInfoService
    {
        /// <summary>
        /// åˆ†é…è´§ä½
        /// </summary>
        public Dt_LocationInfo? AssignLocation(string roadwayNo, int palletType, int warehouseId, string beRelocationCode = "", int heightType = 0)
        {
            Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == warehouseId);
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskStatusEnum.cs
@@ -37,33 +37,17 @@
        SC_Finish = 220,
        /// <summary>
        /// è¾“送线待执行
        /// </summary>
        [Description("输送线待执行")]
        Line_Execute = 400,
        /// <summary>
        /// è¾“送线执行中
        /// </summary>
        [Description("输送线执行中")]
        Line_Executing = 410,
        /// <summary>
        /// è¾“送线完成
        /// </summary>
        [Description("输送线完成")]
        Line_Finish = 420,
        /// <summary>
        /// AGV待执行
        /// </summary>
        [Description("AGV待执行")]
        AGV_Execute = 300,
        /// <summary>
        /// AGV取货中
        /// AGV取货完成
        /// </summary>
        [Description("AGV取货中")]
        AGV_Takeing =305,
        [Description("AGV取货完成")]
        AGV_TakeFinish = 305,
        /// <summary>
        /// AGV执行中
        /// </summary>
@@ -88,6 +72,41 @@
        AGV_Finish = 330,
        /// <summary>
        /// è¾“送线待执行
        /// </summary>
        [Description("输送线待执行")]
        Line_Execute = 400,
        /// <summary>
        /// è¾“送线执行中
        /// </summary>
        [Description("输送线执行中")]
        Line_Executing = 410,
        /// <summary>
        /// è¾“送线完成
        /// </summary>
        [Description("输送线完成")]
        Line_Finish = 420,
        /// <summary>
        /// RGV待执行
        /// </summary>
        [Description("RGV待执行")]
        RGV_Execute = 500,
        /// <summary>
        /// RGV执行中
        /// </summary>
        [Description("RGV执行中")]
        RGV_Executing = 510,
        /// <summary>
        /// ç åž›æ‰§è¡Œä¸­
        /// </summary>
        [Description("码垛执行中")]
        MD_Executing = 520,
        /// <summary>
        /// ä»»åŠ¡å®Œæˆ
        /// </summary>
        [Description("任务完成")]
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs
@@ -80,21 +80,37 @@
        /// </summary>
        [Description("成品MES提库")]
        OutMesRworkProduct =250,
        /// <summary>
        /// å°åˆ·å‡ºåº“
        /// </summary>
        [Description("印刷出库")]
        PrintOutbound = 310,
        /// <summary>
        /// æ— çººå¸ƒå‡ºåº“
        /// </summary>
        [Description("无纺布出库")]
        OutWFB = 320,
        /// <summary>
        /// é‡‡è´­å…¥åº“
        /// </summary>
        [Description("采购入库")]
        Inbound = 510,
        /// <summary>
        /// ç›˜ç‚¹å…¥åº“
        /// </summary>
        [Description("盘点入库")]
        InInventory = 520,
        /// <summary>
        /// åˆ†æ‹£å…¥åº“
        /// </summary>
        [Description("分拣入库")]
        InPick = 530,
        /// <summary>
        /// è´¨æ£€å…¥åº“
        /// </summary>
@@ -155,6 +171,24 @@
        EmptyProductBack = 630,
        /// <summary>
        /// æˆå“ç åž›
        /// </summary>
        [Description("成品码垛")]
        ProductMD = 640,
        /// <summary>
        /// å°åˆ·åŠæˆå“å…¥åº“
        /// </summary>
        [Description("印刷半成品入库")]
        PrintInbound = 710,
        /// <summary>
        /// å°åˆ·åŽŸæ–™ä½™æ–™é€€åº“
        /// </summary>
        [Description("印刷原料余料退库")]
        PrintBackInbound = 720,
        /// <summary>
        /// å··é“内移库
        /// </summary>
        [Description("巷道内移库")]
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_ITaskInfoService/ITaskService.cs
@@ -167,6 +167,14 @@
        /// <param name="Count"></param>
        /// <returns></returns>
        WebResponseContent RequestCPWMSTaskOut(int Count);
        /// <summary>
        /// æ— çººå¸ƒå‡ºåº“
        /// </summary>
        /// <param name="Count"></param>
        /// <returns></returns>
        WebResponseContent RequestWFBWMSTaskOut(int Count);
        /// <summary>
        /// åŽŸæ–™å‡ºåº“ä»»åŠ¡
        /// </summary>
@@ -174,8 +182,38 @@
        /// <param name="materielWide">物料幅宽</param>
        /// <param name="Count">卷数</param>
        /// <returns></returns>
        WebResponseContent RequestYLWMSTaskOut(string materielCode, int materielWide, int Count);
        WebResponseContent RequestYLWMSTaskOut(string materielCode, int materielWide, int Count, string address = "");
        /// <summary>
        /// åŽŸæ–™ç§»åº“
        /// </summary>
        /// <param name="startAddress"></param>
        /// <param name="endAddress"></param>
        /// <param name="roadWay"></param>
        /// <returns></returns>
        WebResponseContent IsRelocation(string startAddress, string endAddress, string roadWay);
        /// <summary>
        /// åŽŸæ–™å··é“é—´ç§»åº“ä»»åŠ¡
        /// </summary>
        WebResponseContent RelocationRoadWay(string roadWay,int Count);
        /// <summary>
        /// åˆ†é…å··é“
        /// </summary>
        /// <returns></returns>
        string AssignCPRoadwayNo();
        /// <summary>
        /// å°åˆ·ä½™æ–™é€€æ–™ä»»åŠ¡
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        WebResponseContent PrintBackInbound(SaveModel saveModel);
        /// <summary>
        /// å°åˆ·ä¸‹æ–™ä»»åŠ¡
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        WebResponseContent PrintInbound(SaveModel saveModel);
    }
}
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_Model/Models/Stock/Dt_ProCache.cs
@@ -45,6 +45,18 @@
        public string MdQtys { get; set; }
        /// <summary>
        /// ç åž›ä¸­æ•°é‡ï¼ˆå«å·²ç åž›ï¼‰
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "码垛中数量")]
        public string MdingQtys { get; set; }
        /// <summary>
        /// ç åž›ç»“托数量
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "码垛结托数量")]
        public string MdEndQtys { get; set; }
        /// <summary>
        /// å•号
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 30, ColumnDescription = "单号")]
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Completed.cs
@@ -98,10 +98,14 @@
                Dt_Task wmsTask = BaseDal.QueryFirst(x=>x.TaskNum == task.TaskNum);
                if (wmsTask != null)
                {
                    wmsTask.PalletCode= task.PalletCode;
                    wmsTask.Roadway = task.Roadway;
                    wmsTask.TaskStatus = task.TaskState;
                    wmsTask.CurrentAddress = task.CurrentAddress;
                    wmsTask.NextAddress = task.NextAddress;
                    wmsTask.Dispatchertime = task.Dispatchertime;
                    wmsTask.TaskType = task.TaskType;
                    wmsTask.TargetAddress = task.TargetAddress;
                    BaseDal.UpdateData(wmsTask);
                }
                return WebResponseContent.Instance.OK();
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs
@@ -10,6 +10,7 @@
using System.Threading.Tasks;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.MaterielEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
@@ -127,61 +128,78 @@
        /// <returns></returns>
        public WebResponseContent RequestYLWMSTaskSimple(string stationCode, string palletCode)
        {
            Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
            if (task != null)
            WebResponseContent content = new WebResponseContent();
            try
            {
                PushTasksToWCS(new List<Dt_Task> { task });
                return WebResponseContent.Instance.OK($"该托盘已生成任务", _mapper.Map<WMSTaskDTO>(task));
            }
                Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
                if (task != null)
                {
                    PushTasksToWCS(new List<Dt_Task> { task });
                    return content.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())
            {
                return WebResponseContent.Instance.Error($"该托盘状态不正确,不可申请入库");
            }
            string rowWay = AssignYLRoadwayNo(stockInfo.PalletCode);
            Dt_Task newTask = new Dt_Task()
            {
                CurrentAddress = stationCode,
                Grade = 0,
                NextAddress = "",
                PalletCode = palletCode,
                Roadway = rowWay,
                SourceAddress = stationCode,
                TargetAddress = "",
                TaskType = TaskTypeEnum.Inbound.ObjToInt(),
                TaskStatus = TaskStatusEnum.New.ObjToInt(),
                WarehouseId = stockInfo.WarehouseId,
                PalletType = stockInfo.PalletType,
            };
                if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null)
                {
                    return content.Error($"该站点已有未执行的任务");
                }
                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
                if (stockInfo == null)
                {
                    return content.Error($"未找到组盘信息");
                }
                if (stockInfo.StockStatus != StockStatusEmun.手动组盘暂存.ObjToInt())
                {
                    return content.Error($"该托盘状态不正确,不可申请入库");
                }
                string rowWay = AssignYLRoadwayNo(stockInfo.PalletCode);
                if (string.IsNullOrEmpty(rowWay))
                {
                    return content.Error($"未找到可分配巷道");
                }
                Dt_Task newTask = new Dt_Task()
                {
                    CurrentAddress = stationCode,
                    Grade = 0,
                    NextAddress = "",
                    PalletCode = palletCode,
                    Roadway = rowWay,
                    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();
                if (stockInfo.StockStatus == StockStatusEmun.手动组盘暂存.ObjToInt())
                {
                    stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt();
                }
                _unitOfWorkManage.BeginTran();
                int taskId = BaseDal.AddData(newTask);
                newTask.TaskId = taskId;
                _stockRepository.StockInfoRepository.UpdateData(stockInfo);
                _unitOfWorkManage.CommitTran();
                PushTasksToWCS(new List<Dt_Task> { newTask });
                WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
                return content.OK(data: wMSTaskDTO);
            }
            _unitOfWorkManage.BeginTran();
            int taskId = BaseDal.AddData(newTask);
            newTask.TaskId = taskId;
            _stockRepository.StockInfoRepository.UpdateData(stockInfo);
            _unitOfWorkManage.CommitTran();
            PushTasksToWCS(new List<Dt_Task> { newTask });
            WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
            return WebResponseContent.Instance.OK(data: wMSTaskDTO);
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        public string AssignYLRoadwayNo(string palletCode)
        {
            try
            {
                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
                if (stockInfo==null)
                {
                    throw new Exception($"组盘库存不存在");
                }
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == stockInfo.WarehouseId);
                if (warehouse == null)
@@ -192,11 +210,11 @@
                string roadwayNo = "";
                if (stockInfo.MaterielThickness > 800)
                {
                    List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationType == LocationTypeEnum.Undefined.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YL")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                    List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YL")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                    roadwayNo = locationCounts.OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? "";
                    if (stockInfo.MaterielWide > 2200)
                    {
                        locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationType == LocationTypeEnum.Undefined.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && !x.RoadwayNo.Contains("SC01_YL")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                        locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo=="SC02_YL").GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                        roadwayNo = locationCounts.OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? "";
                    }
                }
@@ -223,7 +241,7 @@
                    {
                        return WebResponseContent.Instance.Error($"未找到对应的终点货位信息");
                    }
                    Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && x.StationArea == AGVStationAreaEnum.AreaA.ObjToInt());
                    Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == AGVStationAreaEnum.AreaA.ObjToInt() || x.StationArea == AGVStationAreaEnum.AreaC.ObjToInt()));
                    if (agvstation != null)
                    {
                        agvstation.IsOccupied = WhetherEnum.False.ObjToInt();
@@ -261,8 +279,14 @@
                    {
                        return WebResponseContent.Instance.Error($"未找到对应的终点货位信息");
                    }
                    task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
                    _unitOfWorkManage.BeginTran();
                    if (task.TaskType == TaskTypeEnum.InPick.ObjToInt())
                    {
                        Dt_LocationInfo locationInfoStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
                        _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
                    }
                    stockInfo.LocationCode = locationInfoEnd.LocationCode;
                    stockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                    _stockService.StockInfoService.Repository.UpdateData(stockInfo);
@@ -293,9 +317,8 @@
                }
                string roadwayNo = "";
                List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationType == LocationTypeEnum.Undefined.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("CP")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                //获取当前入库任务中已分配巷道任务数量
                List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("CP")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                //筛选当前入库任务中已分配巷道任务数量
                List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => x.WarehouseId == warehouse.WarehouseId 
                && locationCounts.Select(j=>j.RoadwayNo).Contains(x.Roadway)
                && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList();
@@ -336,7 +359,7 @@
                {
                    return WebResponseContent.Instance.OK(data: task.TargetAddress);
                }
                //分配货位
                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId);
                if (locationInfo == null)
                {
@@ -356,7 +379,7 @@
                
                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);
@@ -418,119 +441,6 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public readonly string[] OutStartPonits = { "5230", "5237", "5244" };
        /// <summary>
        /// æˆå“ä½™æ–™é€€åº“入仓
        /// </summary>
        /// <param name="barCode"></param>
        /// <param name="startPoint"></param>
        /// <returns></returns>
        //public WebResponseContent BackProductTask(string barCode, string startPoint)
        //{
        //    WebResponseContent content = new WebResponseContent();
        //    try
        //    {
        //        string palletCode = @"^C\d{5}$";  // æ­£åˆ™è¡¨è¾¾å¼
        //        bool isValid = Regex.IsMatch(barCode, palletCode);
        //        if (!isValid)
        //        {
        //            return content.Error($"框码格式错误{barCode}");
        //        }
        //        if (!OutStartPonits.Contains(startPoint))
        //        {
        //            return content.Error($"起点错误{startPoint}");
        //        }
        //        //判断当前点位是否重复
        //        Dt_Task taskOldPoint = BaseDal.QueryFirst(x=>x.SourceAddress==startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt()||x.TaskStatus==TaskStatusEnum.Line_Execute.ObjToInt()|| x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Takeing.ObjToInt()));
        //        if (taskOldPoint != null)
        //        {
        //            return content.Error($"站点{startPoint}已存在任务");
        //        }
        //        Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode);
        //        if (taskOld != null)
        //        {
        //            return content.Error($"胶框{barCode}任务已存在");
        //        }
        //        //获取胶框余料
        //        Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x=>x.PalletCode== barCode).Includes(x=>x.proStockInfoDetails).First();
        //        if (proStockInfo==null)
        //        {
        //            return content.Error($"未找到{barCode}胶框信息");
        //        }
        //        if (proStockInfo.proStockInfoDetails==null || proStockInfo.proStockInfoDetails.Count<=0)
        //        {
        //            return content.Error($"{barCode}胶框信息为空");
        //        }
        //        if (proStockInfo.StockStatus!=StockStatusEmun.出库完成.ObjToInt())
        //        {
        //            return content.Error($"{barCode}胶框信息状态异常");
        //        }
        //        //获取成品平库
        //        Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString());
        //        if (proStockInfo.WarehouseId != warehouse.WarehouseId && proStockInfo.LocationCode!= "成品包装拣货区")
        //        {
        //            return content.Error($"{barCode}胶框信息不在拣货区");
        //        }
        //        //获取当前的库存属性
        //        Dt_Warehouse? warePoint = null;
        //        switch (proStockInfo.ProStockAttribute)
        //        {
        //            case (int)ProStockAttributeEnum.成品:
        //                warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString());
        //                break;
        //            case (int)ProStockAttributeEnum.尾数:
        //                warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString());
        //                break;
        //            case (int)ProStockAttributeEnum.研发:
        //                warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA73.ToString());
        //                break;
        //            default:
        //                throw new Exception($"未找到{barCode}胶框信息库存属性");
        //        }
        //        Dt_Warehouse warehouseLocation = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString());
        //        Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseLocation.WarehouseId);
        //        if (locationInfo == null)
        //        {
        //            return content.Error($"未找到{warehouse.WarehouseCode}货位信息");
        //        }
        //        proStockInfo.StockStatus = StockStatusEmun.成品余料回库.ObjToInt();
        //        proStockInfo.proStockInfoDetails.ForEach(x =>
        //        {
        //            x.ProOutDetailStatus = StockStatusEmun.成品余料回库.ObjToInt();
        //        });
        //        Dt_Task newTask = new Dt_Task()
        //        {
        //            CurrentAddress = startPoint,
        //            Grade = 0,
        //            NextAddress = "",
        //            PalletCode = proStockInfo.PalletCode,
        //            Roadway = locationInfo.RoadwayNo,
        //            SourceAddress = startPoint,
        //            TargetAddress = "",
        //            TaskType = TaskTypeEnum.InProductBack.ObjToInt(),
        //            TaskStatus = TaskStatusEnum.New.ObjToInt(),
        //            WarehouseId = warePoint.WarehouseId,
        //            PalletType = proStockInfo.PalletType,
        //            MaterielCode = proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.ProductCode,
        //            Quantity = (float)proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty)
        //        };
        //        _unitOfWorkManage.BeginTran();
        //        int taskId = BaseDal.AddData(newTask);
        //        newTask.TaskId = taskId;
        //        _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo);
        //        _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails);
        //        _unitOfWorkManage.CommitTran();
        //        //推送任务
        //        PushTasksToWCS(new List<Dt_Task> { newTask });
        //        content.OK("发送成功");
        //    }
        //    catch (Exception ex)
        //    {
        //        _unitOfWorkManage.RollbackTran();
        //        content.Error(ex.Message);
        //    }
        //    return content;
        //}
        /// <summary>
        /// ç©ºæ¡†å›žåº“
        /// </summary>
@@ -551,7 +461,7 @@
                    return content.Error($"起点错误{startPoint}");
                }
                //判断当前点位是否重复
                Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && x.TaskStatus == TaskStatusEnum.New.ObjToInt());
                Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint &&( x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus==TaskStatusEnum.AGV_Executing.ObjToInt()));
                if (taskOldPoint != null)
                {
                    return content.Error($"站点{startPoint}已存在任务");
@@ -606,6 +516,175 @@
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// å°åˆ·ä½™æ–™é€€æ–™ä»»åŠ¡
        /// </summary>
        public WebResponseContent PrintBackInbound(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var barcode = saveModel.MainData["palletCode"].ToString();
                var warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
                var materSn = saveModel.MainData["materSn"];
                //直径
                var thickness = saveModel.MainData["thickness"].ObjToInt();
                var weight = saveModel.MainData["weight"].ObjToInt();
                var address = saveModel.MainData["address"].ToString();
                //幅宽
                var wide = saveModel.MainData["wide"].ObjToInt();
                Dt_MaterielInfo? materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materSn);
                if (materielInfo == null)
                {
                    return content.Error("未找到物料信息");
                }
                Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode);
                if (stockInfoOld != null)
                {
                    return content.Error("托盘信息已存在");
                }
                //生成库存组盘信息
                Dt_StockInfo stockInfo = new Dt_StockInfo()
                {
                    MaterielInvOrgId = materielInfo.MaterielInvOrgId,
                    PalletCode = barcode,
                    LocationCode = "",
                    PalletType = 1,
                    WarehouseId = warehouseId,
                    StockAttribute = materielInfo.MaterielSourceType,
                    StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt(),
                    MaterielSpec = materielInfo.MaterielSpec,
                    Unit = materielInfo.MaterielUnit,
                    MaterielThickness = thickness,
                    MaterielWide = wide,
                    MaterielWeight = weight,
                    MaterielCode = materielInfo.MaterielCode,
                    MaterielName = materielInfo.MaterielName,
                };
                if (wide > 1200)
                {
                    stockInfo.PalletType = 2;
                }
                //生成印刷余料退料任务
                Dt_Task newTask = new Dt_Task()
                {
                    CurrentAddress = address,
                    Grade = 0,
                    NextAddress = "",
                    PalletCode = barcode,
                    Roadway = "",
                    SourceAddress = address,
                    TargetAddress = "",
                    TaskType = TaskTypeEnum.PrintBackInbound.ObjToInt(),
                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
                    WarehouseId = warehouseId,
                    PalletType = 1,
                    TaskLength= wide
                };
                _unitOfWorkManage.BeginTran();
                int taskId = BaseDal.AddData(newTask);
                _stockRepository.StockInfoRepository.AddData(stockInfo);
                newTask.TaskId = taskId;
                _unitOfWorkManage.CommitTran();
                //推送任务
                PushTasksToWCS(new List<Dt_Task> { newTask });
                content.OK("发送成功");
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// å°åˆ·ä¸‹æ–™ä»»åŠ¡
        /// </summary>
        public WebResponseContent PrintInbound(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var barcode = saveModel.MainData["palletCode"].ToString();
                var warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
                var materSn = saveModel.MainData["materSn"];
                //直径
                var thickness = saveModel.MainData["thickness"].ObjToInt();
                var weight = saveModel.MainData["weight"].ObjToInt();
                var address = saveModel.MainData["address"].ToString();
                //幅宽
                var wide = saveModel.MainData["wide"].ObjToInt();
                Dt_MaterielInfo? materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materSn);
                if (materielInfo == null)
                {
                    return content.Error("未找到物料信息");
                }
                if (materielInfo.MaterielSourceType!=MaterielTypeEnum.半成品.ObjToInt())
                {
                    return content.Error($"未找到物料{materielInfo.MaterielCode}半成品信息");
                }
                Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode);
                if (stockInfoOld != null)
                {
                    return content.Error("托盘信息已存在");
                }
                //生成库存组盘信息
                Dt_StockInfo stockInfo = new Dt_StockInfo()
                {
                    MaterielInvOrgId = materielInfo.MaterielInvOrgId,
                    PalletCode = barcode,
                    LocationCode = "",
                    PalletType = 1,
                    WarehouseId = warehouseId,
                    StockAttribute = materielInfo.MaterielSourceType,
                    StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt(),
                    MaterielSpec = materielInfo.MaterielSpec,
                    Unit = materielInfo.MaterielUnit,
                    MaterielThickness = thickness,
                    MaterielWide = wide,
                    MaterielWeight = weight,
                    MaterielCode = materielInfo.MaterielCode,
                    MaterielName = materielInfo.MaterielName,
                };
                if (wide > 1200)
                {
                    stockInfo.PalletType = 2;
                }
                //生成印刷半成品入库任务
                Dt_Task newTask = new Dt_Task()
                {
                    CurrentAddress = address,
                    Grade = 0,
                    NextAddress = "",
                    PalletCode = barcode,
                    Roadway = "",
                    SourceAddress = address,
                    TargetAddress = "",
                    TaskType = TaskTypeEnum.PrintInbound.ObjToInt(),
                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
                    WarehouseId = warehouseId,
                    PalletType = 1,
                    TaskLength = wide
                };
                _unitOfWorkManage.BeginTran();
                int taskId = BaseDal.AddData(newTask);
                _stockRepository.StockInfoRepository.AddData(stockInfo);
                newTask.TaskId = taskId;
                _unitOfWorkManage.CommitTran();
                //推送任务
                PushTasksToWCS(new List<Dt_Task> { newTask });
                content.OK("发送成功");
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -284,13 +284,77 @@
            return content;
        }
        /// <summary>
        /// æ— çººå¸ƒå‡ºåº“
        /// </summary>
        /// <param name="Count"></param>
        /// <returns></returns>
        public WebResponseContent RequestWFBWMSTaskOut(int Count)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x => x.StationArea == AGVStationAreaEnum.AreaC.ObjToInt() && x.IsOccupied == WhetherEnum.False.ObjToInt());
                if (aGVStationInfos.Count < Count)
                {
                    return content.Error($"可用缓存数不足");
                }
                List<Dt_ProStockInfo> stockInfos = _stockRepository.ProStockInfoRepository.QueryData(x => x.ProStockAttribute == ProStockAttributeEnum.空托.ObjToInt() && x.StockStatus == StockStatusEmun.入库完成.ObjToInt()).OrderBy(x => x.CreateDate).Take(Count).ToList();
                List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => stockInfos.Select(x => x.LocationCode).Contains(x.LocationCode));
                if (stockInfos.Count < Count)
                {
                    return content.Error($"库存数量不足");
                }
                foreach (var item in stockInfos)
                {
                    Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode);
                    if (locationInfo != null && (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || locationInfo.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && locationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt())
                    {
                        item.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                    }
                    else
                    {
                        return content.Error($"货位状态不正确");
                    }
                }
                List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutWFB);
                if (tasks == null || tasks.Count <= 0)
                {
                    return content.Error($"生成任务失败");
                }
                for (int i = 0; i < tasks.Count; i++)
                {
                    aGVStationInfos[i].IsOccupied = WhetherEnum.True.ObjToInt();
                    tasks[i].TargetAddress = aGVStationInfos[i].AGVStationCode;
                }
                //判断是否有出库单信息
                _unitOfWorkManage.BeginTran();
                //更新库存状态
                _stockRepository.ProStockInfoRepository.UpdateData(stockInfos);
                _agvStationInfoRepository.UpdateData(aGVStationInfos);
                //更新货位状态
                _basicRepository.LocationInfoRepository.UpdateLocationStatus(locationInfos, LocationStatusEnum.Lock);
                //加入货位变动记录
                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, LocationStatusEnum.Lock, LocationChangeType.OutboundAssignLocation, taskNums: tasks.Select(x => x.TaskNum).ToList());
                //新建任务
                BaseDal.AddData(tasks);
                _unitOfWorkManage.CommitTran();
                PushTasksToWCS(tasks);
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// åŽŸæ–™å‡ºåº“ä»»åŠ¡
        /// </summary>
        /// <param name="materielCode">物料代码</param>
        /// <param name="materielWide">物料幅宽</param>
        /// <param name="Count">卷数</param>
        /// <returns></returns>
        public WebResponseContent RequestYLWMSTaskOut(string materielCode, int materielWide, int Count)
        public WebResponseContent RequestYLWMSTaskOut(string materielCode, int materielWide, int Count, string address = "")
        {
            WebResponseContent content = new WebResponseContent();
            try
@@ -323,13 +387,20 @@
                }
                else
                {
                    taskTypeEnum = TaskTypeEnum.Outbound;
                    taskTypeEnum = TaskTypeEnum.PrintOutbound;
                }
                List<Dt_Task> tasks = GetTasks(stockInfos, taskTypeEnum);
                if (tasks == null || tasks.Count <= 0)
                {
                    return content.Error($"生成任务失败");
                }
                if (!string.IsNullOrEmpty(address))
                {
                    tasks.ForEach(x =>
                    {
                        x.TargetAddress= address;
                    });
                }
                //判断是否有出库单信息
                _unitOfWorkManage.BeginTran();
                //更新库存状态
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Reloaction.cs
@@ -1,10 +1,12 @@
using System;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.MaterielEnum;
using WIDESEA_Common.OtherEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
@@ -176,8 +178,10 @@
                Dt_LocationInfo startLocationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == startAddress);
                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.LocationCode == startAddress);
                Dt_LocationInfo endLocationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == endAddress);
                //判断条件
                if (startLocationInfo != null && startLocationInfo.LocationStatus==LocationStatusEnum.InStock.ObjToInt() && endLocationInfo != null && endLocationInfo.LocationStatus==LocationStatusEnum.Free.ObjToInt() && endLocationInfo.EnableStatus==EnableStatusEnum.Normal.ObjToInt() && stockInfo!=null)
                {
                    //生成任务
                    Dt_Task newTask = new Dt_Task()
                    {
                        Roadway = roadWay,
@@ -191,7 +195,7 @@
                        SourceAddress = startLocationInfo.LocationCode,
                        TargetAddress = endLocationInfo.LocationCode,
                        TaskNum = Repository.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                        TaskStatus = 0,
                        TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(),
                        TaskType = TaskTypeEnum.Relocation.ObjToInt()
                    };
                    stockInfo.StockStatus = StockStatusEmun.移库锁定.ObjToInt();
@@ -216,5 +220,60 @@
            }
            return content;
        }
        /// <summary>
        /// åŽŸæ–™å··é“é—´ç§»åº“ä»»åŠ¡ todo:临时
        /// </summary>
        public WebResponseContent RelocationRoadWay(string roadWay, int Count)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                //获取对应库存
                List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.QueryData(x =>  x.MaterielWide <2200 && x.StockStatus == StockStatusEmun.入库完成.ObjToInt()).OrderBy(x => x.CreateDate).Take(Count).ToList();
                //获取货位
                List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => stockInfos.Select(x => x.LocationCode).Contains(x.LocationCode));
                foreach (var item in stockInfos)
                {
                    Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode);
                    if (locationInfo != null && (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || locationInfo.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && locationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt())
                    {
                        item.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                    }
                    else
                    {
                        return content.Error($"货位状态不正确");
                    }
                }
                List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutPick);
                if (tasks == null || tasks.Count <= 0)
                {
                    return content.Error($"生成任务失败");
                }
                tasks.ForEach(x =>
                {
                    x.TargetAddress = roadWay;
                });
                //判断是否有出库单信息
                _unitOfWorkManage.BeginTran();
                //更新库存状态
                _stockRepository.StockInfoRepository.UpdateData(stockInfos);
                //更新货位状态
                _basicRepository.LocationInfoRepository.UpdateLocationStatus(locationInfos, LocationStatusEnum.Lock);
                //加入货位变动记录
                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, LocationStatusEnum.Lock, LocationChangeType.OutboundAssignLocation, taskNums: tasks.Select(x => x.TaskNum).ToList());
                //新建任务
                BaseDal.AddData(tasks);
                _unitOfWorkManage.CommitTran();
                PushTasksToWCS(tasks);
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs
@@ -172,6 +172,21 @@
        {
            return Service.RequestYLWMSTaskSimple(stationCode,palletCode);
        }
        /// <summary>
        /// åˆ†é…åŽŸæ–™å…¥åº“å··é“
        /// </summary>
        /// <param name="palletCode"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("AssignYLRoadwayNo"), AllowAnonymous]
        public WebResponseContent AssignYLRoadwayNo(string palletCode)
        {
            string roadWay= Service.AssignYLRoadwayNo(palletCode);
            if (string.IsNullOrEmpty(roadWay))
            {
                return WebResponseContent.Instance.Error("未找到可分配巷道");
            }
            return WebResponseContent.Instance.OK(data: roadWay);
        }
        /// <summary>
        /// æˆå“å‡ºåº“任务请求
@@ -182,6 +197,17 @@
        {
            return Service.RequestCPWMSTaskOut(Count);
        }
        /// <summary>
        /// æ— çººå¸ƒå‡ºåº“
        /// </summary>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("RequestWFBWMSTaskOut"), AllowAnonymous]
        public WebResponseContent RequestWFBWMSTaskOut(int Count)
        {
            return Service.RequestWFBWMSTaskOut(Count);
        }
        /// <summary>
        /// åŽŸæ–™å‡ºåº“ä»»åŠ¡
        /// </summary>
@@ -190,9 +216,9 @@
        /// <param name="Count">卷数</param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("RequestYLWMSTaskOut"), AllowAnonymous]
        public WebResponseContent RequestYLWMSTaskOut(string materielCode,int materielWide, int Count)
        public WebResponseContent RequestYLWMSTaskOut(string materielCode,int materielWide, int count,string address="")
        {
            return Service.RequestYLWMSTaskOut(materielCode, materielWide, Count);
            return Service.RequestYLWMSTaskOut(materielCode, materielWide, count, address);
        }
        /// <summary>
        /// åŽŸæ–™ç§»åº“ä»»åŠ¡
@@ -206,5 +232,43 @@
        {
            return Service.IsRelocation(startAddress, endAddress, roadWay);
        }
        /// <summary>
        /// åŽŸæ–™å··é“é—´ç§»åº“ä»»åŠ¡
        /// </summary>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("RelocationRoadWay"), AllowAnonymous]
        public WebResponseContent RelocationRoadWay(string roadWay,int Count)
        {
            return Service.RelocationRoadWay(roadWay, Count);
        }
        /// <summary>
        /// åˆ†é…æˆå“å··é“
        /// </summary>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("AssignCPRoadwayNo"), AllowAnonymous]
        public string AssignCPRoadwayNo()
        {
            return Service.AssignCPRoadwayNo();
        }
        /// <summary>
        /// å°åˆ·ä½™æ–™é€€æ–™ä»»åŠ¡
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("PrintBackInbound"), AllowAnonymous]
        public WebResponseContent PrintBackInbound([FromBody]SaveModel saveModel)
        {
            return Service.PrintBackInbound(saveModel);
        }
        /// <summary>
        /// å°åˆ·ä¸‹æ–™ä»»åŠ¡
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("PrintInbound"), AllowAnonymous]
        public WebResponseContent PrintInbound([FromBody] SaveModel saveModel)
        {
            return Service.PrintInbound(saveModel);
        }
    }
}
ÏîÄ¿´úÂë/ÁúÀûµÃPDA/common/config.js
@@ -1,5 +1,5 @@
let config = {
    baseUrl: 'http://127.0.0.1:9293',
    baseUrl: 'http://192.168.35.3:9283',
    urls: [
        'http://192.168.35.3:9283',
        'http://192.168.35.3:9283'
ÏîÄ¿×ÊÁÏ/½Ó¿ÚЭÒé/Ò»ÆÚBSTERPÐèÇó×Ö¶Î.xlsx
Binary files differ
ÏîÄ¿×ÊÁÏ/ͨÐÅЭÒé/ÉìËõ»õ²æ½Ó²µÌ¨IP·ÖÅä±í.xlsx
Binary files differ
ÏîÄ¿×ÊÁÏ/ͨÐÅЭÒé/Ó¡ÖÇÔÆÊý¾Ý×Öµä.xlsx
Binary files differ
ÏîÄ¿×ÊÁÏ/ͨÐÅЭÒé/Ô­ÁÏ¿âÊäËÍÏßͨѶЭÒé.xlsx
Binary files differ
ÏîÄ¿×ÊÁÏ/ͨÐÅЭÒé/³ÉÆ·ÊäËÍÏßͨѶЭÒé_20250707.xlsx
Binary files differ
ÏîÄ¿×ÊÁÏ/ͨÐÅЭÒé/ÁúÀûµÃ»úÆ÷ÈËIOͨѶ±í20250712.xlsx
Binary files differ