陈勇
2024-11-18 3dedd7d65f61d09a1117e2586dd71b9e433e6b8b
优化结构
已删除2个文件
已修改7个文件
已添加7个文件
944 ■■■■ 文件已修改
.gitignore 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/CateGoryConst.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/SysConfigKeyConst.cs 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemRepository/ISys_ConfigRepository.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_ConfigService.cs 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/System/Sys_Config.cs 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/WIDESEAWCS_Server.MvcApplicationPartsAssemblyInfo.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets/msbuild.WIDESEAWCS_Server.Microsoft.AspNetCore.StaticWebAssets.props 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets/msbuild.build.WIDESEAWCS_Server.props 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_ConfigRepository.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_ConfigService.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs 198 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WIDESEAWCS_TaskInfoService.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs 309 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs 102 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -1323,3 +1323,19 @@
/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Tasks/obj/project.nuget.cache
/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Tasks/obj/WIDESEA_Tasks.csproj.nuget.dgspec.json
/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/obj/Debug/net6.0/staticwebassets.removed.txt
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/Log_PLCReadWrite/化成入库输送线/Logs_20241118165252.txt
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/Log_PLCReadWrite/陈化1号堆垛机/Logs_20241118165246.txt
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/Log_PLCReadWrite/陈化入库输送线/Logs_20241118165251.txt
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/Log_PLCReadWrite/陈化出库输送线/Logs_20241118165251.txt
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/Log_PLCReadWrite/静置1号堆垛机/Logs_20241118165301.txt
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/Log_PLCReadWrite/静置输送线/Logs_20241118165311.txt
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/WIDESEAWCS_Server.staticwebassets.endpoints.json
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/EndpointInfo/WIDESEAWCS_Server.OpenApiFiles.cache
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/EndpointInfo/WIDESEAWCS_Server_V1.json
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/EndpointInfo/WIDESEAWCS_Server_V2.json
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets/msbuild.build.WIDESEAWCS_Server.props
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets/msbuild.WIDESEAWCS_Server.Microsoft.AspNetCore.StaticWebAssetEndpoints.props
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets/msbuild.WIDESEAWCS_Server.Microsoft.AspNetCore.StaticWebAssets.props
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets.build.endpoints.json
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets.references.upToDateCheck.txt
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets.upToDateCheck.txt
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/CateGoryConst.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEAWCS_Common
{
    /// <summary>
    /// åˆ†ç±»å¸¸é‡
    /// </summary>
    public class CateGoryConst
    {
        /// <summary>
        /// IP接口地址
        /// </summary>
        public const string CONFIG_SYS_IPAddress = "SYS_IPAddress";
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/Const/SysConfigKeyConst.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEAWCS_Common
{
    public class SysConfigKeyConst
    {
        /// <summary>
        /// WMS BASE
        /// </summary>
        public const string WMSIP_BASE = "WMSIPBASE";
        /// <summary>
        /// è¯·æ±‚任务
        /// </summary>
        public const string RequestTask = "RequestTask";
        /// <summary>
        /// è¯·æ±‚任务货位
        /// </summary>
        public const string RequestLocation = "RequestLocation";
        /// <summary>
        /// ä¿®æ”¹ä»»åŠ¡çŠ¶æ€
        /// </summary>
        public const string UpdateTask = "UpdateTask";
        /// <summary>
        /// ä»»åŠ¡å®Œæˆ
        /// </summary>
        public const string CompleteTask = "CompleteTask";
        /// <summary>
        /// è¯·æ±‚空托盘任务
        /// </summary>
        public const string RequestTrayInTask = "RequestTrayInTask";
        /// <summary>
        /// ç©ºæ‰˜ç›˜å®žç›˜å‡ºåº“任务
        /// </summary>
        public const string RequestTrayOutTask = "RequestTrayOutTask";
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemRepository/ISys_ConfigRepository.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_ISystemRepository
{
    public interface ISys_ConfigRepository : IRepository<Sys_Config>
    {
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_ConfigService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_ISystemServices
{
    public interface ISys_ConfigService : IService<Sys_Config>
    {
        /// <summary>
        /// èŽ·å–æ‰€æœ‰ç³»ç»Ÿé…ç½®
        /// </summary>
        /// <returns></returns>
        List<Sys_Config> GetAll();
        /// <summary>
        /// æ ¹æ®ç±»åˆ«èŽ·å–ç³»ç»Ÿé…ç½®
        /// </summary>
        /// <param name="category">类别</param>
        /// <returns></returns>
        List<Sys_Config> GetConfigsByCategory(string category);
        /// <summary>
        /// æ ¹æ®ç±»åˆ«å’ŒKey获取系统配置
        /// </summary>
        /// <param name="category">类别</param>
        /// <param name="configKey">配置Key</param>
        /// <returns></returns>
        Sys_Config GetByConfigKey(string category, string configKey);
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs
@@ -63,7 +63,7 @@
        /// <param name="palletCode">托盘号</param>
        /// <param name="sourceAddress">起始地址</param>
        /// <returns></returns>
        WebResponseContent RequestWMSTask(string palletCode, string sourceAddress);
        Task<WebResponseContent> RequestWMSTask(string palletCode, string sourceAddress);
        /// <summary>
        /// æ ¹æ®è®¾å¤‡ç¼–号、当前地址查询输送线未执行的任务
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/System/Sys_Config.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
using SqlSugar;
using WIDESEAWCS_Core.DB.Models;
using WIDESEAWCS_Core.Tenants;
namespace WIDESEAWCS_Model.Models;
/// <summary>
/// ç³»ç»Ÿé…ç½®è¡¨
/// </summary>
[SugarTable("Sys_Config", "系统配置表"), MultiTenant]
public class Sys_Config : BaseEntity
{
    /// <summary>
    /// ä¸»é”®
    /// </summary>
    [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
    public int Id { get; set; }
    /// <summary>
    /// é…ç½®é”®
    /// </summary>
    [SugarColumn(ColumnDescription = "配置键", Length = 255, IsNullable = false)]
    public string ConfigKey { get; set; }
    /// <summary>
    /// é…ç½®å€¼
    /// </summary>
    [SugarColumn(ColumnDescription = "配置值", IsNullable = false, ColumnDataType = "text")]
    public string ConfigValue { get; set; }
    /// <summary>
    /// åˆ†ç±»
    /// </summary>
    [SugarColumn(ColumnDescription = "分类", Length = 255, IsNullable = false)]
    public string Category { get; set; }
    /// <summary>
    /// å¤‡æ³¨
    /// </summary>
    [SugarColumn(ColumnDescription = "备注", Length = 255, IsNullable = true)]
    public string Remark { get; set; }
    /// <summary>
    /// æŽ’序码
    /// </summary>
    [SugarColumn(ColumnDescription = "排序码", IsNullable = true)]
    public int? SortCode { get; set; }
    /// <summary>
    /// çŠ¶æ€
    /// </summary>
    [SugarColumn(ColumnDescription = "状态", Length = 20, IsNullable = true)]
    public string Status { get; set; }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/WIDESEAWCS_Server.MvcApplicationPartsAssemblyInfo.cs
@@ -28,7 +28,7 @@
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEAWCS_SystemRepository")]
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEAWCS_SystemServices")]
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEAWCS_TaskInfoRepository")]
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEAWCS_TaskInfoService")]
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEAWCs_TaskInfoService")]
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("WIDESEAWCS_Tasks")]
// ç”± MSBuild WriteCodeFragment ç±»ç”Ÿæˆã€‚
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets/msbuild.WIDESEAWCS_Server.Microsoft.AspNetCore.StaticWebAssets.props
ÎļþÒÑɾ³ý
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/staticwebassets/msbuild.build.WIDESEAWCS_Server.props
ÎļþÒÑɾ³ý
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_ConfigRepository.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_ISystemRepository;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_SystemRepository
{
    public class Sys_ConfigRepository : RepositoryBase<Sys_Config>, ISys_ConfigRepository
    {
        public Sys_ConfigRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
        {
        }
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_ConfigService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@

using System.Net;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_ISystemRepository;
using WIDESEAWCS_ISystemServices;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Model.Models;
namespace WIDESEA_Services
{
    public class Sys_ConfigService : ServiceBase<Sys_Config, ISys_ConfigRepository>, ISys_ConfigService
    {
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        public Sys_ConfigService(ISys_ConfigRepository repository, IUnitOfWorkManage unitOfWorkManage) : base(repository)
        {
            _unitOfWorkManage = unitOfWorkManage;
        }
        /// <inheritdoc/>
        public List<Sys_Config> GetAll()
        {
            return BaseDal.QueryData();
        }
        /// <inheritdoc/>
        public List<Sys_Config> GetConfigsByCategory(string category)
        {
            return BaseDal.QueryData(x => x.Category == category).ToList();
        }
        /// <inheritdoc/>
        public Sys_Config GetByConfigKey(string category, string configKey)
        {
            return BaseDal.QueryData(x => x.Category == category && x.ConfigKey == configKey).FirstOrDefault();
        }
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -1,34 +1,18 @@
#region << ç‰ˆ æœ¬ æ³¨ é‡Š >>
/*----------------------------------------------------------------
 * å‘½åç©ºé—´ï¼šWIDESEAWCS_TaskInfoService
 * åˆ›å»ºè€…:胡童庆
 * åˆ›å»ºæ—¶é—´ï¼š2024/8/2 16:13:36
 * ç‰ˆæœ¬ï¼šV1.0.0
 * æè¿°ï¼š
 *
 * ----------------------------------------------------------------
 * ä¿®æ”¹äººï¼š
 * ä¿®æ”¹æ—¶é—´ï¼š
 * ç‰ˆæœ¬ï¼šV1.0.1
 * ä¿®æ”¹è¯´æ˜Žï¼š
 *
 *----------------------------------------------------------------*/
#endregion << ç‰ˆ æœ¬ æ³¨ é‡Š >>

using AutoMapper;
using HslCommunication;
using Newtonsoft.Json;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_ISystemServices;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
@@ -42,13 +26,14 @@
        private readonly IRouterService _routerService;
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
        private readonly ISys_ConfigService _sys_ConfigService;
        private readonly IMapper _mapper;
        private Dictionary<string, OrderByType> _taskOrderBy = new()
            {
                {nameof(Dt_Task.Grade),OrderByType.Desc },
                {nameof(Dt_Task.CreateDate),OrderByType.Asc},
            };
        {
            {nameof(Dt_Task.Grade), OrderByType.Desc },
            {nameof(Dt_Task.CreateDate), OrderByType.Asc},
        };
        public Dictionary<string, OrderByType> TaskOrderBy
        { get { return _taskOrderBy; } set { _taskOrderBy = value; } }
@@ -57,12 +42,13 @@
        public List<int> TaskOutboundTypes => typeof(TaskOutboundTypeEnum).GetEnumIndexList();
        public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper) : base(BaseDal)
        public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ISys_ConfigService sys_ConfigService) : base(BaseDal)
        {
            _routerService = routerService;
            _taskExecuteDetailService = taskExecuteDetailService;
            _taskExecuteDetailRepository = taskExecuteDetailRepository;
            _mapper = mapper;
            _sys_ConfigService = sys_ConfigService;
        }
        /// <summary>
@@ -87,7 +73,6 @@
                    if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                    {
                        List<Dt_Router> routers = _routerService.QueryNextRoutes(item.RoadWay, item.TargetAddress);
                        //暂不考虑多路径
                        if (routers.Count > 0)
                        {
                            task.TaskState = (int)TaskOutStatusEnum.OutNew;
@@ -98,7 +83,6 @@
                    else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                    {
                        List<Dt_Router> routers = _routerService.QueryNextRoutes(item.SourceAddress, item.TargetAddress);
                        //暂不考虑多路径
                        if (routers.Count > 0)
                        {
                            task.TaskState = (int)TaskInStatusEnum.InNew;
@@ -127,71 +111,42 @@
        /// <param name="palletCode">托盘号</param>
        /// <param name="sourceAddress">起始地址</param>
        /// <returns></returns>
        public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress)
        public async Task<WebResponseContent> RequestWMSTask(string palletCode, string sourceAddress)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var hasTask = BaseDal.QueryFirst(x => x.PalletCode == palletCode);
                var hasTask = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode);
                if (hasTask != null)
                {
                    return content;
                    return content.Error("当前托盘存在任务");
                }
                #region è¯·æ±‚入库任务巷道
                // TODO: è°ƒç”¨æŽ¥å£èŽ·å–ä¸‹ä¸€ä¸ªåœ°å€
                // åˆ›å»ºè¯·æ±‚对象
                RequestTaskDto request = new RequestTaskDto()
                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
                if (wmsBase == null || requestTask == null)
                {
                    Position = sourceAddress,
                    PalletCode = palletCode,
                };
                    throw new InvalidOperationException("WMS IP æœªé…ç½®");
                }
                var wmsIpAddrss = wmsBase + requestTask;
                // å‘送请求并等待响应
                var result = HttpHelper.PostAsync("http://127.0.0.1:5000/api/Task/RequestTaskAsync", request.ToJsonString()).Result;
                // ååºåˆ—化响应内容
                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = sourceAddress, PalletCode = palletCode }.ToJsonString());
                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                WMSTaskDTO task = new WMSTaskDTO();
                // æ£€æŸ¥çŠ¶æ€å¹¶è¿”å›ž
                if (!content.Status)
                {
                    task = new WMSTaskDTO()
                    {
                        TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
                        Grade = 1,
                        PalletCode = palletCode,
                        RoadWay = "CHSC01",
                        SourceAddress = sourceAddress,
                        TargetAddress = "1020",
                        TaskState = (int)TaskOutStatusEnum.Line_OutExecuting,
                        Id = 0,
                        TaskType = (int)TaskOutboundTypeEnum.Outbound
                    };
                    Dt_Task task1 = _mapper.Map<Dt_Task>(task);
                    task1.CurrentAddress = task.SourceAddress;
                    task1.NextAddress = "1020";
                    BaseDal.AddData(task1);
                    return content.OK();
                }
                else
                {
                    // ååºåˆ—化任务数据
                    task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                    // å¤„理任务并返回结果
                    content = ReceiveWMSTask(new List<WMSTaskDTO> { task });
                    // wms失败返回去NG口任务
                    return content;
                }
                #endregion
                var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                return ReceiveWMSTask(new List<WMSTaskDTO> { task });
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
                return WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
@@ -340,7 +295,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                if (task == null) return WebResponseContent.Instance.Error($"未找到该任务信息,任务号:【{taskNum}】");
                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
@@ -372,7 +327,7 @@
        /// <param name="status">任务状态</param>
        public void UpdateTaskStatus(int taskNum, int status)
        {
            Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
            var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
            if (task == null) return;
            task.TaskState = status;
            task.ModifyDate = DateTime.Now;
@@ -388,7 +343,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                if (task == null) return WebResponseContent.Instance.Error($"未找到该任务信息,任务号:【{taskNum}】");
                return UpdateTaskStatusToNext(task);
            }
@@ -412,11 +367,6 @@
                int oldState = task.TaskState;
                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
                    //if (task.TaskState >= (int)TaskOutStatusEnum.OutFinish)
                    //{
                    //    return content = WebResponseContent.Instance.Error($"该任务状态不可跳转到下一步,任务号:【{task.TaskNum}】,任务状态:【{task.TaskState}】");
                    //}
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>();
                    task.TaskState = nextStatus;
@@ -430,11 +380,6 @@
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                {
                    //if (task.TaskState >= (int)TaskInStatusEnum.InFinish)
                    //{
                    //    return content = WebResponseContent.Instance.Error($"该任务状态不可跳转到下一步,任务号:【{task.TaskNum}】,任务状态:【{task.TaskState}】");
                    //}
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
                    task.TaskState = nextStatus;
@@ -444,14 +389,24 @@
                        #region å…¥åº“调用接口获取货位地址
                        // TODO: è°ƒç”¨æŽ¥å£èŽ·å–è´§ä½åœ°å€
                        // åˆ›å»ºè¯·æ±‚对象
                        RequestTaskDto taskDto = new RequestTaskDto()
                        var taskDto = new RequestTaskDto()
                        {
                            Position = task.NextAddress,
                            PalletCode = task.PalletCode,
                        };
                        // èŽ·å–WMSip地址
                        var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                        var wmsBasez = configz.Where(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE).FirstOrDefault()?.ConfigValue;
                        var requestLocation = configz.Where(x => x.ConfigKey == SysConfigKeyConst.RequestLocation).FirstOrDefault()?.ConfigValue;
                        if (wmsBasez == null || requestLocation == null)
                        {
                            throw new InvalidOperationException("WMS IP æœªé…ç½®");
                        }
                        var wmsIpAddrss = wmsBasez + requestLocation;
                        // å‘送请求并等待响应
                        var abc = HttpHelper.PostAsync("http://127.0.0.1:5000/api/Task/RequestLocationTaskAsync", taskDto.ToJsonString()).Result;
                        var abc = HttpHelper.PostAsync(wmsIpAddrss, taskDto.ToJsonString()).Result;
                        if (abc == null)
                            return content.Error();
                        // ååºåˆ—化响应内容
@@ -462,7 +417,7 @@
                            return content;
                        // ååºåˆ—化任务数据
                        WMSTaskDTO taskResult = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                        var taskResult = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                        task.CurrentAddress = task.NextAddress;
                        task.NextAddress = taskResult.TargetAddress;
@@ -496,12 +451,17 @@
                _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, App.User.UserId > 0 ? $"人工手动将任务状态从【{oldState}】跳转到【{task.TaskState}】" : $"系统自动流程,任务状态从【{oldState}】转到【{task.TaskState}】");
                #region  æ›´æ–°ä»»åŠ¡çŠ¶æ€
                object request = new
                // èŽ·å–WMSip地址
                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                var updateTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.UpdateTask)?.ConfigValue;
                if (wmsBase == null || updateTask == null)
                {
                    TaskNum = task.TaskNum,
                    TaskState = task.TaskState
                };
                var result = HttpHelper.PostAsync("http://127.0.0.1:5000/api/Task/UpdateTaskStatus", request.ToJsonString()).Result;
                    throw new InvalidOperationException("WMS IP æœªé…ç½®");
                }
                var wmsIpAddress = wmsBase + updateTask;
                var result = HttpHelper.PostAsync(wmsIpAddress, new { TaskNum = task.TaskNum, TaskState = task.TaskState }.ToJsonString()).Result;
                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                #endregion
@@ -524,13 +484,13 @@
        {
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress);
                var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress);
                if (task == null) throw new Exception($"未找到该任务信息,任务号:【{taskNum}】");
                string oldCurrentPos = task.CurrentAddress;
                string oldNextPos = task.NextAddress;
                List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress);
                var routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress);
                if (!routers.Any()) throw new Exception($"未找到设备路由信息");
                task.CurrentAddress = task.NextAddress;
@@ -559,12 +519,12 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                if (task == null) return WebResponseContent.Instance.Error($"未找到该任务信息,任务号:【{taskNum}】");
                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting)
                {
                    List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress);
                    var routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress);
                    if (!routers.Any()) return WebResponseContent.Instance.Error($"未找到设备路由信息");
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>();
@@ -589,8 +549,6 @@
                    task.Modifier = "System";
                    BaseDal.UpdateData(task);
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机入库完成");
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
                {
@@ -607,19 +565,34 @@
                #region WMS同步任务完成
                var keys = new Dictionary<string, object>()
            {
                {"taskNum", taskNum}
            };
                // èŽ·å–WMSip地址
                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
                if (wmsBase == null || completeTask == null)
                {
                    {"taskNum", taskNum}
                };
                var result = HttpHelper.GetAsync($"http://127.0.0.1:5000/api/Task/CompleteTaskAsync", keys).Result;
                    throw new InvalidOperationException("WMS IP æœªé…ç½®");
                }
                var wmsIpAddress = wmsBase + completeTask;
                var result = HttpHelper.GetAsync(wmsIpAddress, keys).Result;
                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                #endregion
                #region  æ›´æ–°ä»»åŠ¡çŠ¶æ€
                object request = new
                var updateTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
                if (wmsBase == null || updateTask == null)
                {
                    TaskNum = task.TaskNum,
                    TaskState = task.TaskState
                };
                result = HttpHelper.PostAsync("http://127.0.0.1:5000/api/Task/UpdateTaskStatus", request.ToJsonString()).Result;
                    throw new InvalidOperationException("WMS IP æœªé…ç½®");
                }
                wmsIpAddress = wmsBase + updateTask;
                result = HttpHelper.PostAsync(wmsIpAddress, new { TaskNum = task.TaskNum, TaskState = task.TaskState }.ToJsonString()).Result;
                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                #endregion
                //content = WebResponseContent.Instance.OK();
@@ -641,14 +614,14 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                if (task == null) return WebResponseContent.Instance.Error($"未找到该任务信息,任务号:【{taskNum}】");
                if (task.TaskState != (int)TaskInStatusEnum.InPending && task.TaskState != (int)TaskOutStatusEnum.OutPending)
                {
                    return content = WebResponseContent.Instance.Error($"该任务状态不可恢复,任务号:【{taskNum}】,任务状态:【{task.TaskState}】");
                }
                Dt_TaskExecuteDetail taskExecuteDetail = _taskExecuteDetailRepository.QueryFirst(x => x.TaskId == task.TaskId && x.IsNormal, new Dictionary<string, OrderByType> { { nameof(Dt_TaskExecuteDetail.TaskDetailId), OrderByType.Desc } });
                var taskExecuteDetail = _taskExecuteDetailRepository.QueryFirst(x => x.TaskId == task.TaskId && x.IsNormal, new Dictionary<string, OrderByType> { { nameof(Dt_TaskExecuteDetail.TaskDetailId), OrderByType.Desc } });
                if (taskExecuteDetail != null)
                {
                    task.TaskState = taskExecuteDetail.TaskState;
@@ -663,7 +636,6 @@
                    {
                        task.TaskState = (int)TaskInStatusEnum.InNew;
                    }
                    //todo
                }
                task.ExceptionMessage = string.Empty;
@@ -688,14 +660,14 @@
        /// <returns>返回处理结果</returns>
        public WebResponseContent RollbackTaskStatusToLast(int taskNum)
        {
            WebResponseContent content = new();
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                if (task == null) return WebResponseContent.Instance.Error($"未找到该任务信息,任务号:【{taskNum}】");
                int oldState = task.TaskState;
                Dt_TaskExecuteDetail taskExecuteDetail = _taskExecuteDetailRepository.QueryFirst(x => x.TaskId == task.TaskId && x.TaskState < task.TaskState && x.TaskState > 0, new Dictionary<string, OrderByType> { { nameof(Dt_TaskExecuteDetail.TaskDetailId), OrderByType.Desc } });
                var taskExecuteDetail = _taskExecuteDetailRepository.QueryFirst(x => x.TaskId == task.TaskId && x.TaskState < task.TaskState && x.TaskState > 0, new Dictionary<string, OrderByType> { { nameof(Dt_TaskExecuteDetail.TaskDetailId), OrderByType.Desc } });
                if (taskExecuteDetail != null)
                {
                    task.TaskState = taskExecuteDetail.TaskState;
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WIDESEAWCS_TaskInfoService.csproj
@@ -9,6 +9,7 @@
    <ItemGroup>
        <ProjectReference Include="..\WIDESEAWCS_BasicInfoService\WIDESEAWCS_BasicInfoService.csproj" />
        <ProjectReference Include="..\WIDESEAWCS_ITaskInfoService\WIDESEAWCS_ITaskInfoService.csproj" />
        <ProjectReference Include="..\WIDESEAWCS_SystemServices\WIDESEAWCS_SystemServices.csproj" />
    </ItemGroup>
</Project>
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -1,33 +1,16 @@
#region << ç‰ˆ æœ¬ æ³¨ é‡Š >>
/*----------------------------------------------------------------
 * å‘½åç©ºé—´ï¼šWIDESEAWCS_Tasks.ConveyorLineJob
 * åˆ›å»ºè€…:胡童庆
 * åˆ›å»ºæ—¶é—´ï¼š2024/8/2 16:13:36
 * ç‰ˆæœ¬ï¼šV1.0.0
 * æè¿°ï¼š
 *
 * ----------------------------------------------------------------
 * ä¿®æ”¹äººï¼š
 * ä¿®æ”¹æ—¶é—´ï¼š
 * ç‰ˆæœ¬ï¼šV1.0.1
 * ä¿®æ”¹è¯´æ˜Žï¼š
 *
 *----------------------------------------------------------------*/
#endregion << ç‰ˆ æœ¬ æ³¨ é‡Š >>
using AutoMapper;
using AutoMapper;
using HslCommunication;
using Newtonsoft.Json;
using Quartz;
using SqlSugar;
using System.Reflection;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_IProcessRepository;
using WIDESEAWCS_ISystemServices;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
@@ -47,9 +30,10 @@
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly IRouterService _routerService;
        private readonly IPlatFormRepository _platFormRepository;
        private readonly ISys_ConfigService _sys_ConfigService;
        private readonly IMapper _mapper;
        public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository)
        public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository, ISys_ConfigService sys_ConfigService)
        {
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -57,9 +41,10 @@
            _mapper = mapper;
            _taskRepository = taskRepository;
            _platFormRepository = platFormRepository;
            _sys_ConfigService = sys_ConfigService;
        }
        public Task Execute(IJobExecutionContext context)
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
@@ -67,89 +52,9 @@
                if (conveyorLine != null)
                {
                    List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
                    List<Task> tasks = new List<Task>();
                    foreach (string childDeviceCode in childDeviceCodes)
                    {
                        //Task task = Task.Run(() =>
                        //{
                        ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode);
                        ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(childDeviceCode, "DeviceCommand");
                        if (command != null && commandWrite != null)
                        {
                            var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
                            List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList();
                            if (deviceProtocolDetails != null)
                            {
                                foreach (var item in deviceProtocolDetails)
                                {
                                    var outDeviceCodes = _routerService.QueryOutDeviceCodes(conveyorLine.DeviceCode);
                                    if (structs[item.ProtocalDetailValue.ObjToInt()] == true)
                                    {
                                        MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType);
                                        if (method != null)
                                        {
                                            command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                            method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, item.ProtocalDetailValue.ObjToInt() });
                                        }
                                    }
                                    else
                                    {
                                        DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == childDeviceCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                                        string[] x = devicePro.DeviceProAddress.Split('.');
                                        x[x.Length - 1] = (item.ProtocalDetailValue.ObjToInt() + 1).ToString();
                                        string DeviceProAddress = string.Join(".", x);
                                        var writeRead = conveyorLine.Communicator.Read<bool>(DeviceProAddress);
                                        if (writeRead)
                                        {
                                            ConveyorLineSendFinish(conveyorLine, childDeviceCode, item.ProtocalDetailValue.ObjToInt(), false);
                                        }
                                    }
                                }
                            }
                            Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active");
                            if (platform != null)
                            {
                                if (command.InteractiveSignal != 2)
                                {
                                    MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                                    if (method != null)
                                    {
                                        command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                        int count = string.IsNullOrEmpty(platform.Location) ? 0 + 1 : platform.Location.Split(',').Count() + 1;
                                        method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
                                    }
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(platform.Location))
                                    {
                                        var strings = platform.Location.Split(',').ToList();
                                        foreach (var ite in strings)
                                        {
                                            int index = strings.FindIndex(p => p == ite);
                                            ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite);
                                            if (command1.InteractiveSignal != 2)
                                            {
                                                MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                                                if (method != null)
                                                {
                                                    command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                                    int count = strings.Count - index;
                                                    method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //});
                        //tasks.Add(task);
                        Task.WaitAll(tasks.ToArray());
                        await ProcessDeviceAsync(conveyorLine, childDeviceCode);
                    }
                }
            }
@@ -157,13 +62,84 @@
            {
                Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString());
            }
            finally
            {
                //WriteDebug("CommonConveyorLineJob", "test");
                //Console.Out.WriteLine(DateTime.Now);
            }
        }
            return Task.CompletedTask;
        private async Task ProcessDeviceAsync(CommonConveyorLine conveyorLine, string childDeviceCode)
        {
            ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode);
            ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(childDeviceCode, "DeviceCommand");
            if (command != null && commandWrite != null)
            {
                var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
                List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList();
                if (deviceProtocolDetails != null)
                {
                    foreach (var item in deviceProtocolDetails)
                    {
                        var outDeviceCodes = _routerService.QueryOutDeviceCodes(conveyorLine.DeviceCode);
                        if (structs[item.ProtocalDetailValue.ObjToInt()] == true)
                        {
                            MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType);
                            if (method != null)
                            {
                                command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, item.ProtocalDetailValue.ObjToInt() });
                            }
                        }
                        else
                        {
                            DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == childDeviceCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                            string[] x = devicePro.DeviceProAddress.Split('.');
                            x[x.Length - 1] = (item.ProtocalDetailValue.ObjToInt() + 1).ToString();
                            string DeviceProAddress = string.Join(".", x);
                            var writeRead = conveyorLine.Communicator.Read<bool>(DeviceProAddress);
                            if (writeRead)
                            {
                                ConveyorLineSendFinish(conveyorLine, childDeviceCode, item.ProtocalDetailValue.ObjToInt(), false);
                            }
                        }
                    }
                }
                Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active");
                if (platform != null)
                {
                    if (command.InteractiveSignal != 2)
                    {
                        MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                        if (method != null)
                        {
                            command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                            int count = string.IsNullOrEmpty(platform.Location) ? 0 + 1 : platform.Location.Split(',').Count() + 1;
                            method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(platform.Location))
                        {
                            var strings = platform.Location.Split(',').ToList();
                            foreach (var ite in strings)
                            {
                                int index = strings.FindIndex(p => p == ite);
                                ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite);
                                if (command1.InteractiveSignal != 2)
                                {
                                    MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                                    if (method != null)
                                    {
                                        command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                        int count = strings.Count - index;
                                        method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
@@ -177,14 +153,9 @@
        {
            try
            {
                // èŽ·å–ä¸‹ä¸€ä¸ªä»»åŠ¡
                var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
                //var taskOut = _taskService.QueryNextConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                //return;
                // å¤„理出库任务
                HandleTaskOut(conveyorLine, command, childDeviceCode, ProtocalDetailValue, task);
                // å¦‚果没有出库任务,处理新任务
                if (task == null && command.Barcode != "NoRead")
                {
                    HandleNewTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
@@ -192,34 +163,9 @@
            }
            catch (Exception ex)
            {
                return;
                Console.Out.WriteLine(ex.ToString());
            }
        }
        #region è¾“送线请求入库下一地址
        /// <summary>
        /// è¾“送线请求入库下一地址
        /// </summary>
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="command">读取的请求信息</param>
        /// <param name="childDeviceCode">子设备编号</param>
        //public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
        //{
        //    Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
        //    if (task != null)
        //    {
        //        Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
        //        if (newTask != null)
        //        {
        //            ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask);
        //            taskCommand.InteractiveSignal = command.InteractiveSignal;
        //            conveyorLine.SendCommand(taskCommand, childDeviceCode);
        //        }
        //    }
        //}
        #endregion
        /// <summary>
        /// è¾“送线入库完成
@@ -230,15 +176,14 @@
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish)
            {
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
                //Console.Out.WriteLine(content.Serialize());
                Console.Out.WriteLine(content.Serialize());
            }
        }
@@ -251,7 +196,7 @@
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            if (task != null)
            {
                ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
@@ -262,28 +207,6 @@
                _taskService.UpdateTaskStatusToNext(task);
            }
        }
        /// <summary>
        /// è¾“送线请求出库下一地址
        /// </summary>
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="command">读取的请求信息</param>
        /// <param name="childDeviceCode">子设备编号</param>
        public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
        {
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null)
            {
                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
                if (newTask != null)
                {
                    ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask);
                    taskCommand.InteractiveSignal = command.InteractiveSignal;
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                }
            }
        }
        /// <summary>
        /// è¾“送线出库完成
        /// </summary>
@@ -292,7 +215,7 @@
        /// <param name="childDeviceCode">子设备编号</param>
        public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null)
            {
                WebResponseContent content = new WebResponseContent();
@@ -312,6 +235,22 @@
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                content = _taskService.UpdateTaskStatusToNext(task);
            }
        }
        /// <summary>
        /// è¾“送线交互完成
        /// </summary>
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="childDeviceCode">子设备编号</param>
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        /// <param name="value">值</param>
        public void ConveyorLineSendFinish(CommonConveyorLine conveyorLine, string childDeviceCode, int ProtocalDetailValue, bool value)
        {
            DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == childDeviceCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
            string[] x = devicePro.DeviceProAddress.Split('.');
            x[x.Length - 1] = (ProtocalDetailValue + 1).ToString();
            string DeviceProAddress = string.Join(".", x);
            conveyorLine.Communicator.Write(DeviceProAddress, value);
        }
        /// <summary>
@@ -348,14 +287,20 @@
                #region è°ƒç”¨WMS获取出库任务
                WMSTaskDTO taskDTO = new WMSTaskDTO();
                object dynamic = new
                // èŽ·å–WMSip地址
                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                var requestTrayOutTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTrayOutTask)?.ConfigValue;
                if (wmsBase == null || requestTrayOutTask == null)
                {
                    position = childDeviceCode,
                    tag = (int)taskType,
                    areaCdoe = roadWay,
                    roadways = roadways
                };
                var result = await HttpHelper.PostAsync("http://localhost:5000/api/Task/RequestTrayOutTaskAsync", dynamic.ToJsonString());
                    throw new InvalidOperationException("WMS IP æœªé…ç½®");
                }
                var wmsIpAddress = wmsBase + requestTrayOutTask;
                var result = await HttpHelper.PostAsync(wmsIpAddress, new { position = childDeviceCode, tag = (int)taskType, areaCdoe = roadWay, roadways = roadways }.ToJsonString());
                //var result = await HttpHelper.PostAsync("http://localhost:5000/api/Task/RequestTrayOutTaskAsync", dynamic.ToJsonString());
                WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
@@ -382,22 +327,6 @@
                Console.WriteLine($"{taskDTO.TaskType}呼叫成功");
            }
            return content;
        }
        /// <summary>
        /// è¾“送线交互完成
        /// </summary>
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="childDeviceCode">子设备编号</param>
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        /// <param name="value">值</param>
        public void ConveyorLineSendFinish(CommonConveyorLine conveyorLine, string childDeviceCode, int ProtocalDetailValue, bool value)
        {
            DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == childDeviceCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
            string[] x = devicePro.DeviceProAddress.Split('.');
            x[x.Length - 1] = (ProtocalDetailValue + 1).ToString();
            string DeviceProAddress = string.Join(".", x);
            conveyorLine.Communicator.Write(DeviceProAddress, value);
        }
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
@@ -12,8 +12,8 @@
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using HslCommunication;
using OfficeOpenXml.ConditionalFormatting;
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_Common;
namespace WIDESEAWCS_Tasks
{
@@ -24,29 +24,22 @@
        /// </summary>
        private void HandleTaskOut(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue, Dt_Task taskOut)
        {
            // å¦‚果没有任务,直接返回
            if (taskOut == null) return;
            // æ˜ å°„任务命令
            var taskCommand = MapTaskCommand(taskOut, command);
            // æ ¹æ®ä¸åŒçš„任务类型和状态执行不同的逻辑
            bool isOutTray = taskOut.TaskType == (int)TaskOutboundTypeEnum.OutTray;
            bool isOutboundAndOutFinish = taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.SC_OutFinish;
            bool isOutboundAndLineOutExecuting = taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting;
            if (isOutTray || isOutboundAndOutFinish || !isOutboundAndLineOutExecuting)
            {
                // å‘送命令到输送线
                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                // æ ‡è®°å‘送完成
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                _taskService.UpdateTaskStatusToNext(taskOut);
            }
            else if (taskOut.TaskType == (int)TaskOutboundTypeEnum.OutTray && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
            {
                // å®ŒæˆWMS任务
                CompleteWmsTask(taskOut, command, conveyorLine, childDeviceCode, ProtocalDetailValue);
            }
        }
@@ -56,20 +49,13 @@
        /// </summary>
        private void HandleNewTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            // ç‰¹å®šæ¡ä»¶ä¸‹åˆ›å»ºå¹¶å‘送空托盘入库任务
            if ((conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016") || (conveyorLine.DeviceCode == "1005" && childDeviceCode == "1048"))
            {
                // è¯·æ±‚WMS空托盘任务
                CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
            }
            else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1088") || (conveyorLine.DeviceCode == "1004" && childDeviceCode == "1339"))
            {
                // è¯·æ±‚WMS入库任务
                RequestWmsTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
            }
            else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1073") || (conveyorLine.DeviceCode == "1003" && childDeviceCode == "1002"))
            {
                //TODO å‘送直接去NG口任务
            }
        }
@@ -78,7 +64,6 @@
        /// </summary>
        private ConveyorLineTaskCommand MapTaskCommand(Dt_Task task, ConveyorLineTaskCommand command)
        {
            // ä½¿ç”¨mapper映射任务命令
            var comm = _mapper.Map<ConveyorLineTaskCommand>(task);
            comm.InteractiveSignal = command.InteractiveSignal;
            return comm;
@@ -89,25 +74,30 @@
        /// </summary>
        private void CompleteWmsTask(Dt_Task taskOut, ConveyorLineTaskCommand command, CommonConveyorLine conveyorLine, string childDeviceCode, int ProtocalDetailValue)
        {
            // å¦‚果没有条码信息,则设置目标地址为NG地址
            if (command.Barcode == "NoRead")
            {
                var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == taskOut.TargetAddress).Capacity;
                taskOut.TargetAddress = NGAddress.ToString();
            }
            // TODO调用WMS任务完成接口
            var keys = new Dictionary<string, object>()
                {
                    {"taskNum", taskOut.TaskNum}
                };
            var result = HttpHelper.GetAsync($"http://127.0.0.1:5000/api/Task/CompleteTaskAsync", keys).Result;
            {
                {"taskNum", taskOut.TaskNum}
            };
            var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
            var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
            if (wmsBase == null || completeTask == null)
            {
                throw new InvalidOperationException("WMS IP æœªé…ç½®");
            }
            var wmsIpAddress = wmsBase + completeTask;
            var result = HttpHelper.GetAsync(wmsIpAddress, keys).Result;
            WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
            if (content.Status)
            {
                // æ ‡è®°å‘送完成
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                _taskService.UpdateTaskStatusToNext(taskOut);
            }
        }
@@ -119,23 +109,23 @@
        {
            if (command.Barcode != "NoRead")
            {
                // åˆ›å»ºç©ºæ‰˜ç›˜ä»»åŠ¡DTO
                WMSTaskDTO taskDTO = CreateEmptyTrayTaskDto(command.Barcode, childDeviceCode);
                // åˆ›å»ºå¹¶å‘送任务
                WebResponseContent content = CreateAndSendTask(taskDTO);
                var taskDTO = CreateEmptyTrayTaskDto(command.Barcode, childDeviceCode);
                if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null)
                {
                    WriteInfo(conveyorLine.DeviceName, "当前托盘存在任务");
                    return;
                }
                var content = CreateAndSendTask(taskDTO);
                if (content.Status)
                {
                    // æŸ¥è¯¢ä»»åŠ¡
                    Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                    if (task != null)
                    {
                        // æ˜ å°„任务命令
                        ConveyorLineTaskCommand taskCommand = MapTaskCommand(task, command);
                        // å‘送命令到输送线
                        var taskCommand = MapTaskCommand(task, command);
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        // æ ‡è®°å‘送完成
                        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                        // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                        _taskService.UpdateTaskStatusToNext(task);
                    }
                }
@@ -147,49 +137,51 @@
        /// </summary>
        private WMSTaskDTO CreateEmptyTrayTaskDto(string barcode, string childDeviceCode)
        {
            #region å‘WMS请求空托盘任务
            WMSTaskDTO wMSTaskDTO = new WMSTaskDTO();
            RequestTaskDto request = new RequestTaskDto()
            var request = new RequestTaskDto()
            {
                Position = childDeviceCode,
                PalletCode = barcode,
            };
            var result = HttpHelper.PostAsync("http://127.0.0.1:5000/api/Task/RequestTrayInTaskAsync", request.ToJsonString()).Result;
            var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
            var requestTrayInTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTrayInTask)?.ConfigValue;
            if (wmsBase == null || requestTrayInTask == null)
            {
                throw new InvalidOperationException("WMS IP æœªé…ç½®");
            }
            var wmsIpAddrss = wmsBase + requestTrayInTask;
            var result = HttpHelper.PostAsync(wmsIpAddrss, request.ToJsonString()).Result;
            if (result == null)
                return wMSTaskDTO;
                return new WMSTaskDTO();
            WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
            // æ£€æŸ¥çŠ¶æ€å¹¶è¿”å›ž
            if (!content.Status)
                return wMSTaskDTO;
                return new WMSTaskDTO();
            return JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
            #endregion å‘WMS请求空托盘任务
        }
        /// <summary>
        /// è¯·æ±‚WMS任务
        /// </summary>
        private void RequestWmsTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        private async void RequestWmsTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            // è¯·æ±‚WMS任务
            if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status)
            var content = await _taskService.RequestWMSTask(command.Barcode, childDeviceCode);
            if (content.Status)
            {
                // æŸ¥è¯¢ä»»åŠ¡
                Dt_Task task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
                var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
                if (task != null)
                {
                    // æ˜ å°„任务命令
                    ConveyorLineTaskCommand taskCommand = MapTaskCommand(task, command);
                    // å‘送命令到输送线
                    var taskCommand = MapTaskCommand(task, command);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    // æ ‡è®°å‘送完成
                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                    // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                    _taskService.UpdateTaskStatusToNext(task);
                }
            }
            else
                WriteInfo(conveyorLine.DeviceName, content.Message);
        }
    }
}
}