执行代码清理,修复warning

This commit is contained in:
2023-11-06 19:59:12 +08:00
parent c6b8dfc861
commit 1dbb17f103
118 changed files with 5046 additions and 4111 deletions

View File

@@ -39,22 +39,24 @@ namespace Tnb.QcMgr
private async Task<dynamic> GetListAsync(VisualDevModelListQueryInput input)
{
var db = _repository.AsSugarClient();
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("ok", "合格");
dic.Add("no", "合格");
dic.Add("barelyok", "让步合格");
dic.Add("await", "待检");
dic.Add("temporarily", "暂控");
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
ISqlSugarClient db = _repository.AsSugarClient();
Dictionary<string, string> dic = new()
{
{ "ok", "合格" },
{ "no", "合格" },
{ "barelyok", "让步合格" },
{ "await", "待检" },
{ "temporarily", "暂控" }
};
Dictionary<string, string>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
string materialid = queryJson.ContainsKey("materialid") ? queryJson["materialid"].ToString() : "";
string checktype = queryJson.ContainsKey("checktype") ? queryJson["checktype"].ToString() : "";
string status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : "";
var list = await db.Queryable<DictionaryDataEntity>()
List<DictionaryDataEntity> list = await db.Queryable<DictionaryDataEntity>()
.LeftJoin<DictionaryTypeEntity>((a, b) => a.DictionaryTypeId == b.Id)
.Where((a, b) => b.FullName == "质检状态" || b.FullName == "质检类型选择").ToListAsync();
var BasLocations = await db.Queryable<BasLocation>().ToListAsync();
var result = await db.Queryable<QcCheckExecH>()
List<BasLocation> BasLocations = await db.Queryable<BasLocation>().ToListAsync();
SqlSugarPagedList<QcCheckExecHOut> result = await db.Queryable<QcCheckExecH>()
.LeftJoin<BasMaterial>((a, b) => a.materialid == b.id)
.LeftJoin<BasProcess>((a, b, c) => a.processid == c.id)
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workid == d.Id)
@@ -74,11 +76,11 @@ namespace Tnb.QcMgr
checknum = a.checknum,
status = a.status,
result = a.result,
tasktime = a.tasktime == null ? "" : a.tasktime,
exectime = a.exectime == null ? "" : a.exectime,
execuser = e.RealName == null ? "" : e.RealName,
tasktime = a.tasktime ?? "",
exectime = a.exectime ?? "",
execuser = e.RealName ?? "",
}).OrderByDescending(a => DateTime.Parse(a.tasktime)).ToPagedListAsync(input.currentPage, input.pageSize);
foreach (var item in result.list)
foreach (QcCheckExecHOut? item in result.list)
{
item.checktype = list.Select(p => p.Id).Contains(item.checktype) ? list.Where(p => p.Id == item.checktype).First().FullName : "";
item.status = list.Select(p => p.Id).Contains(item.status) ? list.Where(p => p.Id == item.status).First().FullName : "";
@@ -95,55 +97,66 @@ namespace Tnb.QcMgr
[HttpGet]
public async Task<dynamic> GetTaskItems(string id)
{
var db = _repository.AsSugarClient();
var QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == id).FirstAsync();
var QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == id).ToListAsync();
var QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
var QcCheckTypes = await db.Queryable<QcCheckType>().ToListAsync();
var QcErrorCauses = await db.Queryable<QcErrorCause>().ToListAsync();
var QcErrorLevels = await db.Queryable<QcErrorLevel>().ToListAsync();
ISqlSugarClient db = _repository.AsSugarClient();
QcCheckExecH QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == id).FirstAsync();
List<QcCheckExecD> QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == id).ToListAsync();
List<QcCheckItem> QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
List<QcCheckType> QcCheckTypes = await db.Queryable<QcCheckType>().ToListAsync();
List<QcErrorCause> QcErrorCauses = await db.Queryable<QcErrorCause>().ToListAsync();
List<QcErrorLevel> QcErrorLevels = await db.Queryable<QcErrorLevel>().ToListAsync();
CheckTaskOut CheckTaskOut = new CheckTaskOut();
CheckTaskOut.mainid = id;
CheckTaskOut.wareid = QcCheckExecH.wareid!;
CheckTaskOut.workid = QcCheckExecH.workid!;
CheckTaskOut.status = QcCheckExecH.status!;
CheckTaskOut CheckTaskOut = new()
{
mainid = id,
wareid = QcCheckExecH.wareid!,
workid = QcCheckExecH.workid!,
status = QcCheckExecH.status!
};
if (!string.IsNullOrEmpty(CheckTaskOut.workid))
{
CheckTaskOut.workname = db.Queryable<OrganizeEntity>().Where(p => p.Id == CheckTaskOut.workid).First().FullName;
}
CheckTaskOut.checktypes = new List<CheckExecTypeOut>();
foreach (var QcCheckExecD in QcCheckExecDs)
foreach (QcCheckExecD QcCheckExecD in QcCheckExecDs)
{
if (CheckTaskOut.checktypes.Where(p => p.checktypeid == QcCheckExecD.typeid).ToList().Count == 0)
{
CheckExecTypeOut checkType = new CheckExecTypeOut();
checkType.checktypeid = QcCheckExecD.typeid!;
checkType.checktypename = QcCheckTypes.Where(p => p.id == QcCheckExecD.typeid).First().name!;
checkType.items = new List<ExecItemOut>();
CheckExecTypeOut checkType = new()
{
checktypeid = QcCheckExecD.typeid!,
checktypename = QcCheckTypes.Where(p => p.id == QcCheckExecD.typeid).First().name!,
items = new List<ExecItemOut>()
};
CheckTaskOut.checktypes.Add(checkType);
}
ExecItemOut Item = new ExecItemOut();
Item.itemid = QcCheckExecD.itemid!;
Item.itemdid = QcCheckExecD.id!;
Item.code = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().code!;
Item.name = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().name!;
Item.setData = new ExecItemData();
Item.setData.extype = QcCheckExecD.extype!;
Item.setData.excontent = JSON.Deserialize<Excontent>(QcCheckExecD.excontent!);
Item.setData.check = QcCheckExecD.check!;
ExecItemOut Item = new()
{
itemid = QcCheckExecD.itemid!,
itemdid = QcCheckExecD.id!,
code = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().code!,
name = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().name!,
setData = new ExecItemData
{
extype = QcCheckExecD.extype!,
excontent = JSON.Deserialize<Excontent>(QcCheckExecD.excontent!),
check = QcCheckExecD.check!
}
};
if (!string.IsNullOrEmpty(QcCheckExecD.errorcause))
{
var strs = QcCheckExecD.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
string[] strs = QcCheckExecD.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
Item.setData.errorcause = new List<Error>();
foreach (var str in strs)
foreach (string str in strs)
{
Item.setData.errorcause.Add(new Error { id = str, name = QcErrorCauses.Where(p => p.id == str).First().name! });
}
}
if (!string.IsNullOrEmpty(QcCheckExecD.errorlevel))
{
var strs = QcCheckExecD.errorlevel!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
string[] strs = QcCheckExecD.errorlevel!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
Item.setData.errorlevel = new List<Error>();
foreach (var str in strs)
foreach (string str in strs)
{
Item.setData.errorlevel.Add(new Error { id = str, name = QcErrorLevels.Where(p => p.id == str).First().name! });
}
@@ -152,17 +165,22 @@ namespace Tnb.QcMgr
Item.setData.attachment = QcCheckExecD.attachment!;
Item.setData.customer = QcCheckExecD.custom!;
if (!string.IsNullOrEmpty(QcCheckExecD.isexec))
{
Item.setData.isexec = JSON.Deserialize<IsexecE>(QcCheckExecD.isexec!);
Item.setShow = new ExecItemShow();
Item.setShow.extype = !string.IsNullOrEmpty(Item.setData.extype);
Item.setShow.excontent = !string.IsNullOrEmpty(QcCheckExecD.excontent);
Item.setShow.check = !string.IsNullOrEmpty(Item.setData.check);
Item.setShow.errorcause = Item.setData.errorcause == null || Item.setData.errorcause?.Count == 0 ? false : true;
Item.setShow.errorlevel = Item.setData.errorlevel == null || Item.setData.errorlevel?.Count == 0 ? false : true;
Item.setShow.remark = !string.IsNullOrEmpty(Item.setData.remark);
Item.setShow.attachment = !string.IsNullOrEmpty(Item.setData.attachment);
Item.setShow.customer = !string.IsNullOrEmpty(Item.setData.customer);
Item.setShow.isexec = Item.setData.isexec == null ? false : true;
}
Item.setShow = new ExecItemShow
{
extype = !string.IsNullOrEmpty(Item.setData.extype),
excontent = !string.IsNullOrEmpty(QcCheckExecD.excontent),
check = !string.IsNullOrEmpty(Item.setData.check),
errorcause = Item.setData.errorcause != null && (Item.setData.errorcause?.Count) != 0,
errorlevel = Item.setData.errorlevel != null && (Item.setData.errorlevel?.Count) != 0,
remark = !string.IsNullOrEmpty(Item.setData.remark),
attachment = !string.IsNullOrEmpty(Item.setData.attachment),
customer = !string.IsNullOrEmpty(Item.setData.customer),
isexec = Item.setData.isexec != null
};
CheckTaskOut.checktypes.Where(p => p.checktypeid == QcCheckExecD.typeid).First()?.items?.Add(Item);
}
return CheckTaskOut;
@@ -176,57 +194,68 @@ namespace Tnb.QcMgr
[HttpPost]
public async Task SaveData(CheckTaskInput CheckTaskInput)
{
var db = _repository.AsSugarClient();
ISqlSugarClient db = _repository.AsSugarClient();
try
{
var QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == CheckTaskInput.mainid).FirstAsync();
var DictionaryType = await db.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
var DictionaryData = await db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "已完成").FirstAsync();
QcCheckExecH QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == CheckTaskInput.mainid).FirstAsync();
DictionaryTypeEntity DictionaryType = await db.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
DictionaryDataEntity DictionaryData = await db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "已完成").FirstAsync();
QcCheckExecH.checknum = CheckTaskInput.checknum;
QcCheckExecH.status = DictionaryData.Id;
QcCheckExecH.result = CheckTaskInput.result;
QcCheckExecH.execuser = _userManager.UserId;
QcCheckExecH.exectime = DateTime.Now.ToString();
var QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == CheckTaskInput.mainid).ToListAsync();
var QcCheckExecDdel = new List<QcCheckExecD>();
var QcCheckExecDinsert = new List<QcCheckExecD>();
List<QcCheckExecD> QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == CheckTaskInput.mainid).ToListAsync();
List<QcCheckExecD> QcCheckExecDdel = new();
List<QcCheckExecD> QcCheckExecDinsert = new();
if (CheckTaskInput.checktypes?.Count > 0)
{
for (int i = 0; i < CheckTaskInput.checktypes.Count; i++)
{
if (CheckTaskInput.checktypes[i].Count > 0)
{
foreach (var exextype in CheckTaskInput.checktypes[i])
foreach (Exextype exextype in CheckTaskInput.checktypes[i])
{
if (exextype.items != null)
{
foreach (var item in exextype.items)
foreach (ExecItemInput item in exextype.items)
{
if (item.postItemForm == null)
{
throw Oops.Oh("执行失败");
var QcCheckExecD = QcCheckExecDs.Where(p => p.id == item.itemdid).FirstOrDefault();
}
QcCheckExecD? QcCheckExecD = QcCheckExecDs.Where(p => p.id == item.itemdid).FirstOrDefault();
if (QcCheckExecD == null)
{
continue;
}
if (QcCheckExecDdel.Where(p => p.id == QcCheckExecD.id).FirstOrDefault() == null)
{
QcCheckExecDdel.Add(QcCheckExecD);
var insert = new QcCheckExecD();
insert.mainid = QcCheckExecD.mainid;
insert.extype = QcCheckExecD.extype;
insert.excontent = QcCheckExecD.excontent;
insert.check = QcCheckExecD.check;
insert.errorcause = QcCheckExecD.errorcause;
insert.errorlevel = QcCheckExecD.errorlevel;
insert.remark = QcCheckExecD.remark;
insert.attachment = QcCheckExecD.attachment;
insert.isexec = QcCheckExecD.isexec;
insert.custom = QcCheckExecD.custom;
insert.typeid = QcCheckExecD.typeid;
insert.itemid = QcCheckExecD.itemid;
insert.create_id = QcCheckExecD.create_id;
insert.create_time = QcCheckExecD.create_time;
insert.postdata = item.postItemForm;
insert.result = item.result;
insert.checkindex = (i + 1).ToString();
}
QcCheckExecD insert = new()
{
mainid = QcCheckExecD.mainid,
extype = QcCheckExecD.extype,
excontent = QcCheckExecD.excontent,
check = QcCheckExecD.check,
errorcause = QcCheckExecD.errorcause,
errorlevel = QcCheckExecD.errorlevel,
remark = QcCheckExecD.remark,
attachment = QcCheckExecD.attachment,
isexec = QcCheckExecD.isexec,
custom = QcCheckExecD.custom,
typeid = QcCheckExecD.typeid,
itemid = QcCheckExecD.itemid,
create_id = QcCheckExecD.create_id,
create_time = QcCheckExecD.create_time,
postdata = item.postItemForm,
result = item.result,
checkindex = (i + 1).ToString()
};
QcCheckExecDinsert.Add(insert);
}
}
@@ -235,9 +264,9 @@ namespace Tnb.QcMgr
}
}
await db.Ado.BeginTranAsync();
await db.Updateable(QcCheckExecH).ExecuteCommandAsync();
await db.Deleteable(QcCheckExecDdel).ExecuteCommandAsync();
await db.Insertable(QcCheckExecDinsert).ExecuteCommandAsync();
_ = await db.Updateable(QcCheckExecH).ExecuteCommandAsync();
_ = await db.Deleteable(QcCheckExecDdel).ExecuteCommandAsync();
_ = await db.Insertable(QcCheckExecDinsert).ExecuteCommandAsync();
await db.Ado.CommitTranAsync();
}
catch (Exception)
@@ -254,59 +283,67 @@ namespace Tnb.QcMgr
[HttpGet]
public async Task<dynamic> GetTaskResult(string id)
{
var db = _repository.AsSugarClient();
var QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == id).FirstAsync();
var QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == id).ToListAsync();
var QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
var QcCheckTypes = await db.Queryable<QcCheckType>().ToListAsync();
var QcErrorCauses = await db.Queryable<QcErrorCause>().ToListAsync();
var QcErrorLevels = await db.Queryable<QcErrorLevel>().ToListAsync();
ISqlSugarClient db = _repository.AsSugarClient();
QcCheckExecH QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == id).FirstAsync();
List<QcCheckExecD> QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == id).ToListAsync();
List<QcCheckItem> QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
List<QcCheckType> QcCheckTypes = await db.Queryable<QcCheckType>().ToListAsync();
List<QcErrorCause> QcErrorCauses = await db.Queryable<QcErrorCause>().ToListAsync();
List<QcErrorLevel> QcErrorLevels = await db.Queryable<QcErrorLevel>().ToListAsync();
Result Result = new Result();
Result.mainid = id;
Result.checknum = QcCheckExecH.checknum!;
Result.status = QcCheckExecH.status!;
Result.checktypes = new List<List<Checktype>>();
Result.result = QcCheckExecH.result;
var groupkeys = QcCheckExecDs.Select(p => p.checkindex).Distinct().ToList();
foreach (var key in groupkeys)
Result Result = new()
{
var QcCheckExecDsbykey = QcCheckExecDs.Where(p => p.checkindex == key).ToList();
var checktype = new List<Checktype>();
foreach (var QcCheckExecD in QcCheckExecDsbykey)
mainid = id,
checknum = QcCheckExecH.checknum!,
status = QcCheckExecH.status!,
checktypes = new List<List<Checktype>>(),
result = QcCheckExecH.result
};
List<string?> groupkeys = QcCheckExecDs.Select(p => p.checkindex).Distinct().ToList();
foreach (string? key in groupkeys)
{
List<QcCheckExecD> QcCheckExecDsbykey = QcCheckExecDs.Where(p => p.checkindex == key).ToList();
List<Checktype> checktype = new();
foreach (QcCheckExecD? QcCheckExecD in QcCheckExecDsbykey)
{
if (checktype.Where(p => p.checktypeid == QcCheckExecD.typeid).ToList().Count == 0)
{
Checktype checkType = new Checktype();
checkType.checktypeid = QcCheckExecD.typeid!;
checkType.checktypename = QcCheckTypes.Where(p => p.id == QcCheckExecD.typeid).First().name!;
checkType.items = new List<ExecItem>();
Checktype checkType = new()
{
checktypeid = QcCheckExecD.typeid!,
checktypename = QcCheckTypes.Where(p => p.id == QcCheckExecD.typeid).First().name!,
items = new List<ExecItem>()
};
checktype.Add(checkType);
}
ExecItem Item = new ExecItem();
Item.itemid = QcCheckExecD.itemid!;
Item.itemdid = QcCheckExecD.id!;
Item.code = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().code!;
Item.name = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().name!;
Item.result = QcCheckExecD.result;
Item.setData = new ExecItemData();
Item.setData.extype = QcCheckExecD.extype!;
Item.setData.excontent = JSON.Deserialize<Excontent>(QcCheckExecD.excontent!);
Item.setData.check = QcCheckExecD.check!;
ExecItem Item = new()
{
itemid = QcCheckExecD.itemid!,
itemdid = QcCheckExecD.id!,
code = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().code!,
name = QcCheckItems.Where(p => p.id == QcCheckExecD.itemid).First().name!,
result = QcCheckExecD.result,
setData = new ExecItemData
{
extype = QcCheckExecD.extype!,
excontent = JSON.Deserialize<Excontent>(QcCheckExecD.excontent!),
check = QcCheckExecD.check!
}
};
if (!string.IsNullOrEmpty(QcCheckExecD.errorcause))
{
var strs = QcCheckExecD.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
string[] strs = QcCheckExecD.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
Item.setData.errorcause = new List<Error>();
foreach (var str in strs)
foreach (string str in strs)
{
Item.setData.errorcause.Add(new Error { id = str, name = QcErrorCauses.Where(p => p.id == str).First().name! });
}
}
if (!string.IsNullOrEmpty(QcCheckExecD.errorlevel))
{
var strs = QcCheckExecD.errorlevel!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
string[] strs = QcCheckExecD.errorlevel!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
Item.setData.errorlevel = new List<Error>();
foreach (var str in strs)
foreach (string str in strs)
{
Item.setData.errorlevel.Add(new Error { id = str, name = QcErrorLevels.Where(p => p.id == str).First().name! });
}
@@ -315,19 +352,27 @@ namespace Tnb.QcMgr
Item.setData.attachment = QcCheckExecD.attachment!;
Item.setData.customer = QcCheckExecD.custom!;
if (!string.IsNullOrEmpty(QcCheckExecD.isexec))
{
Item.setData.isexec = JSON.Deserialize<IsexecE>(QcCheckExecD.isexec!);
Item.setShow = new ExecItemShow();
Item.setShow.extype = !string.IsNullOrEmpty(Item.setData.extype);
Item.setShow.excontent = !string.IsNullOrEmpty(QcCheckExecD.excontent);
Item.setShow.check = !string.IsNullOrEmpty(Item.setData.check);
Item.setShow.errorcause = Item.setData.errorcause?.Count == 0 ? false : true;
Item.setShow.errorlevel = Item.setData.errorlevel?.Count == 0 ? false : true;
Item.setShow.remark = !string.IsNullOrEmpty(Item.setData.remark);
Item.setShow.attachment = !string.IsNullOrEmpty(Item.setData.attachment);
Item.setShow.customer = !string.IsNullOrEmpty(Item.setData.customer);
Item.setShow.isexec = Item.setData.isexec == null ? false : true;
}
Item.setShow = new ExecItemShow
{
extype = !string.IsNullOrEmpty(Item.setData.extype),
excontent = !string.IsNullOrEmpty(QcCheckExecD.excontent),
check = !string.IsNullOrEmpty(Item.setData.check),
errorcause = (Item.setData.errorcause?.Count) != 0,
errorlevel = (Item.setData.errorlevel?.Count) != 0,
remark = !string.IsNullOrEmpty(Item.setData.remark),
attachment = !string.IsNullOrEmpty(Item.setData.attachment),
customer = !string.IsNullOrEmpty(Item.setData.customer),
isexec = Item.setData.isexec != null
};
if (!string.IsNullOrEmpty(QcCheckExecD.postdata))
{
Item.postItemForm = JSON.Deserialize<PostItemForm>(QcCheckExecD.postdata!);
}
checktype.Where(p => p.checktypeid == QcCheckExecD.typeid).First()?.items?.Add(Item);
}
Result.checktypes.Add(checktype);
@@ -339,51 +384,55 @@ namespace Tnb.QcMgr
[HttpPost]
public async Task CreateTaskData(CheckTaskData checkTaskData)
{
var db = _repository.AsSugarClient();
var DictionaryType = await db.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
var DictionaryData = await db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
QcCheckExecH QcCheckExecH = new QcCheckExecH();
QcCheckExecH.checktype = checkTaskData.checktype;
QcCheckExecH.materialid = checkTaskData.materialid;
QcCheckExecH.processid = checkTaskData.processid;
QcCheckExecH.workid = checkTaskData.workid;
QcCheckExecH.wareid = checkTaskData.wareid;
QcCheckExecH.status = DictionaryData.Id;
QcCheckExecH.tasktime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
QcCheckExecH.create_id = _userManager.UserId;
QcCheckExecH.create_time = DateTime.Now;
List<QcCheckExecD> QcCheckExecDs = new List<QcCheckExecD>();
ISqlSugarClient db = _repository.AsSugarClient();
DictionaryTypeEntity DictionaryType = await db.Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
DictionaryDataEntity DictionaryData = await db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
QcCheckExecH QcCheckExecH = new()
{
checktype = checkTaskData.checktype,
materialid = checkTaskData.materialid,
processid = checkTaskData.processid,
workid = checkTaskData.workid,
wareid = checkTaskData.wareid,
status = DictionaryData.Id,
tasktime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
create_id = _userManager.UserId,
create_time = DateTime.Now
};
List<QcCheckExecD> QcCheckExecDs = new();
if (checkTaskData.checktypes != null)
{
foreach (var checktype in checkTaskData.checktypes)
foreach (CheckTaskDataInput checktype in checkTaskData.checktypes)
{
if (checktype.items != null)
{
foreach (var item in checktype.items)
foreach (TaskItemInput item in checktype.items)
{
QcCheckExecD QcCheckExecD = new QcCheckExecD();
QcCheckExecD.mainid = QcCheckExecH.id;
QcCheckExecD.typeid = checktype.id;
QcCheckExecD.itemid = item.itemid;
QcCheckExecD.extype = item.extype;
QcCheckExecD.excontent = item.excontent;
QcCheckExecD.check = item.check;
QcCheckExecD.errorcause = item.errorcause?.Replace("\"", "").Trim();
QcCheckExecD.errorlevel = item.errorlevel?.Replace("\"", "").Trim();
QcCheckExecD.remark = item.remark;
QcCheckExecD.attachment = item.attachment;
QcCheckExecD.isexec = item.isexec;
QcCheckExecD.custom = item.customer;
QcCheckExecD.create_id = _userManager.UserId;
QcCheckExecD.create_time = DateTime.Now;
QcCheckExecD QcCheckExecD = new()
{
mainid = QcCheckExecH.id,
typeid = checktype.id,
itemid = item.itemid,
extype = item.extype,
excontent = item.excontent,
check = item.check,
errorcause = item.errorcause?.Replace("\"", "").Trim(),
errorlevel = item.errorlevel?.Replace("\"", "").Trim(),
remark = item.remark,
attachment = item.attachment,
isexec = item.isexec,
custom = item.customer,
create_id = _userManager.UserId,
create_time = DateTime.Now
};
QcCheckExecDs.Add(QcCheckExecD);
}
}
}
}
await db.Ado.BeginTranAsync();
await db.Insertable(QcCheckExecH).ExecuteCommandAsync();
await db.Insertable(QcCheckExecDs).ExecuteCommandAsync();
_ = await db.Insertable(QcCheckExecH).ExecuteCommandAsync();
_ = await db.Insertable(QcCheckExecDs).ExecuteCommandAsync();
await db.Ado.CommitTranAsync();
}