| | |
| | | using MES.Service.DB; |
| | | using System.Data; |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.service; |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | | using SqlSugar; |
| | | using DbType = System.Data.DbType; |
| | | |
| | | namespace MES.Service.service.QC; |
| | | |
| | |
| | | |
| | | |
| | | //获取工单号 |
| | | /* public List<RKJDaa001> GetDaa001s(string lineNo) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | return db.Queryable<RKJDaa001>() |
| | | .Where(t => t.LineNo == lineNo) |
| | | .OrderBy(t => t.LotNo, OrderByType.Desc) |
| | | .ToList(); |
| | | }*/ |
| | | /* public List<RKJDaa001> GetDaa001s(string lineNo) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | return db.Queryable<RKJDaa001>() |
| | | .Where(t => t.LineNo == lineNo) |
| | | .OrderBy(t => t.LotNo, OrderByType.Desc) |
| | | .ToList(); |
| | | }*/ |
| | | |
| | | //根据检验标准来计算检验个数 |
| | | public List<QsItemOqcItem> SetItems(string itemNo, decimal quantity) |
| | | public List<QsItemOqcItem> SetItems(decimal itemId, decimal quantity) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var count = db.Queryable<MesQa>().Where(s => s.QsType == "3" |
| | | && s.ItemNo == itemNo && s.Fsubmit == 1).Count(); |
| | | && s.ItemId == itemId && s.Fsubmit == 1).Count(); |
| | | |
| | | if (count <= 0) return []; |
| | | |
| | | var qsItemOqcItems = db |
| | | .Queryable<MesQualityStandard>() |
| | | .Where(b => b.QsType == "3" |
| | | && b.ItemNo == itemNo).Select( |
| | | b => new QsItemOqcItem |
| | | { |
| | | ProjName = b.ProjName, |
| | | ItemMod = b.ItemMod, |
| | | InspectionMethod = b.InspectionMethod, |
| | | UsingInstruments = b.UsingInstruments, |
| | | LevelNum = SqlFunc.IsNull( |
| | | SqlFunc.IsNull(b.LevelNum * b.InspectionLevel, 1), |
| | | b.InspectionLevel), |
| | | MaxValue = b.MaxValue, |
| | | StandardValue = b.StandardValue, |
| | | MinValue = b.MinValue, |
| | | Notes = b.Notes, |
| | | FcheckLevel = b.FcheckLevel, |
| | | FacLevel = b.FacLevel, |
| | | QsCode = b.QsCode, |
| | | QsName = b.QsName, |
| | | Result = "未检测", |
| | | isCheck = 0, |
| | | Picture = b.Picture, |
| | | Picturename = b.Picturename |
| | | }).ToList(); |
| | | && b.ItemId == itemId).Select(b => new QsItemOqcItem |
| | | { |
| | | 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), |
| | | Convert.ToDecimal(b.InspectionLevel)), |
| | | MaxValue = Convert.ToDecimal(b.MaxValue), |
| | | StandardValue = Convert.ToDecimal(b.StandardValue), |
| | | MinValue = Convert.ToDecimal(b.MinValue), |
| | | Notes = b.Notes, |
| | | FcheckLevel = b.FcheckLevel, |
| | | FacLevel = b.FacLevel, |
| | | QsCode = b.QsCode, |
| | | QsName = b.QsName, |
| | | Result = "未检测", |
| | | isCheck = 0, |
| | | Picture = b.Picture, |
| | | Picturename = b.Picturename |
| | | }).ToList(); |
| | | |
| | | qsItemOqcItems.ForEach(item => |
| | | { |
| | |
| | | break; |
| | | default: |
| | | LEV = ""; // 默认值 |
| | | |
| | | break; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(LEV)) |
| | | throw new Exception("该物料未维护检验项目或检验水平为空"); |
| | | |
| | | var sql = |
| | | "SELECT " + LEV + |
| | |
| | | return db.Queryable<QsItemOqcItem, QsItemOqcItemDetail>((a, b) => |
| | | new JoinQueryInfos(JoinType.Left, a.Id == b.Pid)) |
| | | .WhereIF(pid > 0, (a, b) => a.Pid == pid) |
| | | .WhereIF(id > 0, (a, b) => a.Id == id) |
| | | //.WhereIF(id > 0, (a, b) => a.Id == id) |
| | | .GroupBy((a, b) => new |
| | | { |
| | | a.Id, |
| | |
| | | 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>() |
| | |
| | | .ExecuteCommand()); |
| | | } |
| | | |
| | | |
| | | public List<QsItemOqcReq> getPage(XJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | |
| | | lineNo = _baseService.getUserLineNo(queryObj.createUser); |
| | | |
| | | return db.Queryable<QsItemOqcReq, RKJDaa001>((a, b) => |
| | | new JoinQueryInfos(JoinType.Left, a.BillNo == b.RbillNo && a.ItemId ==b.ItemId)) |
| | | |
| | | new JoinQueryInfos(JoinType.Left, |
| | | a.Id == b.ItemInId && a.ItemId == b.ItemId)) |
| | | .WhereIF(lineNo != null && lineNo.Length > 0, |
| | | (a, b) => lineNo.Contains(b.LineNo)) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | "未完成".Equals(queryObj.result), |
| | | (a, b) => a.FcheckResu == null || a.Fsubmit == null || |
| | | a.Fsubmit == 0) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | !"未完成".Equals(queryObj.result), |
| | | (a, b) => a.FcheckResu != null && a.Fsubmit != null && |
| | | a.Fsubmit != 0) |
| | | .WhereIF(id > 0, (a, b) => a.Id == id) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.itemCj), |
| | | (a, b) => b.itemCj.Contains(queryObj.itemCj)) |
| | | .Select((a, b) => new QsItemOqcReq |
| | | { |
| | | Id = a.Id, |
| | | ReleaseNo = a.ReleaseNo, |
| | | BillNo = a.BillNo, |
| | | Quantity = b.Quantity, |
| | | CreateBy = a.CreateBy, |
| | | CreateDate = a.CreateDate, |
| | | ItemNo = a.ItemNo, |
| | | TaskNo = b.WorkNo, |
| | | ItemName = b.ItemName, |
| | | ItemModel = b.ItemModel, |
| | | LineNo = b.LineNo, |
| | | FcheckResu = a.FcheckResu, |
| | | FcheckBy = a.FcheckBy, |
| | | FcheckDate = a.FcheckDate, |
| | | MoidNum = a.MoidNum, |
| | | Remarks = a.Remarks, |
| | | ItemId = a.ItemId, |
| | | Fsubmit = a.Fsubmit, |
| | | itemCj = b.itemCj |
| | | }) |
| | | .OrderBy(a => a.CreateDate, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | } |
| | | |
| | | public PageResult<QsItemOqcReq> getSearchPage(XJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | var id = Convert.ToDecimal(queryObj.id); |
| | | string[]? lineNo = null; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(queryObj.createUser)) |
| | | lineNo = _baseService.getUserLineNo(queryObj.createUser); |
| | | |
| | | var query = db.Queryable<QsItemOqcReq, RKJDaa001>((a, b) => |
| | | new JoinQueryInfos(JoinType.Left, |
| | | a.Id == b.ItemInId && a.ItemId == b.ItemId)) |
| | | .WhereIF(lineNo != null && lineNo.Length > 0, |
| | | (a, b) => lineNo.Contains(b.LineNo)) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | "未完成".Equals(queryObj.result), |
| | | (a, b) => a.FcheckResu == null || a.Fsubmit == null || |
| | | a.Fsubmit == 0) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | !"未完成".Equals(queryObj.result), |
| | | (a, b) => a.FcheckResu != null && a.Fsubmit != null && |
| | | a.Fsubmit != 0) |
| | | .WhereIF(id > 0, (a, b) => a.Id == id) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemNo), |
| | | (a, b) => a.ItemNo.Contains(queryObj.ItemNo)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemModel), |
| | | (a, b) => b.ItemModel.Contains(queryObj.ItemModel)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SongJ), |
| | | (a, b) => a.FcheckBy.Contains(queryObj.SongJ)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SongNo), |
| | | (a, b) => a.ReleaseNo.Contains(queryObj.SongNo)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemName), |
| | | (a, b) => b.ItemName.Contains(queryObj.ItemName)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.itemCj), |
| | | (a, b) => b.itemCj.Contains(queryObj.itemCj)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemCode), |
| | | (a, b) => a.BillNo.Contains(queryObj.ItemCode)) |
| | | .Select((a, b) => new |
| | | { |
| | | a.Id, |
| | | a.ReleaseNo, |
| | | a.BillNo, |
| | | b.Quantity, |
| | | a.CreateBy, |
| | | a.CreateDate, |
| | | a.ItemNo, |
| | | b.WorkNo, |
| | | b.ItemName, |
| | | b.ItemModel, |
| | | b.LineNo, |
| | | a.FcheckResu, |
| | | a.FcheckBy, |
| | | a.FcheckDate, |
| | | a.MoidNum, |
| | | a.Remarks, |
| | | a.ItemId, |
| | | a.Fsubmit, |
| | | b.itemCj |
| | | }) |
| | | .MergeTable() |
| | | .OrderBy(it => it.CreateDate, OrderByType.Desc); |
| | | |
| | | var totalCountRef = 0; |
| | | var rawList = query.ToPageList(queryObj.PageIndex, queryObj.Limit, |
| | | ref totalCountRef); |
| | | |
| | | var resultList = rawList.Select(it => new QsItemOqcReq |
| | | { |
| | | Id = it.Id, |
| | | ReleaseNo = it.ReleaseNo, |
| | | BillNo = it.BillNo, |
| | | Quantity = it.Quantity, |
| | | CreateBy = it.CreateBy, |
| | | CreateDate = it.CreateDate, |
| | | ItemNo = it.ItemNo, |
| | | TaskNo = it.WorkNo, |
| | | ItemName = it.ItemName, |
| | | ItemModel = it.ItemModel, |
| | | LineNo = it.LineNo, |
| | | FcheckResu = it.FcheckResu, |
| | | FcheckBy = it.FcheckBy, |
| | | FcheckDate = it.FcheckDate, |
| | | MoidNum = it.MoidNum, |
| | | Remarks = it.Remarks, |
| | | ItemId = it.ItemId, |
| | | Fsubmit = it.Fsubmit, |
| | | itemCj = it.itemCj |
| | | }).ToList(); |
| | | |
| | | return new PageResult<QsItemOqcReq> |
| | | { |
| | | tbBillList = resultList |
| | | }; |
| | | } |
| | | |
| | | /* |
| | | public List<QsItemOqcReq> getPage(XJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var id = Convert.ToDecimal(queryObj.id); |
| | | |
| | | string[]? lineNo = null; |
| | | |
| | | if (StringUtil.IsNotNullOrEmpty(queryObj.createUser)) |
| | | lineNo = _baseService.getUserLineNo(queryObj.createUser); |
| | | |
| | | return db.Queryable<QsItemOqcReq, RKJDaa001>((a, b) => |
| | | new JoinQueryInfos(JoinType.Left, a.Id == b.ItemInId && a.ItemId ==b.ItemId)) |
| | | |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | "未完成".Equals(queryObj.result), |
| | |
| | | CreateBy = a.CreateBy, |
| | | CreateDate = a.CreateDate, |
| | | ItemNo = a.ItemNo, |
| | | TaskNo = b.LotNo, |
| | | TaskNo = b.WorkNo, |
| | | ItemName = b.ItemName, |
| | | ItemModel = b.ItemModel, |
| | | LineNo = b.LineNo, |
| | |
| | | FcheckBy = a.FcheckBy, |
| | | FcheckDate = a.FcheckDate, |
| | | MoidNum = a.MoidNum, |
| | | |
| | | Remarks = a.Remarks |
| | | |
| | | Remarks = a.Remarks, |
| | | ItemId = a.ItemId |
| | | }).OrderBy(a => a.CreateDate, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | } |
| | | */ |
| | | |
| | | //删除主表并且连级删除子表和孙表 |
| | | public int removeXJ(decimal? id) |
| | |
| | | rkjDto.ItemXj02s = db.Queryable<QsItemOqcItemDetail>() |
| | | .Where(s => s.Pid == id) |
| | | .ToList(); |
| | | // 修复:查询主表数据应该使用qsItemOqcItem.Gid而非id |
| | | // rkjDto.from = db.Queryable<QsItemOqcReq>() |
| | | // .Where(s => s.Id == id) |
| | | // .First(); // 使用First()获取单个对象 |
| | | |
| | | return rkjDto; |
| | | } |
| | |
| | | |
| | | return Convert.ToInt32(rkjDto.gid); |
| | | } |
| | | |
| | | public bool RKJQaSubmit(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 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), |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | // 使用 SqlSugar 执行存储过程 |
| | | db.Ado.ExecuteCommand( |
| | | "BEGIN PRC_WOMDAA_RKJ_UPDATE_RES(:p_Id,:p_Flag,:p_User,:o_Result, :o_Msg); END;", |
| | | parameters.ToArray()); |
| | | |
| | | // 获取输出参数的值 |
| | | 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); |
| | | |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// 使用 MergeTable + 返回最终扁平结构:data.tbBillList = List |
| | | /// <T> |
| | | public class PageResult<T> |
| | | { |
| | | public List<T> tbBillList { get; set; } = new(); |
| | | } |
| | | } |