yanjinhui
15 小时以前 39531cf0ea52494fe56b8734afa552db32b7a164
Merge branch 'master' of http://115.159.85.185:8098/r/RuiShengZhiNeng/GaoPuLiTiKu
已添加4个文件
已修改6个文件
340 ■■■■■ 文件已修改
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ApiInfoService.cs 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/InterfaceLogService.cs 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoService/IApiInfoService.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoService/IInterfaceLogService.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_ApiInfo.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_InterfaceLog.cs 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/InterfaceLogController.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ApiInfoService.cs
@@ -3,8 +3,12 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.RGV.FOURBOT;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_Model.Models;
@@ -12,10 +16,78 @@
{
    public class ApiInfoService : ServiceBase<Dt_ApiInfo, IRepository<Dt_ApiInfo>>, IApiInfoService
    {
        public ApiInfoService(IRepository<Dt_ApiInfo> BaseDal) : base(BaseDal)
        private readonly IInterfaceLogService _interfaceLogService;
        public ApiInfoService(IRepository<Dt_ApiInfo> BaseDal, IInterfaceLogService interfaceLogService) : base(BaseDal)
        {
            _interfaceLogService = interfaceLogService;
        }
        public IRepository<Dt_ApiInfo> Repository => BaseDal;
        /// <summary>
        /// Post接口请求
        /// </summary>
        /// <param name="apiCode">接口编号</param>
        /// <param name="requestParameters">请求内容</param>
        /// <param name="remark">备注</param>
        /// <param name="isAdd">是否添加日志</param>
        /// <returns></returns>
        public WebResponseContent PostInterfaceRequest(string apiCode, string requestParameters, string remark, bool isAdd = true)
        {
            WebResponseContent content = new WebResponseContent();
            string response = string.Empty;
            Dt_ApiInfo? apiInfo = null;
            try
            {
                apiInfo = BaseDal.QueryFirst(x => x.ApiCode == apiCode) ?? throw new Exception($"未找到{remark}接口配置信息!请检查接口配置");
                response = HttpHelper.Post(apiInfo.ApiAddress, requestParameters);
                if (apiInfo.Remark.Contains("四向车"))
                {
                    FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                    if (fOURBOTReturn == null) throw new Exception($"{apiInfo.Remark}响应内容转换实体失败!");
                    if (fOURBOTReturn.returnCode != 0) throw new Exception(fOURBOTReturn.returnUserMsg);
                    content.Data = fOURBOTReturn;
                }
                else if (apiInfo.Remark.Contains("凯乐士"))
                {
                }
                else if (apiInfo.Remark.Contains("海康"))
                {
                }
                else if (apiInfo.Remark.Contains("WMS"))
                {
                }
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            finally
            {
                if (isAdd && !string.IsNullOrEmpty(response) && apiInfo != null)
                {
                    Dt_InterfaceLog interfaceLog = new Dt_InterfaceLog()
                    {
                        ApiCode = apiCode,
                        RequestParameters = requestParameters,
                        ApiAddress = apiInfo.ApiAddress,
                        ApiName = apiInfo.ApiName,
                        PushFrequency = 1,
                        PushState = content.Status ? 1 : 2,
                        Requestor = "WCS",
                        Recipient = apiInfo.Remark,
                        ResponseParameters = response,
                        Creater = "System",
                        Remark = content.Status ? remark : content.Message,
                    };
                    _interfaceLogService.Repository.AddData(interfaceLog);
                }
            }
            return content;
        }
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/InterfaceLogService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,52 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_BasicInfoService
{
    public class InterfaceLogService : ServiceBase<Dt_InterfaceLog, IRepository<Dt_InterfaceLog>>, IInterfaceLogService
    {
        public InterfaceLogService(IRepository<Dt_InterfaceLog> BaseDal) : base(BaseDal)
        {
        }
        public IRepository<Dt_InterfaceLog> Repository => BaseDal;
        /// <summary>
        /// æ·»åŠ æ—¥å¿—
        /// </summary>
        /// <param name="ApiCode">接口编号</param>
        /// <param name="ApiName">接口名称</param>
        /// <param name="ApiAddress">接口地址</param>
        /// <param name="Requestor">请求方</param>
        /// <param name="RequestParameters">请求内容</param>
        /// <param name="Recipient">接收方</param>
        /// <param name="ResponseParameters">响应内容</param>
        /// <param name="Add">是否添加</param>
        /// <returns></returns>
        public WebResponseContent AddInterfaceLog(string ApiCode, string ApiName, string ApiAddress, string Requestor, string RequestParameters, string Recipient, string ResponseParameters, bool Add)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs
@@ -60,7 +60,7 @@
                    if (rGVLocationInfo == null) break;
                    Dt_Task dt_Task = new()
                    {
                        Grade = 1,
                        Grade = 66,
                        PalletCode = locationInfo.PalletCode,
                        Roadway = locationInfo.RoadwayNo,
                        TaskState = TaskStatusEnum.RGV_NewMoveTask.ObjToInt(),
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoService/IApiInfoService.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Model.Models;
@@ -12,5 +13,15 @@
    public interface IApiInfoService : IService<Dt_ApiInfo>
    {
        public IRepository<Dt_ApiInfo> Repository { get; }
        /// <summary>
        /// Post接口请求
        /// </summary>
        /// <param name="apiCode">接口编号</param>
        /// <param name="requestParameters">请求内容</param>
        /// <param name="remark">备注</param>
        /// <param name="isAdd">是否添加日志</param>
        /// <returns></returns>
        public WebResponseContent PostInterfaceRequest(string apiCode, string requestParameters, string remark, bool isAdd = true);
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_IBasicInfoService/IInterfaceLogService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_IBasicInfoService
{
    public interface IInterfaceLogService : IService<Dt_InterfaceLog>
    {
        public IRepository<Dt_InterfaceLog> Repository { get; }
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_ApiInfo.cs
@@ -36,6 +36,12 @@
        public string ApiAddress { get; set; }
        /// <summary>
        /// æŽ¨é€æ¬¡æ•°
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "货位行")]
        public int PushFrequency { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "备注")]
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_InterfaceLog.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,83 @@
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_InterfaceLog), "接口日志")]
    public class Dt_InterfaceLog : BaseEntity
    {
        /// <summary>
        /// ä¸»é”®
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
        public int Id { get; set; }
        /// <summary>
        /// æŽ¥å£ç¼–号
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "接口编号")]
        public string ApiCode { get; set; }
        /// <summary>
        /// æŽ¥å£åç§°
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "接口名称")]
        public string ApiName { get; set; }
        /// <summary>
        /// æŽ¥å£åœ°å€
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "接口地址")]
        public string ApiAddress { get; set; }
        /// <summary>
        /// æŽ¨é€æ¬¡æ•°
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "推送次数")]
        public int PushFrequency { get; set; } = 0;
        /// <summary>
        /// æŽ¨é€çŠ¶æ€
        /// 0未推送
        /// 1推送成功
        /// 2推送失败
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "推送状态")]
        public int PushState { get; set; } = 0;
        /// <summary>
        /// è¯·æ±‚æ–¹
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "请求方")]
        public string Requestor { get; set; }
        /// <summary>
        /// è¯·æ±‚内容
        /// </summary>
        [SugarColumn(IsNullable = true, Length = int.MaxValue, ColumnDescription = "请求内容")]
        public string RequestParameters { get; set; }
        /// <summary>
        /// æŽ¥æ”¶æ–¹
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "接收方")]
        public string Recipient { get; set; }
        /// <summary>
        /// å“åº”内容
        /// </summary>
        [SugarColumn(IsNullable = true, Length = int.MaxValue, ColumnDescription = "响应内容")]
        public string ResponseParameters { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 100, ColumnDescription = "备注")]
        public string Remark { get; set; }
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/InterfaceLogController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc;
using WIDESEAWCS_Core.BaseController;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_Server.Controllers.BasicInfo
{
    /// <summary>
    ///接口信息
    /// </summary>
    [Route("api/InterfaceLog")]
    [ApiController]
    public class InterfaceLogController : ApiBaseController<IInterfaceLogService, Dt_InterfaceLog>
    {
        public InterfaceLogController(IInterfaceLogService service) : base(service)
        {
        }
    }
}
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs
@@ -397,16 +397,24 @@
                            {
                                task.ExceptionMessage = Rgv.content.errorReason;
                                var Error = _taskErrorMessageService.Repository.QueryFirst(x => x.ErrorCode == Rgv.content.errorCode && x.DeviceType == (int)deviceTypeEnum);
                                if (Error != null)
                                if (task.TaskType == (int)TaskTypeEnum.CPOutbound && task.TaskState == (int)TaskStatusEnum.Execut && Rgv.content.errorCode == 1330003)//成品出库任务下发后反馈有阻碍托,修改任务状态为新建重新查询阻碍托关系
                                {
                                    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());
                                    task.TaskState = (int)TaskStatusEnum.New;
                                    BaseDal.UpdateData(task);
                                }
                                else
                                    ErrorTaskFeedback(task, true);
                                {
                                    if (Error != null)
                                    {
                                        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);
                                }
                            }
                        }
                    }
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs
@@ -161,15 +161,11 @@
        /// <param name="tasks"></param>
        public void IsMoveTask(List<Dt_Task> tasks)
        {
            object requestData = null;  // æ·»åŠ å˜é‡è®°å½•è¯·æ±‚æ•°æ®
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(GetBlockPodContentDto)) ?? throw new Exception("未找到批量获取阻碍托盘关系接口配置信息!请检查接口配置");
                List<Dt_Task> dt_Tasks = new List<Dt_Task>();
                var PalletCodes = tasks.Select(x => x.PalletCode).ToList();
                //GetBlockPodContentDto content = new GetBlockPodContentDto();
                var request = new GetBlockPodContentListDto
                {
                    content = new List<GetBlockPodContentDto>
@@ -181,21 +177,49 @@
                        }
                    }
                };
                requestData = request;  // ä¿å­˜è¯·æ±‚数据用于日志
                //content.candidatePodIDs = tasks.Select(x => x.PalletCode).ToList();
                //string response = HttpHelper.Post("http://127.0.0.1:4523/m2/6165241-5857331-default/440906899?apifoxApiId=440906899", request.Serialize());
                string response = HttpHelper.Post(apiInfo.ApiAddress, request.Serialize());
                FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                content.OK(data: fOURBOTReturn);
                content = _apiInfoService.PostInterfaceRequest(nameof(GetBlockPodContentDto), request.Serialize(), "批量获取阻碍托盘关系");
                if (!content.Status)
                {
                    foreach (var item in tasks)
                    {
                        item.ExceptionMessage = content.Message;
                    }
                    _taskService.UpdateData(tasks);
                    return;
                }
                FOURBOTReturn fOURBOTReturn = content.Data as FOURBOTReturn;
                if (fOURBOTReturn.returnCode == 0)
                {
                    //ReturnBlockPodResultDto getBlockPod = fOURBOTReturn.data as ReturnBlockPodResultDto ?? throw new Exception("未获取到阻碍托盘关系数据");
                    var dataJson = fOURBOTReturn.data.ToString();
                    if (string.IsNullOrEmpty(dataJson))
                    {
                        foreach (var item in tasks)
                        {
                            item.ExceptionMessage = "获取阻碍托盘关系失败!";
                        }
                        _taskService.UpdateData(tasks);
                        return;
                    }
                    ReturnBlockPodResultDto? getBlockPod = JsonConvert.DeserializeObject<ReturnBlockPodResultDto>(dataJson);
                    if (getBlockPod == null)
                    {
                        foreach (var item in tasks)
                        {
                            item.ExceptionMessage = "阻碍托盘关系数据转换实体失败!";
                        }
                        _taskService.UpdateData(tasks);
                        return;
                    }
                    if (getBlockPod.Result.Count == 0)
                    {
                        throw new Exception("未获取到阻碍托盘关系数据");
                        foreach (var item in tasks)
                        {
                            item.ExceptionMessage = "未获取到阻碍托盘关系数据!";
                        }
                        _taskService.UpdateData(tasks);
                        return;
                    }
                    foreach (var Result in getBlockPod.Result)
                    {
@@ -234,7 +258,7 @@
            }
            finally
            {
                _trackloginfoService.AddTrackLog(requestData, content, "处理出库任务是否需要移库", "", "");
                //_trackloginfoService.AddTrackLog(requestData, content, "处理出库任务是否需要移库", "", "");
            }
        }
        #endregion