| | |
| | | // 参数验证 |
| | | if (string.IsNullOrWhiteSpace(itemNo)) |
| | | throw new ArgumentException("物料编号不能为空", nameof(itemNo)); |
| | | |
| | | |
| | | if (quantity <= 0) |
| | | throw new ArgumentException("数量必须大于0", nameof(quantity)); |
| | | |
| | |
| | | .Where(s => s.QsType == "3" && s.ItemNo == itemNo && s.Fsubmit == 1) |
| | | .Count(); |
| | | |
| | | if (count <= 0) |
| | | if (count <= 0) |
| | | return []; |
| | | |
| | | // 获取质量标准 |
| | |
| | | return qsItemOqcItems; |
| | | } |
| | | |
| | | private void ProcessQualityItem(ISqlSugarClient db, QsItemOqcItem item, decimal quantity) |
| | | private void ProcessQualityItem(ISqlSugarClient db, QsItemOqcItem item, |
| | | decimal quantity) |
| | | { |
| | | // 验证必要字段 |
| | | if (string.IsNullOrWhiteSpace(item.FcheckLevel) || string.IsNullOrWhiteSpace(item.QsCode)) |
| | | if (string.IsNullOrWhiteSpace(item.FcheckLevel) || |
| | | string.IsNullOrWhiteSpace(item.QsCode)) |
| | | { |
| | | item.LevelNum = 1; |
| | | item.FreQty = 0; |
| | |
| | | |
| | | // 获取检验级别对应的数据库字段 |
| | | var levelField = GetLevelField(item.FcheckLevel); |
| | | |
| | | |
| | | // 使用参数化查询防止SQL注入 |
| | | 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 }); |
| | | 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)) |
| | | { |
| | |
| | | var facLevelValue = ExtractSubstring(item.FacLevel ?? "", '(', ')'); |
| | | if (string.IsNullOrWhiteSpace(facLevelValue)) |
| | | { |
| | | item.LevelNum = decimal.TryParse(aqlResult, out var level) ? level : 1; |
| | | 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, |
| | | 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) |
| | |
| | | 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("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", |
| | |
| | | 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>() |
| | |
| | | } |
| | | |
| | | |
| | | 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; |
| | | |
| | | |
| | | var query = db.Queryable<QsItemOqcReq, MesItems, Womdaa,MesLine,SysUser>((a, b, da,c,us) => |
| | | 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 // 关联工单信息 |
| | | )) |
| | | |
| | | var query = db |
| | | .Queryable<QsItemOqcReq, MesItems, Womdaa, MesLine, SysUser>((a, b, |
| | | da, c, us) => |
| | | 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 // 关联工单信息 |
| | | )) |
| | | // 用户线体过滤条件 |
| | | //.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,c,us) => a.Id.ToString() == queryObj.id) |
| | | (a, b, da, c, us) => a.Id.ToString() == queryObj.id) |
| | | // 完成状态过滤 |
| | | .WhereIF("未完成".Equals(queryObj.result), (a, b, da,c,us) => a.FcheckResu == null) |
| | | .WhereIF(!"未完成".Equals(queryObj.result), (a, b, da,c,us) => 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,c,us) => b.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()) || |
| | | a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower())) |
| | | (a, b, da, c, us) => |
| | | b.ItemName.ToLower() |
| | | .Contains(queryObj.SearchValue.ToLower()) || |
| | | a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower())) |
| | | // 查询字段 |
| | | .Select((a, b, da,c,us) => new QsItemOqcReq |
| | | .Select((a, b, da, c, us) => new QsItemOqcReq |
| | | { |
| | | Id = a.Id, |
| | | BillNo = a.BillNo, |
| | |
| | | FcheckDate = a.FcheckDate, |
| | | ReleaseNo = a.ReleaseNo, |
| | | Remarks = a.Remarks, |
| | | Daa015 = da.Daa015, // 工单线体 |
| | | Daa015 = da.Daa015, // 工单线体 |
| | | Fsubmit = a.Fsubmit, |
| | | Quantity = da.Daa008, |
| | | LineNo = c.LineName |
| | |
| | | .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); |
| | | } |
| | |
| | | }); |
| | | |
| | | 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(); |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | 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) |
| | | .Where(s => s.Pid == rkjDto.gid && |
| | | s.MaxValue == null && s.StandardValue == null && |
| | | s.MinValue == null) |
| | | .Select(s => new { s.Id, s.LevelNum }) |
| | | .ToList(); |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | private int UpdateMainInspectionStatus(ISqlSugarClient db, decimal? gid, string userNo) |
| | | private int UpdateMainInspectionStatus(ISqlSugarClient db, decimal? gid, |
| | | string userNo) |
| | | { |
| | | // 检查是否还有未完成的检验项目 |
| | | var unfinishedCount = db.Queryable<QsItemOqcItem>() |
| | |
| | | return updateResult; |
| | | } |
| | | |
| | | private void GenerateQualityIssueRecord(ISqlSugarClient db, decimal? gid, string userNo) |
| | | private void GenerateQualityIssueRecord(ISqlSugarClient db, decimal? gid, |
| | | string userNo) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | public int IqcQaSubmit(RKJDto dto) |
| | | { |
| | | 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(); |
| | | }); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | // 备份:原始版本的saveItem方法 |
| | | public int saveItemOriginal(RKJDto rkjDto) |
| | | { |