From b52018589bf6c7ec1d51ce8ad000a7aa993b0ab5 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 13 四月 2026 16:06:15 +0800
Subject: [PATCH] 优化组盘表获取成品编号、流水号、供方代码

---
 代码管理/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/BoxingService.cs |   64 +++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 2 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/BoxingService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/BoxingService.cs"
index 0c26b86..00f5f64 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/BoxingService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/BoxingService.cs"
@@ -1,20 +1,80 @@
-锘縰sing System;
+锘縰sing Autofac.Core;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEAWCS_Common;
+using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.BaseServices;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_IBasicInfoService;
 using WIDESEAWCS_Model.Models;
 
 namespace WIDESEAWCS_BasicInfoService
 {
     public class BoxingService : ServiceBase<Dt_Boxing, IRepository<Dt_Boxing>>, IBoxingService
     {
-        public BoxingService(IRepository<Dt_Boxing> BaseDal) : base(BaseDal)
+        private readonly IProcessInfoService _processInfoService;
+        // 鐩存帴娉ㄥ叆 BoxingDetail 鐨勪粨鍌紝鏇夸唬娉ㄥ叆 BoxingDetailService
+        private readonly IRepository<Dt_BoxingDetail> _boxingDetailRepo;
+
+        public BoxingService(
+            IRepository<Dt_Boxing> BaseDal,
+            IProcessInfoService processInfoService,
+            // 鏂板娉ㄥ叆 BoxingDetail 浠撳偍
+            IRepository<Dt_BoxingDetail> boxingDetailRepo
+            ) : base(BaseDal)
         {
+            _processInfoService = processInfoService;
+            _boxingDetailRepo = boxingDetailRepo; // 璧嬪��
         }
 
         public IRepository<Dt_Boxing> Repository => BaseDal;
+
+        //鍒犻櫎褰撳墠鎵樼洏
+        public WebResponseContent DeleteCurrentTray()
+        {
+            try
+            {
+                var PalletCode = TcpClientExample.Start("192.168.2.120", 2001);
+                if (!PalletCode.IsNotEmptyOrNull() || PalletCode == "NoRead")
+                {
+                    return WebResponseContent.Instance.Error("鎵樼洏鐮佹湭鎵埌锛岃閲嶈瘯");
+                }
+                Db.Ado.BeginTran();
+
+                // 1. 鍒犻櫎 Boxing 涓昏〃鏁版嵁
+                Dt_Boxing dt_Boxing = BaseDal.QueryFirst(x => x.PalletCode == PalletCode);
+                if (dt_Boxing != null)
+                {
+                    BaseDal.DeleteData(dt_Boxing);
+
+                    // 2. 鐩存帴閫氳繃浠撳偍鍒犻櫎 BoxingDetail 鏁版嵁锛堟牳蹇冧慨鏀癸級
+                    Dt_BoxingDetail dt_BoxingDetail = _boxingDetailRepo.QueryFirst(x => x.BoxingId == dt_Boxing.Id);
+                    if (dt_BoxingDetail != null)
+                    {
+                        _boxingDetailRepo.DeleteData(dt_BoxingDetail);
+                    }
+                }
+
+                // 3. 鍒犻櫎 ProcessInfo 鏁版嵁
+                Dt_ProcessInfo dt_ProcessInfo = _processInfoService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
+                if (dt_ProcessInfo != null)
+                {
+                    _processInfoService.Repository.DeleteData(dt_ProcessInfo);
+                }
+
+                Db.Ado.CommitTran();
+                return WebResponseContent.Instance.OK("鍒犻櫎鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                Db.Ado.RollbackTran();
+                throw new Exception(ex.Message);
+            }
+        }
+
     }
 }

--
Gitblit v1.9.3