dengjunjie
6 天以前 7680bc7561730f1f37ae655646c0bc785a1fe2f3
添加任务异常信息表,设备反馈异常代码处理
已添加4个文件
已修改3个文件
186 ■■■■ 文件已修改
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskErrorMessageService.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/TaskInfo/Dt_TaskErrorMessage.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/Task/TaskErrorMessageController.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskErrorMessageService.cs 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskErrorMessageService.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_Core.BaseServices;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_ITaskInfoService
{
    public interface ITaskErrorMessageService : IService<Dt_TaskErrorMessage>
    {
        /// <summary>
        /// ä»“储层(数据库访问)
        /// </summary>
        IRepository<Dt_TaskErrorMessage> Repository { get; }
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs
@@ -75,14 +75,14 @@
        /// </summary>
        /// <param name="wMSCancelTask">取消任务实体类</param>
        /// <returns></returns>
         WebResponseContent CancelWMSTask(WMSCancelTask wMSCancelTask);
        WebResponseContent CancelWMSTask(WMSCancelTask wMSCancelTask);
        /// <summary>
        /// ä¿®æ”¹ä»»åŠ¡ä¼˜å…ˆçº§
        /// </summary>
        /// <param name="updateTaskPriority"></param>
        /// <returns></returns>
         WebResponseContent UpdateWMSTaskPriority(WMSUpdateTaskPriority updateTaskPriority);
        WebResponseContent UpdateWMSTaskPriority(WMSUpdateTaskPriority updateTaskPriority);
        /// <summary>
        /// æ ¹æ®æ‰˜ç›˜å·ã€èµ·å§‹åœ°å€å‘WMS请求任务
@@ -210,7 +210,7 @@
        /// <param name="taskNum">任务号</param>
        /// <returns>返回处理结果</returns>
        WebResponseContent TaskStatusRecovery(int taskNum);
        WebResponseContent ErrorTaskFeedback(Dt_Task dt_Task, bool Del);
        WebResponseContent ErrorTaskFeedback(Dt_Task dt_Task, bool Del = false, string ErrorCode = "");
        /// <summary>
        /// å›žæ»šä»»åŠ¡çŠ¶æ€
        /// </summary>
@@ -233,7 +233,7 @@
        /// <param name="deviceTypeEnum"></param>
        /// <param name="locationStatusEnum"></param>
        /// <returns></returns>
        WebResponseContent UpdateLocationStatus(string locationCode,string palletCode, DeviceTypeEnum deviceTypeEnum, LocationStatusEnum locationStatusEnum);
        WebResponseContent UpdateLocationStatus(string locationCode, string palletCode, DeviceTypeEnum deviceTypeEnum, LocationStatusEnum locationStatusEnum);
        WebResponseContent ModifyWMSLayoutZone(WMSUpdateLocationArea wMSUpdateLocationArea);
@@ -268,7 +268,7 @@
        /// <param name="taskCode">任务号</param>
        /// <param name="containerCode">容器编码</param>
        /// <returns></returns>
        public WebResponseContent MaterialBoxInspection(string taskCode ,string containerCode);
        public WebResponseContent MaterialBoxInspection(string taskCode, string containerCode);
        /// <summary>
        /// 4F提升机出口托盘号上报WMS
@@ -311,7 +311,7 @@
        /// </summary>
        /// <param name="TaskCode">任务号</param>
        /// <returns></returns>
        WebResponseContent Hikvisiontaskscontinue(string TaskCode, string Address=null);
        WebResponseContent Hikvisiontaskscontinue(string TaskCode, string Address = null);
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/TaskInfo/Dt_TaskErrorMessage.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,55 @@
using Magicodes.ExporterAndImporter.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.DB.Models;
namespace WIDESEAWCS_Model.Models
{
    [SugarTable(nameof(Dt_TaskErrorMessage), "任务异常信息")]
    public class Dt_TaskErrorMessage : BaseEntity
    {
        /// <summary>
        /// ä¸»é”®
        /// </summary>
        [ImporterHeader(Name = "主键")]
        [ExporterHeader(DisplayName = "主键")]
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
        public int TaskId { get; set; }
        /// <summary>
        /// é”™è¯¯ä»£ç 
        /// </summary>
        [ImporterHeader(Name = "错误代码")]
        [ExporterHeader(DisplayName = "错误代码")]
        [SugarColumn(IsNullable = false, ColumnDescription = "错误代码")]
        public int ErrorCode { get; set; }
        /// <summary>
        /// å¼‚常信息英文
        /// </summary>
        [ImporterHeader(Name = "异常信息英文")]
        [ExporterHeader(DisplayName = "异常信息英文")]
        [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "异常信息英文")]
        public string ErrorMessage { get; set; }
        /// <summary>
        /// å¼‚常信息
        /// </summary>
        [ImporterHeader(Name = "异常信息")]
        [ExporterHeader(DisplayName = "异常信息")]
        [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "异常信息")]
        public string ExceptionMessage { get; set; }
        /// <summary>
        /// è®¾å¤‡ç±»åž‹ï¼Œ0凯乐士,1海康,2四向车
        /// </summary>
        [ImporterHeader(Name = "设备类型")]
        [ExporterHeader(DisplayName = "设备类型")]
        [SugarColumn(IsNullable = false, ColumnDescription = "设备类型")]
        public int DeviceType { get; set; }
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/Task/TaskErrorMessageController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_WCSServer.Controllers.Task
{
    [Route("api/TaskErrorMessage")]
    [ApiController]
    public class TaskErrorMessageController : ApiBaseController<ITaskErrorMessageService, Dt_TaskErrorMessage>
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        public TaskErrorMessageController(ITaskErrorMessageService service, IHttpContextAccessor httpContextAccessor) : base(service)
        {
            _httpContextAccessor = httpContextAccessor;
        }
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskErrorMessageService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_TaskInfoService
{
    public class TaskErrorMessageService : ServiceBase<Dt_TaskErrorMessage, IRepository<Dt_TaskErrorMessage>>, ITaskErrorMessageService
    {
        public TaskErrorMessageService(IRepository<Dt_TaskErrorMessage> BaseDal) : base(BaseDal)
        {
        }
        public IRepository<Dt_TaskErrorMessage> Repository => BaseDal;
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs
@@ -8,6 +8,7 @@
using System.Reflection.Metadata;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.LocationEnum;
@@ -393,12 +394,18 @@
                            }
                            if (Rgv.content.status == 5)
                            {
                                if (task.TaskState == (int)TaskStatusEnum.Execut)
                                task.ExceptionMessage = Rgv.content.errorReason;
                                var Error = _taskErrorMessageService.Repository.QueryFirst(x => x.ErrorCode == Rgv.content.errorCode && x.DeviceType == (int)deviceTypeEnum);
                                if (Error != null)
                                {
                                    task.TaskState = (int)TaskStatusEnum.New;
                                    task.Remark = "四向车反馈失败,重新下发";
                                    BaseDal.UpdateData(task);
                                    task.ExceptionMessage = Error.ExceptionMessage;
                                    MatchCollection matches = Regex.Matches(Rgv.content.errorReason, @"\(([^)]+)\)");
                                    if (matches.Count > 0)
                                        task.ExceptionMessage = ReplacePlaceholders(Rgv.content.errorReason, Error.ExceptionMessage);
                                    ErrorTaskFeedback(task, true, Error.ErrorCode.ToString());
                                }
                                else
                                    ErrorTaskFeedback(task, true);
                            }
                        }
                    }
@@ -414,6 +421,30 @@
                _trackloginfoService.AddTrackLog(TaskDTO, content, $"{deviceName}任务状态反馈", "", "");
            }
            return content;
        }
        #endregion
        #region å¼‚常信息转换
        /// <summary>
        /// å¼‚常信息()内容转换
        /// </summary>
        /// <param name="source"></param>
        /// <param name="targetTemplate"></param>
        /// <returns></returns>
        public string ReplacePlaceholders(string source, string targetTemplate)
        {
            // æå–源字符串中的所有括号值
            var values = Regex.Matches(source, @"\(([^)]+)\)")
                              .Cast<Match>()
                              .Select(m => m.Groups[1].Value)
                              .ToList();
            // æ›¿æ¢ç›®æ ‡æ¨¡æ¿ä¸­çš„æ‰€æœ‰ (%v)
            int idx = 0;
            string result = Regex.Replace(targetTemplate, @"\(\%v\)", _ =>
                idx < values.Count ? values[idx++] : "");
            return result;
        }
        #endregion
@@ -692,7 +723,7 @@
        }
        #endregion
        #region å¤±è´¥ä»»åŠ¡ä¸ŠæŠ¥WMS并删除任务
        public WebResponseContent ErrorTaskFeedback(Dt_Task dt_Task, bool Del)
        public WebResponseContent ErrorTaskFeedback(Dt_Task dt_Task, bool Del = false, string ErrorCode = "")
        {
            WebResponseContent content = new WebResponseContent();
            WMSInOutBoundCompleteFeedback boundCompleteFeedback = new WMSInOutBoundCompleteFeedback();
@@ -708,7 +739,7 @@
                    boundCompleteFeedback.fromStationCode = dt_Task.SourceAddress;
                    boundCompleteFeedback.toLocationCode = dt_Task.TargetAddress;
                    boundCompleteFeedback.status = 3;
                    boundCompleteFeedback.custStatus = "";
                    boundCompleteFeedback.custStatus = ErrorCode;
                    boundCompleteFeedback.memo = dt_Task.ExceptionMessage;
                    string response = HttpHelper.Post(apiInfo.ApiAddress, boundCompleteFeedback.Serialize());
                    agvContent = response.DeserializeObject<WMSReturn>();
@@ -729,15 +760,12 @@
            finally
            {
                _trackloginfoService.AddTrackLog(boundCompleteFeedback, content, "出入库任务状态反馈WMS", "", "");
                if (agvContent != null && agvContent.code == 200 && Del) BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动删除);
                if (agvContent != null && agvContent.code == 200 && Del)
                    BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动删除);
                else BaseDal.UpdateData(dt_Task);
            }
            return content;
        }
        #endregion
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -57,6 +57,7 @@
        private readonly IApiInfoService _apiInfoService;
        private readonly IStationMangerService _stationMangerService;
        private readonly IStationInfoService _stationInfo;
        private readonly ITaskErrorMessageService _taskErrorMessageService;
        private readonly IMapper _mapper;
        private Dictionary<string, OrderByType> _taskOrderBy = new()
@@ -76,7 +77,7 @@
        /// </summary>
        public IRepository<Dt_Task> Repository => BaseDal;
        public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService, ITrackloginfoService trackloginfoService, IStationMangerService stationMangerService, IStationInfoService stationInfo) : base(BaseDal)
        public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService, ITrackloginfoService trackloginfoService, IStationMangerService stationMangerService, IStationInfoService stationInfo, ITaskErrorMessageService taskErrorMessageService) : base(BaseDal)
        {
            _routerService = routerService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -89,6 +90,7 @@
            _trackloginfoService = trackloginfoService;
            _stationMangerService = stationMangerService;
            _stationInfo = stationInfo;
            _taskErrorMessageService = taskErrorMessageService;
        }
        public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTasksDTO> taskDTOs)
        {