| | |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | | using SqlSugar; |
| | | using System.Data; |
| | | |
| | | namespace MES.Service.service.QC; |
| | | |
| | |
| | | number = no.ToString().PadLeft(4, '0'); |
| | | } |
| | | |
| | | return "SJN" + date.Replace("-", "") + number; |
| | | return "SJ" + date.Replace("-", "") + number; |
| | | } |
| | | |
| | | //获取所有数据分页 |
| | | public List<SJPageResult> getPage(SJPageResult queryObj) |
| | | public (List<SJPageResult> item, int TotalCount) getPage(SJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | |
| | | if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser)) |
| | | lineNo = _baseService.getUserLineNo(queryObj.StatusUser); |
| | | |
| | | var data = db.Queryable<SJPageResult>() |
| | | var query = db.Queryable<SJPageResult>() |
| | | .WhereIF(lineNo != null && lineNo.Length > 0, |
| | | a => lineNo.Contains(a.line)) |
| | | .WhereIF(queryObj.Id != null, a => a.Id == queryObj.Id) |
| | |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | "未完成".Equals(queryObj.Result), |
| | | a => a.Result == queryObj.Result) |
| | | a => a.Fsubmit == 0) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | !"未完成".Equals(queryObj.Result), |
| | | a => a.Result != "未完成") |
| | | .OrderBy(a => a.BillNo, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | a => a.Fsubmit == 1); |
| | | |
| | | return data; |
| | | // 新增的动态搜索逻辑 |
| | | if (!string.IsNullOrEmpty(queryObj.SearchValue) && !string.IsNullOrEmpty(queryObj.searchField)) |
| | | { |
| | | switch (queryObj.searchField) |
| | | { |
| | | case "daa001": // 工单 |
| | | query = query.Where(x => x.daa001.Contains(queryObj.SearchValue)); |
| | | break; |
| | | case "billNo": // 检验单号 |
| | | query = query.Where(x => x.BillNo.Contains(queryObj.SearchValue)); |
| | | break; |
| | | case "line": // 产线 |
| | | query = query.Where(x => x.line.Contains(queryObj.SearchValue)); |
| | | break; |
| | | case "itemNo": // 物料编码 |
| | | query = query.Where(x => x.ItemNo.Contains(queryObj.SearchValue)); |
| | | break; |
| | | case "daa003": // 物料名称 |
| | | query = query.Where(x => x.Daa003.Contains(queryObj.SearchValue)); |
| | | break; |
| | | default: |
| | | // 如果没有指定字段或字段不匹配,使用原有的模糊查询逻辑作为兜底方案 |
| | | query = query.Where(x => |
| | | x.ItemNo.Contains(queryObj.SearchValue) || |
| | | x.Daa003.Contains(queryObj.SearchValue) || |
| | | x.daa001.Contains(queryObj.SearchValue) || |
| | | x.BillNo.Contains(queryObj.SearchValue) || |
| | | x.line.Contains(queryObj.SearchValue)); |
| | | break; |
| | | } |
| | | } |
| | | // 为了兼容旧版本,如果没有传递 searchField,使用原来的查询逻辑 |
| | | else if (string.IsNullOrEmpty(queryObj.searchField) && !string.IsNullOrEmpty(queryObj.SearchValue)) |
| | | { |
| | | // 保持原有的多字段模糊查询逻辑 |
| | | query = query.Where(x => |
| | | x.ItemNo.Contains(queryObj.SearchValue) || |
| | | x.Daa003.Contains(queryObj.SearchValue) || |
| | | x.daa001.Contains(queryObj.SearchValue) || |
| | | x.BillNo.Contains(queryObj.SearchValue) || |
| | | x.line.Contains(queryObj.SearchValue)); |
| | | } |
| | | |
| | | var totalCount = 0; |
| | | var data = query.OrderBy(a => a.BillNo, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); |
| | | |
| | | return (data, totalCount); |
| | | } |
| | | |
| | | |
| | |
| | | // result = "未检测" |
| | | // }).ToList(); |
| | | // } |
| | | public List<QsItemIpiItem> SetQSItems(string itemNo) |
| | | public List<QsItemIpiItem> SetQSItems(string? itemNo) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | |
| | | { |
| | | ProjName = b.ProjName, |
| | | ItemMod = b.ItemMod, |
| | | |
| | | InspectionMethod = b.InspectionMethod, |
| | | UsingInstruments = b.UsingInstruments, |
| | | LevelNum = SqlFunc.IsNull( |
| | |
| | | item.Items = getQSItems(qsItemIpiReq.Id, null); |
| | | var sjPageResult = new SJPageResult |
| | | { Id = item.From.Id, Limit = 1, PageIndex = 1 }; |
| | | item.Result = getPage(sjPageResult)[0]; |
| | | item.Result = getPage(sjPageResult).item[0]; |
| | | |
| | | return item; |
| | | } |
| | |
| | | |
| | | return withOracle; |
| | | } |
| | | //刷新检验项目 |
| | | 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(: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); |
| | | |
| | | // 定义输入参数,固定FLAG为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_SJ_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); |
| | | } |
| | | } |
| | | } |