| | |
| | | using MES.Service.Dto.service; |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.VisualBasic.CompilerServices; |
| | | using SqlSugar; |
| | | //using DbType = SqlSugar.DbType; |
| | | using DbType = System.Data.DbType; |
| | |
| | | |
| | | // 获取仓库代码的子查询 |
| | | var depotCodes = db.Queryable<SysUser>() |
| | | .LeftJoin<SysUserRole>((h, f) => h.Fid == f.Userid) // SysUser 和 SysUserRole 关联 |
| | | .LeftJoin<SysRole>((h, f, e) => f.Roleid == e.Roleid) // SysUserRole 和 SysRole 关联 |
| | | .LeftJoin<MesDepots>((h, f, e, dp) => f.DepotId == dp.DepotId) // SysUserRole 和 MesDepots 关联 |
| | | .LeftJoin< |
| | | SysUserRole>((h, f) => |
| | | h.Fid == f.Userid) // SysUser 和 SysUserRole 关联 |
| | | .LeftJoin< |
| | | SysRole>((h, f, e) => |
| | | f.Roleid == e.Roleid) // SysUserRole 和 SysRole 关联 |
| | | .LeftJoin< |
| | | MesDepots>((h, f, e, dp) => |
| | | f.DepotId == dp.DepotId) // SysUserRole 和 MesDepots 关联 |
| | | .Where((h, f, e, dp) => h.Fcode == userCode) // 筛选条件:SysUser 的 Fcode |
| | | .Select((h, f, e, dp) => dp.DepotCode) // 选择字段:MesDepots 的 DepotCode |
| | | .ToList(); // 转换为列表 |
| | |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | "未完成".Equals(queryObj.result), |
| | | a => a.FcheckResu == null) |
| | | a => a.FcheckResu == null && a.STATUS == "未提交") |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | !"未完成".Equals(queryObj.result), |
| | | a => a.FcheckResu != null) |
| | | a => a.FcheckResu != null && a.STATUS == "已提交") |
| | | .WhereIF(id > 0, a => a.Id == id) |
| | | .Where(a => depotCodes.Contains(a.DepotCode)) // 使用 Contains 方法模拟 IN 条件 根据仓库过滤 |
| | | .Where(a => |
| | | depotCodes.Contains(a |
| | | .DepotCode)) // 使用 Contains 方法模拟 IN 条件 根据仓库过滤 |
| | | .OrderByDescending(a => a.Id) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); |
| | | |
| | |
| | | } |
| | | |
| | | //根据检验标准来计算检验个数 |
| | | public List<MesQaItemsDetectDetail5> SetItems(string itemNo, decimal quantity, string releaseNo) |
| | | public List<MesQaItemsDetectDetail5> SetItems(string itemId, |
| | | decimal quantity, string releaseNo) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var count = db.Queryable<MesQaIqc>().Where(s => s.EE == 1 && s.ISENABLED == 1 |
| | | && s.ItemNo == itemNo && s.FTYPE == "1").Count(); |
| | | var count = db.Queryable<MesQaIqc>().Where(s => s.EE == 1 && |
| | | s.ISENABLED == 1 |
| | | && s.ItemId == itemId && s.FTYPE == "1").Count(); |
| | | |
| | | 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 |
| | | && s.ItemId == itemId && s.FTYPE == "1").Select(b => |
| | | new MesQaItemsDetectDetail5 |
| | | { |
| | | ReleaseNo = releaseNo, |
| | | FacLevel = b.FacLevel, |
| | |
| | | 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; |
| | |
| | | .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 = "不合格"; |
| | |
| | | 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) |
| | |
| | | // result = "不合格"; |
| | | else if (noCount >= QsItemOqcItem.FreQty) |
| | | result = "不合格"; |
| | | var useTransactionWithOracle = SqlSugarHelper.UseTransactionWithOracle( |
| | | db => |
| | | var useTransactionWithOracle = |
| | | SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | var commit = 0; |
| | | commit += db.Updateable<MesQaItemsDetectDetail5>() |
| | |
| | | }); |
| | | |
| | | 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 = "不合格"; |
| | | |
| | |
| | | { |
| | | 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>() |
| | |
| | | } |
| | | } |
| | | |
| | | public (List<LtsLlj> item, int TotalCount) GetSearchPage(XJPageResult queryObj) |
| | | public (List<LtsLlj> item, int TotalCount) GetSearchPage( |
| | | XJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var id = Convert.ToDecimal(queryObj.id); |
| | | |
| | | int totalCount = 0; |
| | | var totalCount = 0; |
| | | var userCode = queryObj.createUser; |
| | | |
| | | // 获取仓库代码的子查询 |
| | | var depotCodes = db.Queryable<SysUser>() |
| | | .LeftJoin<SysUserRole>((h, f) => h.Fid == f.Userid) // SysUser 和 SysUserRole 关联 |
| | | .LeftJoin<SysRole>((h, f, e) => f.Roleid == e.Roleid) // SysUserRole 和 SysRole 关联 |
| | | .LeftJoin<MesDepots>((h, f, e, dp) => f.DepotId == dp.DepotId) // SysUserRole 和 MesDepots 关联 |
| | | .LeftJoin< |
| | | SysUserRole>((h, f) => |
| | | h.Fid == f.Userid) // SysUser 和 SysUserRole 关联 |
| | | .LeftJoin< |
| | | SysRole>((h, f, e) => |
| | | f.Roleid == e.Roleid) // SysUserRole 和 SysRole 关联 |
| | | .LeftJoin< |
| | | MesDepots>((h, f, e, dp) => |
| | | f.DepotId == dp.DepotId) // SysUserRole 和 MesDepots 关联 |
| | | .Where((h, f, e, dp) => h.Fcode == userCode) // 筛选条件:SysUser 的 Fcode |
| | | .Select((h, f, e, dp) => dp.DepotCode) // 选择字段:MesDepots 的 DepotCode |
| | | .ToList(); // 转换为列表 |
| | |
| | | .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) |
| | | .WhereIF(id > 0, (a) => a.Id == id) |
| | | a => a.FcheckResu != null) |
| | | .WhereIF(id > 0, a => a.Id == id) |
| | | // .Where(a=>a.SuppName.Contains(queryObj.SuppNameContains) |
| | | // && a.SalesOrderId.Contains(queryObj.SalesOrder) |
| | | // && a.ItemNo.Contains(queryObj.ItemNo) |
| | | // ) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SuppNameContains), a => a.SuppName.Contains(queryObj.SuppNameContains)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemNo), a => a.ItemNo.Contains(queryObj.ItemNo)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SalesOrder), a => a.ItemModel.Contains(queryObj.SalesOrder)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SongJ), a => a.FcheckBy.Contains(queryObj.SongJ)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SongNo), a => a.ReleaseNo.Contains(queryObj.SongNo)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemName), a => a.ItemName.Contains(queryObj.ItemName)) |
| | | |
| | | |
| | | .Where(a => depotCodes.Contains(a.DepotCode)) // 使用 Contains 方法模拟 IN 条件 根据仓库过滤 |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SuppNameContains), |
| | | a => a.SuppName.Contains(queryObj.SuppNameContains)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemNo), |
| | | a => a.ItemNo.Contains(queryObj.ItemNo)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SalesOrder), |
| | | a => a.ItemModel.Contains(queryObj.SalesOrder)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SongJ), |
| | | a => a.FcheckBy.Contains(queryObj.SongJ)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SongNo), |
| | | a => a.ReleaseNo.Contains(queryObj.SongNo)) |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.ItemName), |
| | | a => a.ItemName.Contains(queryObj.ItemName)) |
| | | .Where(a => |
| | | depotCodes.Contains(a |
| | | .DepotCode)) // 使用 Contains 方法模拟 IN 条件 根据仓库过滤 |
| | | .OrderBy(a => a.CreateDate, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); |
| | | |