From d3470bb47c0f4627962b270f9667f420e394d0de Mon Sep 17 00:00:00 2001
From: duyongjia <adu_555@163.com>
Date: 星期五, 27 十二月 2024 15:11:17 +0800
Subject: [PATCH] PDA端上传

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs |  158 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 152 insertions(+), 6 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
index 8435005..3d4527a 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
@@ -2,6 +2,7 @@
 using SqlSugar;
 using System;
 using System.Collections.Generic;
+using System.Data;
 using System.Linq;
 using System.Reflection.Metadata;
 using System.Text;
@@ -19,7 +20,9 @@
 using WIDESEA_IInboundService;
 using WIDESEA_IStockService;
 using WIDESEA_ITaskInfoRepository;
+using WIDESEA_Model;
 using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.System.Request;
 
 namespace WIDESEA_InboundService
 {
@@ -46,6 +49,7 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
+                materielGroupDTO.OrderNo = GetOrderNo();
                 Dt_StockInfo? stockInfo = _stockService.StockInfoService.GetStockByPalletCode(materielGroupDTO.PalletCode);
                 (bool, string, object?) result = CheckMaterielGroupParam(materielGroupDTO, stockInfo);
                 if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
@@ -54,7 +58,7 @@
                     stockInfo = new Dt_StockInfo();
                     stockInfo.PalletCode = materielGroupDTO.PalletCode;
                     stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
-                    stockInfo.Creater = "System";
+                    stockInfo.Creater = "绔嬪簱WMS";
                     stockInfo.Details = new List<Dt_StockInfoDetail>();
                    
                 }
@@ -66,13 +70,29 @@
                     if(labmaster == null)
                     {
                         //閫氳繃鏉$爜鎺ュ彛鍚屾鏉$爜涓绘暟鎹�
-                        _sys_JobService.GetLabMaster(lablel);
-                        labmaster = _labelMasterRepository.QueryFirst(x => x.LABEL_NO == lablel);
-                        if (labmaster == null)
+                        var res= _sys_JobService.GetLabMaster(lablel);
+                        if (res != null && res.Status)
                         {
-                            notExistLabels.Add(labmaster);
+                            labmaster = _labelMasterRepository.QueryFirst(x => x.LABEL_NO == lablel);
+                            if (labmaster == null)
+                            {
+                                notExistLabels.Add(labmaster);
+                            }
                         }
+                        else
+                        {
+                          return  content = WebResponseContent.Instance.Error("缁勭洏鏉$爜鍦ㄤ笂娓竁MS绯荤粺涓笉瀛樺湪!");
+                        }    
                     } 
+                    if(labmaster!=null)
+                    {
+                        //涓绘暟鎹潯鐮佺姸鎬佸厑璁哥粍鐩橈細01宸叉敹鏂欏緟璐ㄦ锛�02宸叉敹鏂欐棤闇�璐ㄦ锛�03寰呰繘浠撳凡璐ㄦ锛�09宸蹭笅鏋讹紱
+                        //涓绘暟鎹潯鐮佺姸鎬佷笉鍏佽缁勭洏锛�00鍒涘缓锛�04宸茶川妫�寰呴��璐э紝05鏀舵枡鎴块��璐э紝06搴撴埧閫�璐э紝07宸茶繘浠擄紝08宸蹭笂鏋讹紝10宸插嚭搴擄紝11宸插喕缁擄紝12宸查攣瀹氾紝20鍏抽棴鐨勶紱
+                        if (labmaster.LABEL_STATUS=="00"|| labmaster.LABEL_STATUS == "04" || labmaster.LABEL_STATUS == "05"|| labmaster.LABEL_STATUS == "06" || labmaster.LABEL_STATUS == "07" || labmaster.LABEL_STATUS == "08" || labmaster.LABEL_STATUS == "10" || labmaster.LABEL_STATUS == "11" || labmaster.LABEL_STATUS == "12" || labmaster.LABEL_STATUS == "20")
+                        {
+                            return content = WebResponseContent.Instance.Error("涓绘暟鎹潯鐮佺姸鎬佷笉鍏佽缁勭洏!鏉$爜鐘舵�侊細"+ labmaster.LABEL_STATUS);
+                        }
+                    }
                 }
                 if (notExistLabels.Count == 0)
                 {
@@ -96,7 +116,10 @@
                     content = MaterielGroupUpdateData(stockInfo);
 
                 }
-               
+                else
+                {
+                    content = WebResponseContent.Instance.Error("缁勭洏鏉$爜鍦ㄤ笂娓竁MS绯荤粺涓笉瀛樺湪!");
+                }      
 
             }
             catch (Exception ex)
@@ -112,6 +135,129 @@
 
 
         /// <summary>
+        /// 浣欐枡閫�鍥炵粍鐩�
+        /// </summary>
+        /// <param name="materielGroupDTO"></param>
+        /// <returns></returns>
+        public WebResponseContent ReturnMaterielGroup(MaterielGroupDTO materielGroupDTO)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                materielGroupDTO.OrderNo = GetOrderNo();
+                Dt_StockInfo? stockInfo = _stockService.StockInfoService.GetStockByPalletCode(materielGroupDTO.PalletCode);
+                (bool, string, object?) result = CheckMaterielGroupParam(materielGroupDTO, stockInfo);
+                if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
+                if (stockInfo == null)
+                {
+                    stockInfo = new Dt_StockInfo();
+                    stockInfo.PalletCode = materielGroupDTO.PalletCode;
+                    stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
+                    stockInfo.Creater = "绔嬪簱WMS";
+                    stockInfo.Details = new List<Dt_StockInfoDetail>();
+
+                }
+                List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>();
+                List<Dt_LabelMaster> notExistLabels = new List<Dt_LabelMaster>();
+                foreach (var lablel in materielGroupDTO.SerialNumbers)
+                {
+                    Dt_LabelMaster labmaster = _labelMasterRepository.QueryFirst(x => x.LABEL_NO == lablel);
+                    if (labmaster == null)
+                    {
+                        //閫氳繃鏉$爜鎺ュ彛鍚屾鏉$爜涓绘暟鎹�
+                        var res = _sys_JobService.GetLabMaster(lablel);
+                        if (res != null && res.Status)
+                        {
+                            labmaster = _labelMasterRepository.QueryFirst(x => x.LABEL_NO == lablel);
+                            if (labmaster == null)
+                            {
+                                notExistLabels.Add(labmaster);
+                            }
+                        }
+                        else
+                        {
+                            return content = WebResponseContent.Instance.Error("缁勭洏鏉$爜鍦ㄤ笂娓竁MS绯荤粺涓笉瀛樺湪!");
+                        }
+                    }
+                    if (labmaster != null)
+                    {
+                        //涓绘暟鎹潯鐮佺姸鎬佸厑璁哥粍鐩橈細01宸叉敹鏂欏緟璐ㄦ锛�02宸叉敹鏂欐棤闇�璐ㄦ锛�03寰呰繘浠撳凡璐ㄦ锛�09宸蹭笅鏋讹紱
+                        //涓绘暟鎹潯鐮佺姸鎬佷笉鍏佽缁勭洏锛�00鍒涘缓锛�04宸茶川妫�寰呴��璐э紝05鏀舵枡鎴块��璐э紝06搴撴埧閫�璐э紝07宸茶繘浠擄紝08宸蹭笂鏋讹紝10宸插嚭搴擄紝11宸插喕缁擄紝12宸查攣瀹氾紝20鍏抽棴鐨勶紱
+                        if (labmaster.LABEL_STATUS == "00" || labmaster.LABEL_STATUS == "04" || labmaster.LABEL_STATUS == "05" || labmaster.LABEL_STATUS == "06" || labmaster.LABEL_STATUS == "07" || labmaster.LABEL_STATUS == "08" || labmaster.LABEL_STATUS == "10" || labmaster.LABEL_STATUS == "11" || labmaster.LABEL_STATUS == "12" || labmaster.LABEL_STATUS == "20")
+                        {
+                            return content = WebResponseContent.Instance.Error("涓绘暟鎹潯鐮佺姸鎬佷笉鍏佽缁勭洏!鏉$爜鐘舵�侊細" + labmaster.LABEL_STATUS);
+                        }
+                    }
+                }
+                if (notExistLabels.Count == 0)
+                {
+                    foreach (var item in materielGroupDTO.SerialNumbers)
+                    {
+                        Dt_LabelMaster labmaster = _labelMasterRepository.QueryFirst(x => x.LABEL_NO == item);
+                        Dt_StockInfoDetail dt_StockInfoDetail = new Dt_StockInfoDetail();
+                        dt_StockInfoDetail.Status = 0;
+                        dt_StockInfoDetail.OrderNo = materielGroupDTO.OrderNo;
+                        dt_StockInfoDetail.StockId = stockInfo.Id != 0 ? stockInfo.Id : 0;
+                        dt_StockInfoDetail.MaterielCode = labmaster.MATNR;
+                        dt_StockInfoDetail.MaterielName = labmaster.MAKTX;
+                        dt_StockInfoDetail.BatchNo = labmaster.BATCH;
+                        dt_StockInfoDetail.SerialNumber = labmaster.LABEL_NO;
+                        dt_StockInfoDetail.StockQuantity = int.Parse(labmaster.BOX_QTY);
+                        dt_StockInfoDetail.OutboundQuantity = 0;
+                        dt_StockInfoDetail.Creater = "System";
+                        stockInfoDetails.Add(dt_StockInfoDetail);
+                        stockInfo.Details.AddRange(stockInfoDetails);
+                    }
+                    content = MaterielGroupUpdateData(stockInfo);
+
+                }
+                else
+                {
+                    content = WebResponseContent.Instance.Error("缁勭洏鏉$爜鍦ㄤ笂娓竁MS绯荤粺涓笉瀛樺湪!");
+                }
+
+            }
+            catch (Exception ex)
+            {
+                content = WebResponseContent.Instance.Error(ex.Message);
+            }
+            finally
+            {
+
+            }
+            return content;
+        }
+
+        /// <summary>
+        /// 鏍规嵁BYDWMS缁勭洏淇℃伅锛屽啀鐢熸垚绔嬪簱缁勭洏淇℃伅
+        /// </summary>
+        /// <param name="inventoryRequest"></param>
+        /// <returns></returns>
+        public ReturnInventoryResponse returnInventory(ReturnInventoryRequest inventoryRequest)
+        {
+            ReturnInventoryResponse response= new ReturnInventoryResponse();
+            MaterielGroupDTO materielGroupDTO = new MaterielGroupDTO();
+            materielGroupDTO.PalletCode = inventoryRequest.TPNUM;
+            materielGroupDTO.OrderNo = inventoryRequest.IZLID; //閫�璐у叆搴撴寚浠�
+            List<string> SerialNumbers = new List<string>();
+            foreach (ReturnInventory item in inventoryRequest.DATA)
+            {
+                SerialNumbers.Add(item.LABEL_NO);
+            }
+            ReturnMaterielGroup(materielGroupDTO);
+            return response;
+        }
+        /// <summary>
+        /// 鐢熸垚璁㈠崟鍙�
+        /// </summary>
+        /// <returns></returns>
+        public string GetOrderNo()
+        {
+            DataTable dt = BaseDal.QueryTable("SELECT FORMAT(NEXT VALUE FOR dbo.seqOrderNum, '000000000');");
+            return DateTime.Now.ToString("yyyyMMdd") + dt.Rows[0][0].ToString();
+        }
+
+        /// <summary>
         /// 鎾ら攢缁勭洏
         /// </summary>
         /// <param name="materielGroupDTO"></param>

--
Gitblit v1.9.3