using Microsoft.IdentityModel.Tokens;
|
using NewPdaSqlServer.DB;
|
using NewPdaSqlServer.Dto.service;
|
using NewPdaSqlServer.entity;
|
using NewPdaSqlServer.util;
|
using SqlSugar;
|
|
namespace NewPdaSqlServer.service.QC;
|
|
public class LljService : RepositoryNoEntity
|
{
|
public (List<LLJView> item, int TotalCount) GetPage(XJPageResult queryObj)
|
{
|
var parsedGuid = Guid.Empty;
|
if (!queryObj.id.IsNullOrEmpty())
|
{
|
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.STATUS ?? "") != "已提交")
|
//a => (a.FcheckResu ?? "") == ""|| (a.FcheckResu ?? "") == "检验中")
|
.WhereIF(
|
StringUtil.IsNotNullOrEmpty(queryObj.result) &&
|
!"未完成".Equals(queryObj.result),
|
a => (a.STATUS ?? "") == "已提交")
|
.WhereIF(UtilityHelper.CheckGuid(parsedGuid),
|
a => a.guid == parsedGuid)
|
.OrderByDescending(a => a.CreateDate)
|
.ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
|
|
return (pageList, totalCount);
|
}
|
|
//根据检验标准来计算检验个数
|
public List<MesQaItemsDetectDetail5> SetItems(string itemId,
|
decimal quantity, string releaseNo)
|
{
|
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.ItemId == itemId && s.FTYPE == "1").Select(
|
b => new MesQaItemsDetectDetail5
|
{
|
ReleaseNo = releaseNo,
|
FacLevel = b.FacLevel,
|
FcheckItem = b.FcheckItem,
|
FdownAllow = b.FdownAllow,
|
FcheckLevel = b.FREQUENCY,
|
Fstand = Convert.ToInt32(b.FSTAND),
|
FupAllow = b.FupAllow,
|
SampleSizeNo = b.SampleSizeNo,
|
FenterQty = 0,
|
Factory = "1000",
|
Company = "1000",
|
FcheckTool = b.FcheckTool,
|
FspecRequ = b.FspecRequ
|
}).ToList();
|
|
mesQaIqcItem.ForEach(item =>
|
{
|
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",
|
_ => ""
|
};
|
|
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.guid WHERE A.SAMPLE_SIZE_NO='" +
|
item.SampleSizeNo + "' AND B.LOT_FROM<= " + quantity +
|
" AND " +
|
quantity + "<=B.LOT_TO";
|
|
var maxBillNo = Db.Ado.SqlQuerySingle<string>(sql);
|
|
if (string.IsNullOrEmpty(maxBillNo))
|
throw new Exception(item.SampleSizeNo + "下的" + quantity +
|
"这个范围下没有匹配到检验项目");
|
|
var result = ExtractSubstring(item.FacLevel, '(', ')');
|
|
if (string.IsNullOrEmpty(result))
|
throw new Exception(item.SampleSizeNo + "下的" + quantity +
|
"拒收水平不正确");
|
|
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 = (int)resultClass.FSAMPLE_SIZE_WORD;
|
item.FreQty = (int)resultClass.Result;
|
});
|
|
return mesQaIqcItem;
|
}
|
|
private string ExtractSubstring(string input, char startChar, char endChar)
|
{
|
var startIndex = input.IndexOf(startChar);
|
var endIndex = input.IndexOf(endChar, startIndex);
|
|
if (startIndex == -1 || endIndex == -1)
|
// 如果未找到起始字符或结束字符,则返回空字符串或者抛出异常,根据实际情况选择
|
return string.Empty;
|
// 或者抛出异常
|
// throw new ArgumentException("Start or end character not found");
|
// 提取子字符串
|
var length = endIndex - startIndex - 1;
|
return input.Substring(startIndex + 1, length);
|
}
|
|
public int saveItem(LLJDto rkjDto)
|
{
|
var items = rkjDto.items;
|
var userNo = rkjDto.userNo;
|
|
UseTransaction(db =>
|
{
|
foreach (var item in items) item.ReleaseNo = rkjDto.releaseNo;
|
|
return db.Insertable(items).IgnoreColumns(true).ExecuteCommand();
|
});
|
|
rkjDto.items = GetItems(rkjDto.releaseNo, null);
|
|
|
rkjDto.items.ForEach(s =>
|
{
|
if (s.FupAllow != null || s.Fstand != null ||
|
s.FdownAllow != null) return;
|
|
// 没有录入参考值,判断有多少个NG,那么录入的抽检结果必须是OK或者NG,NG代表不合格
|
var ifck = Db.Queryable<MesQaItemsDetectDetail12>()
|
.Where(x => x.FcheckResu == "NG" && x.ParentGuid == s.Guid)
|
.Count();
|
|
//检验明细总数
|
var count = Db.Queryable<MesQaItemsDetectDetail12>()
|
.Where(x1 => x1.ParentGuid == s.Guid).Count();
|
|
if (ifck > s.FreQty && s.CheckQyt == count)
|
s.FcheckResu = "不合格";
|
else if (ifck < s.FreQty && s.CheckQyt == count)
|
s.FcheckResu = "合格";
|
else
|
s.FcheckResu = "未完成";
|
|
|
var detail = new MesQaItemsDetectDetail12();
|
detail.ParentGuid = s.Guid;
|
// detail.ReleaseNo = rkjDto.releaseNo;
|
detail.Fstand = "√";
|
detail.FcheckResu = "OK";
|
detail.LastupdateBy = rkjDto.userNo;
|
detail.count = s.CheckQyt;
|
SetQSItemDetail(detail);
|
});
|
|
return Convert.ToInt32(rkjDto.gid);
|
}
|
|
public List<MesQaItemsDetectDetail5> GetItems(string? releaseNo,
|
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(UtilityHelper.CheckGuid(parsedGuid),
|
(a, b) => a.Guid == parsedGuid)
|
.GroupBy((a, b) => new
|
{
|
a.Guid,
|
a.ParentGuid,
|
a.ReleaseNo,
|
a.FacLevel,
|
a.FcheckItem,
|
a.FcheckTool,
|
a.FdownAllow,
|
a.FcheckLevel,
|
a.Fstand,
|
a.FupAllow,
|
a.SampleSizeNo,
|
a.FspecRequ,
|
a.FreQty,
|
a.CheckQyt,
|
a.FcheckResu
|
}).Select((a, b) => new MesQaItemsDetectDetail5
|
{
|
Guid = a.Guid,
|
ParentGuid = a.ParentGuid,
|
ReleaseNo = a.ReleaseNo,
|
CheckQyt = a.CheckQyt,
|
FacLevel = a.FacLevel,
|
FcheckItem = a.FcheckItem,
|
FcheckTool = a.FcheckTool,
|
FdownAllow = a.FdownAllow,
|
FcheckLevel = a.FcheckLevel,
|
Fstand = a.Fstand,
|
FupAllow = a.FupAllow,
|
SampleSizeNo = a.SampleSizeNo,
|
FspecRequ = a.FspecRequ,
|
FreQty = a.FreQty,
|
Factory = "1000",
|
Company = "1000",
|
FenterQty = SqlFunc.AggregateCount(b.Guid),
|
FcheckResu = a.FcheckResu
|
}).ToList();
|
}
|
|
public int SetQSItemDetail(MesQaItemsDetectDetail12 detail)
|
{
|
var oracle = UseTransaction(db =>
|
{
|
List<MesQaItemsDetectDetail12> result = new();
|
for (var i = 0; i < detail.count; i++)
|
{
|
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;
|
item.CreateDate = DateTime.Now;
|
result.Add(item);
|
}
|
|
return db.Insertable(result).PageSize(1).IgnoreColumnsNull().ExecuteCommand();
|
});
|
|
detail.CreateBy = detail.LastupdateBy;
|
|
|
autoResult(detail);
|
|
return oracle;
|
}
|
|
|
private int autoResult(MesQaItemsDetectDetail12 detail)
|
{
|
// Single 没有查询到结果时返回Null,如果结果大于1条会抛出错误
|
var QsItemOqcItem = Db.Queryable<MesQaItemsDetectDetail5>()
|
.Single(s => s.Guid == detail.ParentGuid);
|
|
if (QsItemOqcItem == null) return 0;
|
|
//查询这个检验项目下的检验结果
|
var count = Db.Queryable<MesQaItemsDetectDetail12>()
|
.Where(s => s.ParentGuid == detail.ParentGuid).Count();
|
|
updateDetail5(detail);
|
var result = "";
|
|
//检验实际结果不等于应该检验的个数时直接推出
|
if (QsItemOqcItem.CheckQyt != count) return 0;
|
|
//合格的有多少个
|
var passCount = Db.Queryable<MesQaItemsDetectDetail12>()
|
.Where(s => s.ParentGuid == detail.ParentGuid && s.Fstand == "√")
|
.Count();
|
//不合格的有多少个
|
var noCount = Db.Queryable<MesQaItemsDetectDetail12>()
|
.Where(s => s.ParentGuid == detail.ParentGuid && s.Fstand == "×")
|
.Count();
|
|
if (count == passCount)
|
result = "合格";
|
//else if (count - passCount < QsItemOqcItem.FreQty)
|
// result = "不合格";
|
else if (noCount >= QsItemOqcItem.FreQty)
|
result = "不合格";
|
var useTransactionWithOracle = UseTransaction(
|
db =>
|
{
|
var commit = 0;
|
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();
|
|
return commit;
|
});
|
|
var isNull = Db.Queryable<MesQaItemsDetectDetail5>()
|
.Where(s => s.Guid == detail.ParentGuid && s.FcheckResu == null)
|
.Count();
|
|
if (isNull > 0) return 1;
|
|
|
//获取检验单的检验项目的个数
|
var sum = Db.Queryable<MesQaItemsDetectDetail5>()
|
.Where(s => s.Guid == detail.ParentGuid).Count();
|
|
if (sum == 0) return 1;
|
|
//获取检验单下的合格的检验项目个数
|
var icount = Db.Queryable<MesQaItemsDetectDetail5>()
|
.Where(s => s.Guid == detail.ParentGuid && s.FcheckResu == "合格")
|
.Count();
|
|
var FcheckResu = "不合格";
|
|
//实际个数等于理论个数时对检验单进行判定
|
if (sum == icount)
|
//合格的检验结果等于总检验数视为合格
|
FcheckResu = "合格";
|
|
var sysUser = Db.Queryable<SysUser>()
|
.Where(s => s.Account == detail.CreateBy).First();
|
|
UseTransaction(db =>
|
{
|
return db.Updateable<MesQaItemsDetect01>()
|
.SetColumns(s => s.FcheckResu == FcheckResu)
|
.SetColumns(s => s.FcheckDate == DateTime.Now)
|
.SetColumns(s => s.FcheckBy == sysUser.Account)
|
.SetColumns(s => s.LastupdateBy == detail.CreateBy)
|
.SetColumns(s => s.LastupdateDate == DateTime.Now)
|
.Where(s => s.Guid == detail.GrandpaGuid)
|
.ExecuteCommand();
|
});
|
// if (FcheckResu.Equals("不合格"))
|
//自动生成入库检异常对策
|
/// saveDetect02(detail.Id, detail.CreateBy);
|
|
return useTransactionWithOracle;
|
}
|
/* public int saveDetect02(decimal? gid, string? createBy)
|
{
|
var db = SqlSugarHelper.GetInstance();
|
|
var qsItemOqcReq =
|
db.Queryable<QsItemOqcReq>().Single(s => s.Id == gid);
|
|
var mesInvItemIns = db.Queryable<MesInvItemIns>()
|
.Single(s => s.BillNo == qsItemOqcReq.BillNo);
|
|
var mesSchemeResult = db.Queryable<MesSchemeResult>()
|
.Single(s => s.BillNo == mesInvItemIns.CbillNo);
|
|
var entity = new MesQaItemsDetect02();
|
entity.ItemNo = mesSchemeResult.BoardItem;
|
entity.BoardItem = mesSchemeResult.BoardItem;
|
entity.LineNo = mesSchemeResult.LineNo;
|
entity.Aufnr = mesSchemeResult.TaskNo;
|
entity.ReleaseNo = qsItemOqcReq.ReleaseNo;
|
entity.LotNo = qsItemOqcReq.BillNo;
|
entity.FcheckDate = qsItemOqcReq.FcheckDate;
|
entity.FcheckMemo = qsItemOqcReq.Remarks;
|
entity.Gid = qsItemOqcReq.Id;
|
// entity.PlanQty = qsItemOqcReq.FcheckDate;
|
|
|
entity.FcheckResu = "不合格";
|
entity.FcheckLevel = "严重";
|
entity.CreateDate = DateTime.Now;
|
entity.Factory = "10000";
|
entity.Company = "1000";
|
entity.Ftype = "4";
|
entity.Fversion = 0;
|
entity.Modify1Flag = 0;
|
entity.IpqcStatus = 0;
|
entity.Fsubmit = 1;
|
entity.CreateBy = createBy;
|
entity.FcheckBy = createBy;
|
|
return SqlSugarHelper.UseTransactionWithOracle(db => db
|
.Insertable(entity)
|
.ExecuteCommand());
|
}
|
*/
|
|
public LLJDto getXjDetail02ById(string? id)
|
{
|
var rkjDto = new LLJDto();
|
|
var isValid = Guid.TryParse(id, out var parsedGuid);
|
|
if (!isValid) throw new Exception("GUID转换错误");
|
|
var qsItemOqcItem =
|
Db.Queryable<MesQaItemsDetectDetail5>()
|
.Single(s => s.Guid == parsedGuid);
|
|
/* if (qsItemOqcItem.IsPass == 0)
|
qsItemOqcItem.Result = "不合格";
|
else if (qsItemOqcItem.IsPass == 1)
|
qsItemOqcItem.Result = "合格";
|
else
|
qsItemOqcItem.Result = "未完成";
|
|
if (qsItemOqcItem.Picture is { Length: > 0 })
|
qsItemOqcItem.imageData =
|
Convert.ToBase64String(qsItemOqcItem.Picture);
|
*/
|
//获取不合格数
|
var count = Db.Queryable<MesQaItemsDetectDetail12>()
|
.Where(s => s.Fstand == "×" && s.ParentGuid == parsedGuid).Count();
|
|
qsItemOqcItem.Unqualified = count;
|
|
rkjDto.ItemXj01 = qsItemOqcItem;
|
|
|
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 UpdateQSItemDetail(MesQaItemsDetectDetail12 detail)
|
{
|
var withOracle = UseTransaction(db =>
|
{
|
return db.Updateable<MesQaItemsDetectDetail12>()
|
.SetColumns(s => s.LastupdateBy == detail.LastupdateBy)
|
.SetColumnsIF(StringUtil.IsNotNullOrEmpty(detail.Fstand),
|
s => s.Fstand == detail.Fstand)
|
.SetColumnsIF(StringUtil.IsNotNullOrEmpty(detail.FcheckResu),
|
s => s.FcheckResu == detail.FcheckResu)
|
.Where(s => s.ParentGuid
|
== detail.ParentGuid && s.Guid == detail.Guid)
|
.ExecuteCommand();
|
});
|
|
detail.CreateBy = detail.LastupdateBy;
|
|
withOracle += autoResult(detail);
|
|
return withOracle;
|
}
|
|
//更新检验明细已检、不合格数量
|
private int updateDetail5(MesQaItemsDetectDetail12 detail)
|
{
|
//查询这个检验项目下的检验数量
|
var count = Db.Queryable<MesQaItemsDetectDetail12>()
|
.Where(s => s.ParentGuid == detail.ParentGuid).Count();
|
|
//获取不合格数
|
var countNo = Db.Queryable<MesQaItemsDetectDetail12>()
|
.Where(s => s.ParentGuid == detail.ParentGuid && s.Fstand == "×")
|
.Count();
|
//更新检验明细已检数量
|
var withOracle = UseTransaction(db =>
|
{
|
return db.Updateable<MesQaItemsDetectDetail5>()
|
.SetColumns(s => s.FenterQty == count)
|
.SetColumns(s => s.FngQty == countNo)
|
.Where(s => s.Guid == detail.ParentGuid)
|
.ExecuteCommand();
|
});
|
|
return withOracle;
|
}
|
|
//主表修改备注字段
|
public int saveRemarksGid(LLJDto dto)
|
{
|
return UseTransaction(db =>
|
{
|
return db.Updateable<MesQaItemsDetect01>()
|
.SetColumns(it =>
|
it.Remarks == dto.Remarks) //SetColumns是可以叠加的 写2个就2个字段赋值
|
.Where(it => it.ReleaseNo == dto.releaseNo)
|
.ExecuteCommand();
|
});
|
}
|
|
//子表修改备注字段
|
public int saveRemarksPid(LLJDto dto)
|
{
|
var isValid = Guid.TryParse(dto.pid, out var parsedGuid);
|
|
if (isValid)
|
return UseTransaction(db =>
|
{
|
return db.Updateable<MesQaItemsDetectDetail5>()
|
.SetColumns(it =>
|
it.Remarks == dto.Remarks)
|
.Where(it => it.Guid == parsedGuid)
|
.ExecuteCommand();
|
});
|
|
throw new Exception("GUID转换错误");
|
}
|
|
//删除主表并且连级删除子表和孙表
|
public int removeXJ(string? releaseNo)
|
{
|
var withOracle = UseTransaction(db =>
|
{
|
var commit = 0;
|
//删除主表
|
commit += db.Deleteable<MesQaItemsDetect01>()
|
.Where(s => s.ReleaseNo == releaseNo)
|
.ExecuteCommand();
|
//删除子表
|
commit += db.Deleteable<MesQaItemsDetectDetail5>()
|
.Where(s => s.ReleaseNo == releaseNo)
|
.ExecuteCommand();
|
//删除孙表
|
// commit += db.Deleteable<MesQaItemsDetectDetail12>()
|
// .Where(s => s.ReleaseNo == releaseNo)
|
// .ExecuteCommand();
|
return commit;
|
});
|
|
return withOracle;
|
}
|
|
public bool IqcQaSubmit(LLJDto dto)
|
{
|
//var (factory, company) = UserUtil.GetFactory(dto.userNo);
|
var sysUser = Db.Queryable<SysUser>()
|
.Where(s => s.Account == dto.userNo).First();
|
|
if (sysUser == null)
|
return false;
|
|
var mesQaItemsDetect01 = Db.Queryable<MesQaItemsDetect01>()
|
.Where(s => s.ReleaseNo == dto.releaseNo).First();
|
|
if (mesQaItemsDetect01 == null)
|
return false;
|
|
if (mesQaItemsDetect01.Fsubmit == 1)
|
throw new Exception("该检验单已提交");
|
|
if (mesQaItemsDetect01.FcheckDate == null)
|
throw new Exception("该检测单没有检验完成,请核对。");
|
|
if (mesQaItemsDetect01.FcheckBy.IsNullOrEmpty())
|
throw new Exception("该检测单未输入检验人员,请核对。");
|
|
var list = Db.Queryable<MesQaItemsDetectDetail5>()
|
.Where(s => s.ReleaseNo == dto.releaseNo).ToList();
|
|
if (CollectionUtil.IsNullOrEmpty(list))
|
throw new Exception("抽样信息从表不允许为空,请维护检验项目");
|
|
foreach (var mesQaItemsDetectDetail5 in list)
|
{
|
mesQaItemsDetectDetail5.FenterQty ??= 0;
|
if (mesQaItemsDetectDetail5.FenterQty == 0)
|
throw new Exception("检验项目:" +
|
mesQaItemsDetectDetail5.FcheckItem +
|
" 已录入数量为0,请确认。");
|
}
|
|
var com = UseTransaction(db =>
|
{
|
var executeCommand = db.Updateable<MesQaItemsDetect01>()
|
.SetColumns(s => s.Fsubmit == 1)
|
.Where(s => s.ReleaseNo == dto.releaseNo)
|
.ExecuteCommand();
|
|
var mesInvItemArn = db.Queryable<MesInvItemArn>()
|
.Where(b => b.BillNo == mesQaItemsDetect01.LotNo).First();
|
|
if (mesInvItemArn == null)
|
throw new Exception(mesQaItemsDetect01.LotNo + "到货单不存在,请核对。");
|
|
if ("合格".Equals(mesQaItemsDetect01.FcheckResu))
|
{
|
executeCommand += db.Updateable<MesInvItemArnDetail>()
|
.SetColumns(s => s.CheckStates == "已检")
|
.SetColumns(s => s.CheckRes == "合格")
|
.SetColumns(s => s.Ischeck == 1)
|
.SetColumns(s => s.CheckDate == DateTime.Now)
|
.Where(s => s.ParentGuid == mesInvItemArn.Guid
|
&& s.ItemId == mesQaItemsDetect01.ItemId)
|
.ExecuteCommand();
|
|
executeCommand += db.Updateable<MesQaItemsDetect01>()
|
.SetColumns(s => s.Modify1Flag == 1)
|
.SetColumns(s => s.Modify1By == sysUser.Account)
|
.SetColumns(s => s.Modify1Date == DateTime.Now)
|
.SetColumns(s => s.FngHandle == "")
|
.SetColumns(s => s.IqcDate == DateTime.Now)
|
.SetColumns(s => s.FcheckDate == DateTime.Now)
|
.SetColumns(s => s.FcheckBy == sysUser.Account)
|
.Where(s => s.Guid == mesQaItemsDetect01.Guid)
|
.ExecuteCommand();
|
|
//MesInvItemStocks
|
executeCommand += db.Updateable<MesInvItemStocks>()
|
.SetColumns(t => t.CheckDate == DateTime.Now)
|
.SetColumns(t => t.IqcStatus == "已检")
|
.Where(t => t.ItemId == mesQaItemsDetect01.ItemId
|
&& t.BillNo == mesQaItemsDetect01.LotNo)
|
.ExecuteCommand();
|
|
var first = db
|
.Queryable<MesInvItemArnDetail, MesInvItemArn>(
|
(b, a) => new object[]
|
{
|
JoinType.Left, b.ParentGuid == a.Guid
|
})
|
.Where((b, a) =>
|
a.BillNo == mesQaItemsDetect01.LotNo &&
|
b.ReturnFlag == 0)
|
.Select((b, a) => new
|
{
|
TotalQuantity =
|
SqlFunc.AggregateSum(b.Quantity),
|
TotalOkRkQty = SqlFunc.AggregateSum(b.OkRkqty)
|
})
|
.First();
|
|
var totalQuantity = first.TotalQuantity ?? 0;
|
var totalOkRkQty = first.TotalOkRkQty ?? 0;
|
|
if (totalQuantity == totalOkRkQty)
|
executeCommand += db.Updateable<MesInvItemArn>()
|
.SetColumns(s => s.Status == 1)
|
.Where(s => s.BillNo == mesQaItemsDetect01.LotNo)
|
.ExecuteCommand();
|
}
|
else
|
{
|
executeCommand += db.Updateable<MesInvItemArnDetail>()
|
.SetColumns(s => s.CheckStates == "不合格待审批")
|
.SetColumns(s => s.Ischeck == 1)
|
.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)
|
.SetColumns(s => s.FcheckBy == sysUser.Account)
|
.Where(s => s.Guid == mesQaItemsDetect01.Guid)
|
.ExecuteCommand();
|
}
|
|
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];
|
}
|
}
|