| | |
| | | } |
| | | |
| | | //获取所有数据分页 |
| | | |
| | | public List<SJPageResult> getPage(SJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | string[]? lineNo = null; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser)) |
| | | lineNo = _baseService.getUserLineNo(queryObj.StatusUser); |
| | | |
| | | var data = 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.BillNo), |
| | | a => a.BillNo == queryObj.BillNo) |
| | | .WhereIF( |
| | | (StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | "未完成".Equals(queryObj.Result)) || |
| | | (queryObj.Fsubmit != null && |
| | | (queryObj.Fsubmit == 0 || queryObj.Fsubmit == null)), |
| | | a => a.Result == "未完成" || |
| | | (a.Fsubmit != null && a.Fsubmit == 0) || a.Fsubmit == null) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | !"未完成".Equals(queryObj.Result), |
| | | a => a.Result != "未完成" && a.Fsubmit != null && a.Fsubmit != 0) |
| | | .WhereIF(StringUtil.IsNotNullOrEmpty(queryObj.ItemCj), |
| | | a => a.ItemCj == queryObj.ItemCj) |
| | | .OrderBy(a => a.BillNo, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | |
| | | return data; |
| | | } |
| | | |
| | | public List<SJPageResult> getSearchPage(SJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | string[]? lineNo = null; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser)) |
| | | lineNo = _baseService.getUserLineNo(queryObj.StatusUser); |
| | | |
| | | var data = 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.BillNo), a => a.BillNo == queryObj.BillNo) |
| | | .WhereIF( |
| | | (StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | "未完成".Equals(queryObj.Result)) || |
| | | (queryObj.Fsubmit != null && |
| | | (queryObj.Fsubmit == 0 || queryObj.Fsubmit == null)), |
| | | a => a.Result == "未完成" || |
| | | (a.Fsubmit != null && a.Fsubmit == 0) || a.Fsubmit == null) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | !"未完成".Equals(queryObj.Result), |
| | | a => a.Result != "未完成" && a.Fsubmit != null && a.Fsubmit != 0) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemNo), |
| | | a => a.ItemNo.Contains(queryObj.ItemNo)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemModel), |
| | | a => a.ItemModel.Contains(queryObj.ItemModel)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SongJ), |
| | | a => a.SongJ.Contains(queryObj.SongJ)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.BillNo), |
| | | a => a.BillNo.Contains(queryObj.BillNo)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemName), |
| | | a => a.ItemName.Contains(queryObj.ItemName)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemCj), |
| | | a => a.ItemCj.Contains(queryObj.ItemCj)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.daa001), |
| | | a => a.daa001.Contains(queryObj.daa001)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.Cjr), |
| | | a => a.Cjr.Contains(queryObj.Cjr)) |
| | | .OrderBy(a => a.BillNo, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | |
| | | return data; |
| | | } |
| | | /* |
| | | public List<SJPageResult> getPage(SJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | |
| | | |
| | | return data; |
| | | } |
| | | */ |
| | | |
| | | |
| | | //SetQSItem |
| | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var count = db.Queryable<MesQa>().Where(s => s.QsType == "1" |
| | | && s.ItemId == itemId && s.Fsubmit == 1).Count(); |
| | | && s.ItemId == itemId && s.Fsubmit == 1).Count(); |
| | | |
| | | if (count <= 0) return new List<QsItemIpiItem>(); |
| | | |
| | | return db |
| | | .Queryable<MesQualityStandard>() |
| | | .Where(b => b.QsType == "1" && b.ItemId == itemId).Select( |
| | | b => new QsItemIpiItem |
| | | .Where(b => b.QsType == "1" && b.ItemId == itemId) |
| | | .OrderBy(b => b.Xh) // 按Xh字段升序排序 |
| | | .Select(b => |
| | | new QsItemIpiItem |
| | | { |
| | | 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), |
| | | 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), |
| | |
| | | { |
| | | var qsItemIpiReq = item.From; |
| | | var qsItemIpiItems = item.Items; |
| | | SqlSugarHelper.UseTransactionWithOracle( |
| | | db => |
| | | { |
| | | qsItemIpiReq.StatusDate = DateTime.Now; |
| | | var pid = db.Insertable(qsItemIpiReq) |
| | | .ExecuteReturnIdentity(); |
| | | qsItemIpiReq.Id = pid; |
| | | SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | qsItemIpiReq.StatusDate = DateTime.Now; |
| | | var pid = db.Insertable(qsItemIpiReq) |
| | | .ExecuteReturnIdentity(); |
| | | qsItemIpiReq.Id = pid; |
| | | |
| | | item.gid = pid; |
| | | item.gid = pid; |
| | | |
| | | qsItemIpiItems.ForEach(s => s.Pid = pid); |
| | | qsItemIpiItems.ForEach(s => s.Pid = pid); |
| | | |
| | | return db.Insertable(qsItemIpiItems) |
| | | .ExecuteCommand(); |
| | | }); |
| | | return db.Insertable(qsItemIpiItems) |
| | | .ExecuteCommand(); |
| | | }); |
| | | item.Items = getQSItems(qsItemIpiReq.Id, null); |
| | | |
| | | //没有上下限的检验项目自动盘点为合格 |
| | |
| | | public QsItem SaveItem(QsItem item) |
| | | { |
| | | var qsItemIpiItems = item.Items; |
| | | SqlSugarHelper.UseTransactionWithOracle( |
| | | db => |
| | | { |
| | | qsItemIpiItems.ForEach(s => s.Pid = item.gid); |
| | | SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | qsItemIpiItems.ForEach(s => s.Pid = item.gid); |
| | | |
| | | return db.Insertable(qsItemIpiItems) |
| | | .ExecuteCommand(); |
| | | }); |
| | | return db.Insertable(qsItemIpiItems) |
| | | .ExecuteCommand(); |
| | | }); |
| | | item.Items = getQSItems(item.gid, null); |
| | | |
| | | //没有上下限的检验项目自动盘点为合格 |
| | |
| | | |
| | | if (count == passCount) result = 1; |
| | | |
| | | var useTransactionWithOracle = SqlSugarHelper.UseTransactionWithOracle( |
| | | db => |
| | | var useTransactionWithOracle = |
| | | SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | var commit = 0; |
| | | commit += db.Updateable<QsItemIpiItem>() |
| | |
| | | //合格的检验结果等于总检验数视为合格 |
| | | if (icount == passCount) result = 1; |
| | | |
| | | useTransactionWithOracle += SqlSugarHelper.UseTransactionWithOracle( |
| | | db => |
| | | useTransactionWithOracle += |
| | | SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | return db.Updateable<QsItemIpiReq>() |
| | | .SetColumns(s => s.IsPass == result) |
| | | .SetColumns(s => s.StatusUser == detail.CreateBy) |
| | | .SetColumns(s => s.StatusDate== DateTime.Now) |
| | | .SetColumns(s => s.CompleteTime == DateTime.Now) |
| | | .Where(s => s.Id == detail.Gid) |
| | | .ExecuteCommand(); |
| | |
| | | |
| | | return withOracle; |
| | | } |
| | | |
| | | |
| | | public bool SJQaSubmit(QsItem item) |
| | | { |
| | | var (factory, company) = UserUtil.GetFactory(item.userNo); |
| | | try |
| | | { |
| | | // 定义输出参数 |
| | | 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 outputResult = new SugarParameter("o_Result", null, |
| | | DbType.Int32, 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_Id", item.gid, DbType.Int32, ParameterDirection.Input), |
| | | new("p_Flag", 1, DbType.Int32, ParameterDirection.Input), |
| | | new("p_User", item.userNo, DbType.String, |
| | | ParameterDirection.Input), |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | |
| | | var resultValue = outputResult.Value?.ToString(); |
| | | var messageValue = outputMessage.Value?.ToString(); |
| | | |
| | | if ("1".Equals(resultValue)) {throw new Exception(messageValue);} |
| | | if ("0".Equals(resultValue)) {throw new Exception(messageValue);} |
| | | |
| | | if ("1".Equals(resultValue)) |
| | | // 处理失败情况,返回错误信息 |
| | | throw new Exception($"操作失败: {messageValue}"); |
| | | |
| | | // 当 resultValue 为 "0" 时返回成功状态 |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | // 重新抛出更友好的异常信息 |
| | | throw new Exception($"提交质量检验数据时发生错误: {ex.Message}", ex); |
| | | } |
| | | } |
| | | |
| | | public List<SysDepartment> getWorkshop() |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | return db.Queryable<SysDepartment>() |
| | | .Where(d => d.Depextr1 == "基本生产部门") |
| | | .GroupBy(d => new { d.Departmentname }) |
| | | .Select(d => new SysDepartment |
| | | { |
| | | Departmentname = d.Departmentname |
| | | // 其他需要的字段 |
| | | }) |
| | | .OrderBy("DEPARTMENTNAME") |
| | | .ToList(); |
| | | } |
| | | } |