From 6d3ea08855337c0cfcc60df2903d3431611c7097 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期六, 13 十二月 2025 17:36:56 +0800
Subject: [PATCH] 优化程序,输送线入库按钮对接

---
 项目代码/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs |  317 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 243 insertions(+), 74 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
index d7eea4a..c3526ee 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -21,10 +21,13 @@
 using SqlSugar;
 using System.Diagnostics.CodeAnalysis;
 using System.DirectoryServices.Protocols;
+using System.Linq;
 using System.Net.Http.Headers;
 using System.Security.Policy;
+using System.Threading.Tasks;
 using WIDESEA_DTO.Agv;
 using WIDESEA_External.Model;
+using WIDESEAWCS_BasicInfoService;
 using WIDESEAWCS_Common;
 using WIDESEAWCS_Common.APIEnum;
 using WIDESEAWCS_Common.TaskEnum;
@@ -62,6 +65,7 @@
         private readonly IApiInfoRepository _apiInfoRepository;
         private readonly ILocationInfoRepository _locationInfoRepository;
         private readonly ILocationInfoService _locationInfoService;
+        private readonly ILocationStatusChangeRecordService _locationStatusChangeRecordService;
 
         private Dictionary<string, OrderByType> _taskOrderBy = new()
             {
@@ -79,7 +83,7 @@
 
         public List<int> TaskRelocationTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 900 && x < 1000).ToList();
 
-        public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository,ILocationInfoRepository locationInfoRepository,IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService) : base(BaseDal)
+        public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository,ILocationInfoRepository locationInfoRepository,IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService,ILocationStatusChangeRecordService locationStatusChangeRecordService) : base(BaseDal)
         {
             _mapper = mapper;
             _cacheService = cacheService;
@@ -92,6 +96,7 @@
             _locationInfoRepository = locationInfoRepository;
             _unitOfWorkManage = unitOfWorkManage;
             _locationInfoService = locationInfoService;
+            _locationStatusChangeRecordService=locationStatusChangeRecordService;
         }
         static object lock_taskReceive = new object();
         /// <summary>
@@ -102,27 +107,38 @@
         public WebResponseContent ReceiveWMSTask([NotNull] WMSTaskDTO taskDTO)
         {
             WebResponseContent content = new WebResponseContent();
+            string errorMsg = "";
             try
             {
                 lock (lock_taskReceive)
                 {
                     List<Dt_Task> tasks = new List<Dt_Task>();
-                    List<Dt_LocationInfo> locationInfos = _locationInfoRepository.GetCanOut(taskDTO.Tasks.Select(x=>x.ContainerCode).ToList());
-                    TasksItem? tasksItem = taskDTO.Tasks.FirstOrDefault(x => !locationInfos.Select(t => t.PalletCode).Contains(x.ContainerCode));
-                    if (tasksItem != null) throw new Exception($"浠诲姟{tasksItem.TaskCode}鏂欑鍙穥tasksItem.ContainerCode}涓嶅瓨鍦�");
+                    Dt_Task taskOld = BaseDal.QueryFirst(x=> taskDTO.Tasks.Select(x => x.TaskDescribe.ContainerCode).Contains(x.PalletCode));
+                    if (taskOld != null) throw new Exception($"鏂欑{taskOld.PalletCode}"+(taskOld.TaskType == TaskTypeEnum.Inbound.ObjToInt() ? "鍏ュ簱浠诲姟宸插瓨鍦�" : "鍑哄簱浠诲姟宸插瓨鍦�"));
+                    List<Dt_LocationInfo> locationInfos = _locationInfoRepository.GetCanOut(taskDTO.Tasks.Select(x=>x.TaskDescribe.ContainerCode).ToList());
+                    
                     Dt_LocationInfo? noOutLocation = locationInfos.FirstOrDefault(x=>x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() || x.EnableStatus != EnableStatusEnum.Normal.ObjToInt());
+
                     if (noOutLocation != null) throw new Exception($"鏂欑{noOutLocation.PalletCode}璐т綅{noOutLocation.LocationCode}鐘舵�佷笉鍙嚭搴�");
                     List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData();
                     //涓嬪彂浠诲姟缁�
                     string taskGroup= taskDTO.TaskGroupCode.IsNullOrEmpty() ? Guid.NewGuid().ToString().Replace("-","") : taskDTO.TaskGroupCode;
-                    foreach (var item in taskDTO.Tasks.OrderBy(x=>x.ToStationCode))
+                    foreach (var item in taskDTO.Tasks.OrderBy(x=>x.TaskDescribe.ToStationCode))
                     {
-                        if (item.ToStationCode.IsNullOrEmpty()) throw new Exception($"浠诲姟{item.TaskCode}鍑哄簱鐩爣鎿嶄綔鍙颁笉鑳戒负绌�");
+                        if (item.TaskDescribe.ToStationCode.IsNullOrEmpty()) throw new Exception($"浠诲姟{item.TaskCode}鍑哄簱鐩爣鎿嶄綔鍙颁笉鑳戒负绌�");
                         //鑾峰彇鎿嶄綔鍙�
-                        Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.PickStationCode == item.ToStationCode);
-                        if (stationManger == null) throw new Exception($"浠诲姟{item.TaskCode}鍑哄簱鐩爣鎿嶄綔鍙皗item.ToStationCode}涓嶅瓨鍦�");
+                        Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.PickStationCode == item.TaskDescribe.ToStationCode);
+                        if (stationManger == null) throw new Exception($"浠诲姟{item.TaskCode}鍑哄簱鐩爣鎿嶄綔鍙皗item.TaskDescribe.ToStationCode}涓嶅瓨鍦�");
+
+                        Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.PalletCode == item.TaskDescribe.ContainerCode);
+                        if (locationInfo == null)
+                        {
+                            errorMsg += $"鏂欑{item.TaskDescribe.ContainerCode}涓嶅瓨鍦�;";
+                            continue;
+                        };
+
                         Dt_Task task = _mapper.Map<Dt_Task>(item);
-                        Dt_LocationInfo locationInfo = locationInfos.FirstOrDefault(x=>x.PalletCode==item.ContainerCode);
+                        
                         task.SourceAddress = locationInfo.LocationCode;
                         task.CurrentAddress = locationInfo.LocationCode;
                         task.NextAddress = stationManger.PickStationCode;
@@ -144,10 +160,9 @@
                     BaseDal.AddData(tasks);
                     _locationInfoRepository.UpdateData(locationInfos);
                     _unitOfWorkManage.CommitTran();
-
                     _taskExecuteDetailService.AddTaskExecuteDetail(tasks.Select(x => x.TaskNum).ToList(), "鎺ユ敹WMS浠诲姟");
-
-                    content = tasks.Count > 0 ? content.OK("鎴愬姛") : content.Error("澶辫触");
+                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfos, LocationStatusEnum.InStock, LocationStatusEnum.Lock, LocationChangeType.OutboundAssignLocation, tasks.Select(x => x.TaskNum).ToList());
+                    content = tasks.Count > 0 ? content.OK("鎴愬姛!"+(errorMsg.IsNullOrEmpty()? "": errorMsg)) : content.Error("澶辫触");
                 }
             }
             catch (Exception ex)
@@ -156,46 +171,105 @@
             }
             return content;
         }
-        static object lock_containerFlow = new object();
+        
         /// <summary>
         /// 瀹瑰櫒鍏ュ簱鍒涘缓浠诲姟
         /// </summary>
         /// <returns></returns>
-        public WebResponseContent ContainerFlow(ContainerFlowDTO containerFlowDTO, string deviceCode)
+        public WebResponseContent ContainerFlow(ContainerFlowDTO containerFlowDTO, string deviceCode, string stationCode)
         {
             WebResponseContent content = new WebResponseContent();
             try
             {
-                lock (lock_containerFlow)
+                List<Dt_LocationInfo> locationInfos = _locationInfoRepository.QueryData();
+                Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.PalletCode == containerFlowDTO.ContainerCode);
+                if (locationInfo != null) throw new Exception($"搴撲綅鏂欑鍙穥containerFlowDTO.ContainerCode}宸插瓨鍦�");
+                if (BaseDal.QueryFirst(x => x.PalletCode == containerFlowDTO.ContainerCode && x.TaskType == TaskTypeEnum.Inbound.ObjToInt() && x.TaskState == TaskStatusEnum.CL_Executing.ObjToInt() && x.DeviceCode== deviceCode) != null)
                 {
-                    List<Dt_LocationInfo> locationInfos = _locationInfoRepository.QueryData();
-                    Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x=>x.PalletCode== containerFlowDTO.ContainerCode);
-                    if (locationInfo != null) throw new Exception($"鏂欑鍙穥containerFlowDTO.ContainerCode}宸插瓨鍦�");
-                    if (BaseDal.QueryFirst(x=>x.PalletCode==containerFlowDTO.ContainerCode)!=null) throw new Exception($"鏂欑鍙穥containerFlowDTO.ContainerCode}浠诲姟宸插瓨鍦�");
-                    Dt_LocationInfo? noInLocation = locationInfos.FirstOrDefault(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt());
-                    if (noInLocation == null) throw new Exception($"鍙敤璐т綅涓嶈冻!");
-                    Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && x.StationDeviceCode == deviceCode);
-                    //涓嬪彂浠诲姟缁�
-                    Dt_Task task = new Dt_Task();
-                    task.PalletCode = containerFlowDTO.ContainerCode;
-                    task.SourceAddress = containerFlowDTO.SlotCode;
-                    task.CurrentAddress = containerFlowDTO.SlotCode;
-                    task.NextAddress = stationManger.StationCode;
-                    task.TargetAddress = "";
-                    task.WMSId = "";
-                    task.TaskType = TaskTypeEnum.Inbound.ObjToInt();
-                    task.Roadway = noInLocation.RoadwayNo;
-                    task.DeviceCode = stationManger.StationDeviceCode;
-                    task.TaskState = TaskStatusEnum.CL_Executing.ObjToInt();
-                    //娣诲姞浠诲姟
-                    BaseDal.AddData(task);
-                    _taskExecuteDetailService.AddTaskExecuteDetail(new List<int>() { task.TaskNum }, "鍒涘缓鍏ュ簱浠诲姟");
-                    content.OK("鎴愬姛");
+                    return content.OK();
                 }
+                else if(BaseDal.QueryFirst(x => x.PalletCode == containerFlowDTO.ContainerCode) != null)
+                {
+                    throw new Exception($"鏂欑鍙穥containerFlowDTO.ContainerCode}浠诲姟宸插瓨鍦�");
+                }
+                Dt_LocationInfo? noInLocation = locationInfos.FirstOrDefault(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt());
+                if (noInLocation == null) throw new Exception($"鍙敤璐т綅涓嶈冻!");
+                Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && x.StationDeviceCode == deviceCode);
+                //鍒涘缓浠诲姟
+                Dt_Task task = new Dt_Task();
+                task.PalletCode = containerFlowDTO.ContainerCode;
+                task.SourceAddress = containerFlowDTO.SlotCode;
+                task.CurrentAddress = containerFlowDTO.SlotCode;
+                task.NextAddress = stationManger.StationCode;
+                task.TargetAddress = "";
+                task.WMSId = "";
+                task.TaskType = TaskTypeEnum.Inbound.ObjToInt();
+                task.Roadway = noInLocation.RoadwayNo;
+                task.DeviceCode = stationManger.StationDeviceCode;
+                task.TaskState = TaskStatusEnum.CL_Executing.ObjToInt();
+                //娣诲姞浠诲姟
+                BaseDal.AddData(task);
+                _taskExecuteDetailService.AddTaskExecuteDetail(new List<int>() { task.TaskNum }, "鍒涘缓鍏ュ簱浠诲姟");
+                content.OK("鎴愬姛");
             }
             catch (Exception ex)
             {
                 content.Error($"閿欒淇℃伅:{ex.Message}");
+            }
+            return content;
+        }
+        /// <summary>
+        /// 鎾澧欏垵濮嬪寲
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent InitLight()
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                EPLightContent lightContent = INITIALIZATION();
+                if (lightContent.Result != "0") throw new Exception($"{lightContent.Msg}");
+                content.OK();
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
+        }
+        /// <summary>
+        /// 缁撴潫浣滀笟
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent EndLight()
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                EPLightContent lightContent = ENDWORK();
+                if (lightContent.Result != "0") throw new Exception($"{lightContent.Msg}");
+                content.OK();
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
+        }
+        /// <summary>
+        /// 鎾澧欎寒鐏�
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent SendLight(TaskSendLight taskSendLight)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                EPLightContent pLightContent = new EPLightContent();
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
             }
             return content;
         }
@@ -211,7 +285,7 @@
             {
                 lock (lock_requestInTask)
                 {
-                    Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == barCode && x.NextAddress == stationCode && x.TaskState == TaskStatusEnum.CL_Executing.ObjToInt());
+                    Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == barCode && x.TaskType==TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == stationCode && x.TaskState == TaskStatusEnum.CL_Executing.ObjToInt());
                     if (task == null) throw new Exception($"{barCode}鏂欑鏈壘鍒颁换鍔�!");
                     Dt_LocationInfo? locationInfo = _locationInfoService.AssignLocation();
                     if (locationInfo == null) throw new Exception($"鍙敤璐т綅涓嶈冻!");
@@ -227,7 +301,7 @@
                     _locationInfoRepository.UpdateData(locationInfo);
                     _unitOfWorkManage.CommitTran();
                     _taskExecuteDetailService.AddTaskExecuteDetail(new List<int>() { task.TaskNum }, $"鍒嗛厤璐т綅{locationInfo.LocationCode}");
-
+                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, LocationStatusEnum.Free, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation, task.TaskNum);
                     content.OK("鎴愬姛");
                 }
             }
@@ -245,23 +319,11 @@
             DateTime beginDate = DateTime.Now;
             try
             {
-                using (HttpContent httpContent = new StringContent(requestJson))
+                using (HttpContent httpContent = new StringContent(string.Empty))
                 {
                     httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
-
                     using HttpClient httpClient = new HttpClient();
                     httpClient.Timeout = new TimeSpan(0, 0, 30);
-                    string LoginToken = AppSettings.Get("MESLoginToken");
-                    headers = new Dictionary<string, string>
-                    {
-                        //姝e紡
-                        { "LoginToken", LoginToken }
-                    };
-                    if (headers != null)
-                    {
-                        foreach (var header in headers)
-                            httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
-                    }
                     HttpResponseMessage responseMessage = httpClient.PostAsync(serviceAddress, httpContent).Result;
                     result = responseMessage.Content.ReadAsStringAsync().Result;
                 }
@@ -478,7 +540,7 @@
             try
             {
                 Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
-                if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)//鍑哄簱浠诲姟閫昏緫
+                if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)//鍑哄簱浠诲姟瀹屾垚閫昏緫
                 {
                     Dt_LocationInfo locationInfo = _locationInfoRepository.QueryFirst(x=>x.PalletCode==task.PalletCode);
                     if (locationInfo.LocationStatus != LocationStatusEnum.Lock.ObjToInt())
@@ -488,32 +550,55 @@
                     task.TaskState = TaskStatusEnum.Finish.ObjToInt();
                     locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
                     locationInfo.PalletCode = "";
+                    //鏂欑鍑哄簱瀹屾垚涓婃姤缁橶MS
+                    string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSInOutBoundBack.ToString())?.ApiAddress;
+                    if (string.IsNullOrEmpty(url))
+                    {
+                        _taskExecuteDetailService.AddTaskExecuteDetail(task, $"鏈壘鍒癢MS鍑哄簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                        UpdateTaskExceptionMessage(taskNum, $"鏈壘鍒癢MS鍑哄簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                        return content.Error($"{taskNum},鏈壘鍒癢MS鍑哄簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                    }
+                    ContainerInFinishDTO containerInFinishDTO = new ContainerInFinishDTO()
+                    {
+                        TaskCode = task.TaskNum.ToString(),
+                        ContainerCode = task.PalletCode,
+                        StationCode = task.TargetAddress,
+                        LocationCode = task.SourceAddress,
+                        CompleteType = 1
+                    };
+                    string request = JsonConvert.SerializeObject(containerInFinishDTO, settings);
+                    //璋冪敤鎺ュ彛
+                    string response = HttpHelper.Post(url, request);
+                    WMSResponseContent wMSResponse = JsonConvert.DeserializeObject<WMSResponseContent>(response) ?? throw new Exception($"{taskNum},鏈帴鏀跺埌WMS鍑哄簱涓婃姤杩斿洖鍊�");
+                    if (wMSResponse.Code != "0") throw new Exception($"鍑哄簱浠诲姟{task.TaskNum}WMS鍑哄簱涓婃姤閿欒,淇℃伅:{wMSResponse.Msg}");
                     _unitOfWorkManage.BeginTran();
                     _locationInfoRepository.UpdateData(locationInfo);
                     BaseDal.DeleteAndMoveIntoHty(task, App.User?.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
                     _unitOfWorkManage.CommitTran();
+                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, LocationStatusEnum.Lock, LocationStatusEnum.Free, LocationChangeType.OutboundCompleted, task.TaskNum);
                 }
-                else if(task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍏ュ簱浠诲姟閫昏緫
+                else if(task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍏ュ簱浠诲姟瀹屾垚閫昏緫
                 {
-                    //string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSInBoundBack.ToString())?.ApiAddress;
-                    //if (string.IsNullOrEmpty(url))
-                    //{
-                    //    _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
-                    //    UpdateTaskExceptionMessage(taskNum, $"鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
-                    //    return content.Error($"{taskNum},鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
-                    //}
-                    //ContainerInFinishDTO containerInFinishDTO = new ContainerInFinishDTO()
-                    //{
-                    //    TaskCode= task.TaskNum.ToString(),
-                    //    ContainerCode = task.PalletCode,
-                    //    FromStationCode = task.SourceAddress,
-                    //    ToLocationCode = task.TargetAddress
-                    //};
-                    //string request = JsonConvert.SerializeObject(containerInFinishDTO, settings);
-                    ////璋冪敤鎺ュ彛
-                    //string response = HttpHelper.Post(url, request);
-                    //WMSResponseContent wMSResponse = JsonConvert.DeserializeObject<WMSResponseContent>(response) ??throw new Exception($"{taskNum},鏈帴鏀跺埌WMS鍏ュ簱涓婃姤杩斿洖鍊�");
-                    //if (wMSResponse.Code!="0") throw new Exception($"鍏ュ簱浠诲姟{task.TaskNum}WMS鍏ュ簱涓婃姤閿欒,淇℃伅:{wMSResponse.Msg}");
+                    string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSInOutBoundBack.ToString())?.ApiAddress;
+                    if (string.IsNullOrEmpty(url))
+                    {
+                        _taskExecuteDetailService.AddTaskExecuteDetail(task, $"鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                        UpdateTaskExceptionMessage(taskNum, $"鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                        return content.Error($"{taskNum},鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                    }
+                    ContainerInFinishDTO containerInFinishDTO = new ContainerInFinishDTO()
+                    {
+                        TaskCode = task.TaskNum.ToString(),
+                        ContainerCode = task.PalletCode,
+                        StationCode = task.SourceAddress,
+                        LocationCode = task.TargetAddress,
+                        CompleteType = 2
+                    };
+                    string request = JsonConvert.SerializeObject(containerInFinishDTO, settings);
+                    //璋冪敤鎺ュ彛
+                    string response = HttpHelper.Post(url, request);
+                    WMSResponseContent wMSResponse = JsonConvert.DeserializeObject<WMSResponseContent>(response) ?? throw new Exception($"{taskNum},鏈帴鏀跺埌WMS鍏ュ簱涓婃姤杩斿洖鍊�");
+                    if (wMSResponse.Code != "0") throw new Exception($"鍏ュ簱浠诲姟{task.TaskNum}WMS鍏ュ簱涓婃姤閿欒,淇℃伅:{wMSResponse.Msg}");
                     Dt_LocationInfo locationInfo = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress);
                     if (locationInfo.LocationStatus != LocationStatusEnum.Lock.ObjToInt())
                     {
@@ -526,6 +611,7 @@
                     _locationInfoRepository.UpdateData(locationInfo);
                     BaseDal.DeleteAndMoveIntoHty(task, App.User?.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
                     _unitOfWorkManage.CommitTran();
+                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, LocationStatusEnum.Lock, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted, task.TaskNum);
                 }
                 content.OK("浠诲姟瀹屾垚");
             }
@@ -536,5 +622,88 @@
             }
             return content;
         }
+
+        /// <summary>
+        /// 浜屾湡鎾澧欎笅鍙�
+        /// </summary>
+        /// <param name="taskNum"></param>
+        /// <returns></returns>
+        public EPLightContent PickOrderInfoRequest(List<EPLightSendDTO> lightSendDTOs)
+        {
+            EPLightContent content = new EPLightContent();
+            try
+            {
+                string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.PickOrderInfoRequest.ToString())?.ApiAddress;
+                if (string.IsNullOrEmpty(url))
+                {
+                    return content.Error($"鏈壘鍒版挱绉嶅涓嬪彂鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                }
+                string request = JsonConvert.SerializeObject(lightSendDTOs, settings);
+                //璋冪敤鎺ュ彛
+                string response = HttpHelper.Post(url, request);
+                EPLightContent lightContent = JsonConvert.DeserializeObject<EPLightContent>(response) ?? throw new Exception($"鏈帴鏀跺埌鎾澧欎笅鍙戜笂鎶ヨ繑鍥炲��");
+                if (lightContent.Result != "0") throw new Exception($"鎾澧欎笅鍙戦敊璇�,淇℃伅:{lightContent.Msg}");
+                content.OK("鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
+        }
+        /// <summary>
+        /// 浜屾湡鎾澧欏垵濮嬪寲
+        /// </summary>
+        /// <param name="taskNum"></param>
+        /// <returns></returns>
+        public EPLightContent INITIALIZATION()
+        {
+            EPLightContent content = new EPLightContent();
+            try
+            {
+                string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.INITIALIZATION.ToString())?.ApiAddress;
+                if (string.IsNullOrEmpty(url))
+                {
+                    return content.Error($"鏈壘鍒版挱绉嶅鍒濆鍖栨帴鍙�,璇锋鏌ユ帴鍙i厤缃�");
+                }
+                //璋冪敤鎺ュ彛
+                string response = Post(url);
+                EPLightContent lightContent = JsonConvert.DeserializeObject<EPLightContent>(response) ?? throw new Exception($"鏈帴鏀跺埌鎾澧欏垵濮嬪寲涓婃姤杩斿洖鍊�");
+                if (lightContent.Result != "0") throw new Exception($"鎾澧欏垵濮嬪寲閿欒,淇℃伅:{lightContent.Msg}");
+                content.OK("鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
+        }
+        /// <summary>
+        /// 浜屾湡鎾澧欑粨鏉熶綔涓�
+        /// </summary>
+        /// <param name="taskNum"></param>
+        /// <returns></returns>
+        public EPLightContent ENDWORK()
+        {
+            EPLightContent content = new EPLightContent();
+            try
+            {
+                string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.ENDWORK.ToString())?.ApiAddress;
+                if (string.IsNullOrEmpty(url))
+                {
+                    return content.Error($"鏈壘鍒版挱绉嶅缁撴潫浣滀笟鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+                }
+                //璋冪敤鎺ュ彛
+                string response = Post(url);
+                EPLightContent lightContent = JsonConvert.DeserializeObject<EPLightContent>(response) ?? throw new Exception($"鏈帴鏀跺埌鎾澧欑粨鏉熶綔涓氫笂鎶ヨ繑鍥炲��");
+                if (lightContent.Result != "0") throw new Exception($"鎾澧欑粨鏉熶綔涓氶敊璇�,淇℃伅:{lightContent.Msg}");
+                content.OK("鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
+        }
     }
 }

--
Gitblit v1.9.3