品质模块
This commit is contained in:
@@ -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