From 52e709fcf50517c2b953eae2be753b71df347fa5 Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期四, 11 十二月 2025 17:10:43 +0800
Subject: [PATCH] 供应商信息:采购员和负责人电话推送

---
 MES.Service/service/BasicData/MesItemsManager.cs |  171 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 154 insertions(+), 17 deletions(-)

diff --git a/MES.Service/service/BasicData/MesItemsManager.cs b/MES.Service/service/BasicData/MesItemsManager.cs
index ef92180..e98e3a8 100644
--- a/MES.Service/service/BasicData/MesItemsManager.cs
+++ b/MES.Service/service/BasicData/MesItemsManager.cs
@@ -6,7 +6,9 @@
 using SqlSugar;
 
 namespace MES.Service.service.BasicData;
-
+/// <summary>
+/// 鐗╂枡淇℃伅
+/// </summary>
 public class MesItemsManager : Repository<MesItems>
 {
     public bool Save(ErpItems item)
@@ -131,7 +133,7 @@
             ItemNo = item.FNumber,
             ItemName = item.FName,
             ItemModel = item.FSpecification,
-            ItemUnit = item.FBaseUnitId,
+            ItemUnit = item.FBaseUnitId,//鐗╂枡鍩烘湰鍗曚綅缂栫爜杞琁D
             Lowlimit = Convert.ToDouble(item.FSafeStock),
             Highlimit = Convert.ToDouble(item.FMaxStock),
             PrdPack = Convert.ToDouble(item.FMinPackCount),
@@ -140,7 +142,15 @@
             Remarks = item.FDescription,
             Ffinishreceiptoverrate =
                 Convert.ToDecimal(item.FFinishReceiptOverRate),
-            Fissuetype = item.FIssueType,
+            //鍙戞枡鏂瑰紡
+            Fissuetype = item.FIssueType switch
+            {
+                "1" => "閫愭壒棰嗘枡",
+                "2" => "鑷姩鎵f枡",
+                _ => item.FIssueType
+            },
+            //Fissuetype = item.FIssueType,
+
             //鎵瑰彿绠$悊
             Fisbatchmanage = item.FIsBatchManage switch
             {
@@ -154,13 +164,13 @@
             Fpurchaseunitid = item.FPurchaseUnitId,
             Storeunit = item.FStoreUnitID,
             Saleunit = item.FSaleUnitId,
-            //Fforbidstatus = item.FForbidStatus,
+            Fforbidstatus = item.FForbidStatus,//鍚敤涓庣鐢�
             MaterialProperti = item.FErpClsID,
             ProductionWorkshop = item.FWorkShopId,
             ProduceUnit = item.FPRODUCEUNITID,
             SubconUnit = item.FSUBCONUNITID,
-            FSubsidiary = item.FUseOrgId,
-            Fumbrella = item.FCreateOrgId,
+            //FSubsidiary = item.FUseOrgId,
+            //Fumbrella = item.FCreateOrgId,
             LastupdateDate = DateTime.Now,
             // 濡傛灉瀛樺湪锛屼娇鐢ㄧ幇鏈夌殑CreateDate锛屽悗缁皢鍒犻櫎鍚庨噸鏂版彃鍏�
             // 濡傛灉涓嶅瓨鍦紝璁句负褰撳墠鏃堕棿
@@ -173,21 +183,149 @@
             ExpirationDate= item.Expirationdate,
             ReviewPeriod= item.Reviewperiod,
             LeadDays= item.FLeadDays,
-            Remark5 = item.FRemark5
-        };
+            Remark5 = item.FRemark5,
 
-        // ERP: 0=鏈鐢�, 1=绂佺敤
-        // MES: A=鏈鐢�, B=绂佺敤
-        if (string.IsNullOrEmpty(item.FForbidStatus))
+            FSubsidiary = string.IsNullOrEmpty(item.FUseOrgId) ? "1" : item.FUseOrgId,
+            Fumbrella = string.IsNullOrEmpty(item.FCreateOrgId) ? "1" : item.FCreateOrgId,
+        };
+        //鐗╂枡鍩烘湰鍗曚綅缂栫爜杞琁D,ItemUnit = item.FBaseUnitId
+        var entityItemUnit = Db.Queryable<MesUnit>()
+        .Where(x => x.Fnumber == item.FBaseUnitId)
+        .Select(x => x.Id.ToString())
+        .First();
+        if (!string.IsNullOrWhiteSpace(entityItemUnit))
         {
-            entity.Fforbidstatus = "A";
+            entity.ItemUnit = entityItemUnit;
+        }
+        else if (!string.IsNullOrWhiteSpace(item.FBaseUnitId))
+        {
+            entity.ItemUnit = item.FBaseUnitId;
         }
         else
         {
-            //鎴戞湡鏈涚殑鍊兼槸A=鍚�,B=鏄�
-            //瀹為檯缁欐垜鐨勫�兼槸0鎴�1锛屾垜甯屾湜涓烘垜杞崲浠嶢鍜孊鐨勬柟寮�
-            entity.Fforbidstatus = item.FForbidStatus == "1" ? "B" : "A";
+            entity.ItemUnit = "0";
         }
+
+        //鐗╂枡閿�鍞崟浣嶇紪鐮佽浆ID,Saleunit = item.FSaleUnitId
+        var entitySaleunit = Db.Queryable<MesUnit>()
+        .Where(x => x.Fnumber == item.FSaleUnitId)
+        .Select(x => x.Id.ToString())
+        .First();
+        if (!string.IsNullOrWhiteSpace(entitySaleunit))
+        {
+            entity.Saleunit = entitySaleunit;
+        }
+        else if (!string.IsNullOrWhiteSpace(item.FSaleUnitId))
+        {
+            entity.Saleunit = item.FSaleUnitId;
+        }
+        else
+        {
+            entity.Saleunit = "0";
+        }
+
+        //鐗╂枡搴撴埧鍗曚綅缂栫爜杞琁D,Storeunit = item.FStoreUnitID
+        var entityStoreunit = Db.Queryable<MesUnit>()
+        .Where(x => x.Fnumber == item.FStoreUnitID)
+        .Select(x => x.Id.ToString())
+        .First();
+        if (!string.IsNullOrWhiteSpace(entityStoreunit))
+        {
+            entity.Storeunit = entityStoreunit;
+        }
+        else if (!string.IsNullOrWhiteSpace(item.FStoreUnitID))
+        {
+            entity.Storeunit = item.FStoreUnitID;
+        }
+        else
+        {
+            entity.Storeunit = "0";
+        }
+
+        //鐗╂枡閲囪喘鍗曚綅缂栫爜杞琁D,Fpurchaseunitid = item.FPurchaseUnitId
+        var entityFpurchaseunitid = Db.Queryable<MesUnit>()
+        .Where(x => x.Fnumber == item.FPurchaseUnitId)
+        .Select(x => x.Id.ToString())
+        .First();
+        if (!string.IsNullOrWhiteSpace(entityFpurchaseunitid))
+        {
+            entity.Fpurchaseunitid = entityFpurchaseunitid;
+        }
+        else if (!string.IsNullOrWhiteSpace(item.FPurchaseUnitId))
+        {
+            entity.Fpurchaseunitid = item.FPurchaseUnitId;
+        }
+        else
+        {
+            entity.Fpurchaseunitid = "0";
+        }
+
+        //鐗╂枡鐢熶骇鍗曚綅缂栫爜杞琁D,ProduceUnit = item.FPRODUCEUNITID
+        var entityProduceUnit = Db.Queryable<MesUnit>()
+        .Where(x => x.Fnumber == item.FPRODUCEUNITID)
+        .Select(x => x.Id.ToString())
+        .First();
+        if (!string.IsNullOrWhiteSpace(entityProduceUnit))
+        {
+            entity.ProduceUnit = entityProduceUnit;
+        }
+        else if (!string.IsNullOrWhiteSpace(item.FPRODUCEUNITID))
+        {
+            entity.ProduceUnit = item.FPRODUCEUNITID;
+        }
+        else
+        {
+            entity.ProduceUnit = "0";
+        }
+
+        //鐗╂枡濮斿鍗曚綅缂栫爜杞琁D,SubconUnit = item.FSUBCONUNITID
+        var entitySubconUnit = Db.Queryable<MesUnit>()
+        .Where(x => x.Fnumber == item.FSUBCONUNITID)
+        .Select(x => x.Id.ToString())
+        .First();
+        if (!string.IsNullOrWhiteSpace(entitySubconUnit))
+        {
+            entity.SubconUnit = entitySubconUnit;
+        }
+        else if (!string.IsNullOrWhiteSpace(item.FSUBCONUNITID))
+        {
+            entity.SubconUnit = item.FSUBCONUNITID;
+        }
+        else
+        {
+            entity.SubconUnit = "0";
+        }
+
+        //榛樿浠撳簱缂栫爜杞琁D,DepotCode = item.FStockId,
+        var entityDepotCode = Db.Queryable<MesDepots>()
+        .Where(x => x.DepotCode == item.FStockId)
+        .Select(x => x.DepotId.ToString())
+        .First();
+        if (!string.IsNullOrWhiteSpace(entityDepotCode))
+        {
+            entity.DepotCode = entityDepotCode;
+        }
+        else if (!string.IsNullOrWhiteSpace(item.FStockId))
+        {
+            entity.DepotCode = item.FStockId;
+        }
+        else
+        {
+            entity.SubconUnit = "0";
+        }
+
+        //// ERP: Y=鏈鐢�, N=绂佺敤
+        //// MES: A=鏈鐢�, B=绂佺敤
+        //if (string.IsNullOrEmpty(item.FForbidStatus))
+        //{
+        //    entity.Fforbidstatus = "A";
+        //}
+        //else
+        //{
+        //    //鎴戞湡鏈涚殑鍊兼槸A=鍚敤,B=绂佺敤
+        //    //瀹為檯缁欐垜鐨勫�兼槸Y鎴朜锛屾垜甯屾湜涓烘垜杞崲浠嶢鍜孊鐨勬柟寮�
+        //    entity.Fforbidstatus = item.FForbidStatus == "N" ? "B" : "A";
+        //}
 
         return entity;
     }
@@ -210,8 +348,7 @@
         return newId;
     }
 
-    private bool UpdateItemStatusBatch(SqlSugarScope db,
-        List<MesItems> itemList, string status)
+    private bool UpdateItemStatusBatch(SqlSugarScope db,List<MesItems> itemList, string status)
     {
         var ids = itemList.Select(it => it.Id).ToArray();
         var result = db.Updateable<MesItems>()

--
Gitblit v1.9.3