| | |
| | | using System.Data; |
| | | using MES.Service.Models; |
| | | using Microsoft.IdentityModel.Tokens; |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | | using NewPdaSqlServer.entity; |
| | | using NewPdaSqlServer.util; |
| | | using SqlSugar; |
| | | using DbType = System.Data.DbType; |
| | | |
| | | using static Azure.Core.HttpHeader; |
| | | |
| | | namespace NewPdaSqlServer.service.QC; |
| | | |
| | |
| | | var parsedGuid = Guid.Empty; |
| | | if (!queryObj.id.IsNullOrEmpty()) |
| | | { |
| | | bool isValid = Guid.TryParse(queryObj.id, out parsedGuid); |
| | | var isValid = Guid.TryParse(queryObj.id, out parsedGuid); |
| | | if (!isValid) |
| | | throw new ApplicationException("GUID转换错误"); |
| | | } |
| | |
| | | var totalCount = 0; |
| | | |
| | | var pageList = Db.Queryable<LLJView>() |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | "未完成".Equals(queryObj.result), |
| | | a => a.FcheckResu == null) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | !"未完成".Equals(queryObj.result), |
| | | a => a.FcheckResu != null) |
| | | //.WhereIF( |
| | | // StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | // "未完成".Equals(queryObj.result), |
| | | // a => (a.STATUS ?? "") != "已提交") |
| | | // //a => (a.FcheckResu ?? "") == ""|| (a.FcheckResu ?? "") == "检验中") |
| | | //.WhereIF( |
| | | // StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | | // !"未完成".Equals(queryObj.result), |
| | | // a => (a.STATUS ?? "") == "已提交") |
| | | |
| | | .WhereIF(!string.IsNullOrWhiteSpace(queryObj.keyword), a => |
| | | a.ItemNo.Contains(queryObj.keyword) || |
| | | a.ItemName.Contains(queryObj.keyword) || |
| | | a.LotNo.Contains(queryObj.keyword) || |
| | | a.ReleaseNo.Contains(queryObj.keyword) || |
| | | a.SuppName.Contains(queryObj.keyword) |
| | | ) |
| | | .WhereIF(UtilityHelper.CheckGuid(parsedGuid), |
| | | a => a.guid == parsedGuid) |
| | | a => a.guid == parsedGuid ) |
| | | .Where(a => (a.fsubmit ?? 0) == 0) |
| | | .OrderByDescending(a => a.CreateDate) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); |
| | | |
| | |
| | | FcheckItem = b.FcheckItem, |
| | | FdownAllow = b.FdownAllow, |
| | | FcheckLevel = b.FREQUENCY, |
| | | Fstand = Convert.ToInt32(b.FSTAND), |
| | | Fstand = b.FSTAND, |
| | | FupAllow = b.FupAllow, |
| | | SampleSizeNo = b.SampleSizeNo, |
| | | FenterQty = 0, |
| | |
| | | |
| | | mesQaIqcItem.ForEach(item => |
| | | { |
| | | string LEV = item.FcheckLevel switch |
| | | var LEV = item.FcheckLevel switch |
| | | { |
| | | null => "" // 默认值 |
| | | , |
| | |
| | | { |
| | | foreach (var item in items) item.ReleaseNo = rkjDto.releaseNo; |
| | | |
| | | return db.Insertable(items).ExecuteCommand(); |
| | | return db.Insertable(items).IgnoreColumns(true).ExecuteCommand(); |
| | | }); |
| | | |
| | | rkjDto.items = GetItems(rkjDto.releaseNo, null); |
| | |
| | | } |
| | | |
| | | public List<MesQaItemsDetectDetail5> GetItems(string? releaseNo, |
| | | decimal? id) |
| | | string? id) |
| | | { |
| | | var parsedGuid = Guid.Empty; |
| | | |
| | | if (id != null) |
| | | { |
| | | var isValid = Guid.TryParse(id, out parsedGuid); |
| | | if (!isValid) |
| | | throw new ApplicationException("GUID转换错误"); |
| | | } |
| | | |
| | | return Db.Queryable<MesQaItemsDetectDetail5, MesQaItemsDetectDetail12>( |
| | | (a, b) => |
| | | new JoinQueryInfos(JoinType.Left, a.Guid == b.ParentGuid)) |
| | | .Where((a, b) => a.ReleaseNo == releaseNo) |
| | | // .WhereIF(id > 0, (a, b) => a.Id == id) |
| | | .WhereIF(UtilityHelper.CheckGuid(parsedGuid), |
| | | (a, b) => a.Guid == parsedGuid) |
| | | .GroupBy((a, b) => new |
| | | { |
| | | a.Guid, |
| | | a.ParentGuid, |
| | | a.ReleaseNo, |
| | | a.FacLevel, |
| | | a.FcheckItem, |
| | |
| | | a.FspecRequ, |
| | | a.FreQty, |
| | | a.CheckQyt, |
| | | a.FcheckResu |
| | | a.FcheckResu, |
| | | a.Order, |
| | | a.Ybsl |
| | | }).Select((a, b) => new MesQaItemsDetectDetail5 |
| | | { |
| | | Guid = a.Guid, |
| | | ParentGuid = a.ParentGuid, |
| | | ReleaseNo = a.ReleaseNo, |
| | | CheckQyt = a.CheckQyt, |
| | | FacLevel = a.FacLevel, |
| | |
| | | Factory = "1000", |
| | | Company = "1000", |
| | | FenterQty = SqlFunc.AggregateCount(b.Guid), |
| | | FcheckResu = a.FcheckResu |
| | | }).ToList(); |
| | | FcheckResu = a.FcheckResu, |
| | | Order = a.Order, |
| | | Ybsl = a.Ybsl, |
| | | }).OrderBy(a => a.Order) |
| | | .ToList(); |
| | | } |
| | | |
| | | public int SetQSItemDetail(MesQaItemsDetectDetail12 detail) |
| | |
| | | { |
| | | var item = new MesQaItemsDetectDetail12(); |
| | | item.ParentGuid = detail.ParentGuid; |
| | | item.GrandpaGuid = detail.GrandpaGuid; |
| | | item.FcheckItem = detail.FcheckItem; |
| | | item.Fstand = detail.Fstand; |
| | | item.FcheckResu = detail.FcheckResu; |
| | | item.CreateBy = detail.LastupdateBy; |
| | |
| | | result.Add(item); |
| | | } |
| | | |
| | | return db.Insertable(result).ExecuteCommand(); |
| | | return db.Insertable(result).PageSize(1).IgnoreColumnsNull().ExecuteCommand(); |
| | | }); |
| | | |
| | | detail.CreateBy = detail.LastupdateBy; |
| | |
| | | commit += db.Updateable<MesQaItemsDetectDetail5>() |
| | | .SetColumns(s => s.FcheckResu == result) |
| | | .SetColumns(s => s.FenterQty == count) |
| | | .SetColumns(s => s.FngRate == (s.CheckQyt == 0 ? (decimal?)null : (decimal?)(Convert.ToDouble(noCount) / Convert.ToDouble(count)))) |
| | | .Where(s => s.Guid == detail.ParentGuid) |
| | | .ExecuteCommand(); |
| | | |
| | |
| | | { |
| | | var rkjDto = new LLJDto(); |
| | | |
| | | bool isValid = Guid.TryParse(id, out var parsedGuid); |
| | | var isValid = Guid.TryParse(id, out var parsedGuid); |
| | | |
| | | if (!isValid) |
| | | { |
| | | throw new Exception("GUID转换错误"); |
| | | } |
| | | if (!isValid) throw new Exception("GUID转换错误"); |
| | | |
| | | var qsItemOqcItem = |
| | | Db.Queryable<MesQaItemsDetectDetail5>() |
| | |
| | | rkjDto.ItemXj02s = Db.Queryable<MesQaItemsDetectDetail12>() |
| | | .Where(s => s.ParentGuid == parsedGuid) |
| | | .ToList(); |
| | | |
| | | foreach (var mesQaItemsDetectDetail12 in rkjDto.ItemXj02s) |
| | | { |
| | | //this.formData.fupAllow && this.formData.fdownAllow && this.formData.fstand |
| | | mesQaItemsDetectDetail12.isNumber = true; |
| | | if (qsItemOqcItem.FupAllow.IsNullOrEmpty() |
| | | && qsItemOqcItem.FdownAllow.IsNullOrEmpty() |
| | | && qsItemOqcItem.Fstand == null) |
| | | mesQaItemsDetectDetail12.isNumber = false; |
| | | } |
| | | |
| | | return rkjDto; |
| | | } |
| | |
| | | //子表修改备注字段 |
| | | public int saveRemarksPid(LLJDto dto) |
| | | { |
| | | bool isValid = Guid.TryParse(dto.pid, out var parsedGuid); |
| | | var isValid = Guid.TryParse(dto.pid, out var parsedGuid); |
| | | |
| | | if (isValid) |
| | | { |
| | | return UseTransaction(db => |
| | | { |
| | | return db.Updateable<MesQaItemsDetectDetail5>() |
| | |
| | | .Where(it => it.Guid == parsedGuid) |
| | | .ExecuteCommand(); |
| | | }); |
| | | } |
| | | |
| | | throw new Exception("GUID转换错误"); |
| | | } |
| | |
| | | throw new Exception("该检验单已提交"); |
| | | |
| | | if (mesQaItemsDetect01.FcheckDate == null) |
| | | throw new Exception("该检测单未输入检验日期,请核对。"); |
| | | throw new Exception("该检测单没有检验完成,请核对。"); |
| | | |
| | | if (mesQaItemsDetect01.FcheckBy.IsNullOrEmpty()) |
| | | throw new Exception("该检测单未输入检验人员,请核对。"); |
| | |
| | | { |
| | | mesQaItemsDetectDetail5.FenterQty ??= 0; |
| | | if (mesQaItemsDetectDetail5.FenterQty == 0) |
| | | { |
| | | throw new Exception("检验项目:" + |
| | | mesQaItemsDetectDetail5.FcheckItem + |
| | | " 已录入数量为0,请确认。"); |
| | | } |
| | | } |
| | | |
| | | var com = UseTransaction(db => |
| | |
| | | TotalOkRkQty = SqlFunc.AggregateSum(b.OkRkqty) |
| | | }) |
| | | .First(); |
| | | |
| | | |
| | | var totalQuantity = first.TotalQuantity ?? 0; |
| | | var totalOkRkQty = first.TotalOkRkQty ?? 0; |
| | | |
| | |
| | | executeCommand += db.Updateable<MesInvItemArnDetail>() |
| | | .SetColumns(s => s.CheckStates == "不合格待审批") |
| | | .SetColumns(s => s.Ischeck == 1) |
| | | .SetColumns(s => s.CheckRes == mesQaItemsDetect01.FcheckResu) |
| | | .SetColumns( |
| | | s => s.CheckRes == mesQaItemsDetect01.FcheckResu) |
| | | .SetColumns(s => s.CheckDate == DateTime.Now) |
| | | .Where(s => s.ParentGuid == mesInvItemArn.Guid |
| | | && s.ItemId == mesQaItemsDetect01.ItemId) |
| | | .ExecuteCommand(); |
| | | |
| | | |
| | | executeCommand += db.Updateable<MesQaItemsDetect01>() |
| | | .SetColumns(s => s.IqcDate == DateTime.Now) |
| | | .SetColumns(s => s.FcheckDate == DateTime.Now) |
| | |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | if (executeCommand >=3) |
| | | if (executeCommand >= 3) |
| | | return executeCommand; |
| | | |
| | | throw new Exception("更新失败"); |
| | |
| | | |
| | | return com > 0; |
| | | } |
| | | |
| | | public int[] getBadge() |
| | | { |
| | | var isNullCount = Db.Queryable<MesQaItemsDetect01>() |
| | | .Where(a => (a.FcheckResu ?? "") == "").Count(); |
| | | |
| | | var isNotNullCount = Db.Queryable<MesQaItemsDetect01>() |
| | | .Where(a => (a.FcheckResu ?? "") != "").Count(); |
| | | |
| | | return [isNullCount, isNotNullCount]; |
| | | } |
| | | |
| | | |
| | | |
| | | //删除特征值 |
| | | public int deleteDetail13(LLJDto dto) |
| | | { |
| | | var withOracle = Db.Deleteable<MesQaItemsDetectDetail13>() |
| | | .Where(s => s.Guid.ToString() == dto.id13) |
| | | .ExecuteCommand(); |
| | | |
| | | return withOracle; |
| | | } |
| | | |
| | | //更新不合格描述 |
| | | public int updateRemarks(LLJDto dto) |
| | | { |
| | | var withOracle = Db.Updateable<MesQaItemsDetect01>() |
| | | .SetColumns(s => s.FngDesc == dto.Remarks) |
| | | .Where(s => s.Guid.ToString() == dto.gid) |
| | | .ExecuteCommand(); |
| | | |
| | | return withOracle; |
| | | } |
| | | } |