From 250d7667b3229969a6dd3bc6ebc68d828a266fe8 Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期六, 20 十二月 2025 14:31:19 +0800
Subject: [PATCH] 修改员工初始密码
---
MES.Service/service/WomcaaManager.cs | 243 +++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 227 insertions(+), 16 deletions(-)
diff --git a/MES.Service/service/WomcaaManager.cs b/MES.Service/service/WomcaaManager.cs
index f0fff71..57342c4 100644
--- a/MES.Service/service/WomcaaManager.cs
+++ b/MES.Service/service/WomcaaManager.cs
@@ -3,9 +3,12 @@
using MES.Service.Modes;
using MES.Service.util;
using SqlSugar;
+using System.Data;
namespace MES.Service.service;
-
+/// <summary>
+/// 鐢熶骇璁㈠崟
+/// </summary>
public class WomcaaManager : Repository<Womcaa>
{
//褰撳墠绫诲凡缁忕户鎵夸簡 Repository 澧炪�佸垹銆佹煡銆佹敼鐨勬柟娉�
@@ -65,10 +68,30 @@
if (StringUtil.CheckGuid(mesWomcaa.Guid))
base.DeleteById(mesWomcaa.Guid);
+ //if (mesWomcabs.Count > 0)
+ // db.Deleteable<Womcab>()
+ // .Where(s => s.Pid == mesWomcaa.Erpid).ExecuteCommand();
+ // 鍦ㄦ彃鍏� mesWomcabs 涔嬪墠锛屽厛鍒犻櫎鎵�鏈� Guid 宸插瓨鍦ㄧ殑璁板綍
+ //var guids = mesWomcabs.Select(x => x.Guid).ToList();
+ //if (guids.Count > 0)
+ //{
+ // db.Deleteable<Womcab>().In(x => x.Guid, guids).ExecuteCommand();
+ //}
if (mesWomcabs.Count > 0)
+ {
+ // 鍏堟寜 Pid 鍒犻櫎
db.Deleteable<Womcab>()
.Where(s => s.Pid == mesWomcaa.Erpid).ExecuteCommand();
+
+ // // 鍐嶆寜 Guid 鍒犻櫎锛屽交搴曢伩鍏嶄富閿啿绐�
+ // var guids = mesWomcabs.Select(x => x.Guid).ToList();
+ // db.Deleteable<Womcab>().In(x => x.Guid, guids).ExecuteCommand();
+ }
+
+ //// 妫�鏌� Guid 鏄惁鍞竴
+ //if (mesWomcabs.Select(x => x.Guid).Distinct().Count() != mesWomcabs.Count)
+ // throw new Exception("鍗冲皢鎻掑叆鐨刉omcab鏁版嵁涓瓨鍦ㄩ噸澶嶇殑Guid锛岃妫�鏌ユ暟鎹敓鎴愰�昏緫銆�");
//鍗曟潯鎻掑叆蹇界暐绌哄瓧娈�
var orUpdate = db.Insertable(mesWomcaa)
@@ -170,9 +193,9 @@
SrcBillentryseq = dto.FSrcBillEntrySeq, /// 婧愬崟鍒嗗綍琛屽彿
SaleOrderNo = dto.FSaleOrderNo, /// 闇�姹傚崟鎹彿
SaleOrderEntryseq = dto.FSaleOrderEntrySeq, /// 闇�姹傚崟鎹鍙�
-
-
-
+
+
+ CustNumber = dto.CustNumber, /// 瀹㈡埛缂栧彿
ErpSczz = Convert.ToInt32(dto.FPrdOrgId), /// 鐢熶骇缁勭粐ID
ErpWtzz = Convert.ToInt32(dto.FEnTrustOrgId), /// 濮旀墭缁勭粐ID
Btbz = dto.Btbz, /// 濮旀墭缁勭粐ID
@@ -190,6 +213,104 @@
SynchronousDate = DateTime.Now,
DocumentStatus = dto.FDocumentStatus
};
+
+ //宸ヤ綔涓績缂栫爜杞琁D,Caa021 = dto.FWorkShopID0
+ var entityCaa021 = Db.Queryable<SysDepartment>()
+ .Where(x => x.Departmentcode == dto.FWorkShopID0)
+ .Select(x => x.Id.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityCaa021))
+ {
+ entity.Caa021 = entityCaa021;
+ }
+ else
+ {
+ entity.Caa021 = "0";
+ }
+
+ //浠撳簱缂栫爜杞琁D,DepotCode = dto.FStockId,
+ var entityDepotCode = Db.Queryable<MesDepots>()
+ .Where(x => x.DepotCode == dto.FStockId)
+ .Select(x => x.DepotId.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityDepotCode))
+ {
+ entity.DepotCode = entityDepotCode;
+ }
+ else
+ {
+ entity.DepotCode = "0";
+ }
+
+ //浜у搧(鐗╂枡)缂栫爜杞琁D,Caa006 = dto.FMaterialId, ///
+ var entityCaa006 = Db.Queryable<MesItems>()
+ .Where(x => x.ItemNo == dto.FMaterialId)
+ .Select(x => x.Id.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityCaa006))
+ {
+ entity.Caa006 = entityCaa006;
+ }
+ else
+ {
+ entity.Caa006 = "0";
+ }
+
+ //鍗曚綅缂栫爜杞琁D,Caa009 = dto.FUnitId,
+ var entityCaa009 = Db.Queryable<MesUnit>()
+ .Where(x => x.Fnumber == dto.FUnitId)
+ .Select(x => x.Id.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityCaa009))
+ {
+ entity.Caa009 = entityCaa009;
+ }
+ else
+ {
+ entity.Caa009 = "0";
+ }
+
+ //璁″垝鍛樼紪鐮佽浆ID,PlanId = dto.FPlannerID,
+ var entityPlanId = Db.Queryable<MesStaff>()
+ .Where(x => x.StaffNo == dto.FPlannerID)
+ .Select(x => x.Id.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityPlanId))
+ {
+ entity.PlanId = entityPlanId;
+ }
+ else
+ {
+ entity.PlanId = "0";
+ }
+
+ //缁撴浜虹紪鐮佽浆ID,ForceCloserid = dto.FForceCloserId,
+ var entityForceCloserid = Db.Queryable<MesStaff>()
+ .Where(x => x.StaffNo == dto.FForceCloserId)
+ .Select(x => x.Id.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityForceCloserid))
+ {
+ entity.ForceCloserid = entityForceCloserid;
+ }
+ else
+ {
+ entity.ForceCloserid = "0";
+ }
+
+ //瀹㈡埛缂栫爜杞琁D,CustNumber = dto.CustNumber,
+ var entityCustNumber = Db.Queryable<MesStaff>()
+ .Where(x => x.StaffNo == dto.CustNumber)
+ .Select(x => x.Id.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityCustNumber))
+ {
+ entity.CustNumber = entityCustNumber;
+ }
+ else
+ {
+ entity.CustNumber = "0";
+ }
//鏍规嵁鍗曞彿+鍗曞埆锛岃幏鍙栧搴旂殑id
var singleId = Db.Queryable<Womcaa>()
@@ -273,6 +394,34 @@
// ParentItemName = dto.F_XIFG_Base_apv /// 鐖堕」鐗╂枡鍚嶇О
};
+ //浠撳簱缂栫爜杞琁D,DepotCode = dto.FStockID,
+ var entityDepotCode = Db.Queryable<MesDepots>()
+ .Where(x => x.DepotCode == dto.FStockID)
+ .Select(x => x.DepotId.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityDepotCode))
+ {
+ womcab.DepotCode = entityDepotCode;
+ }
+ else
+ {
+ womcab.DepotCode = "0";
+ }
+
+ //鍗曚綅缂栫爜杞琁D,Cab009 = dto.FUnitID,
+ var entityCab009 = Db.Queryable<MesUnit>()
+ .Where(x => x.Fnumber == dto.FUnitID)
+ .Select(x => x.Id.ToString())
+ .First();
+ if (!string.IsNullOrWhiteSpace(entityCab009))
+ {
+ womcab.Cab009 = entityCab009;
+ }
+ else
+ {
+ womcab.Cab009 = "0";
+ }
+
//鏍规嵁鍗曞彿+鍗曞埆+鏉愭枡鍝佸彿锛岃幏鍙栧搴旂殑id
var singleId = Db.Queryable<Womcab>()
.Where(x => x.Cab001 == dto.FBillNo && x.Cab003 == dto.FMaterialID2 && x.Cab002 == Convert.ToInt32(dto.FBillNoType))
@@ -291,11 +440,12 @@
}
var entity = Db.Queryable<Womcab>()
- .Where(s => s.Eid == womcab.Eid).Single();
+ .Where(s => s.Cab001 == womcab.Cab001 && s.Cab002 == womcab.Cab002 && s.Cab003 == womcab.Cab003)
+ .Single();
if (entity != null)
womcab.Guid = entity.Guid;
else
- womcab.Guid = Guid.NewGuid();
+ womcab.Guid = Guid.NewGuid(); // 纭繚姣忔潯鏂版暟鎹敮涓�
womcabList.Add(womcab);
}
@@ -303,22 +453,50 @@
return womcabList;
}
+ ///// <summary>
+ ///// 鐢熸垚鏂扮殑涓昏〃ID锛岀‘淇濅笉閲嶅
+ ///// </summary>
+ //private decimal GenerateNewId()
+ //{
+ // // 澶勭悊绌鸿〃鐨勬儏鍐碉紝浠�1寮�濮�
+ // var maxId = Db.Queryable<Womcaa>().Max(x => (decimal?)x.Erpid) ?? 0;
+ // var newId = maxId + 1;
+
+ // // 鍙岄噸妫�鏌ワ紝纭繚鐢熸垚鐨処D涓嶅瓨鍦�
+ // while (Db.Queryable<Womcaa>().Where(x => x.Erpid == newId).Any())
+ // {
+ // newId++;
+ // }
+
+ // return newId;
+ //}
+
/// <summary>
- /// 鐢熸垚鏂扮殑涓昏〃ID锛岀‘淇濅笉閲嶅
+ /// 鐢熸垚鏂扮殑涓昏〃ID锛岄�氳繃鏁版嵁搴撳簭鍒楄幏鍙栧敮涓�ID
/// </summary>
private decimal GenerateNewId()
{
- // 澶勭悊绌鸿〃鐨勬儏鍐碉紝浠�1寮�濮�
- var maxId = Db.Queryable<Womcaa>().Max(x => (decimal?)x.Erpid) ?? 0;
- var newId = maxId + 1;
-
- // 鍙岄噸妫�鏌ワ紝纭繚鐢熸垚鐨処D涓嶅瓨鍦�
- while (Db.Queryable<Womcaa>().Where(x => x.Erpid == newId).Any())
+ try
{
- newId++;
- }
+ // 鏇挎崲涓猴細
+ var sequenceValueObj = Db.Ado.GetScalar("SELECT NEXT VALUE FOR MES_WOMCAB_IN_seq");
+ var sequenceValue = Convert.ToDecimal(sequenceValueObj);
+ // 楠岃瘉搴忓垪鍊兼槸鍚︽湁鏁�
+ if (sequenceValue <= 0)
+ {
+ throw new InvalidOperationException($"鏁版嵁搴撳簭鍒� MES_WOMCAB_IN_seq 杩斿洖浜嗘棤鏁堢殑鍊�: {sequenceValue}");
+ }
- return newId;
+ return sequenceValue;
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍寮傚父淇℃伅
+ Console.WriteLine($"璋冪敤鏁版嵁搴撳簭鍒� MES_WOMCAB_IN_seq 澶辫触: {ex.Message}");
+
+ // 鍚戜笂灞傛姏鍑烘槑纭殑寮傚父淇℃伅
+ throw new InvalidOperationException($"鐢熸垚瀛愯〃ID澶辫触锛屾棤娉曡幏鍙栨暟鎹簱搴忓垪鍊�: {ex.Message}", ex);
+ }
}
/// <summary>
@@ -348,4 +526,37 @@
throw new InvalidOperationException($"鐢熸垚瀛愯〃ID澶辫触锛屾棤娉曡幏鍙栨暟鎹簱搴忓垪鍊�: {ex.Message}", ex);
}
}
+ //鍞竴閿粍鍚堬細涓昏〃灏辨槸宸ュ崟鍗曞埆+宸ュ崟鍗曞彿锛屽瓙琛ㄦ槸宸ュ崟鍗曞彿+宸ュ崟鍗曞彿+鏉愭枡鍝佸彿
+
+ /// <summary>
+ /// 鏁村崟鍒犻櫎锛岃皟鐢ㄥ瓨鍌ㄨ繃绋�
+ /// </summary>
+ /// <param name="billNo">鍗曞彿</param>
+ /// <returns>琚垹闄ょ殑鍗曞彿</returns>
+ public (int outSum, string outMsg) Delete(string FBillNo, string FBillTypeID)
+ {
+ try
+ {
+ var outMsg = string.Empty;
+ var outSum = 0;
+
+ var parameters = new List<SugarParameter>
+ {
+ new SugarParameter("@FBillNo", FBillNo),
+ new SugarParameter("@FBillTypeID", FBillTypeID),
+ new SugarParameter("@outMsg", outMsg, typeof(string), ParameterDirection.Output, 2500),
+ new SugarParameter("@outSum", outSum, typeof(int), ParameterDirection.Output)
+ };
+
+ Db.Ado.UseStoredProcedure().ExecuteCommand("ERP_DeleteWomcaaByBillNo", parameters);
+
+ outMsg = parameters[2].Value?.ToString() ?? "";
+ outSum = parameters[3].Value != null ? Convert.ToInt32(parameters[index: 3].Value) : -1;
+ return (outSum, outMsg);
+ }
+ catch (Exception ex)
+ {
+ throw new InvalidOperationException($"璋冪敤瀛樺偍杩囩▼ ERP_DeleteWomcaaByBillNo 澶辫触: {ex.Message}", ex);
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3