From 50fd5cc9cfad08714c4daa6d481c5293ff2ae6b1 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期三, 31 一月 2024 18:55:28 +0800
Subject: [PATCH] 逻辑完善

---
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs"
index 4b4f70c..9bb2ced 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs"
@@ -17,9 +17,19 @@
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.AspNetCore.Http;
 using WIDESEA_WMS.IRepositories;
+using Newtonsoft.Json;
+using WIDESEA_Comm.LogInfo;
+using WIDESEA_Core.FreeDB;
+using WIDESEA_Core.ManageUser;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 
 namespace WIDESEA_WMS.Services
 {
+    public class Parm
+    {
+        public List<string> data { get; set; }
+        public int type { get; set; }
+    }
     public partial class dt_stationinfoService
     {
         private readonly IHttpContextAccessor _httpContextAccessor;
@@ -37,6 +47,53 @@
             //澶氱鎴蜂細鐢ㄥ埌杩檌nit浠g爜锛屽叾浠栨儏鍐靛彲浠ヤ笉鐢�
             //base.Init(dbRepository);
         }
+        FreeDB freeDB=new FreeDB();
+        /// <summary>
+        /// 璁剧疆缂撳瓨鏋剁鐢ㄥ惎鐢�
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        public WebResponseContent SetStationEnable(object json)
+        {
+            WebResponseContent webResponse = new WebResponseContent();
+            try
+            {
+                var Tel = UserContext.Current.UserInfo.Tel;//缂撳瓨鏋舵潈闄�
+                var data = JsonConvert.DeserializeObject<Parm>(json.ToString());
+                //var updateList = FreeDB.DB.Select<dt_stationinfo>().Where(t => data.data.Contains(t.id.ToString())).ToList();
+                var updateList = _repository.Find(x => data.data.Contains(x.id.ToString())).ToList();
+                if (!string.IsNullOrEmpty(Tel))
+                {
+                    var types = Tel.Split(',');
+                    foreach (var update in updateList)
+                    {
+                        var OK = false;
+                        foreach (var type in types)
+                        {
+                            if (update.stationCode.Contains(type))
+                                OK = true;
+                        }
+                        if (!OK) throw new Exception("褰撳墠璐﹀彿鏃犵鐢ㄦ潈闄�!");
+                    }
+                }
+
+                var res = freeDB.Update<dt_stationinfo>()
+                     .Set(t => t.enable, data.type == 1)
+                     .Where(t => data.data.Contains(t.id.ToString()))
+                     .ExecuteAffrows();
+
+                var msg = data.type == 1 ? "鍚敤" : "绂佺敤";
+                WriteDBLog.Write($"鎵嬪姩{msg}绔欑偣 ", $"{string.Join('銆�', updateList.Select(t => t.stationCode).ToArray())}", LogState.Sucess, "WCS", UserContext.Current.UserName);
+
+                webResponse.OK();
+            }
+            catch (Exception ex)
+            {
+                WriteDBLog.Write($"鎵嬪姩鍚敤鎴栫鐢ㄧ珯鐐� ", new { 閿欒淇℃伅 = ex.Message, 鏁版嵁 = json }, LogState.Error, "WCS", UserContext.Current.UserName);
+                webResponse.Error(ex.Message);
+            }
+            return webResponse;
+        }
         public override WebResponseContent Add(SaveModel saveDataModel)
         {
 

--
Gitblit v1.9.3