From bdfcb2760a617d0fb95ee934696a3dde477d7e68 Mon Sep 17 00:00:00 2001 From: kyy <3283105747@qq.com> Date: 星期五, 29 八月 2025 17:56:58 +0800 Subject: [PATCH] 1、获取检验项目前先删除 --- MES.Service/service/QC/RKJService.cs | 159 +++++++++++++++++++++++++++++++--------------------- 1 files changed, 94 insertions(+), 65 deletions(-) diff --git a/MES.Service/service/QC/RKJService.cs b/MES.Service/service/QC/RKJService.cs index 4b2eca2..fdf43a1 100644 --- a/MES.Service/service/QC/RKJService.cs +++ b/MES.Service/service/QC/RKJService.cs @@ -71,36 +71,37 @@ var db = SqlSugarHelper.GetInstance(); var count = db.Queryable<MesQa>().Where(s => s.QsType == "3" - && s.ItemId == itemId && s.Fsubmit == 1).Count(); + && s.ItemId == itemId && s.Fsubmit == 1).Count(); if (count <= 0) return []; var qsItemOqcItems = db .Queryable<MesQualityStandard>() .Where(b => b.QsType == "3" - && b.ItemId == itemId).Select( - b => new QsItemOqcItem - { - ProjName = b.ProjName, - // ItemMod = b.ItemMod, - InspectionMethod = b.InspectionMethod, - UsingInstruments = b.UsingInstruments, - LevelNum = SqlFunc.IsNull( - SqlFunc.IsNull(Convert.ToDecimal(b.LevelNum) * Convert.ToDecimal(b.InspectionLevel), 1), - Convert.ToDecimal(b.InspectionLevel)), - MaxValue = Convert.ToDecimal(b.MaxValue), - StandardValue = Convert.ToDecimal(b.StandardValue), - MinValue = Convert.ToDecimal(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(); + && b.ItemId == itemId).Select(b => new QsItemOqcItem + { + ProjName = b.ProjName, + // ItemMod = b.ItemMod, + InspectionMethod = b.InspectionMethod, + UsingInstruments = b.UsingInstruments, + LevelNum = SqlFunc.IsNull( + SqlFunc.IsNull( + Convert.ToDecimal(b.LevelNum) * + Convert.ToDecimal(b.InspectionLevel), 1), + Convert.ToDecimal(b.InspectionLevel)), + MaxValue = Convert.ToDecimal(b.MaxValue), + StandardValue = Convert.ToDecimal(b.StandardValue), + MinValue = Convert.ToDecimal(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(); qsItemOqcItems.ForEach(item => { @@ -134,7 +135,8 @@ break; } - if (string.IsNullOrEmpty(LEV)) throw new Exception("璇ョ墿鏂欐湭缁存姢妫�楠岄」鐩垨妫�楠屾按骞充负绌�"); + if (string.IsNullOrEmpty(LEV)) + throw new Exception("璇ョ墿鏂欐湭缁存姢妫�楠岄」鐩垨妫�楠屾按骞充负绌�"); var sql = "SELECT " + LEV + @@ -359,8 +361,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>() @@ -469,17 +471,22 @@ lineNo = _baseService.getUserLineNo(queryObj.createUser); return db.Queryable<QsItemOqcReq, RKJDaa001>((a, b) => - new JoinQueryInfos(JoinType.Left, a.Id == b.ItemInId && a.ItemId == b.ItemId)) - .WhereIF(lineNo != null && lineNo.Length > 0, (a, b) => lineNo.Contains(b.LineNo)) + new JoinQueryInfos(JoinType.Left, + a.Id == b.ItemInId && a.ItemId == b.ItemId)) + .WhereIF(lineNo != null && lineNo.Length > 0, + (a, b) => lineNo.Contains(b.LineNo)) .WhereIF( - StringUtil.IsNotNullOrEmpty(queryObj.result) && "鏈畬鎴�".Equals(queryObj.result), - (a, b) => a.FcheckResu == null || a.Fsubmit == null || a.Fsubmit == 0) + StringUtil.IsNotNullOrEmpty(queryObj.result) && + "鏈畬鎴�".Equals(queryObj.result), + (a, b) => a.Fsubmit == null || + a.Fsubmit == 0) .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.result) && !"鏈畬鎴�".Equals(queryObj.result), - (a, b) => a.FcheckResu != null && a.Fsubmit != null && a.Fsubmit != 0) + (a, b) => a.Fsubmit == 1) .WhereIF(id > 0, (a, b) => a.Id == id) - .WhereIF(!string.IsNullOrEmpty(queryObj.itemCj), (a,b) => b.itemCj.Contains(queryObj.itemCj)) + .WhereIF(!string.IsNullOrEmpty(queryObj.itemCj), + (a, b) => b.itemCj.Contains(queryObj.itemCj)) .Select((a, b) => new QsItemOqcReq { Id = a.Id, @@ -506,12 +513,6 @@ .ToPageList(queryObj.PageIndex, queryObj.Limit); } - /// 浣跨敤 MergeTable + 杩斿洖鏈�缁堟墎骞崇粨鏋勶細data.tbBillList = List<T> - public class PageResult<T> - { - public List<T> tbBillList { get; set; } = new(); - } - public PageResult<QsItemOqcReq> getSearchPage(XJPageResult queryObj) { var db = SqlSugarHelper.GetInstance(); @@ -522,21 +523,35 @@ lineNo = _baseService.getUserLineNo(queryObj.createUser); var query = db.Queryable<QsItemOqcReq, RKJDaa001>((a, b) => - new JoinQueryInfos(JoinType.Left, a.Id == b.ItemInId && a.ItemId == b.ItemId)) - .WhereIF(lineNo != null && lineNo.Length > 0, (a, b) => lineNo.Contains(b.LineNo)) - .WhereIF(StringUtil.IsNotNullOrEmpty(queryObj.result) && "鏈畬鎴�".Equals(queryObj.result), - (a, b) => a.FcheckResu == null || a.Fsubmit == null || a.Fsubmit == 0) - .WhereIF(StringUtil.IsNotNullOrEmpty(queryObj.result) && !"鏈畬鎴�".Equals(queryObj.result), - (a, b) => a.FcheckResu != null && a.Fsubmit != null && a.Fsubmit != 0) + new JoinQueryInfos(JoinType.Left, + a.Id == b.ItemInId && a.ItemId == b.ItemId)) + .WhereIF(lineNo != null && lineNo.Length > 0, + (a, b) => lineNo.Contains(b.LineNo)) + .WhereIF( + StringUtil.IsNotNullOrEmpty(queryObj.result) && + "鏈畬鎴�".Equals(queryObj.result), + (a, b) => a.FcheckResu == null || a.Fsubmit == null || + a.Fsubmit == 0) + .WhereIF( + StringUtil.IsNotNullOrEmpty(queryObj.result) && + !"鏈畬鎴�".Equals(queryObj.result), + (a, b) => a.FcheckResu != null && a.Fsubmit != null && + a.Fsubmit != 0) .WhereIF(id > 0, (a, b) => a.Id == id) - .WhereIF(!string.IsNullOrEmpty(queryObj.ItemNo), (a, b) => a.ItemNo.Contains(queryObj.ItemNo)) - .WhereIF(!string.IsNullOrEmpty(queryObj.ItemModel), (a, b) => b.ItemModel.Contains(queryObj.ItemModel)) - .WhereIF(!string.IsNullOrEmpty(queryObj.SongJ), (a, b) => a.FcheckBy.Contains(queryObj.SongJ)) - .WhereIF(!string.IsNullOrEmpty(queryObj.SongNo), (a, b) => a.ReleaseNo.Contains(queryObj.SongNo)) - .WhereIF(!string.IsNullOrEmpty(queryObj.ItemName), (a, b) => b.ItemName.Contains(queryObj.ItemName)) - .WhereIF(!string.IsNullOrEmpty(queryObj.itemCj), (a, b) => b.itemCj.Contains(queryObj.itemCj)) - .WhereIF(!string.IsNullOrEmpty(queryObj.ItemCode), (a, b) => a.BillNo.Contains(queryObj.ItemCode)) - + .WhereIF(!string.IsNullOrEmpty(queryObj.ItemNo), + (a, b) => a.ItemNo.Contains(queryObj.ItemNo)) + .WhereIF(!string.IsNullOrEmpty(queryObj.ItemModel), + (a, b) => b.ItemModel.Contains(queryObj.ItemModel)) + .WhereIF(!string.IsNullOrEmpty(queryObj.SongJ), + (a, b) => a.FcheckBy.Contains(queryObj.SongJ)) + .WhereIF(!string.IsNullOrEmpty(queryObj.SongNo), + (a, b) => a.ReleaseNo.Contains(queryObj.SongNo)) + .WhereIF(!string.IsNullOrEmpty(queryObj.ItemName), + (a, b) => b.ItemName.Contains(queryObj.ItemName)) + .WhereIF(!string.IsNullOrEmpty(queryObj.itemCj), + (a, b) => b.itemCj.Contains(queryObj.itemCj)) + .WhereIF(!string.IsNullOrEmpty(queryObj.ItemCode), + (a, b) => a.BillNo.Contains(queryObj.ItemCode)) .Select((a, b) => new { a.Id, @@ -563,7 +578,8 @@ .OrderBy(it => it.CreateDate, OrderByType.Desc); var totalCountRef = 0; - var rawList = query.ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCountRef); + var rawList = query.ToPageList(queryObj.PageIndex, queryObj.Limit, + ref totalCountRef); var resultList = rawList.Select(it => new QsItemOqcReq { @@ -771,6 +787,15 @@ { var items = rkjDto.items; var userNo = rkjDto.userNo; + + var db = SqlSugarHelper.GetInstance(); + db.Deleteable<QsItemOqcItem>() + .Where(s => s.Pid == rkjDto.gid) + .ExecuteCommand(); + + db.Deleteable<QsItemOqcItemDetail>() + .Where(s => s.Gid == rkjDto.gid) + .ExecuteCommand(); SqlSugarHelper.UseTransactionWithOracle(db => { @@ -804,17 +829,20 @@ try { // 瀹氫箟杈撳嚭鍙傛暟 - var outputResult = new SugarParameter("o_Result", null, DbType.Int32, ParameterDirection.Output, + var outputResult = new SugarParameter("o_Result", null, + DbType.Int32, ParameterDirection.Output, 4000); - var outputMessage = new SugarParameter("o_Msg", null, DbType.String, ParameterDirection.Output, 4000); + var outputMessage = new SugarParameter("o_Msg", null, DbType.String, + ParameterDirection.Output, 4000); // 瀹氫箟杈撳叆鍙傛暟 var parameters = new List<SugarParameter> { new("p_Id", item.gid, DbType.Int32, ParameterDirection.Input), new("p_Flag", 1, DbType.Int32, ParameterDirection.Input), - new("p_User", item.userNo, DbType.String, ParameterDirection.Input), + new("p_User", item.userNo, DbType.String, + ParameterDirection.Input), outputResult, outputMessage }; @@ -830,15 +858,9 @@ var resultValue = outputResult.Value?.ToString(); var messageValue = outputMessage.Value?.ToString(); - if ("1".Equals(resultValue)) - { - throw new Exception(messageValue); - } + if ("1".Equals(resultValue)) throw new Exception(messageValue); - if ("0".Equals(resultValue)) - { - throw new Exception(messageValue); - } + if ("0".Equals(resultValue)) throw new Exception(messageValue); return true; } @@ -847,4 +869,11 @@ throw new Exception(ex.Message); } } + + /// 浣跨敤 MergeTable + 杩斿洖鏈�缁堟墎骞崇粨鏋勶細data.tbBillList = List + /// <T> + public class PageResult<T> + { + public List<T> tbBillList { get; set; } = new(); + } } \ No newline at end of file -- Gitblit v1.9.3