| | |
| | | using System.Data; |
| | | using System.Xml; |
| | | using Masuit.Tools; |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.service; |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | | using SqlSugar; |
| | | using Tea.Utils; |
| | | using DbType = System.Data.DbType; |
| | | |
| | | |
| | |
| | | |
| | | var totalCount = 0; |
| | | |
| | | //var itemIds = GetQaItem(db, queryObj.createUser); |
| | | |
| | | var pageList = db.Queryable<LtsLlj>() |
| | | var pageList = db.Queryable<LtsLlj, IqcBefore, SysUser, |
| | | IqcBeforeFrom, SysUser, SysUser>((a, b, |
| | | e, f, g, i) => |
| | | new JoinQueryInfos(JoinType.Left, a.ItemId == b.ItemId, |
| | | JoinType.Left, a.CreateBy == e.Fcode, |
| | | JoinType.Left, f.Id == b.Pid, |
| | | JoinType.Left, f.Sid == Convert.ToDecimal(g.Fid), |
| | | JoinType.Left, f.CheckUser == i.Fcode |
| | | )) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | "未完成".Equals(queryObj.result), |
| | | a => a.FcheckResu == null) |
| | | (a, b, |
| | | e, f, g, i) => a.FcheckResu == null) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | !"未完成".Equals(queryObj.result), |
| | | a => a.FcheckResu != null) |
| | | .WhereIF(id > 0, a => a.Id == id) |
| | | (a, b, |
| | | e, f, g, i) => a.FcheckResu != null) |
| | | .WhereIF(id > 0, (a, b, |
| | | e, f, g, i) => a.Id == id) |
| | | .WhereIF(queryObj.createUser != "PL017" && queryObj.UserIndex == "0", (a, b, |
| | | e, f, g, i) => (g.Fcode == queryObj.createUser || i.Fcode == queryObj.createUser || |
| | | (g.Fcode == null && i.Fcode == null)))//判断此单的检验员,或者检验为空就显示此单据 |
| | | |
| | | //加筛选条件,根据供应商,物料编码,物料名称搜索 |
| | | //.WhereIF(queryObj.SearchValue!=null && queryObj.SearchValue!="", (a) => a.SuppName == queryObj.SearchValue|| a.ItemName == queryObj.SearchValue || a.ItemNo == queryObj.SearchValue ) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue), |
| | | a => a.SuppName.ToLower() |
| | | (a, b, |
| | | e, f, g, i) => a.SuppName.ToLower() |
| | | .Contains(queryObj.SearchValue.ToLower()) |
| | | || a.ItemName.ToLower() |
| | | .Contains(queryObj.SearchValue.ToLower()) |
| | | || a.ItemNo.ToLower() |
| | | .Contains(queryObj.SearchValue.ToLower())) |
| | | .OrderByDescending(a => a.Id) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); |
| | | .Contains(queryObj.SearchValue.ToLower()) |
| | | || a.LotNo.ToLower() |
| | | .Contains(queryObj.SearchValue.ToLower()) |
| | | || a.ReleaseNo.ToLower() |
| | | .Contains(queryObj.SearchValue.ToLower()) |
| | | || a.ItemModel.ToLower() |
| | | .Contains(queryObj.SearchValue.ToLower())) |
| | | .OrderByDescending((a, b, |
| | | e, f, g, i) => a.Id) |
| | | //.Select((a, b, |
| | | // e, f, g, i) => new LtsLlj |
| | | // { |
| | | // //UserName = g.Fname, |
| | | // //UserName = (i.Fname!=null ||i.Fname!="") ? i.Fname : g.Fname, |
| | | // UserName = i.Fname != null || i.Fname != "" ? i.Fname : g.Fname, |
| | | // CreateUserName = e.Fname |
| | | // }, true) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); |
| | | |
| | | |
| | | var emergencyValues = pageList.Select(item => item.EMERGENCY).ToList(); |
| | | return (pageList, totalCount); |
| | | } |
| | | |
| | | //根据检验标准来计算检验个数 |
| | | public List<MesQaItemsDetectDetail5> SetItems(string itemNo, |
| | | decimal quantity, string releaseNo) |
| | | /// <summary> |
| | | /// 调用存储过程,重新获取检验项目 |
| | | /// </summary> |
| | | /// <param name="itemNo"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <param name="releaseNo"></param> |
| | | /// <returns></returns> |
| | | public string[] SetItems(decimal itemNo, decimal quantity, string releaseNo) |
| | | { |
| | | |
| | | // 定义输出参数 |
| | | 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_RELEASE_NO", releaseNo, DbType.String, ParameterDirection.Input), |
| | | new("P_ITEM_ID", itemNo, DbType.String, ParameterDirection.Input), |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | // 使用 SqlSugar 执行存储过程 |
| | | db.Ado.ExecuteCommand( |
| | | "BEGIN PRC_QA_ITEM_INSERT_BTN(:P_RELEASE_NO,:P_ITEM_ID, :o_Result, :o_Msg); END;", |
| | | parameters.ToArray()); |
| | | |
| | | // 获取输出参数的值 |
| | | var resultValue = outputResult.Value?.ToString(); |
| | | var messageValue = outputMessage.Value?.ToString(); |
| | | string[] msg = new string[2]; |
| | | msg[0] = resultValue; |
| | | msg[1] = messageValue; |
| | | return msg; |
| | | |
| | | } |
| | | //紧急放行 |
| | | //public string[] EmergencyRelease(int id) |
| | | //{ |
| | | // var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | |
| | | // int emergencyStatus = db.Queryable<MesQaItemsDetect01>() |
| | | // .Where(t => t.Id == id) |
| | | // .Select(t => t.EMERGENCY) |
| | | // .First(); |
| | | |
| | | // if (emergencyStatus != 0) |
| | | // { |
| | | // return new string[] { "1", "非紧急状态,无法执行紧急放行" }; |
| | | // } |
| | | |
| | | |
| | | // var outputResult = new SugarParameter("PO_RESULT", null, |
| | | // DbType.Int32, ParameterDirection.Output, 4000); |
| | | |
| | | // var outputMessage = new SugarParameter("PO_MSG", null, |
| | | // DbType.String, ParameterDirection.Output, 4000); |
| | | |
| | | // var parameters = new List<SugarParameter> |
| | | //{ |
| | | // new("P_ID", id, DbType.Int32, ParameterDirection.Input), |
| | | // outputResult, |
| | | // outputMessage |
| | | //}; |
| | | |
| | | // db.Ado.ExecuteCommand( |
| | | // "BEGIN prc_MES_QA_ITEMS_update1(:P_ID, :PO_RESULT, :PO_MSG); END;", |
| | | // parameters.ToArray()); |
| | | |
| | | // var lotNo1 = db.Queryable<MesQaItemsDetect01>() |
| | | // .Where(t => t.Id == id) |
| | | // .Select(t => t.LotNo1) |
| | | // .First(); |
| | | |
| | | // var resultValue = outputResult.Value?.ToString(); |
| | | // var messageValue = outputMessage.Value?.ToString(); |
| | | // return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" }; |
| | | //} |
| | | |
| | | //public string[] WithdrawEmergencyRelease(int id) |
| | | //{ |
| | | // var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | |
| | | // int emergencyStatus = db.Queryable<MesQaItemsDetect01>() |
| | | // .Where(t => t.Id == id) |
| | | // .Select(t => t.EMERGENCY) |
| | | // .First(); |
| | | |
| | | // if (emergencyStatus != 0) |
| | | // { |
| | | // return new string[] { "1", "非紧急状态,无需撤回" }; |
| | | // } |
| | | |
| | | // var outputResult = new SugarParameter("PO_RESULT", null, |
| | | // DbType.Int32, ParameterDirection.Output, 4000); |
| | | |
| | | // var outputMessage = new SugarParameter("PO_MSG", null, |
| | | // DbType.String, ParameterDirection.Output, 4000); |
| | | |
| | | // var parameters = new List<SugarParameter> |
| | | //{ |
| | | // new("P_ID", id, DbType.Int32, ParameterDirection.Input), |
| | | // outputResult, |
| | | // outputMessage |
| | | //}; |
| | | |
| | | // db.Ado.ExecuteCommand( |
| | | // "BEGIN prc_MES_QA_ITEMS_update2(:P_ID, :PO_RESULT, :PO_MSG); END;", |
| | | // parameters.ToArray()); |
| | | |
| | | // var lotNo1 = db.Queryable<MesQaItemsDetect01>() |
| | | // .Where(t => t.Id == id) |
| | | // .Select(t => t.LotNo1) |
| | | // .First(); |
| | | |
| | | |
| | | // var resultValue = outputResult.Value?.ToString(); |
| | | // var messageValue = outputMessage.Value?.ToString(); |
| | | // return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" }; |
| | | //} |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public string[] EmergencyRelease(int id) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | |
| | | var count = db.Queryable<MesQaIqc>().Where(s => s.EE == 1 && |
| | | s.ISENABLED == 1 |
| | | && s.ItemNo == itemNo && s.FTYPE == "1").Count(); |
| | | int emergencyStatus = db.Queryable<MesQaItemsDetect01>() |
| | | .Where(t => t.Id == id) |
| | | .Select(t => t.EMERGENCY) |
| | | .First(); |
| | | |
| | | if (count <= 0) return []; |
| | | |
| | | var mesQaIqcItem = db |
| | | .Queryable<MesQaIqc>().Where(s => s.EE == 1 && s.ISENABLED == 1 |
| | | && s.ItemNo == itemNo && s.FTYPE == "1").Select( |
| | | b => new MesQaItemsDetectDetail5 |
| | | { |
| | | ReleaseNo = releaseNo, |
| | | FacLevel = b.FacLevel, |
| | | FcheckItem = b.FcheckItem, |
| | | FdownAllow = b.FdownAllow, |
| | | FcheckLevel = b.FREQUENCY, |
| | | Fstand = b.FSTAND, |
| | | FupAllow = b.FupAllow, |
| | | SampleSizeNo = b.SampleSizeNo, |
| | | FenterQty = 0, |
| | | Factory = "1000", |
| | | Company = "1000", |
| | | |
| | | |
| | | // FcheckItemDesc = "0", |
| | | // FcheckResu = "0", |
| | | FcheckTool = b.FcheckTool, |
| | | FspecRequ = b.FspecRequ |
| | | // FtextType = "0", |
| | | // Funit = "0", |
| | | // LastupdateBy = "0", |
| | | // ProcNo = "0", |
| | | // WorkshopCenterCode = "0" |
| | | }).ToList(); |
| | | |
| | | mesQaIqcItem.ForEach(item => |
| | | if (emergencyStatus != 0) |
| | | { |
| | | var LEV = item.FcheckLevel switch |
| | | { |
| | | null => "" // 默认值 |
| | | , |
| | | { } s when s.Contains("S1") => "B.FLEVEL_S1", |
| | | { } s when s.Contains("S2") => "B.FLEVEL_S2", |
| | | { } s when s.Contains("S3") => "B.FLEVEL_S3", |
| | | { } s when s.Contains("S4") => "B.FLEVEL_S4", |
| | | { } s when s.Contains("(I)") => "B.FLEVEL_I", |
| | | { } s when s.Contains("(II)") => "B.FLEVEL_II", |
| | | { } s when s.Contains("(III)") => "B.FLEVEL_III", |
| | | _ => "" |
| | | }; |
| | | return new string[] { "1", "非紧急状态,无法执行紧急放行" }; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(LEV)) |
| | | throw new Exception(item.SampleSizeNo + "的检验水平不正确"); |
| | | |
| | | var sql = |
| | | "SELECT " + LEV + |
| | | " FROM MES_QM_AQL1 A LEFT JOIN MES_QM_AQL2 B ON B.AQL1_ID=A.ID WHERE A.SAMPLE_SIZE_NO='" + |
| | | item.SampleSizeNo + "' AND B.LOT_FROM<= " + quantity + |
| | | " AND " + |
| | | quantity + "<=B.LOT_TO"; |
| | | var outputResult = new SugarParameter("PO_RESULT", null, |
| | | DbType.Int32, ParameterDirection.Output, 4000); |
| | | |
| | | var maxBillNo = db.Ado.SqlQuerySingle<string>(sql); |
| | | var outputMessage = new SugarParameter("PO_MSG", null, |
| | | DbType.String, ParameterDirection.Output, 4000); |
| | | |
| | | if (string.IsNullOrEmpty(maxBillNo)) |
| | | throw new Exception(item.SampleSizeNo + "下的" + quantity + |
| | | "这个范围下没有匹配到检验项目"); |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | new("P_ID", id, DbType.Int32, ParameterDirection.Input), |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | | |
| | | var result = ExtractSubstring(item.FacLevel, '(', ')'); |
| | | db.Ado.ExecuteCommand( |
| | | "BEGIN prc_MES_QA_ITEMS_update1(:P_ID, :PO_RESULT, :PO_MSG); END;", |
| | | parameters.ToArray()); |
| | | |
| | | if (string.IsNullOrEmpty(result)) |
| | | throw new Exception(item.SampleSizeNo + "下的" + quantity + |
| | | "拒收水平不正确"); |
| | | var lotNo1 = db.Queryable<MesQaItemsDetect01>() |
| | | .Where(t => t.Id == id) |
| | | .Select(t => t.LotNo1) |
| | | .First(); |
| | | |
| | | sql = "SELECT FSAMPLE_SIZE_WORD, " + result + |
| | | " Result FROM MES_QM_AQL1 A LEFT JOIN MES_QM_AQL3 C ON C.AQL1_ID=A.ID WHERE A.SAMPLE_SIZE_NO= '" + |
| | | item.SampleSizeNo + "' AND SAMPLE_SIZE_WORD= '" + maxBillNo + |
| | | "'"; |
| | | var resultClass = db.Ado.SqlQuerySingle<ResultClass>(sql); |
| | | |
| | | item.CheckQyt = resultClass.FSAMPLE_SIZE_WORD; |
| | | item.FreQty = resultClass.Result; |
| | | }); |
| | | |
| | | return mesQaIqcItem; |
| | | var resultValue = outputResult.Value?.ToString(); |
| | | var messageValue = outputMessage.Value?.ToString(); |
| | | return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" }; |
| | | } |
| | | |
| | | public string[] WithdrawEmergencyRelease(int id) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | |
| | | int emergencyStatus = db.Queryable<MesQaItemsDetect01>() |
| | | .Where(t => t.Id == id) |
| | | .Select(t => t.EMERGENCY) |
| | | .First(); |
| | | |
| | | if (emergencyStatus != 0) |
| | | { |
| | | return new string[] { "1", "非紧急状态,无需撤回" }; |
| | | } |
| | | |
| | | var outputResult = new SugarParameter("PO_RESULT", null, |
| | | DbType.Int32, ParameterDirection.Output, 4000); |
| | | |
| | | var outputMessage = new SugarParameter("PO_MSG", null, |
| | | DbType.String, ParameterDirection.Output, 4000); |
| | | |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | new("P_ID", id, DbType.Int32, ParameterDirection.Input), |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | | |
| | | db.Ado.ExecuteCommand( |
| | | "BEGIN prc_MES_QA_ITEMS_update2(:P_ID, :PO_RESULT, :PO_MSG); END;", |
| | | parameters.ToArray()); |
| | | |
| | | var lotNo1 = db.Queryable<MesQaItemsDetect01>() |
| | | .Where(t => t.Id == id) |
| | | .Select(t => t.LotNo1) |
| | | .First(); |
| | | |
| | | |
| | | var resultValue = outputResult.Value?.ToString(); |
| | | var messageValue = outputMessage.Value?.ToString(); |
| | | return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" }; |
| | | } |
| | | |
| | | private string ExtractSubstring(string input, char startChar, char endChar) |
| | | { |
| | |
| | | a.FreQty, |
| | | a.CheckQyt, |
| | | a.FcheckResu, |
| | | a.FcheckItemDesc |
| | | a.FcheckItemDesc, |
| | | a.Funit, |
| | | a.Meom |
| | | }).Select((a, b) => new MesQaItemsDetectDetail5 |
| | | { |
| | | Id = a.Id, |
| | |
| | | Company = "1000", |
| | | FenterQty = SqlFunc.AggregateCount(b.Id), |
| | | FcheckResu = a.FcheckResu, |
| | | FcheckItemDesc = a.FcheckItemDesc |
| | | // FcheckItemDesc = a.FcheckItemDesc |
| | | FcheckItemDesc = a.FspecRequ, |
| | | Funit = a.Funit, |
| | | Meom = a.Meom, |
| | | }).ToList(); |
| | | } |
| | | |
| | |
| | | |
| | | return commit; |
| | | }); |
| | | |
| | | var isNull = db.Queryable<MesQaItemsDetectDetail5>() |
| | | //5.20xwt修改将更新主表检验结果字段放在IqcQaSubmit方法下 |
| | | /*var isNull = db.Queryable<MesQaItemsDetectDetail5>() |
| | | .Where(s => s.ReleaseNo == detail.ReleaseNo && s.FcheckResu == null) |
| | | .Count(); |
| | | |
| | |
| | | .SetColumns(s => s.LastupdateDate == DateTime.Now) |
| | | .Where(s => s.ReleaseNo == detail.ReleaseNo) |
| | | .ExecuteCommand(); |
| | | }); |
| | | });*/ |
| | | // if (FcheckResu.Equals("不合格")) |
| | | //自动生成入库检异常对策 |
| | | /// saveDetect02(detail.Id, detail.CreateBy); |
| | |
| | | return SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | return db.Updateable<MesQaItemsDetectDetail5>() |
| | | // .SetColumns(it => |
| | | // it.Remarks == dto.Remarks) //SetColumns是可以叠加的 写2个就2个字段赋值 |
| | | .SetColumns(it => |
| | | it.Funit == dto.Remarks) //SetColumns是可以叠加的 写2个就2个字段赋值 |
| | | .Where(it => it.Id == dto.pid) |
| | | .ExecuteCommand(); |
| | | return db.Updateable<MesQaItemsDetectDetail5>() |
| | | .SetColumns(it => |
| | | it.Meom == dto.Meom) |
| | | .Where(it => it.Id == dto.pid) |
| | | .ExecuteCommand(); |
| | | }); |
| | |
| | | |
| | | // 使用 SqlSugar 执行存储过程 |
| | | db.Ado.ExecuteCommand( |
| | | "BEGIN Prc_Mes_Iqc_Qa_Submit82(:PI_FACTORY, :PI_COMPANY, :p_Release_No, :p_User, :o_Result, :o_Msg); END;", |
| | | "BEGIN Prc_Mes_Iqc_Qa_Submit83(:PI_FACTORY, :PI_COMPANY, :p_Release_No, :p_User, :o_Result, :o_Msg); END;", |
| | | parameters.ToArray()); |
| | | |
| | | // 获取输出参数的值 |
| | |
| | | |
| | | if ("1".Equals(resultValue)) throw new Exception(messageValue); |
| | | |
| | | var sum = db.Queryable<MesQaItemsDetectDetail5>() |
| | | .Where(s => s.ReleaseNo == dto.releaseNo).Count(); |
| | | |
| | | if (sum == 0) return true; |
| | | |
| | | var icount = db.Queryable<MesQaItemsDetectDetail5>() |
| | | .Where(s => s.ReleaseNo == dto.releaseNo && s.FcheckResu == "合格") |
| | | .Count(); |
| | | |
| | | var FcheckResu = "不合格"; |
| | | |
| | | if (sum == icount) |
| | | FcheckResu = "合格"; |
| | | |
| | | var sysUser = db.Queryable<SysUser>() |
| | | .Where(s => s.Fcode == dto.userNo).First(); |
| | | |
| | | SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | return db.Updateable<MesQaItemsDetect01>() |
| | | .SetColumns(s => s.FcheckResu == FcheckResu) |
| | | .SetColumns(s => s.FcheckDate == DateTime.Now) |
| | | .SetColumns(s => s.FcheckBy == sysUser.Fname) |
| | | .SetColumns(s => s.LastupdateBy == dto.userNo) |
| | | .SetColumns(s => s.LastupdateDate == DateTime.Now) |
| | | .Where(s => s.ReleaseNo == dto.releaseNo) |
| | | .ExecuteCommand(); |
| | | }); |
| | | return true; |
| | | } |
| | | catch (Exception ex) |