From 34bafb439a438c0f4e85ef7006dac590140d155c Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 01 十一月 2024 14:50:15 +0800
Subject: [PATCH] 联调程序变动

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs |   71 ++++++++++++++++++++++++++++++++++-
 1 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
index f703f06..f5b3c70 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
@@ -1,14 +1,26 @@
 锘縰sing LogLibrary.Log;
 using Masuit.Tools;
+using Newtonsoft.Json;
 using WIDESEA_Common;
+using WIDESEA_Core;
 using WIDESEA_DTO;
+using WIDESEA_DTO.MOM;
+using WIDESEA_IStorageBasicService;
 using WIDESEA_IStoragIntegrationServices;
+using WIDESEA_Model.Models;
 
 namespace WIDESEA_StoragIntegrationServices;
 
 public class CellStateService : ICellStateService
 {
     private readonly LogFactory LogFactory = new LogFactory();
+
+    private readonly IBoxingInfoService _boxingInfoService;
+
+    public CellStateService(IBoxingInfoService boxingInfoService)
+    {
+        _boxingInfoService = boxingInfoService;
+    }
 
     /// <summary>
     /// 鍗曠數鑺睘鎬ц幏鍙�
@@ -17,6 +29,7 @@
     /// <returns></returns>
     public async Task<dynamic> GetCellStateAsync(CellStateDto input)
     {
+        WebResponseContent content = new WebResponseContent();
         try
         {
             input.SessionId = Guid.NewGuid().ToString();
@@ -26,6 +39,32 @@
             input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
             var inputJson = input.ToDictionary();
             var x = await HttpsClient.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/CellState", inputJson);
+            if (x != null)
+            {
+                ResultCellState result = JsonConvert.DeserializeObject<ResultCellState>(x);
+                DtBoxingInfo boxingInfo = new DtBoxingInfo()
+                {
+                    IsFull = true,
+                    PalletCode = "",
+                };
+                var details = new List<DtBoxingInfoDetail>();
+                foreach (var item in result.SerialNos)
+                {
+                    DtBoxingInfoDetail detail = new DtBoxingInfoDetail()
+                    {
+                        SerialNumber = item.SerialNo,
+                        OrderNo = item.BindCode,
+                        Status = item.SerialNoStatus,
+                    };
+                    details.Add(detail);
+                }
+                boxingInfo.BoxingInfoDetails = details;
+                var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo);
+                if (abc.Status)
+                    return content.OK("缁勭洏鎴愬姛");
+                else
+                    return content.Error("缁勭洏澶辫触");
+            }
             LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Info(true, $"\r\r--------------------------------------");
             LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Info(true, x);
         }
@@ -43,8 +82,9 @@
     /// </summary>
     /// <param name="input">鐢佃姱鏁版嵁</param>
     /// <returns></returns>
-    public async Task<dynamic> GetTrayCellStatusAsync(TrayCellsStatusDto input)
+    public async Task<WebResponseContent> GetTrayCellStatusAsync(TrayCellsStatusDto input)
     {
+        WebResponseContent content = new WebResponseContent();
         try
         {
             input.SessionId = Guid.NewGuid().ToString();
@@ -54,6 +94,33 @@
             input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
             var inputJson = input.ToDictionary();
             var x = await HttpsClient.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/TrayCellsStatus", inputJson);
+            if (x != null)
+            {
+                ResultTrayCellsStatus result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(x);
+                DtBoxingInfo boxingInfo = new DtBoxingInfo()
+                {
+                    IsFull = true,
+                    PalletCode = "",
+                };
+                var details = new List<DtBoxingInfoDetail>();
+                foreach (var item in result.SerialNos)
+                {
+                    DtBoxingInfoDetail detail = new DtBoxingInfoDetail()
+                    {
+                        SerialNumber = item.SerialNo,
+                        OrderNo = result.BindCode,
+                        Status = item.SerialNoStatus,
+                        BatchNo = item.PositionNo.ToString()
+                    };
+                    details.Add(detail);
+                }
+                boxingInfo.BoxingInfoDetails = details;
+                var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo);
+                if (abc.Status)
+                    content.OK("缁勭洏鎴愬姛", result);
+                else
+                    content.Error("缁勭洏澶辫触");
+            }
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Info(true, $"\r\r--------------------------------------");
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Info(true, x);
         }
@@ -63,6 +130,6 @@
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Error(true, $"\r\r--------------------------------------");
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Error(true, err.StackTrace);
         }
-        return Task.FromResult<dynamic>(null);
+        return content;
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3