1
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
@@ -137,8 +138,6 @@ namespace Tnb.QcMgr
|
||||
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;
|
||||
if(!string.IsNullOrEmpty(QcCheckExecD.postdata))
|
||||
Item.postItemForm= JSON.Deserialize<PostItemForm>(QcCheckExecD.postdata!);
|
||||
CheckTaskOut.checktypes.Where(p => p.checktypeid == QcCheckExecD.typeid).First()?.items?.Add(Item);
|
||||
}
|
||||
return CheckTaskOut;
|
||||
@@ -157,46 +156,155 @@ namespace Tnb.QcMgr
|
||||
{
|
||||
var QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == CheckTaskInput.mainid).FirstAsync();
|
||||
QcCheckExecH.checknum = CheckTaskInput.checknum;
|
||||
QcCheckExecH.status = CheckTaskInput.status;
|
||||
QcCheckExecH.status = "26745885292053";
|
||||
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();
|
||||
if (CheckTaskInput.checktypes != null)
|
||||
var QcCheckExecDdel = new List<QcCheckExecD>();
|
||||
var QcCheckExecDinsert = new List<QcCheckExecD>();
|
||||
if (CheckTaskInput.checktypes?.Count > 0)
|
||||
{
|
||||
foreach (var checktype in CheckTaskInput.checktypes)
|
||||
for (int i=0;i< CheckTaskInput.checktypes.Count;i++)
|
||||
{
|
||||
if (checktype.items != null)
|
||||
if (CheckTaskInput.checktypes[i].Count > 0)
|
||||
{
|
||||
foreach (var item in checktype.items)
|
||||
foreach (var exextype in CheckTaskInput.checktypes[i])
|
||||
{
|
||||
var QcCheckExecD = QcCheckExecDs.Where(p => p.id == item.itemdid).FirstOrDefault();
|
||||
if (QcCheckExecD == null)
|
||||
continue;
|
||||
QcCheckExecD.excontent = item.excontent;
|
||||
QcCheckExecD.check = item.check;
|
||||
QcCheckExecD.errorcause = item.errorcause;
|
||||
QcCheckExecD.errorlevel = item.errorlevel;
|
||||
QcCheckExecD.remark = item.remark;
|
||||
QcCheckExecD.attachment = item.attachment;
|
||||
QcCheckExecD.isexec = item.isexec;
|
||||
QcCheckExecD.custom = item.customer;
|
||||
QcCheckExecD.result = item.result;
|
||||
QcCheckExecD.postdata = item.postItemForm;
|
||||
if (exextype.items != null)
|
||||
{
|
||||
foreach (var item in exextype.items)
|
||||
{
|
||||
var 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();
|
||||
QcCheckExecDinsert.Add(insert);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await db.Ado.BeginTranAsync();
|
||||
await db.Updateable(QcCheckExecH).ExecuteCommandAsync();
|
||||
await db.Updateable(QcCheckExecDs).ExecuteCommandAsync();
|
||||
await db.Deleteable(QcCheckExecDdel).ExecuteCommandAsync();
|
||||
await db.Insertable(QcCheckExecDinsert).ExecuteCommandAsync();
|
||||
await db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
throw Oops.Oh(ErrorCode.COM1000);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取任务结果明细
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[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();
|
||||
|
||||
Result Result = new Result();
|
||||
Result.mainid = id;
|
||||
Result.checknum = QcCheckExecH.checknum!;
|
||||
Result.status = QcCheckExecH.status!;
|
||||
Result.checktypes = new List<List<Checktype>>();
|
||||
var groupkeys = QcCheckExecDs.Select(p=>p.checkindex).Distinct().ToList();
|
||||
foreach (var key in groupkeys)
|
||||
{
|
||||
var QcCheckExecDsbykey= QcCheckExecDs.Where(p=>p.checkindex==key).ToList();
|
||||
var checktype = new List<Checktype>();
|
||||
foreach (var 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.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.setData = new ExecItemData();
|
||||
Item.setData.extype = QcCheckExecD.extype!;
|
||||
Item.setData.excontent = JSON.Deserialize<Excontent>(QcCheckExecD.excontent!);
|
||||
Item.setData.check = QcCheckExecD.check!;
|
||||
if (!string.IsNullOrEmpty(QcCheckExecD.errorcause))
|
||||
{
|
||||
var strs = QcCheckExecD.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
Item.setData.errorcause = new List<Error>();
|
||||
foreach (var 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);
|
||||
Item.setData.errorlevel = new List<Error>();
|
||||
foreach (var str in strs)
|
||||
{
|
||||
Item.setData.errorlevel.Add(new Error { id = str, name = QcErrorLevels.Where(p => p.id == str).First().name! });
|
||||
}
|
||||
}
|
||||
Item.setData.remark = QcCheckExecD.remark!;
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user