xiazhengtongxue
2025-12-24 f5e302847933cb5c09bca3bc5731556ae52d3a4a
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -20,12 +20,14 @@
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using RYB_PTL_API;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.DirectoryServices.Protocols;
using System.Linq;
using System.Net.Http.Headers;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_DTO.Agv;
using WIDESEA_External.Model;
@@ -295,6 +297,96 @@
            return content;
        }
        /// <summary>
        /// ä¸€æœŸæ’­ç§å¢™ä¸‹å‘
        /// </summary>
        /// <returns></returns>
        public EPLightContent Phase1PickOrderInfoRequest(List<EPLightSendDTO> lightSendDTOs)
        {
            EPLightContent content = new EPLightContent();
            try
            {
                string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.Phase1PickOrderInfoRequest.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(url))
                {
                    return content.Error("未找到播种墙下发接口,请检查接口配置");
                }
                bool allSuccess = true;
                StringBuilder errorMessages = new StringBuilder();
                foreach (EPLightSendDTO lightSendDTO in lightSendDTOs)
                {
                    try
                    {
                        bool operationResult;
                        // å¤„理灯光类型转换
                        if (!int.TryParse(lightSendDTO.LIGHTTYPE, out int lightType))
                        {
                            allSuccess = false;
                            errorMessages.AppendLine($"位置 {lightSendDTO.LOCATION} é”™è¯¯: æ— æ•ˆçš„灯光类型 '{lightSendDTO.LIGHTTYPE}'");
                            continue;
                        }
                        // å¤„理关闭灯光请求
                        if (lightType == 2)
                        {
                            operationResult = RYB_PTL.RYB_PTL_CloseDigit5(url, lightSendDTO.LOCATION);
                            // TODO: å…³é—­ç¯å…‰å›žè°ƒå¤„理
                            List<EPLightBackDTO> lightBackDTOs = new List<EPLightBackDTO>();
                            List<TaskBackLight> taskBackLights = lightBackDTOs.Select(x => new TaskBackLight()
                            {
                                TagNo = "B1",
                                TagCode = x.LOCATION,
                            }).ToList();
                            content = WMSLightBack(taskBackLights);
                        }
                        // å¤„理显示灯光请求
                        else
                        {
                            // å¤„理灯光颜色转换
                            if (!int.TryParse(lightSendDTO.LIGHTCOLOR, out int lightColor))
                            {
                                allSuccess = false;
                                errorMessages.AppendLine($"位置 {lightSendDTO.LOCATION} é”™è¯¯: æ— æ•ˆçš„灯光颜色 '{lightSendDTO.LIGHTCOLOR}'");
                                continue;
                            }
                            operationResult = RYB_PTL.RYB_PTL_DspDigit5(
                                url,
                                lightSendDTO.LOCATION,
                                lightSendDTO.QUANTITY,
                                lightType,
                                lightColor);
                        }
                        if (!operationResult)
                        {
                            allSuccess = false;
                            errorMessages.AppendLine($"位置 {lightSendDTO.LOCATION} æ“ä½œå¤±è´¥");
                        }
                    }
                    catch (Exception ex)
                    {
                        allSuccess = false;
                        errorMessages.AppendLine($"位置 {lightSendDTO.LOCATION} å¤„理异常: {ex.Message}");
                    }
                }
                return allSuccess
                    ? content.OK("所有播种墙下发操作成功")
                    : content.Error(errorMessages.ToString());
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// æ’­ç§å¢™äº®ç¯
        /// </summary>
        /// <returns></returns>
@@ -303,7 +395,32 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                if (taskSendLight.TagNo=="B2")
                if (taskSendLight.TagNo == "B1")
                {
                    List<EPLightSendDTO> lightSendDTOs = new List<EPLightSendDTO>()
                    {
                        new EPLightSendDTO
                        {
                            DOCNO = taskSendLight.DocNo,
                            TASKNO= taskSendLight.TaskNo,
                            LOCATION=taskSendLight.TagCode,
                            QUANTITY=taskSendLight.TagQunity,
                            LIGHTCOLOR=taskSendLight.Color switch
                            {
                                "Blue" => "1",
                                "Green" => "2",
                                "Red" => "4",
                                _ => throw new Exception($"未找到颜色定义")
                            },
                            ORDERTYPE="1",
                            LIGHTTYPE=taskSendLight.Mode.ToString(),
                        }
                    };
                    EPLightContent pLightContent = Phase1PickOrderInfoRequest(lightSendDTOs);
                    if (pLightContent.Result != "0") throw new Exception($"{pLightContent.Msg}");
                    content.OK();
                }
                else if (taskSendLight.TagNo == "B2")
                {
                    List<EPLightSendDTO> lightSendDTOs = new List<EPLightSendDTO>()
                    {
@@ -332,7 +449,7 @@
                {
                    content.OK();
                }
            }
            catch (Exception ex)
            {