From 72594e721deaa9f1485836923184c048cafe8270 Mon Sep 17 00:00:00 2001
From: zjh <2207896513@qq.com>
Date: 星期一, 08 九月 2025 09:55:02 +0800
Subject: [PATCH] 采购退货单支持无源单退
---
StandardPda/MES.Service/service/BasicData/MesDepotsManager.cs | 161 +++--------------------------------------------------
1 files changed, 9 insertions(+), 152 deletions(-)
diff --git a/StandardPda/MES.Service/service/BasicData/MesDepotsManager.cs b/StandardPda/MES.Service/service/BasicData/MesDepotsManager.cs
index d0b205c..3fe22a5 100644
--- a/StandardPda/MES.Service/service/BasicData/MesDepotsManager.cs
+++ b/StandardPda/MES.Service/service/BasicData/MesDepotsManager.cs
@@ -46,7 +46,7 @@
string status)
{
var result = db.Updateable<MesDepots>()
- .SetColumns(s => s.IsNg == status)
+ .SetColumns(s => s.ForbidStatus == status)
.Where(s => s.DepotId == depotId).ExecuteCommand();
if (result > 0)
@@ -76,42 +76,12 @@
throw new NotImplementedException("鍙嶅鏍稿け璐�");
}
- /// <summary>
- /// "鎻掑叆鎴栨洿鏂板憳宸ョ殑鏂规硶"璋冩暣锛氫慨鏀逛负鍏堝垹闄ゅ啀鎻掑叆锛屽悓鏃剁敤id鍜孭ositionCode浣滀负鍒ゆ柇渚濇嵁
- /// </summary>
- /// <remarks>
- /// 淇敼浜猴細姹犲崡楠�
- /// 淇敼鏃ユ湡锛�2024-12-30
- /// 淇敼璇存槑锛歚
- /// </remarks>
-
- ///鍘熶唬鐮�
- // 鎻掑叆鎴栨洿鏂颁粨搴撶殑鏂规硶
- //private bool InsertOrUpdate(SqlSugarScope db, MesDepots entity)
- //{
- // var exists = db.Queryable<MesDepots>()
- // .Any(e => e.DepotId == entity.DepotId);
- // if (exists)
- // {
- // var update = db.Updateable(entity).ExecuteCommand();
- // if (update > 0)
- // return true;
- // }
- // else
- // {
- // var insert = db.Insertable(entity).ExecuteCommand();
- // if (insert > 0)
- // return true;
- // }
-
- // return false;
- //}
/// 鏂颁唬鐮�
private bool InsertOrUpdate(SqlSugarScope db, MesDepots entity)
{
db.Deleteable<MesDepots>()
- .Where(s => s.DepotId == entity.DepotId)
- .ExecuteCommand();
+ .Where(s => s.DepotId == entity.DepotId)
+ .ExecuteCommand();
var insert = db.Insertable(entity).ExecuteCommand();
return insert > 0;
@@ -128,27 +98,10 @@
IsFkc = depots.FAllowMinusQty,
CreateBy = depots.FPrincipal,
Depottype = depots.FStockProperty,
- /// <summary>
- /// 鎺ュ彛瀛楁璋冩暣锛氭爣鍑嗙増鎺ュ彛鏂板渚涘簲鍟唅d銆佸鎴穒d銆佹暟鎹姸鎬併�佸簱瀛樼姸鎬佺被鍨嬪瓧娈点��
- /// </summary>
- /// <remarks>
- /// 淇敼浜猴細<姹犲崡楠�>
- /// 淇敼鏃ユ湡锛�<2024-12-30>
- /// 淇敼璇存槑锛�
- /// - 鍘熶唬鐮侊細绌�
- /// - 淇敼鍚庯細
- ///FDOCUMENTSTATUS = supplier.FDocumentStatus,
- /// </remarks>
- FSUPPLIERID = depots.FSupplierId,
- FCUSTOMERID = depots.FCustomerId,
- FDOCUMENTSTATUS = depots.FDocumentStatus,
- FSTOCKSTATUSTYPE = depots.FStockStatusType,
-
-
- IsNg = depots.FForbidStatus,
- Zuid = depots.FGroup,
- CreateOrg= Convert.ToDecimal(depots.FCreateOrgId),
- UseOrg= Convert.ToDecimal(depots.FUseOrgId),
+ IsLot = depots.IsLot,
+ DocumentStatus = depots.FDocumentStatus,
+ ForbidStatus = depots.FForbidStatus,
+ UseOrg = Convert.ToDecimal(depots.FUseOrgId),
CreateDate = DateTime.Now,
Company = "1000",
Factory = "1000"
@@ -158,103 +111,7 @@
// SaveList 鏂规硶鐢ㄤ簬淇濆瓨澶氫釜浠撳簱璁板綍锛屾牴鎹被鍨嬫壒閲忔墽琛屼笉鍚岀殑鎿嶄綔
public bool SaveList(List<ErpDepots> erpDepots)
{
- var list = new List<MesDepots>();
- erpDepots.ForEach(s =>
- {
- var entity = GetMesDepots(s); // 灏� ErpDepots 杞崲涓� MesDepots
- entity.Type = s.Type;
- list.Add(entity);
- });
-
- var groupBy = list.GroupBy(s => s.Type)
- .ToDictionary(g => g.Key, g => g.ToList());
- return UseTransaction(db =>
- {
- foreach (var depotsGroup in groupBy)
- switch (depotsGroup.Key)
- {
- case "0":
- if (!UpdateDepotStatusBatch(db, depotsGroup.Value,
- "A")) // 鎵归噺鍚敤浠撳簱
- throw new NotImplementedException("鍚敤澶辫触");
- break;
- case "1":
- if (!UpdateDepotStatusBatch(db, depotsGroup.Value,
- "B")) // 鎵归噺绂佺敤浠撳簱
- throw new NotImplementedException("绂佺敤澶辫触");
- break;
- //case "2":
- // if (!InsertDepotBatch(db,
- // depotsGroup.Value)) // 鎵归噺鎻掑叆浠撳簱
- // throw new NotImplementedException("鎻掑叆澶辫触");
- // break;
- case "3":
- if (!DeleteDepotBatch(db,
- depotsGroup.Value)) // 鎵归噺鍒犻櫎浠撳簱
- throw new NotImplementedException("鍒犻櫎澶辫触");
- break;
- case "2":
- case "4":
- if (!InsertOrUpdateBatch(db,
- depotsGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂颁粨搴�
- throw new NotImplementedException("鍚屾澶辫触");
- break;
- default:
- throw new ArgumentNullException(
- $"type娌℃湁{depotsGroup.Key}杩欎釜绫诲瀷鐨勫弬鏁�");
- }
-
- return 1;
- }) > 0;
- }
-
- // 鎵归噺鏇存柊浠撳簱鐘舵�佺殑鏂规硶
- private bool UpdateDepotStatusBatch(SqlSugarScope db,
- List<MesDepots> depotList, string status)
- {
- var ids = depotList.Select(it => it.DepotId).ToArray();
- var result = db.Updateable<MesDepots>()
- .SetColumns(s => s.IsNg == status)
- .Where(s => ids.Contains(s.DepotId)).ExecuteCommand();
-
- if (result > 0)
- return true;
-
- throw new NotImplementedException(status == "A" ? "鍚敤澶辫触" : "绂佺敤澶辫触");
- }
-
- // 鎵归噺鎻掑叆浠撳簱鐨勬柟娉�
- private bool InsertDepotBatch(SqlSugarScope db,
- List<MesDepots> depotList)
- {
- var insertRange = db.Insertable(depotList).ExecuteCommand();
- if (insertRange > 0)
- return true;
-
- throw new NotImplementedException("瀹℃牳澶辫触");
- }
-
- // 鎵归噺鍒犻櫎浠撳簱鐨勬柟娉�
- private bool DeleteDepotBatch(SqlSugarScope db,
- List<MesDepots> depotList)
- {
- var ids = depotList.Select(it => it.DepotId).ToArray();
- var deleteByIds =
- db.Deleteable<MesDepots>().In(ids).ExecuteCommand();
- if (deleteByIds > 0)
- return true;
-
- throw new NotImplementedException("鍙嶅鏍稿け璐�");
- }
-
- // 鎵归噺鎻掑叆鎴栨洿鏂颁粨搴撶殑鏂规硶
- private bool InsertOrUpdateBatch(SqlSugarScope db,
- List<MesDepots> depotList)
- {
- foreach (var entity in depotList)
- if (!InsertOrUpdate(db, entity))
- return false;
-
- return true;
+ var result = erpDepots.Select(Save).ToList();
+ return result.All(b => b);
}
}
\ No newline at end of file
--
Gitblit v1.9.3