| | |
| | | using MES.Service.DB; |
| | | using System.Data; |
| | | using System.Dynamic; |
| | | 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 class LljService |
| | | { |
| | | |
| | | public List<LtsLlj> GetPage(XJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | "未完成".Equals(queryObj.result), |
| | | (a) =>a.FcheckResu == null) |
| | | a => a.FcheckResu == null) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | !"未完成".Equals(queryObj.result), |
| | | (a) => a.FcheckResu != null) |
| | | a => a.FcheckResu != null) |
| | | .WhereIF(id > 0, (a) => a.Id == id) |
| | | .OrderByDescending(a=>a.Id) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | |
| | | } |
| | | |
| | | //根据检验标准来计算检验个数 |
| | | public List<MesQaItemsDetectDetail5> SetItems(string itemNo, decimal quantity,string releaseNo) |
| | | public List<MesQaItemsDetectDetail5> SetItems(string itemNo, |
| | | decimal quantity, string releaseNo) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | |
| | | var count = db.Queryable<MesQaIqc>().Where(s => s.EE == 1 && s.ISENABLED == 1 |
| | | var count = db.Queryable<MesQaIqc>().Where(s => s.EE == 1 && |
| | | s.ISENABLED == 1 |
| | | && s.ItemNo == itemNo && s.FTYPE == "1").Count(); |
| | | |
| | | if (count <= 0) return []; |
| | |
| | | && s.ItemNo == itemNo && s.FTYPE == "1").Select( |
| | | b => new MesQaItemsDetectDetail5 |
| | | { |
| | | |
| | | ReleaseNo = releaseNo, |
| | | FacLevel = b.FacLevel, |
| | | FcheckItem = b.FcheckItem , |
| | |
| | | // LastupdateBy = "0", |
| | | // ProcNo = "0", |
| | | // WorkshopCenterCode = "0" |
| | | |
| | | }).ToList(); |
| | | |
| | | mesQaIqcItem.ForEach(item => |
| | |
| | | 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 " + |
| | | item.SampleSizeNo + "' AND B.LOT_FROM<= " + quantity + |
| | | " AND " + |
| | | quantity + "<=B.LOT_TO"; |
| | | |
| | | var maxBillNo = db.Ado.SqlQuerySingle<string>(sql); |
| | |
| | | |
| | | 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 + "'"; |
| | | item.SampleSizeNo + "' AND SAMPLE_SIZE_WORD= '" + maxBillNo + |
| | | "'"; |
| | | var resultClass = db.Ado.SqlQuerySingle<ResultClass>(sql); |
| | | |
| | | item.CheckQyt = resultClass.FSAMPLE_SIZE_WORD; |
| | |
| | | var length = endIndex - startIndex - 1; |
| | | return input.Substring(startIndex + 1, length); |
| | | } |
| | | |
| | | public int saveItem(LLJDto rkjDto) |
| | | { |
| | | var items = rkjDto.items; |
| | |
| | | .Where(x => x.FcheckResu == "NG" && x.MainId == s.Id).Count(); |
| | | |
| | | //检验明细总数 |
| | | var count = db.Queryable<MesQaItemsDetectDetail12>().Where(x1 => x1.MainId == s.Id).Count(); |
| | | var count = db.Queryable<MesQaItemsDetectDetail12>() |
| | | .Where(x1 => x1.MainId == s.Id).Count(); |
| | | |
| | | if (ifck > s.FreQty && s.CheckQyt == count) |
| | | { |
| | | s.FcheckResu = "不合格"; |
| | | }else if (ifck < s.FreQty && s.CheckQyt == count) |
| | | } |
| | | else if (ifck < s.FreQty && s.CheckQyt == count) |
| | | { |
| | | s.FcheckResu = "合格"; |
| | | } |
| | |
| | | |
| | | return Convert.ToInt32(rkjDto.gid); |
| | | } |
| | | public List<MesQaItemsDetectDetail5> GetItems(string? releaseNo, decimal? id) |
| | | |
| | | public List<MesQaItemsDetectDetail5> GetItems(string? releaseNo, |
| | | decimal? id) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | return db.Queryable<MesQaItemsDetectDetail5, MesQaItemsDetectDetail12>((a, b) => |
| | | return db.Queryable<MesQaItemsDetectDetail5, MesQaItemsDetectDetail12>( |
| | | (a, b) => |
| | | new JoinQueryInfos(JoinType.Left, a.Id == b.MainId)) |
| | | .Where((a, b) => a.ReleaseNo == releaseNo) |
| | | // .WhereIF(id > 0, (a, b) => a.Id == id) |
| | |
| | | a.FreQty, |
| | | a.CheckQyt, |
| | | a.FcheckResu |
| | | |
| | | |
| | | }).Select((a, b) => new MesQaItemsDetectDetail5 |
| | | { |
| | | Id = a.Id, |
| | |
| | | item.Factory = "1000"; |
| | | item.Company = "1000"; |
| | | result.Add(item); |
| | | |
| | | } |
| | | |
| | | return db.Insertable(result).ExecuteCommand(); |
| | | |
| | | }); |
| | | |
| | | detail.CreateBy = detail.LastupdateBy; |
| | |
| | | }); |
| | | |
| | | var isNull = db.Queryable<MesQaItemsDetectDetail5>() |
| | | .Where(s => s.ReleaseNo == detail.ReleaseNo && s.FcheckResu == null).Count(); |
| | | .Where(s => s.ReleaseNo == detail.ReleaseNo && s.FcheckResu == null) |
| | | .Count(); |
| | | |
| | | if (isNull > 0) return 1; |
| | | |
| | |
| | | |
| | | //获取检验单下的合格的检验项目个数 |
| | | var icount = db.Queryable<MesQaItemsDetectDetail5>() |
| | | .Where(s => s.ReleaseNo == detail.ReleaseNo && s.FcheckResu == "合格").Count(); |
| | | .Where(s => s.ReleaseNo == detail.ReleaseNo && s.FcheckResu == "合格") |
| | | .Count(); |
| | | |
| | | var FcheckResu = "不合格"; |
| | | |
| | |
| | | .SetColumns(s => s.LastupdateBy == detail.LastupdateBy) |
| | | // .SetColumns(s => s.LastupdateDate == DateTime.Now) |
| | | .SetColumnsIF(StringUtil.IsNotNullOrEmpty(detail.Fstand), |
| | | |
| | | s => s.Fstand == detail.Fstand) |
| | | .SetColumnsIF(StringUtil.IsNotNullOrEmpty(detail.FcheckResu), |
| | | s => s.FcheckResu == detail.FcheckResu) |
| | |
| | | |
| | | return withOracle; |
| | | } |
| | | |
| | | //更新检验明细已检、不合格数量 |
| | | private int updateDetail5(MesQaItemsDetectDetail12 detail) |
| | | { |
| | |
| | | |
| | | return withOracle; |
| | | } |
| | | |
| | | //主表修改备注字段 |
| | | public int saveRemarksGid(LLJDto dto) |
| | | { |
| | |
| | | .ExecuteCommand(); |
| | | }); |
| | | } |
| | | |
| | | //子表修改备注字段 |
| | | public int saveRemarksPid(LLJDto dto) |
| | | { |
| | |
| | | { |
| | | var commit = 0; |
| | | //删除主表 |
| | | commit += db.Deleteable<MesQaItemsDetect01>().Where(s => s.ReleaseNo == releaseNo) |
| | | commit += db.Deleteable<MesQaItemsDetect01>() |
| | | .Where(s => s.ReleaseNo == releaseNo) |
| | | .ExecuteCommand(); |
| | | //删除子表 |
| | | commit += db.Deleteable<MesQaItemsDetectDetail5>().Where(s => s.ReleaseNo == releaseNo) |
| | | commit += db.Deleteable<MesQaItemsDetectDetail5>() |
| | | .Where(s => s.ReleaseNo == releaseNo) |
| | | .ExecuteCommand(); |
| | | //删除孙表 |
| | | commit += db.Deleteable<MesQaItemsDetectDetail12>() |
| | |
| | | |
| | | return withOracle; |
| | | } |
| | | |
| | | public bool IqcQaSubmit(LLJDto dto) |
| | | { |
| | | var (factory, company) = UserUtil.GetFactory(dto.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("PI_FACTORY", factory, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_COMPANY", company, DbType.String, |
| | | ParameterDirection.Input), |
| | | new("p_Release_No", dto.releaseNo, DbType.String, |
| | | ParameterDirection.Input), |
| | | new("p_User", dto.userNo, DbType.String, |
| | | ParameterDirection.Input), |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | // 使用 SqlSugar 执行存储过程 |
| | | db.Ado.ExecuteCommand( |
| | | "BEGIN Prc_Mes_Iqc_Qa_Submit82(:PI_FACTORY, :PI_COMPANY, :p_Release_No, :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); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | } |