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 | 244 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 203 insertions(+), 41 deletions(-)
diff --git a/MES.Service/service/WomcaaManager.cs b/MES.Service/service/WomcaaManager.cs
index 0672037..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 澧炪�佸垹銆佹煡銆佹敼鐨勬柟娉�
@@ -190,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
@@ -210,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>()
@@ -293,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))
@@ -324,51 +453,51 @@
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()
//{
- // try
- // {
- // // 鏇挎崲涓猴細
- // 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}");
- // }
+ // // 澶勭悊绌鸿〃鐨勬儏鍐碉紝浠�1寮�濮�
+ // var maxId = Db.Queryable<Womcaa>().Max(x => (decimal?)x.Erpid) ?? 0;
+ // var newId = maxId + 1;
- // return sequenceValue;
- // }
- // catch (Exception ex)
+ // // 鍙岄噸妫�鏌ワ紝纭繚鐢熸垚鐨処D涓嶅瓨鍦�
+ // while (Db.Queryable<Womcaa>().Where(x => x.Erpid == newId).Any())
// {
- // // 璁板綍寮傚父淇℃伅
- // Console.WriteLine($"璋冪敤鏁版嵁搴撳簭鍒� MES_WOMCAB_IN_seq 澶辫触: {ex.Message}");
-
- // // 鍚戜笂灞傛姏鍑烘槑纭殑寮傚父淇℃伅
- // throw new InvalidOperationException($"鐢熸垚瀛愯〃ID澶辫触锛屾棤娉曡幏鍙栨暟鎹簱搴忓垪鍊�: {ex.Message}", ex);
+ // newId++;
// }
+
+ // return newId;
//}
+
+ /// <summary>
+ /// 鐢熸垚鏂扮殑涓昏〃ID锛岄�氳繃鏁版嵁搴撳簭鍒楄幏鍙栧敮涓�ID
+ /// </summary>
+ private decimal GenerateNewId()
+ {
+ try
+ {
+ // 鏇挎崲涓猴細
+ 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 sequenceValue;
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍寮傚父淇℃伅
+ Console.WriteLine($"璋冪敤鏁版嵁搴撳簭鍒� MES_WOMCAB_IN_seq 澶辫触: {ex.Message}");
+
+ // 鍚戜笂灞傛姏鍑烘槑纭殑寮傚父淇℃伅
+ throw new InvalidOperationException($"鐢熸垚瀛愯〃ID澶辫触锛屾棤娉曡幏鍙栨暟鎹簱搴忓垪鍊�: {ex.Message}", ex);
+ }
+ }
/// <summary>
/// 鐢熸垚鏂扮殑瀛愯〃ID锛岄�氳繃鏁版嵁搴撳簭鍒楄幏鍙栧敮涓�ID
@@ -397,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