From ab01d75a3fbc8467d81a895cba5d6dde76fbe053 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期二, 16 九月 2025 23:29:30 +0800
Subject: [PATCH] 1111

---
 MES.Service/service/BasicData/SysDepartmentManager.cs |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/MES.Service/service/BasicData/SysDepartmentManager.cs b/MES.Service/service/BasicData/SysDepartmentManager.cs
index 1e91613..6f29c07 100644
--- a/MES.Service/service/BasicData/SysDepartmentManager.cs
+++ b/MES.Service/service/BasicData/SysDepartmentManager.cs
@@ -1,4 +1,5 @@
-锘縰sing MES.Service.DB;
+锘縰sing Masuit.Tools;
+using MES.Service.DB;
 using MES.Service.Dto.webApi;
 using MES.Service.Modes;
 using SqlSugar;
@@ -107,6 +108,7 @@
             // 鏂板鎯呭喌锛氱敓鎴愭柊ID骞舵彃鍏�
             var newId = GenerateNewId();
             entity.Id = newId;
+            entity.Departmentid = newId;
             return db.Insertable(entity).IgnoreColumns(ignoreNullColumn:true).ExecuteCommand() > 0;
         }
         else
@@ -126,16 +128,6 @@
     // 灏� ErpDepartment 瀵硅薄杞崲涓� SysDepartment 瀵硅薄鐨勬柟娉�
     private SysDepartment GetSysDepartment(ErpDepartment department)
     {
-        var fForbidStatus = department.FForbidStatus;
-        if (department.FForbidStatus == "0")
-        {
-            fForbidStatus = "A";
-        }
-        else if (department.FForbidStatus == "1")
-        {
-            fForbidStatus = "B";
-        }
-
         var entity = new SysDepartment
         {
             Departmentcode = department.FNumber,
@@ -143,19 +135,25 @@
             Depextr1 = department.FDeptProperty,
             Depextr2 = department.FGroup,
             Depextr3 = department.FWIPStockID,
-            Depextr4 = fForbidStatus,
             FParentID = department.FParentID,
-            FSubsidiary = string.IsNullOrEmpty(department.FUseOrgId)
-                ? "1"
-                : department.FUseOrgId,
-            Fumbrella = string.IsNullOrEmpty(department.FCreateOrgId)
-                ? "1"
-                : department.FCreateOrgId,
+            FSubsidiary = "1",
+            Fumbrella = "1",
             CreateDate = DateTime.Now,
             LastupdateDate = DateTime.Now,
             Company = "1000",
             Factory = "1000"
         };
+
+        if (department.FForbidStatus.IsNullOrEmpty())
+        {
+            entity.Depextr4 = "A";
+        }
+        else
+        {
+            //鎴戞湡鏈涚殑鍊兼槸A=鍚�,B=鏄�
+            //瀹為檯缁欐垜鐨勫�兼槸0鎴�1锛屾垜甯屾湜涓烘垜杞崲浠嶢鍜孊鐨勬柟寮�
+            entity.Depextr4 = department.FForbidStatus == "1" ? "B" : "A";
+        }
 
         // 鏌ユ壘鏄惁宸插瓨鍦ㄧ浉鍚岄儴闂ㄧ紪鐮佺殑璁板綍
         var existingDepartment = Db.Queryable<SysDepartment>()
@@ -166,11 +164,13 @@
         {
             // 濡傛灉瀛樺湪锛屼娇鐢ㄧ幇鏈夌殑ID锛屽悗缁皢鍒犻櫎鍚庨噸鏂版彃鍏�
             entity.Id = existingDepartment.Id;
+            entity.Departmentid = existingDepartment.Id;
         }
         else
         {
             // 濡傛灉涓嶅瓨鍦紝璁句负0锛孖nsertOrUpdate鏂规硶灏嗙敓鎴愭柊ID
             entity.Id = 0;
+            entity.Departmentid = 0;
         }
 
         return entity;

--
Gitblit v1.9.3