From 82dac540156cb29e58c86f7d7d840e3c7e548c15 Mon Sep 17 00:00:00 2001 From: xwt <2740516069@qq.com> Date: 星期四, 14 八月 2025 19:55:41 +0800 Subject: [PATCH] 来料检,入库检,首检巡检。 --- StandardInterface/MES.Service/service/QC/XJService.cs | 188 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 172 insertions(+), 16 deletions(-) diff --git a/StandardInterface/MES.Service/service/QC/XJService.cs b/StandardInterface/MES.Service/service/QC/XJService.cs index 9e9aa40..af5750a 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) @@ -70,21 +71,43 @@ }).OrderBy("b.LINE_NO").ToList(); } - public List<Womdaa> getDaa001(string daa020, string item) + public List<Womdaa> getDaa001(string daa020) { var db = SqlSugarHelper.GetInstance(); - return db.Queryable<Womdaa, MesItems>((a, b) => - new JoinQueryInfos(JoinType.Inner, a.Daa002 == b.Id.ToString())) - .Where((a, b) => - a.Daa015 == daa020 && - b.ItemNo == item && - statusArray.Contains(a.Daa018)) - .Select<Womdaa>(a => new Womdaa + return db.Queryable<Womdaa>() + .Where(a => a.Daa015 == daa020 && statusArray.Contains(a.Daa018)) + .Select(a => new Womdaa { Id = a.Id, Daa001 = a.Daa001, Daa003 = a.Daa003, Daa008 = a.Daa008 + }).ToList(); + } + + /// <summary> + /// 鑾峰彇宸ュ崟璇︾粏淇℃伅锛堝寘鍚墿鏂欎俊鎭級 + /// </summary> + /// <param name="daa020">绾夸綋缂栧彿</param> + /// <returns>宸ュ崟鍒楄〃锛堝寘鍚墿鏂欎俊鎭級</returns> + public List<WorkOrderWithItemDto> getWorkOrderWithItem(string daa020) + { + var db = SqlSugarHelper.GetInstance(); + return db.Queryable<Womdaa, MesItems>((a, b) => + new JoinQueryInfos(JoinType.Inner, a.Daa002 == b.Id.ToString())) + .Where((a, b) => a.Daa015 == daa020 && statusArray.Contains(a.Daa018)) + .Select((a, b) => new WorkOrderWithItemDto + { + Id = a.Id, + Daa001 = a.Daa001, + Daa002 = a.Daa002, + Daa003 = a.Daa003, + Daa008 = a.Daa008, + Daa015 = a.Daa015, + Daa020 = a.Daa020, + ItemNo = b.ItemNo, + ItemName = b.ItemName, + ItemModel = b.ItemModel }).ToList(); } @@ -106,7 +129,7 @@ }).ToList(); } - public List<QsQaItemXj> getPage(XJPageResult queryObj) + public (List<QsQaItemXj> item, int TotalCount) getPage(XJPageResult queryObj) { var db = SqlSugarHelper.GetInstance(); @@ -117,7 +140,8 @@ if (StringUtil.IsNotNullOrEmpty(queryObj.createUser)) lineNo = _baseService.getUserLineNo(queryObj.createUser); - return db + var totalCount = 0; + var data = db .Queryable<QsQaItemXj, Womdaa, MesLine, MesItems>((s, a, c, b) => new JoinQueryInfos( @@ -131,11 +155,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 { @@ -153,7 +177,9 @@ FcheckResu = s.FcheckResu, Remarks = s.Remarks }).OrderBy(s => s.CreateDate, OrderByType.Desc) - .ToPageList(queryObj.PageIndex, queryObj.Limit); + .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); + + return (data, totalCount); } @@ -255,6 +281,7 @@ xj.CreateBy = userNo; xj.CreateDate = DateTime.Now; + xj.Fsubmit = 0; // 璁剧疆榛樿鐘舵�佷负鏈彁浜� var pid = db.Insertable(xj).ExecuteReturnIdentity(); @@ -269,8 +296,10 @@ return commit; }); + // 閲嶆柊鑾峰彇妫�楠岄」鐩紙鍖呭惈ID锛� xjDto.items = getJYItem(xj.Id, null); + // 鑷姩涓烘病鏈変笂涓嬮檺鐨勬楠岄」鐩敓鎴愰粯璁ょ殑鍚堟牸璁板綍 xjDto.items.ForEach(s => { if (s.MaxValue != null || s.StandardValue != null || @@ -284,6 +313,9 @@ detail.count = (int?)s.LevelNum; SetQSItemDetail(detail); }); + + // 閲嶆柊鑾峰彇妫�楠岄」鐩紙鍖呭惈鑷姩鐢熸垚鐨勭粨鏋滐級 + xjDto.items = getJYItem(xj.Id, null); return Convert.ToInt32(xj.Id); } @@ -529,4 +561,128 @@ }); } + //鍒锋柊妫�楠岄」鐩� + 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 db = SqlSugarHelper.GetInstance(); + + // 鐩存帴鏇存柊Fsubmit瀛楁涓�1锛堝凡鎻愪氦鐘舵�侊級 + var result = db.Updateable<QsQaItemXj>() + .SetColumns(s => s.Fsubmit == 1) + .SetColumns(s => s.FsubmitBy == dto.userNo) + .SetColumns(s => s.FsubmitDate == DateTime.Now) + .Where(s => s.Id == dto.id) + .ExecuteCommand(); + + if (result > 0) + { + return true; + } + else + { + throw new Exception("鎻愪氦澶辫触锛氭湭鎵惧埌瀵瑰簲鐨勬楠屽崟"); + } + } + 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