From 3f7693504fdb48ab76fd41029859d84774b42a28 Mon Sep 17 00:00:00 2001 From: xwt <2740516069@qq.com> Date: 星期日, 03 八月 2025 13:38:42 +0800 Subject: [PATCH] 首检巡检修改 --- StandardInterface/MES.Service/service/QC/XJService.cs | 150 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 145 insertions(+), 5 deletions(-) diff --git a/StandardInterface/MES.Service/service/QC/XJService.cs b/StandardInterface/MES.Service/service/QC/XJService.cs index b94657d..efcf669 100644 --- a/StandardInterface/MES.Service/service/QC/XJService.cs +++ b/StandardInterface/MES.Service/service/QC/XJService.cs @@ -1,4 +1,5 @@ -锘縰sing MES.Service.DB; +锘縰sing System.Data; +using MES.Service.DB; using MES.Service.Dto.service; using MES.Service.Modes; using MES.Service.util; @@ -28,14 +29,14 @@ var number = "0001"; var olReleaseNo = executeScalar.ToString(); //鍒ゆ柇浠婂ぉ鏄惁鐢熸垚浜嗗贰妫�鍗� - if (string.IsNullOrEmpty(olReleaseNo)) return "XJN" + date + number; + if (string.IsNullOrEmpty(olReleaseNo)) return "XJ" + date + number; //鎴彇鍚庡洓浣嶇殑娴佹按鍙风疮鍔� var substring = Convert.ToInt32(olReleaseNo.Substring(10)); substring += 1; number = substring.ToString("D4"); //濡傛灉涓虹┖鐩存帴杩斿洖0001 - return "XJN" + date + number; + return "XJ" + date + number; } public List<Womdaa> getItem(string daa001) @@ -132,11 +133,11 @@ .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.result) && "鏈畬鎴�".Equals(queryObj.result), - (s, a, c, b) => s.FcheckResu == null) + (s, a, c, b) => s.Fsubmit == 0) .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.result) && !"鏈畬鎴�".Equals(queryObj.result), - (s, a, c, b) => s.FcheckResu != null) + (s, a, c, b) => s.Fsubmit != 1) .WhereIF(id > 0, (s, a, c, b) => s.Id == id) .Select((s, a, c, b) => new QsQaItemXj { @@ -532,4 +533,143 @@ }); } + //鍒锋柊妫�楠岄」鐩� + public (int result, string message) GenUpdate(decimal? id, string? no, string? user) + { + var outputResult = new SugarParameter("PO_RESULT", null, System.Data.DbType.Int32, ParameterDirection.Output, 4000); + var outputMessage = new SugarParameter("PO_TEXT", null, System.Data.DbType.String, ParameterDirection.Output, 4000); + + var parameters = new List<SugarParameter> + { + new("P_ID", id, System.Data.DbType.Decimal, ParameterDirection.Input), + new("P_NO", no, System.Data.DbType.String, ParameterDirection.Input), + new("P_USER", user, System.Data.DbType.String, ParameterDirection.Input), + outputResult, + outputMessage + }; + + var db = SqlSugarHelper.GetInstance(); + db.Ado.ExecuteCommand( + "BEGIN PRC_GEN_UPDATE_XJ(:P_ID, :P_NO, :P_USER, :PO_RESULT, :PO_TEXT); END;", + parameters.ToArray()); + + int result = outputResult.Value == null ? -1 : Convert.ToInt32(outputResult.Value); + string message = outputMessage.Value?.ToString() ?? ""; + + return (result, message); + } + + public bool SjSubmit(SJDto dto) + { + try + { + // 瀹氫箟杈撳嚭鍙傛暟 + var outputResult = new SugarParameter("c_res", null, + System.Data.DbType.Int32, ParameterDirection.Output, + 4000); + + var outputMessage = new SugarParameter("c_msg", null, + System.Data.DbType.String, + ParameterDirection.Output, 4000); + + // 瀹氫箟杈撳叆鍙傛暟锛屽浐瀹欶LAG涓�1锛堝鏍革級 + var parameters = new List<SugarParameter> + { + new("P_ID", dto.id, System.Data.DbType.Decimal, ParameterDirection.Input), + new("P_FLAG", 1, System.Data.DbType.Int32, ParameterDirection.Input), + new("P_USER", dto.userNo, System.Data.DbType.String, ParameterDirection.Input), + outputResult, + outputMessage + }; + + var db = SqlSugarHelper.GetInstance(); + + // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼ + db.Ado.ExecuteCommand( + "BEGIN PRC_WOMDAA_XJ_UPDATE_RES(:P_ID, :P_FLAG, :P_USER, :c_res, :c_msg); END;", + parameters.ToArray()); + + // 鑾峰彇杈撳嚭鍙傛暟鐨勫�� + var resultValue = outputResult.Value?.ToString(); + var messageValue = outputMessage.Value?.ToString(); + + if ("1".Equals(resultValue)) throw new Exception(messageValue); + + return true; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + + /// <summary> + /// 鑾峰彇鏈夌嚎浣撶殑閮ㄩ棬鍒楄〃 + /// </summary> + /// <returns>閮ㄩ棬鍒楄〃</returns> + public List<SysDepartment> GetDepartmentsWithLines() + { + var db = SqlSugarHelper.GetInstance(); + + // 鏌ヨ鏈夌嚎浣撶殑閮ㄩ棬锛岄摼鎺ユ潯浠舵槸绾夸綋鐨凞EPOT_ID绛変簬閮ㄩ棬鐨凞epartmentid + var departments = db.Queryable<SysDepartment, MesLine>((dept, line) => + new JoinQueryInfos(JoinType.Inner, line.DepotId == dept.Departmentid)) + .Where((dept, line) => line.LineNo != null && line.LineName != null) + .GroupBy((dept, line) => new + { + dept.Departmentid, + dept.Departmentname + }) + .Select((dept, line) => new SysDepartment + { + Departmentid = dept.Departmentid, + Departmentname = dept.Departmentname + }) + .OrderBy(dept => dept.Departmentname) + .ToList(); + + return departments; + } + + /// <summary> + /// 淇濆瓨閮ㄩ棬閫夋嫨 + /// </summary> + /// <param name="id">宸℃鍗旾D</param> + /// <param name="departmentId">閮ㄩ棬ID</param> + /// <param name="departmentName">閮ㄩ棬鍚嶇О</param> + /// <returns>淇濆瓨缁撴灉</returns> + public int SaveDepartmentSelection(decimal id, string departmentId, string departmentName) + { + return SqlSugarHelper.UseTransactionWithOracle(db => + { + return db.Updateable<QsQaItemXj>() + .SetColumns(it => it.WorkShop == departmentName) + .SetColumns(it => it.DepartmentId == departmentId) + .Where(it => it.Id == id) + .ExecuteCommand(); + }); + } + + /// <summary> + /// 鏍规嵁閮ㄩ棬ID鑾峰彇璇ラ儴闂ㄤ笅鐨勭嚎浣撳垪琛� + /// </summary> + /// <param name="departmentId">閮ㄩ棬ID</param> + /// <returns>绾夸綋鍒楄〃</returns> + public List<MesLine> GetLinesByDepartment(string departmentId) + { + var db = SqlSugarHelper.GetInstance(); + + // 灏嗗瓧绗︿覆杞崲涓篸ecimal杩涜姣旇緝 + if (!decimal.TryParse(departmentId, out var deptId)) + { + return new List<MesLine>(); + } + + return db.Queryable<MesLine>() + .Where(line => line.DepotId == deptId && + line.LineNo != null && + line.LineName != null) + .OrderBy(line => line.LineNo) + .ToList(); + } } \ No newline at end of file -- Gitblit v1.9.3