From 2c69e642303e9f9c3b2e37194c4c6cdf7e1b3001 Mon Sep 17 00:00:00 2001
From: xiaojiao <xiaojiao@kaokeziliao.com>
Date: 星期三, 29 四月 2026 17:26:33 +0800
Subject: [PATCH] 4-29

---
 项目代码/WIDESEA_WCSServer/WIDESEAWCS_BasicInfoService/Dt_MaterialInfoService.cs |   43 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 36 insertions(+), 7 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_BasicInfoService/Dt_MaterialInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_BasicInfoService/Dt_MaterialInfoService.cs"
index 5ea22b0..190e5cd 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_BasicInfoService/Dt_MaterialInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_BasicInfoService/Dt_MaterialInfoService.cs"
@@ -1,9 +1,12 @@
-锘縰sing Microsoft.AspNetCore.Mvc;
+锘縰sing AutoMapper;
+using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Reflection.Metadata;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEAWCS_Common.StationEnum;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.BaseServices;
@@ -18,10 +21,16 @@
     {
         private readonly IDt_ContainerInfoRepository _ContainerInfoRepository;
         private readonly IUnitOfWorkManage _unitOfWorkManage;
-        public Dt_MaterialInfoService(IDt_MaterialInfoRepository BaseDal, IDt_ContainerInfoRepository dt_ContainerInfoRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
+        private readonly IDt_MaterialInfo_HtyRepository _MaterialInfo_HtyRepository;
+        private readonly IMapper _mapper;
+        private readonly IDt_StationManagerRepository _stationManagerRepository;
+        public Dt_MaterialInfoService(IDt_MaterialInfoRepository BaseDal, IDt_ContainerInfoRepository dt_ContainerInfoRepository, IUnitOfWorkManage unitOfWorkManage, IDt_MaterialInfo_HtyRepository materialInfo_HtyRepository,IMapper mapper, IDt_StationManagerRepository stationManagerRepository) : base(BaseDal)
         {
             _ContainerInfoRepository = dt_ContainerInfoRepository;
             _unitOfWorkManage = unitOfWorkManage;
+            _MaterialInfo_HtyRepository = materialInfo_HtyRepository;
+            _mapper = mapper;
+            _stationManagerRepository = stationManagerRepository;
         }
         /// <summary>
         /// 鏂板缁勭洏淇℃伅
@@ -39,16 +48,19 @@
                 Dt_MaterialInfo dt_MaterialInfo = await BaseDal.QueryFirstAsync(x => x.ContainerCode == containerbindingDTO.VehicleNumber);
                 if (dt_MaterialInfo != null) return content.Error("褰撳墠瀹瑰櫒宸茬粦瀹� 璇峰嬁閲嶅鎻愪氦");
 
-                dt_MaterialInfo = await BaseDal.QueryFirstAsync(x => x.MaterialName == containerbindingDTO.materSn);
-                if (dt_MaterialInfo != null) return content.Error("褰撳墠闆朵欢鍙峰凡瀛樺湪 璇峰嬁閲嶅鎻愪氦");
+                Dt_StationManager dt_StationManager = _stationManagerRepository.QueryFirst(
+                x => x.StationLocation == containerbindingDTO.Position 
+                && x.StationStatus == ((int)StationEnum.Enable).ToString());
+
+                if (dt_StationManager == null) return content.Error("褰撳墠绔欏彴鏈厤缃� 鎴栧凡鍋滅敤");
 
                 dt_MaterialInfo = new Dt_MaterialInfo();
                 dt_MaterialInfo.MaterialName = containerbindingDTO.materSn;
                 dt_MaterialInfo.ContainerCode = containerbindingDTO.VehicleNumber;
                 dt_MaterialInfo.Position = containerbindingDTO.Position;
                 dt_MaterialInfo.Carmodel = containerbindingDTO.Carmodel;
-                string s = App.User.UserName;
-                await BaseDal.AddDataAsync(dt_MaterialInfo);
+                dt_MaterialInfo.Region = dt_StationManager.StationArea;
+
                 // 2. 鎵ц涓�瀹氫細鎶ラ敊鐨勪唬鐮侊細闄や互闆�
                 //int a = 1;
                 //int b = 0;
@@ -59,10 +71,12 @@
                     containerInfo = new Dt_ContainerInfo();
                     containerInfo.RequestId = Guid.NewGuid().ToString().Replace("-", "");
                     containerInfo.ContainerCode = containerbindingDTO.VehicleNumber;
+                    dt_MaterialInfo.IsNew = true;
                     await _ContainerInfoRepository.AddDataAsync(containerInfo);
                 }
+                await BaseDal.AddDataAsync(dt_MaterialInfo);
                 _unitOfWorkManage.CommitTran();
-                return content.OK();
+                return content.OK(message:"鐗╂枡缁戝畾鎴愬姛");
             }
             catch (Exception ex)
             {
@@ -72,5 +86,20 @@
             }
 
         }
+        public async Task<WebResponseContent> DeleteGroupPlateAsync(string PalletCode)
+        {
+            WebResponseContent content = new WebResponseContent();
+            // 鍏堟煡璇㈢浉搴旂殑缁勭洏缁戝畾淇℃伅 濡傛灉娌℃湁鏁版嵁鍒欒繑鍥�
+            Dt_MaterialInfo dt_MaterialInfo = await BaseDal.QueryFirstAsync(x => x.ContainerCode == PalletCode);
+            if (dt_MaterialInfo == null) return content.Error("鏌ヨ涓嶅埌鐩稿叧鏁版嵁 鎴栬�呭凡缁忚В缁戯紒");
+
+            // 杩欓噷闈㈣鍐欑墿鏂欑粍鐩樹俊鎭殑鐘舵�佹敼鍙樹緥濡傚凡瑙g粦
+            dt_MaterialInfo.IsBind = false;
+
+            Dt_MaterialInfo_Hty dt_MaterialInfo_Hty = _mapper.Map<Dt_MaterialInfo_Hty>(dt_MaterialInfo);
+
+            // 鍒犻櫎褰撳墠缁勭洏鏁版嵁娣诲姞杩涘叆鍘嗗彶璁板綍
+            return content.OK(message: "鐗╂枡瑙g粦鎴愬姛");
+        }
     }
 }

--
Gitblit v1.9.3