From 174707ef5fb6cc8e2b0f973b5f7345e7b89b2d77 Mon Sep 17 00:00:00 2001
From: zyf <1071160500@qq.com>
Date: 星期四, 04 十二月 2025 19:48:27 +0800
Subject: [PATCH] 修复字段类型bug,入库检提交更新结果
---
MES.Service/service/QC/RKJService.cs | 594 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 482 insertions(+), 112 deletions(-)
diff --git a/MES.Service/service/QC/RKJService.cs b/MES.Service/service/QC/RKJService.cs
index bdcaa01..f74a86b 100644
--- a/MES.Service/service/QC/RKJService.cs
+++ b/MES.Service/service/QC/RKJService.cs
@@ -2,7 +2,9 @@
using MES.Service.Dto.service;
using MES.Service.Modes;
using MES.Service.util;
+using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
using SqlSugar;
+using SqlSugar.Extensions;
namespace MES.Service.service.QC;
@@ -67,107 +69,170 @@
//鏍规嵁妫�楠屾爣鍑嗘潵璁$畻妫�楠屼釜鏁�
public List<QsItemOqcItem> SetItems(string itemNo, decimal quantity)
{
+ // 鍙傛暟楠岃瘉
+ if (string.IsNullOrWhiteSpace(itemNo))
+ throw new ArgumentException("鐗╂枡缂栧彿涓嶈兘涓虹┖", nameof(itemNo));
+
+ if (quantity <= 0)
+ throw new ArgumentException("鏁伴噺蹇呴』澶т簬0", nameof(quantity));
+
var db = SqlSugarHelper.GetInstance();
- var count = db.Queryable<MesQa>().Where(s => s.QsType == "3"
- && s.ItemNo == itemNo && s.Fsubmit == 1).Count();
+ // 楠岃瘉鐗╂枡鏄惁瀛樺湪妫�楠屾爣鍑�
+ var count = db.Queryable<MesQa>()
+ .Where(s => s.QsType == "3" && s.ItemNo == itemNo && s.Fsubmit == 1)
+ .Count();
- if (count <= 0) return [];
+ if (count <= 0)
+ return [];
- var qsItemOqcItems = db
- .Queryable<MesQualityStandard>()
- .Where(b => b.QsType == "3"
- && b.ItemNo == itemNo).Select(
- b => new QsItemOqcItem
- {
- ProjName = b.ProjName,
- ItemMod = b.ItemMod,
- InspectionMethod = b.InspectionMethod,
- UsingInstruments = b.UsingInstruments,
- LevelNum = SqlFunc.IsNull(
- SqlFunc.IsNull(b.LevelNum * b.InspectionLevel, 1),
- b.InspectionLevel),
- MaxValue = b.MaxValue,
- StandardValue = b.StandardValue,
- MinValue = b.MinValue,
- Notes = b.Notes,
- FcheckLevel = b.FcheckLevel,
- FacLevel = b.FacLevel,
- QsCode = b.QsCode,
- QsName = b.QsName,
- Result = "鏈娴�",
- isCheck = 0,
- Picture = b.Picture,
- Picturename = b.Picturename
- }).ToList();
+ decimal? ID = db.Queryable<MesQa>()
+ .Where(s => s.QsType == "3" && s.ItemNo == itemNo && s.Fsubmit == 1)
+ .Select(s => s.Id)
+ .First();
- qsItemOqcItems.ForEach(item =>
- {
- string LEV = null;
- switch (item.FcheckLevel)
+ // 鑾峰彇璐ㄩ噺鏍囧噯
+ var qsItemOqcItems = db.Queryable<MesQualityStandard>()
+ .Where(b => b.QsType == "3" && b.Pid == ID)
+ .Select(b => new QsItemOqcItem
{
- case string s when s.Contains("S1"):
- LEV = "B.FLEVEL_S1";
- break;
- case string s when s.Contains("S2"):
- LEV = "B.FLEVEL_S2";
- break;
- case string s when s.Contains("S3"):
- LEV = "B.FLEVEL_S3";
- break;
- case string s when s.Contains("S4"):
- LEV = "B.FLEVEL_S4";
- break;
- case string s when s.Contains("(I)"):
- LEV = "B.FLEVEL_I";
- break;
- case string s when s.Contains("(II)"):
- LEV = "B.FLEVEL_II";
- break;
- case string s when s.Contains("(III)"):
- LEV = "B.FLEVEL_III";
- break;
- default:
- LEV = ""; // 榛樿鍊�
- break;
+ ProjName = b.ProjName,
+ ItemMod = b.ItemMod,
+ InspectionMethod = b.InspectionMethod,
+ UsingInstruments = b.UsingInstruments,
+ LevelNum = SqlFunc.IsNull(
+ SqlFunc.IsNull(b.LevelNum * b.InspectionLevel, 1),
+ b.InspectionLevel),
+ MaxValue = b.MaxValue,
+ StandardValue = b.StandardValue,
+ MinValue = b.MinValue,
+ Notes = b.Notes,
+ FcheckLevel = b.FcheckLevel,
+ FacLevel = b.FacLevel,
+ QsCode = b.QsCode,
+ QsName = b.QsName,
+ Result = "鏈娴�",
+ isCheck = 0,
+ Picture = b.Picture,
+ Picturename = b.Picturename
+ }).ToList();
+
+ if (!qsItemOqcItems.Any())
+ return [];
+
+ // 澶勭悊姣忎釜妫�楠岄」鐩�
+ foreach (var item in qsItemOqcItems)
+ {
+ try
+ {
+ ProcessQualityItem(db, item, quantity);
}
-
- var sql =
- "SELECT " + LEV +
- " FROM MES_QM_AQL1 A LEFT JOIN MES_QM_AQL2 B ON B.AQL1_ID=A.ID WHERE A.SAMPLE_SIZE_NO='" +
- item.QsCode + "' AND B.LOT_FROM<= " + quantity + " AND " +
- quantity + "<=B.LOT_TO";
-
- var maxBillNo = db.Ado.SqlQuerySingle<string>(sql);
-
-
- var result = ExtractSubstring(item.FacLevel, '(', ')');
-
-
- sql = "SELECT FSAMPLE_SIZE_WORD, " + result +
- " Result FROM MES_QM_AQL1 A LEFT JOIN MES_QM_AQL3 C ON C.AQL1_ID=A.ID WHERE A.SAMPLE_SIZE_NO= '" +
- item.QsCode + "' AND SAMPLE_SIZE_WORD= '" + maxBillNo + "'";
- var resultClass = db.Ado.SqlQuerySingle<ResultClass>(sql);
-
- item.LevelNum = resultClass.FSAMPLE_SIZE_WORD;
- item.FreQty = resultClass.Result;
- });
+ catch (Exception ex)
+ {
+ // 璁板綍閿欒浣嗙户缁鐞嗗叾浠栭」鐩�
+ item.LevelNum = 1; // 璁剧疆榛樿鍊�
+ item.FreQty = 0;
+ item.Notes = $"澶勭悊寮傚父: {ex.Message}";
+ }
+ }
return qsItemOqcItems;
}
+ private void ProcessQualityItem(ISqlSugarClient db, QsItemOqcItem item,
+ decimal quantity)
+ {
+ // 楠岃瘉蹇呰瀛楁
+ if (string.IsNullOrWhiteSpace(item.FcheckLevel) ||
+ string.IsNullOrWhiteSpace(item.QsCode))
+ {
+ item.LevelNum = 1;
+ item.FreQty = 0;
+ return;
+ }
+
+ // 鑾峰彇妫�楠岀骇鍒搴旂殑鏁版嵁搴撳瓧娈�
+ var levelField = GetLevelField(item.FcheckLevel);
+
+ // 浣跨敤鍙傛暟鍖栨煡璇㈤槻姝QL娉ㄥ叆
+ var sql =
+ $"SELECT {levelField} FROM MES_QM_AQL1 A LEFT JOIN MES_QM_AQL2 B ON B.AQL1_ID = A.ID " +
+ $"WHERE A.SAMPLE_SIZE_NO = @QsCode AND B.LOT_FROM <= @Quantity AND @Quantity <= B.LOT_TO";
+
+ var aqlResult = db.Ado.SqlQuerySingle<string>(sql,
+ new { QsCode = item.QsCode, Quantity = quantity });
+
+ if (string.IsNullOrWhiteSpace(aqlResult))
+ {
+ item.LevelNum = 1;
+ item.FreQty = 0;
+ return;
+ }
+
+ // 鎻愬彇FacLevel涓殑鍊�
+ var facLevelValue = ExtractSubstring(item.FacLevel ?? "", '(', ')');
+ if (string.IsNullOrWhiteSpace(facLevelValue))
+ {
+ item.LevelNum =
+ decimal.TryParse(aqlResult, out var level) ? level : 1;
+ item.FreQty = 0;
+ return;
+ }
+
+ // 鑾峰彇鏍锋湰澶у皬鍜岀粨鏋�
+ var resultSql =
+ $"SELECT FSAMPLE_SIZE_WORD, {facLevelValue} as Result FROM MES_QM_AQL1 A " +
+ $"LEFT JOIN MES_QM_AQL3 C ON C.AQL1_ID = A.ID " +
+ $"WHERE A.SAMPLE_SIZE_NO = @QsCode AND SAMPLE_SIZE_WORD = @LevelValue";
+
+ var resultQuery = db.Ado.SqlQuerySingle<ResultClass>(resultSql,
+ new { QsCode = item.QsCode, LevelValue = aqlResult });
+
+ if (resultQuery != null)
+ {
+ item.LevelNum = resultQuery.FSAMPLE_SIZE_WORD;
+ item.FreQty = resultQuery.Result;
+ }
+ else
+ {
+ item.LevelNum = 1;
+ item.FreQty = 0;
+ }
+ }
+
+ private string GetLevelField(string checkLevel)
+ {
+ if (string.IsNullOrWhiteSpace(checkLevel))
+ return "B.FLEVEL_S1";
+
+ return checkLevel switch
+ {
+ var s when s.Contains("S1") => "B.FLEVEL_S1",
+ var s when s.Contains("S2") => "B.FLEVEL_S2",
+ var s when s.Contains("S3") => "B.FLEVEL_S3",
+ var s when s.Contains("S4") => "B.FLEVEL_S4",
+ var s when s.Contains("(I)") => "B.FLEVEL_I",
+ var s when s.Contains("(II)") => "B.FLEVEL_II",
+ var s when s.Contains("(III)") => "B.FLEVEL_III",
+ _ => "B.FLEVEL_S1"
+ };
+ }
+
private string ExtractSubstring(string input, char startChar, char endChar)
{
- var startIndex = input.IndexOf(startChar);
- var endIndex = input.IndexOf(endChar, startIndex);
-
- if (startIndex == -1 || endIndex == -1)
- // 濡傛灉鏈壘鍒拌捣濮嬪瓧绗︽垨缁撴潫瀛楃锛屽垯杩斿洖绌哄瓧绗︿覆鎴栬�呮姏鍑哄紓甯革紝鏍规嵁瀹為檯鎯呭喌閫夋嫨
+ if (string.IsNullOrWhiteSpace(input))
return string.Empty;
- // 鎴栬�呮姏鍑哄紓甯�
- // throw new ArgumentException("Start or end character not found");
- // 鎻愬彇瀛愬瓧绗︿覆
+
+ var startIndex = input.IndexOf(startChar);
+ var endIndex = input.IndexOf(endChar, startIndex + 1);
+
+ if (startIndex == -1 || endIndex == -1 || endIndex <= startIndex)
+ return string.Empty;
+
var length = endIndex - startIndex - 1;
+ if (length <= 0)
+ return string.Empty;
+
return input.Substring(startIndex + 1, length);
}
@@ -233,9 +298,11 @@
xj.CreateBy = userNo;
xj.CreateDate = DateTime.Now;
- var pid = db.Insertable(xj).ExecuteReturnIdentity();
+ // var pid = db.Insertable(xj).ExecuteReturnIdentity();
- xj.Id = pid;
+ var pid = (int)xj.Id;
+
+ // xj.Id = pid;
rkjDto.gid = pid;
@@ -355,8 +422,8 @@
result = 1;
else if (count - passCount < QsItemOqcItem.FreQty) result = 1;
- var useTransactionWithOracle = SqlSugarHelper.UseTransactionWithOracle(
- db =>
+ var useTransactionWithOracle =
+ SqlSugarHelper.UseTransactionWithOracle(db =>
{
var commit = 0;
commit += db.Updateable<QsItemOqcItem>()
@@ -454,38 +521,54 @@
}
- public (List<QsItemOqcReq> items, int TotalCount) GetPage(XJPageResult queryObj)
+ public (List<QsItemOqcReq> items, int TotalCount) GetPage(
+ XJPageResult queryObj)
{
var db = SqlSugarHelper.GetInstance();
var totalCount = 0;
- // 鑾峰彇鐢ㄦ埛鍏宠仈鐨勭嚎浣撶紪鍙�
- string[] lineNo = null;
- if (!string.IsNullOrEmpty(queryObj.createUser))
- {
- lineNo = _baseService.getUserLineNo(queryObj.createUser);
- }
- var query = db.Queryable<QsItemOqcReq, MesItems, Womdaa>((a, b, da) =>
- new JoinQueryInfos(
- JoinType.Left, a.ItemNo == b.ItemNo, // 鍏宠仈鐗╂枡淇℃伅
- JoinType.Left, a.BillNo == da.Daa001 // 鍏宠仈宸ュ崟淇℃伅
- ))
+ var query = db
+ .Queryable<QsItemOqcReq, MesItems, Womdaa, MesLine, SysUser, Womcaa,
+ SysDepartment, MesUserDepartmentQc, SysUser>((a, b,
+ da, c, us, ca, d, dq, us2) =>
+ new JoinQueryInfos(
+ JoinType.Left, a.ItemNo == b.ItemNo, // 鍏宠仈鐗╂枡淇℃伅
+ JoinType.Left, a.BillNo == da.Daa001, // 鍏宠仈宸ュ崟淇℃伅
+ JoinType.Left, da.Daa015 == c.LineNo, // 鍏宠仈宸ュ崟淇℃伅
+ JoinType.Left, us.Fcode == a.CreateBy, // 鍏宠仈宸ュ崟淇℃伅
+ JoinType.Left, da.Daa021 == ca.Caa020, //浠诲姟鍗曪紝鐢ㄤ簬鏌ヨ閿�鍞鍗曞彿
+ JoinType.Left,
+ d.Departmentid == Convert.ToDecimal(da.Daa013), //鏌ヨ杞﹂棿
+ JoinType.Left,
+ dq.Departmentcode == d.Departmentcode, //鏌ヨ鐢ㄦ埛鏉冮檺
+ JoinType.Left, us2.Fcode == a.FcheckBy
+ ))
// 鐢ㄦ埛绾夸綋杩囨护鏉′欢
//.WhereIF(lineNo != null && lineNo.Length > 0 && !"PL017".Equals(queryObj.createUser),
// (a, b, da) => lineNo.Contains(da.Daa015))
// ID绮剧‘鏌ヨ
.WhereIF(!string.IsNullOrEmpty(queryObj.id),
- (a, b, da) => a.Id.ToString() == queryObj.id)
+ (a, b, da, c, us) => a.Id.ToString() == queryObj.id)
// 瀹屾垚鐘舵�佽繃婊�
- .WhereIF("鏈畬鎴�".Equals(queryObj.result), (a, b, da) => a.FcheckResu == null)
- .WhereIF(!"鏈畬鎴�".Equals(queryObj.result), (a, b, da) => a.FcheckResu != null)
+ .WhereIF("鏈畬鎴�".Equals(queryObj.result),
+ (a, b, da, c, us) => a.Fsubmit == null || a.Fsubmit == 0)
+ .WhereIF(!"鏈畬鎴�".Equals(queryObj.result),
+ (a, b, da, c, us) => a.Fsubmit == 1)
// 鎼滅储鏉′欢锛堢墿鏂欏悕绉�/缂栧彿锛�
.WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue),
- (a, b, da) => b.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()) ||
- a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+ (a, b, da, c, us, ca) =>
+ b.ItemName.ToLower()
+ .Contains(queryObj.SearchValue.ToLower()) ||
+ ca.Caa015.ToLower()
+ .Contains(queryObj.SearchValue.ToLower()) ||
+ a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+ // 鏂板锛氱敤鎴穋ode杩囨护
+ .WhereIF(!string.IsNullOrEmpty(queryObj.LoginUser),
+ (a, b, da, c, us, ca, d, dq) =>
+ dq.Usercode == queryObj.LoginUser)
// 鏌ヨ瀛楁
- .Select((a, b, da) => new QsItemOqcReq
+ .Select((a, b, da, c, us, ca, d, dq, us2) => new QsItemOqcReq
{
Id = a.Id,
BillNo = a.BillNo,
@@ -494,19 +577,26 @@
ItemModel = b.ItemModel,
CreateDate = a.CreateDate,
CreateBy = a.CreateBy,
+ CreateUser = us.Fname == null ? a.CreateBy : us.Fname,
FcheckResu = a.FcheckResu,
- FcheckBy = a.FcheckBy,
+ FcheckBy = us2.Fname, //a.FcheckBy,
FcheckDate = a.FcheckDate,
ReleaseNo = a.ReleaseNo,
Remarks = a.Remarks,
- Daa015 = da.Daa015, // 宸ュ崟绾夸綋
- Fsubmit = a.Fsubmit
+ Daa015 =
+ d.Departmentname == "娉ㄥ杞﹂棿" ? da.Daa020 : da.Daa015, // 宸ュ崟绾夸綋
+ Fsubmit = a.Fsubmit,
+ Quantity = da.Daa008,
+ LineNo = d.Departmentname == "娉ㄥ杞﹂棿" ? da.Daa020 : c.LineName,
+ SaleOrderNo = ca.Caa015,
+ DepartName = d.Departmentname
})
// 鎺掑簭
.OrderBy(a => a.CreateDate, OrderByType.Desc);
// 鍒嗛〉鏌ヨ
- var result = query.ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
+ var result = query.ToPageList(queryObj.PageIndex, queryObj.Limit,
+ ref totalCount);
return (result, totalCount);
}
@@ -531,6 +621,18 @@
});
return withOracle;
+ }
+
+ public int saveNotesPid(RKJDto dto)
+ {
+ return SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ return db.Updateable<QsItemOqcItem>()
+ .SetColumns(it =>
+ it.Notes == dto.Remarks) //SetColumns鏄彲浠ュ彔鍔犵殑 鍐�2涓氨2涓瓧娈佃祴鍊�
+ .Where(it => it.Id == dto.pid)
+ .ExecuteCommand();
+ });
}
@@ -631,11 +733,279 @@
});
}
+ // 鍘熷saveItem鏂规硶锛堝凡浼樺寲锛屽浠界増鏈湪saveItemOriginal锛�
public int saveItem(RKJDto rkjDto)
{
var items = rkjDto.items;
var userNo = rkjDto.userNo;
+ return SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ var commit = 0;
+
+ // 1. 娓呯┖鐜版湁鐨勬楠岃缁嗚褰曪紙瀛欒〃锛�
+ commit += db.Deleteable<QsItemOqcItemDetail>()
+ .Where(s => s.Gid == rkjDto.gid)
+ .ExecuteCommand();
+
+ // 2. 娓呯┖鐜版湁鐨勬楠岄」鐩褰曪紙瀛愯〃锛�
+ commit += db.Deleteable<QsItemOqcItem>()
+ .Where(s => s.Pid == rkjDto.gid)
+ .ExecuteCommand();
+
+ // 3. 鎵归噺鎻掑叆items
+ foreach (var item in items) item.Pid = rkjDto.gid;
+ commit += db.Insertable(items).ExecuteCommand();
+
+ // 4. 鑾峰彇闇�瑕佸鐞嗙殑妫�楠岄」鐩紙鍙煡璇㈠繀瑕佸瓧娈垫彁鍗囨�ц兘锛�
+ var processItems = db.Queryable<QsItemOqcItem>()
+ .Where(s => s.Pid == rkjDto.gid &&
+ s.MaxValue == null && s.StandardValue == null &&
+ s.MinValue == null)
+ .Select(s => new { s.Id, s.LevelNum })
+ .ToList();
+
+ if (!processItems.Any())
+ {
+ return Convert.ToInt32(rkjDto.gid);
+ }
+
+ // 5. 鎵归噺鍒涘缓鎵�鏈塓sItemOqcItemDetail
+ var allDetails = new List<QsItemOqcItemDetail>();
+ foreach (var item in processItems)
+ {
+ var levelNum = (int)(item.LevelNum ?? 1);
+ for (int i = 0; i < levelNum; i++)
+ {
+ allDetails.Add(new QsItemOqcItemDetail
+ {
+ Gid = rkjDto.gid,
+ Pid = item.Id,
+ Fstand = "鈭�",
+ FcheckResu = "1",
+ CreateBy = userNo,
+ CreateDate = DateTime.Now
+ });
+ }
+ }
+
+ // 6. 鎵归噺鎻掑叆鎵�鏈塪etails
+ if (allDetails.Any())
+ {
+ commit += db.Insertable(allDetails).ExecuteCommand();
+ }
+
+ // 7. 鎵归噺鏇存柊IsPass鐘舵�佷负鍚堟牸锛堝洜涓烘墍鏈塪etail閮芥槸鍚堟牸鐨勶級
+ var itemIds = processItems.Select(x => x.Id).ToList();
+ if (itemIds.Any())
+ {
+ commit += db.Updateable<QsItemOqcItem>()
+ .SetColumns(s => s.IsPass == 1)
+ .Where(s => itemIds.Contains(s.Id))
+ .ExecuteCommand();
+ }
+
+ // 8. 妫�鏌ュ苟鏇存柊涓绘楠屽崟鐘舵��
+ commit += UpdateMainInspectionStatus(db, rkjDto.gid, userNo);
+
+ return Convert.ToInt32(rkjDto.gid);
+ });
+ }
+
+ private int UpdateMainInspectionStatus(ISqlSugarClient db, decimal? gid,
+ string userNo)
+ {
+ // 妫�鏌ユ槸鍚﹁繕鏈夋湭瀹屾垚鐨勬楠岄」鐩�
+ var unfinishedCount = db.Queryable<QsItemOqcItem>()
+ .Where(s => s.Pid == gid && s.IsPass == null)
+ .Count();
+
+ if (unfinishedCount > 0)
+ {
+ return 0; // 杩樻湁鏈畬鎴愮殑椤圭洰锛屼笉鏇存柊涓绘楠屽崟鐘舵��
+ }
+
+ // 鑾峰彇妫�楠屽崟鐨勬楠岄」鐩�绘暟鍜屽悎鏍兼暟
+ var totalCount = db.Queryable<QsItemOqcItem>()
+ .Where(s => s.Pid == gid)
+ .Count();
+
+ if (totalCount == 0)
+ {
+ return 0; // 娌℃湁妫�楠岄」鐩�
+ }
+
+ var passedCount = db.Queryable<QsItemOqcItem>()
+ .Where(s => s.Pid == gid && s.IsPass == 1)
+ .Count();
+
+ // 纭畾妫�楠岀粨鏋�
+ var checkResult = totalCount == passedCount ? "鍚堟牸" : "涓嶅悎鏍�";
+
+ // 鏇存柊涓绘楠屽崟鐘舵��
+ var updateResult = db.Updateable<QsItemOqcReq>()
+ .SetColumns(s => s.FcheckResu == checkResult)
+ .SetColumns(s => s.FcheckDate == DateTime.Now)
+ .SetColumns(s => s.FcheckBy == userNo)
+ .SetColumns(s => s.LastupdateBy == userNo)
+ .SetColumns(s => s.LastupdateDate == DateTime.Now)
+ .Where(s => s.Id == gid)
+ .ExecuteCommand();
+
+ // 濡傛灉妫�楠屼笉鍚堟牸锛岀敓鎴愬紓甯稿绛栬褰�
+ if (checkResult.Equals("涓嶅悎鏍�"))
+ {
+ GenerateQualityIssueRecord(db, gid, userNo);
+ }
+
+ return updateResult;
+ }
+
+ private void GenerateQualityIssueRecord(ISqlSugarClient db, decimal? gid,
+ string userNo)
+ {
+ try
+ {
+ var qsItemOqcReq = db.Queryable<QsItemOqcReq>()
+ .Single(s => s.Id == gid);
+
+ if (qsItemOqcReq == null) return;
+
+ var mesInvItemIns = db.Queryable<MesInvItemIns>()
+ .Single(s => s.BillNo == qsItemOqcReq.BillNo);
+
+ if (mesInvItemIns == null) return;
+
+ var mesSchemeResult = db.Queryable<Womdaa>()
+ .Single(s => s.Daa001 == mesInvItemIns.CbillNo);
+
+ if (mesSchemeResult == null) return;
+
+ var entity = new MesQaItemsDetect02
+ {
+ LineNo = mesSchemeResult.Daa015,
+ ReleaseNo = qsItemOqcReq.ReleaseNo,
+ LotNo = qsItemOqcReq.BillNo,
+ FcheckDate = qsItemOqcReq.FcheckDate,
+ FcheckMemo = qsItemOqcReq.Remarks,
+ Gid = qsItemOqcReq.Id,
+ FcheckResu = "涓嶅悎鏍�",
+ FcheckLevel = "涓ラ噸",
+ CreateDate = DateTime.Now,
+ Factory = "10000",
+ Company = "1000",
+ Ftype = "4",
+ Fversion = 0,
+ Modify1Flag = 0,
+ IpqcStatus = 0,
+ Fsubmit = 1,
+ CreateBy = userNo,
+ FcheckBy = userNo
+ };
+
+ db.Insertable(entity).ExecuteCommand();
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍寮傚父浣嗕笉褰卞搷涓绘祦绋�
+ // 鍙互鑰冭檻娣诲姞鏃ュ織璁板綍
+ Console.WriteLine($"鐢熸垚璐ㄩ噺寮傚父璁板綍澶辫触: {ex.Message}");
+ }
+ }
+
+ public int IqcQaSubmit(RKJDto dto)
+ {
+ var useTransactionWithOracle =
+ SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ return db.Updateable<QsItemOqcReq>()
+ .SetColumns(a => a.Fsubmit == 1)
+ .SetColumns(a => a.FsubmitBy == dto.userNo)
+ .SetColumns(a => a.FsubmitDate == DateTime.Now)
+ .Where(a => a.ReleaseNo == dto.releaseNo)
+ .ExecuteCommand();
+ });
+
+ var P_NO = new SugarParameter("P_NO", dto.releaseNo);
+
+ var db = SqlSugarHelper.GetInstance();
+ var FRes = new SugarParameter("c_result", null, true); // 杈撳嚭鍙傛暟
+ var FMsg = new SugarParameter("c_msg", null, true);
+
+ // 鎵ц瀛樺偍杩囩▼
+ db.Ado.UseStoredProcedure().GetDataTable("PRC_RKJ_UPDATE_RESU_JK",P_NO,FRes, FMsg);
+
+ // 鑾峰彇杈撳嚭缁撴灉
+ var Res = Convert.ToInt32(FRes.Value);
+ var Msg = FMsg.Value?.ToString();
+
+ Console.WriteLine($"缁撴灉: {Res}, 杩斿洖娑堟伅: {Msg}");
+
+ if ( Res == 1 )
+ {
+ throw new Exception(Msg);
+ }
+
+ if (useTransactionWithOracle > 0)
+ {
+
+ // 鎴愬姛鎻愪氦鍚庢帹閫侀拤閽夋秷鎭�
+ var qaRkj = db.Queryable<QaRkj>()
+ .Where(s => s.ReleaseNo == dto.releaseNo)
+ .First();
+
+ if (qaRkj != null)
+ {
+ try
+ {
+ var qaMsgDto = new
+ {
+ id = qaRkj.Id,
+ lineName = qaRkj.Daa020,
+ workshopName = qaRkj.Departmentname,
+ qaType = "鍏ュ簱妫�妫�楠屽畬鎴�"
+ };
+
+ // 璋冪敤閽夐拤娑堟伅鎺ㄩ�佹帴鍙�
+ var client = new System.Net.Http.HttpClient();
+ var json = Newtonsoft.Json.JsonConvert.SerializeObject(qaMsgDto);
+ var content = new System.Net.Http.StringContent(json, System.Text.Encoding.UTF8, "application/json");
+ var response = client.PostAsync("http://192.168.0.100:9096/MesQaDingtalk/sendQaMsgRKJ", content).Result;
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍閽夐拤鎺ㄩ�佸紓甯革紝浣嗕笉褰卞搷涓绘祦绋�
+ Console.WriteLine($"閽夐拤娑堟伅鎺ㄩ�佸け璐�: {ex.Message}");
+ }
+ }
+ }
+
+
+
+ return useTransactionWithOracle;
+ }
+
+ public int reSubmit(RKJDto dto)
+ {
+ SqlSugarHelper.UseTransactionWithOracle(db =>
+ {
+ return db.Updateable<QsItemOqcReq>()
+ .SetColumns(a => a.Fsubmit == 0)
+ .SetColumns(a => a.FsubmitBy == null)
+ .SetColumns(a => a.FsubmitDate == null)
+ .Where(a => a.ReleaseNo == dto.releaseNo)
+ .ExecuteCommand();
+ });
+
+ return 0;
+ }
+
+ // 澶囦唤锛氬師濮嬬増鏈殑saveItem鏂规硶
+ public int saveItemOriginal(RKJDto rkjDto)
+ {
+ var items = rkjDto.items;
+ var userNo = rkjDto.userNo;
+
SqlSugarHelper.UseTransactionWithOracle(db =>
{
foreach (var item in items) item.Pid = rkjDto.gid;
--
Gitblit v1.9.3