品质模块
This commit is contained in:
@@ -11,6 +11,7 @@ using JNPF.Common.Enums;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.JsonSerialization;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
@@ -34,7 +35,7 @@ namespace Tnb.QcMgr
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class QcCheckItemService : IOverideVisualDevService, IQcCheckItemService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "26500755139349";
|
||||
private const string ModuleId = "26477150883109";
|
||||
private readonly ISqlSugarRepository<QcCheckItemsH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
@@ -50,7 +51,7 @@ namespace Tnb.QcMgr
|
||||
var db = _repository.AsSugarClient();
|
||||
var QcCheckItemsH=await db.Queryable< QcCheckItemsH >().Where(p=>p.id==id).FirstAsync();
|
||||
var QcCheckItemsRs = await db.Queryable<QcCheckItemsR>().Where(p => p.itemshid == id).ToListAsync() ;
|
||||
var QcCheckItemsDs=await db.Queryable<QcCheckItemsD>().Where(p=> QcCheckItemsRs.Select(p=>p.id).ToList().Contains( p.id)).ToListAsync() ;
|
||||
var QcCheckItemsDs = await db.Queryable<QcCheckItemsD>().Where(p => QcCheckItemsRs.Select(p => p.itemsdid).ToList().Contains(p.id)).ToListAsync();
|
||||
await db.Ado.BeginTranAsync();
|
||||
await db.Deleteable(QcCheckItemsH).ExecuteCommandAsync();
|
||||
await db.Deleteable(QcCheckItemsRs).ExecuteCommandAsync();
|
||||
@@ -83,21 +84,98 @@ namespace Tnb.QcMgr
|
||||
if (CheckItemOut.items == null)
|
||||
{
|
||||
CheckItemOut.items = new List<CheckItem>();
|
||||
CheckItemOut.items.Add(new CheckItem { itemid = data.id, name = data.name, code = data.code });
|
||||
CheckItemOut.items.Add(new CheckItem { itemid = data.id, name = data.name!, code = data.code! });
|
||||
}
|
||||
else
|
||||
CheckItemOut.items.Add(new CheckItem { itemid = data.id, name = data.name, code = data.code });
|
||||
CheckItemOut.items.Add(new CheckItem { itemid = data.id, name = data.name!, code = data.code! });
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckItemOuts.Add(new CheckItemOut { checktypeid = data.type, checktypename = data.typename, items = new List<CheckItem>() });
|
||||
CheckItemOuts.Add(new CheckItemOut { checktypeid = data.type!, checktypename = data.typename!, items = new List<CheckItem>() });
|
||||
var CheckItemOut = CheckItemOuts.Where(p => p.checktypeid == data.type).First();
|
||||
CheckItemOut.items.Add(new CheckItem() { itemid = data.id, name = data.name, code = data.code });
|
||||
CheckItemOut.items.Add(new CheckItem() { itemid = data.id, name = data.name!, code = data.code! });
|
||||
}
|
||||
}
|
||||
return CheckItemOuts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取质检项清单
|
||||
/// </summary>
|
||||
/// <param name="CheckItemInput"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetCheckItems(CheckItemsInput CheckItemsInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
|
||||
var QcCheckTypes = await db.Queryable<QcCheckType>().ToListAsync();
|
||||
var QcCheckItemsH = await db.Queryable<QcCheckItemsH>().Where(p => p.id == CheckItemsInput.id).FirstAsync();
|
||||
List<QcCheckItemsR> QcCheckItemsRs = null;
|
||||
List<QcCheckItemsD> QcCheckItemsDs = null;
|
||||
if (QcCheckItemsH != null)
|
||||
{
|
||||
QcCheckItemsRs = await db.Queryable<QcCheckItemsR>().Where(p => p.itemshid == QcCheckItemsH.id).ToListAsync();
|
||||
if (QcCheckItemsRs != null)
|
||||
QcCheckItemsDs = await db.Queryable<QcCheckItemsD>().Where(p => QcCheckItemsRs.Select(p => p.itemsdid).ToList().Contains(p.id)).ToListAsync();
|
||||
}
|
||||
else
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
var CheckItemsOut = new CheckItemsOut();
|
||||
CheckItemsOut.id = QcCheckItemsH.id;
|
||||
CheckItemsOut.name = QcCheckItemsH.name!;
|
||||
CheckItemsOut.status = QcCheckItemsH.status!;
|
||||
CheckItemsOut.checktypes = new List<CheckTypeOut>();
|
||||
if (QcCheckItemsRs != null && QcCheckItemsDs != null)
|
||||
{
|
||||
foreach (var QcCheckItemsR in QcCheckItemsRs)
|
||||
{
|
||||
if (CheckItemsOut.checktypes.Where(p => p.checktypeid == QcCheckItemsR.typeid).ToList().Count == 0)
|
||||
{
|
||||
CheckTypeOut checkType = new CheckTypeOut();
|
||||
checkType.checktypeid = QcCheckItemsR.typeid!;
|
||||
checkType.checktypename = QcCheckTypes.Where(p => p.id == QcCheckItemsR.typeid).First().name!;
|
||||
checkType.items = new List<ItemOut>();
|
||||
CheckItemsOut.checktypes.Add(checkType);
|
||||
}
|
||||
var item = QcCheckItemsDs.Where(p => p.id == QcCheckItemsR.itemsdid).FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
ItemOut Item = new ItemOut();
|
||||
Item.itemid = QcCheckItemsR.itemid!;
|
||||
Item.itemdid = item.id!;
|
||||
Item.code = QcCheckItems.Where(p => p.id == QcCheckItemsR.itemid).First().code!;
|
||||
Item.name = QcCheckItems.Where(p => p.id == QcCheckItemsR.itemid).First().name!;
|
||||
Item.setData = new Data();
|
||||
Item.setData.extype = item.extype!;
|
||||
Item.setData.excontent = item.excontent!;
|
||||
Item.setData.check = item.check!;
|
||||
if (!string.IsNullOrEmpty(item.errorcause))
|
||||
Item.setData.errorcause = item.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
Item.setData.errorlevel = item.errorlevel!;
|
||||
Item.setData.remark = item.remark!;
|
||||
Item.setData.attachment = item.attachment!;
|
||||
Item.setData.customer = item.custom!;
|
||||
if (!string.IsNullOrEmpty(item.isexec))
|
||||
Item.setData.isexec = JSON.Deserialize<Isexec>(item.isexec!);
|
||||
Item.setShow = new Show();
|
||||
Item.setShow.extype = !string.IsNullOrEmpty(Item.setData.extype);
|
||||
Item.setShow.excontent = !string.IsNullOrEmpty(Item.setData.excontent);
|
||||
Item.setShow.check = !string.IsNullOrEmpty(Item.setData.check);
|
||||
Item.setShow.errorcause = Item.setData.errorcause == null ? false : true;
|
||||
Item.setShow.errorlevel = !string.IsNullOrEmpty(Item.setData.errorlevel);
|
||||
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;
|
||||
CheckItemsOut.checktypes.Where(p => p.checktypeid == QcCheckItemsR.typeid).First().items.Add(Item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return CheckItemsOut;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存质检项清单
|
||||
/// </summary>
|
||||
@@ -109,7 +187,8 @@ namespace Tnb.QcMgr
|
||||
var db = _repository.AsSugarClient();
|
||||
try
|
||||
{
|
||||
|
||||
if (!string.IsNullOrEmpty(CheckItemsInput.id))
|
||||
await Delete(CheckItemsInput.id);
|
||||
QcCheckItemsH QcCheckItemsH = new QcCheckItemsH();
|
||||
QcCheckItemsH.name = CheckItemsInput.name;
|
||||
QcCheckItemsH.status = CheckItemsInput.status;
|
||||
@@ -117,8 +196,7 @@ namespace Tnb.QcMgr
|
||||
QcCheckItemsH.create_id = _userManager.UserId;
|
||||
List<QcCheckItemsR> QcCheckItemsRs = new List<QcCheckItemsR>();
|
||||
List<QcCheckItemsD> QcCheckItemsDs = new List<QcCheckItemsD>();
|
||||
|
||||
foreach (var checktype in CheckItemsInput.checktypoes)
|
||||
foreach (var checktype in CheckItemsInput.checktypes)
|
||||
{
|
||||
foreach (var item in checktype.items)
|
||||
{
|
||||
@@ -127,11 +205,12 @@ namespace Tnb.QcMgr
|
||||
extype = item.extype,
|
||||
excontent = item.excontent,
|
||||
check = item.check,
|
||||
errorcause = item.errorcause,
|
||||
errorcause = item.errorcause.Replace("\"","").Trim(),
|
||||
errorlevel = item.errorlevel,
|
||||
remark = item.remark,
|
||||
attachment = item.attachment,
|
||||
isexec = item.isexec
|
||||
isexec = item.isexec,
|
||||
custom=item.customer
|
||||
};
|
||||
QcCheckItemsDs.Add(QcCheckItemsD);
|
||||
var QcCheckItemsR = new QcCheckItemsR()
|
||||
@@ -145,6 +224,12 @@ namespace Tnb.QcMgr
|
||||
QcCheckItemsRs.Add(QcCheckItemsR);
|
||||
}
|
||||
}
|
||||
QcCheckItemsDs.ForEach(p =>
|
||||
{
|
||||
p.create_id = _userManager.UserId;
|
||||
p.create_time = DateTime.Now;
|
||||
|
||||
});
|
||||
await db.Ado.BeginTranAsync();
|
||||
await db.Insertable(QcCheckItemsH).ExecuteCommandAsync();
|
||||
await db.Insertable(QcCheckItemsRs).ExecuteCommandAsync();
|
||||
|
||||
@@ -10,11 +10,13 @@ using JNPF.Common.Enums;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.JsonSerialization;
|
||||
using JNPF.VisualDev;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.QcMgr.Entities;
|
||||
using Tnb.QcMgr.Entities.Dto;
|
||||
using Tnb.QcMgr.Entities.Entity;
|
||||
using Tnb.QcMgr.Interfaces;
|
||||
|
||||
namespace Tnb.QcMgr
|
||||
@@ -33,38 +35,122 @@ namespace Tnb.QcMgr
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存质检方案
|
||||
/// 获取方案质检项附加信息
|
||||
/// </summary>
|
||||
/// <param name="CheckPlanInput"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetCheckItems(string id)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
|
||||
var QcCheckTypes = await db.Queryable<QcCheckType>().ToListAsync();
|
||||
var QcCheckPlanAdd = await db.Queryable<QcCheckPlanAdd>().Where(p => p.mainid == id).FirstAsync();
|
||||
var QcCheckPlanDs = await db.Queryable<QcCheckPlanD>().Where(p => p.mainid == id).ToListAsync();
|
||||
var CheckPlansOut = new CheckPlansOut();
|
||||
CheckPlansOut.id= id;
|
||||
CheckPlansOut.hasadd = false;
|
||||
CheckPlansOut.hasitem = false;
|
||||
if (QcCheckPlanAdd != null)
|
||||
{
|
||||
CheckPlansOut.hasadd = true;
|
||||
CheckPlansOut.addid = QcCheckPlanAdd.id;
|
||||
CheckPlansOut.triggertype = QcCheckPlanAdd.triggertype!;
|
||||
CheckPlansOut.content = QcCheckPlanAdd.content!;
|
||||
}
|
||||
if (QcCheckPlanDs != null&& QcCheckPlanDs.Count>0)
|
||||
{
|
||||
CheckPlansOut.hasitem = true;
|
||||
CheckPlansOut.checktypes = new List<CheckPlanTypeOut>();
|
||||
foreach (var QcCheckPlanD in QcCheckPlanDs)
|
||||
{
|
||||
if (CheckPlansOut.checktypes.Where(p => p.checktypeid == QcCheckPlanD.typeid).ToList().Count == 0)
|
||||
{
|
||||
CheckPlanTypeOut checkType = new CheckPlanTypeOut();
|
||||
checkType.checktypeid = QcCheckPlanD.typeid!;
|
||||
checkType.checktypename = QcCheckTypes.Where(p => p.id == QcCheckPlanD.typeid).First().name!;
|
||||
checkType.items = new List<PlanItemOut>();
|
||||
CheckPlansOut.checktypes.Add(checkType);
|
||||
}
|
||||
PlanItemOut Item = new PlanItemOut();
|
||||
Item.itemid = QcCheckPlanD.itemid!;
|
||||
Item.itemdid = QcCheckPlanD.id!;
|
||||
Item.code = QcCheckItems.Where(p => p.id == QcCheckPlanD.itemid).First().code!;
|
||||
Item.name = QcCheckItems.Where(p => p.id == QcCheckPlanD.itemid).First().name!;
|
||||
Item.setData = new PlanItemData();
|
||||
Item.setData.extype = QcCheckPlanD.extype!;
|
||||
Item.setData.excontent = QcCheckPlanD.excontent!;
|
||||
Item.setData.check = QcCheckPlanD.check!;
|
||||
if (!string.IsNullOrEmpty(QcCheckPlanD.errorcause))
|
||||
Item.setData.errorcause = QcCheckPlanD.errorcause!.Replace("[", "").Replace("]", "").Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
Item.setData.errorlevel = QcCheckPlanD.errorlevel!;
|
||||
Item.setData.remark = QcCheckPlanD.remark!;
|
||||
Item.setData.attachment = QcCheckPlanD.attachment!;
|
||||
Item.setData.customer = QcCheckPlanD.custom!;
|
||||
if (!string.IsNullOrEmpty(QcCheckPlanD.isexec))
|
||||
Item.setData.isexec = JSON.Deserialize<IsexecP>(QcCheckPlanD.isexec!);
|
||||
Item.setShow = new PlanItemShow();
|
||||
Item.setShow.extype = !string.IsNullOrEmpty(Item.setData.extype);
|
||||
Item.setShow.excontent = !string.IsNullOrEmpty(Item.setData.excontent);
|
||||
Item.setShow.check = !string.IsNullOrEmpty(Item.setData.check);
|
||||
Item.setShow.errorcause = Item.setData.errorcause == null ? false : true;
|
||||
Item.setShow.errorlevel = !string.IsNullOrEmpty(Item.setData.errorlevel);
|
||||
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;
|
||||
CheckPlansOut.checktypes.Where(p => p.checktypeid == QcCheckPlanD.typeid).First().items.Add(Item);
|
||||
}
|
||||
}
|
||||
return CheckPlansOut;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存质检方案质检项和附加信息
|
||||
/// </summary>
|
||||
/// <param name="CheckPlanInput"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task SaveData(CheckPlanInput CheckPlanInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
try
|
||||
{
|
||||
QcCheckPlanH QcCheckPlanH = new QcCheckPlanH();
|
||||
QcCheckPlanH.name = CheckPlanInput.name;
|
||||
QcCheckPlanH.status = CheckPlanInput.status;
|
||||
QcCheckPlanH.checktype = CheckPlanInput.checktype;
|
||||
QcCheckPlanH.numtype = CheckPlanInput.numtype;
|
||||
QcCheckPlanH.pagetype = CheckPlanInput.pagetype;
|
||||
QcCheckPlanH.writerule = CheckPlanInput.writerule;
|
||||
QcCheckPlanH.remind = CheckPlanInput.remind;
|
||||
QcCheckPlanH.attachment = CheckPlanInput.attachment;
|
||||
QcCheckPlanH.isaddmul = CheckPlanInput.isaddmul;
|
||||
QcCheckPlanH.create_time = DateTime.Now;
|
||||
QcCheckPlanH.create_id = _userManager.UserId;
|
||||
QcCheckPlanD QcCheckPlanD = new QcCheckPlanD();
|
||||
QcCheckPlanD.mainid = QcCheckPlanH.id;
|
||||
QcCheckPlanD.triggertype = CheckPlanInput.triggertype;
|
||||
QcCheckPlanD.content = CheckPlanInput.content;
|
||||
if (string.IsNullOrEmpty(CheckPlanInput.mainid))
|
||||
return;
|
||||
await db.Deleteable<QcCheckPlanD>(p => p.mainid == CheckPlanInput.mainid).ExecuteCommandAsync();
|
||||
await db.Deleteable<QcCheckPlanAdd>(p => p.mainid == CheckPlanInput.mainid).ExecuteCommandAsync();
|
||||
QcCheckPlanAdd QcCheckPlanAdd = new QcCheckPlanAdd();
|
||||
QcCheckPlanAdd.mainid = CheckPlanInput.mainid;
|
||||
QcCheckPlanAdd.triggertype = CheckPlanInput.triggertype;
|
||||
QcCheckPlanAdd.content = CheckPlanInput.content;
|
||||
List<QcCheckPlanD> QcCheckPlanDs = new List<QcCheckPlanD>();
|
||||
foreach (var checktype in CheckPlanInput.checktypes)
|
||||
{
|
||||
foreach (var item in checktype.items)
|
||||
{
|
||||
QcCheckPlanD QcCheckPlanD = new QcCheckPlanD();
|
||||
QcCheckPlanD.mainid = CheckPlanInput.mainid;
|
||||
QcCheckPlanD.typeid = checktype.id;
|
||||
QcCheckPlanD.itemid = item.itemid;
|
||||
QcCheckPlanD.extype = item.extype;
|
||||
QcCheckPlanD.excontent = item.excontent;
|
||||
QcCheckPlanD.check = item.check;
|
||||
QcCheckPlanD.errorcause = item.errorcause;
|
||||
QcCheckPlanD.errorlevel = item.errorlevel;
|
||||
QcCheckPlanD.remark = item.remark;
|
||||
QcCheckPlanD.attachment = item.attachment;
|
||||
QcCheckPlanD.isexec = item.isexec;
|
||||
QcCheckPlanD.custom = item.customer;
|
||||
QcCheckPlanDs.Add(QcCheckPlanD);
|
||||
}
|
||||
}
|
||||
await db.Ado.BeginTranAsync();
|
||||
await db.Insertable(QcCheckPlanH).ExecuteCommandAsync();
|
||||
await db.Insertable(QcCheckPlanD).ExecuteCommandAsync();
|
||||
await db.Insertable(QcCheckPlanDs).ExecuteCommandAsync();
|
||||
await db.Insertable(QcCheckPlanAdd).ExecuteCommandAsync();
|
||||
await db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user