From e5642daf4b6820d0706967e486b16e8d33a46d6d Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期四, 26 十二月 2024 14:37:52 +0800
Subject: [PATCH] 1

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs |  175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 174 insertions(+), 1 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs
index 3de2826..142e609 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs
@@ -4,10 +4,15 @@
 using WIDESEA_Common;
 using WIDESEA_Core;
 using WIDESEA_Core.Const;
+using WIDESEA_Core.Helper;
 using WIDESEA_DTO;
 using WIDESEA_DTO.MOM;
+using WIDESEA_IBusinessesRepository;
 using WIDESEA_IServices;
+using WIDESEA_IStorageBasicRepository;
+using WIDESEA_IStorageTaskRepository;
 using WIDESEA_IStoragIntegrationServices;
+using WIDESEA_Model.Models;
 
 namespace WIDESEA_StoragIntegrationServices;
 
@@ -15,10 +20,18 @@
 {
     private readonly LogFactory LogFactory = new LogFactory();
     private readonly ISys_ConfigService _configService;
+    private readonly IDt_AreaInfoRepository _areaInfoRepository;
+    private readonly ICellStateService _cellStateService;
+    private readonly IStockInfoRepository _stockInfoRepository;
+    private readonly IAgingInOrOutInputService _gingInOrOutInputService;
 
-    public ProcessApplyService(ISys_ConfigService configRepository)
+    public ProcessApplyService(ISys_ConfigService configRepository, IDt_AreaInfoRepository areaInfoRepository, ICellStateService cellStateService, IDt_TaskRepository taskRepository, IStockInfoRepository stockInfoRepository, IAgingInOrOutInputService gingInOrOutInputService)
     {
         _configService = configRepository;
+        _areaInfoRepository = areaInfoRepository;
+        _cellStateService = cellStateService;
+        _stockInfoRepository = stockInfoRepository;
+        _gingInOrOutInputService = gingInOrOutInputService;
     }
 
     /// <summary>
@@ -62,4 +75,164 @@
         }
         return content;
     }
+
+    /// <summary>
+    /// 琛ュ綍鍑哄簱鏁版嵁
+    /// </summary>
+    /// <param name="palletCode"></param>
+    /// <returns></returns>
+    public async Task<WebResponseContent> StockOutDataBackfillInterfaceAsync(string palletCode, int areaID)
+    {
+        WebResponseContent content = new WebResponseContent();
+        try
+        {
+            var area = _areaInfoRepository.QueryFirst(x => x.AreaID == areaID);
+            var trayCells = new TrayCellsStatusDto()
+            {
+                Software = area.Spare3,
+                TrayBarcode = palletCode,
+                EquipmentCode = area.Spare2,
+                SceneType = area.Spare4
+            };
+            content = await _cellStateService.GetTrayCellStatusAsync(trayCells);
+            if (!content.Status) return content;
+
+            var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
+            if (result.SerialNos.Count > 0)
+            {
+                var stockHty = await SqlSugarHelper.Db.Queryable<DtStockInfo>().IncludesAllFirstLayer().FirstAsync();
+                if (stockHty != null)
+                {
+                    var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stockHty.ParameterInfos).FirstOrDefault(y => y.Description.Contains("鏃堕棿"));
+                    if (parameterInfo == null) throw new Exception("");
+
+                    var outHours = (DateTime.Now - (stockHty.LinedProcessFeedbackTime == null ? stockHty.ModifyDate.Value : stockHty.LinedProcessFeedbackTime.ToDateTime())).TotalHours;
+                    var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble();
+
+                    var defectCode = string.Empty;
+                    if (!isNG) defectCode = "TQCK";
+                    var outputDto = new AgingOutputDto
+                    {
+                        OpFlag = 1,
+                        Software = area.Spare3,
+                        EquipmentCode = area.Spare2,
+                        TrayBarcode = palletCode,
+                        SerialNos = result.SerialNos.Select(x => new SerialNoOutDto
+                        {
+                            SlotNo = x.PositionNo,
+                            SerialNo = x.SerialNo,
+                            SerialNoResult = true, //isNG,
+                            ParameterInfo = new List<ParameterInfoOutput> {
+                                new ParameterInfoOutput() {
+                                    Value = outHours.ToString(),
+                                    ParameterCode =parameterInfo.ParameterCode,
+                                    ParameterDesc = parameterInfo.Description,
+                                    ParameterResult  = "OK", //isNG.ToString(),
+                                    TargetValue = parameterInfo.TargetValue,
+                                    LowerLomit = parameterInfo.LowerSpecificationsLimit,
+                                    UpperLimit = parameterInfo.UpperSpecificationsLimit,
+                                    DefectCode = defectCode,
+                                    UOMCode = parameterInfo.UOMCode,
+                                }
+                            }
+                        }).ToList()
+                    };
+                    content = await _gingInOrOutInputService.GetOCVOutputAsync(outputDto);
+                }
+            }
+            else
+            {
+                content.Error("鐢佃姱鏁版嵁涓虹┖");
+            }
+        }
+        catch (Exception ex)
+        {
+        }
+        return content;
+    }
+
+    /// <summary>
+    /// 琛ュ綍鍏ュ簱鏁版嵁
+    /// </summary>
+    /// <param name="palletCode"></param>
+    /// <param name="areaID"></param>
+    /// <returns></returns>
+    public async Task<WebResponseContent> StockInDataBackfillInterfaceAsync(string palletCode, int areaID)
+    {
+        WebResponseContent content = new WebResponseContent();
+        try
+        {
+            var area = _areaInfoRepository.QueryFirst(x => x.AreaID == areaID);
+            var trayCells = new TrayCellsStatusDto()
+            {
+                Software = area.Spare3,
+                TrayBarcode = palletCode,
+                EquipmentCode = area.Spare2,
+                SceneType = area.Spare4
+            };
+            content = await _cellStateService.GetTrayCellStatusAsync(trayCells);
+            if (!content.Status) return content;
+
+            var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
+            if (result.SerialNos.Count > 0 && result.Success)
+            {
+                var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
+                if (stockInfo != null)
+                {
+                    stockInfo.IsFull = true;
+                    stockInfo.StockInfoDetails = result.SerialNos.Select(serialNoObj => new DtStockInfoDetail
+                    {
+                        SerialNumber = serialNoObj.SerialNo,
+                        OrderNo = serialNoObj.PositionNo.ToString(),
+                        Status = serialNoObj.SerialNoStatus,
+                        MaterielCode = result.BindCode,
+                        Remark = result.TrayBarcodePropertys.ToJsonString(),
+                    }).ToList();
+                    stockInfo.Remark = stockInfo.StockInfoDetails.Count().ToString();
+
+                    // 澶勭悊璇锋眰鍙傛暟
+                    AgingInputDto agingInputDto = new AgingInputDto()
+                    {
+                        SerialNos = stockInfo.StockInfoDetails
+                            .Select(item => new SerialNoInDto { SerialNo = item.SerialNumber, PositionNo = item.OrderNo })
+                            .ToList(),
+                        TrayBarcode = palletCode,
+                        OpFlag = 1,
+                        EquipmentCode = area.Spare2,
+                        Software = area.Spare3
+                    };
+
+                    content = _gingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result;
+                    var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(content.Data.ToString());
+
+                    stockInfo.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime;
+                    stockInfo.SpecialParameterDuration = respone.SpecialParameterDuration;
+                    //2024骞�11鏈�16鏃ワ細鏂板瀛楁璁$畻搴斿嚭搴撴椂闂�
+                    stockInfo.OutboundTime = Convert.ToDateTime(respone.LinedProcessFeedbackTime == null ? DateTime.Now : respone.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(respone.SpecialParameterDuration));
+                    stockInfo.ProductionLine = respone.ProductionLine;
+                    stockInfo.ParameterInfos = respone.ParameterInfos.ToJsonString();
+                    stockInfo.StockStatus = 1;
+
+                    var isResult = await _stockInfoRepository.UpdateDataNavAsync(stockInfo);
+                    if (isResult)
+                        content.OK("鏇存柊鏁版嵁鎴愬姛");
+                    else
+                        content.Error("鏇存柊鏁版嵁澶辫触");
+                }
+                else
+                {
+                    content.Error("鏈壘鍒板簱瀛�");
+                }
+            }
+            else
+            {
+                return content;
+            }
+        }
+        catch (Exception ex)
+        {
+            content.Error(ex.Message);
+        }
+        return content;
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3