质量
This commit is contained in:
@@ -5,6 +5,7 @@ using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.JsonSerialization;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.VisualDev;
|
||||
@@ -13,10 +14,17 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using Tnb.QcMgr.Entities;
|
||||
using Tnb.QcMgr.Interfaces;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
|
||||
namespace Tnb.QcMgr
|
||||
{
|
||||
@@ -33,13 +41,19 @@ namespace Tnb.QcMgr
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IWmsSaleService _wmsSaleService;
|
||||
private readonly IWmsPurchaseService _wmsPurchaseService;
|
||||
private readonly IPrdMoTaskService _prdMoTaskService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public QcCheckTaskService(ISqlSugarRepository<QcCheckExecH> repository, IUserManager userManager, IWmsSaleService wmsSaleService, IWmsPurchaseService wmsPurchaseService)
|
||||
public QcCheckTaskService(ISqlSugarRepository<QcCheckExecH> repository,
|
||||
IUserManager userManager,
|
||||
IWmsSaleService wmsSaleService,
|
||||
IPrdMoTaskService prdMoTaskService,
|
||||
IWmsPurchaseService wmsPurchaseService)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
OverideFuncs.GetListAsync = GetListAsync;
|
||||
_wmsSaleService= wmsSaleService;
|
||||
_prdMoTaskService = prdMoTaskService;
|
||||
_wmsPurchaseService= wmsPurchaseService;
|
||||
}
|
||||
|
||||
@@ -50,7 +64,7 @@ namespace Tnb.QcMgr
|
||||
{
|
||||
{ "ok", "合格" },
|
||||
{ "no", "不合格" },
|
||||
{ "barelyOk", "让步合格" },
|
||||
{ "barelyOk", "让步接收" },
|
||||
{ "await", "待检" },
|
||||
{ "temporarily", "暂控" }
|
||||
};
|
||||
@@ -67,11 +81,12 @@ namespace Tnb.QcMgr
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.processid == c.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workid == d.Id)
|
||||
.LeftJoin<UserEntity>((a, b, c, d, e) => a.execuser == e.Id)
|
||||
.LeftJoin<PrdReport>((a,b,c,d,e,f)=>a.report_id==f.id)
|
||||
.WhereIF(!string.IsNullOrEmpty(materialid), (a, b, c, d,e) => b.name.Contains(materialid))
|
||||
.WhereIF(!string.IsNullOrEmpty(checktype), (a, b, c, d, e) => a.checktype == checktype)
|
||||
.WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d, e) => a.status == status)
|
||||
.Where((a, b, c, d, e) => a.status == list.Where(p => p.FullName == "待执行").First().Id)
|
||||
.Select((a, b, c, d, e) => new QcCheckExecHOut
|
||||
.Select((a, b, c, d, e,f) => new QcCheckExecHOut
|
||||
{
|
||||
id = a.id,
|
||||
materialid = b.name,
|
||||
@@ -85,6 +100,9 @@ namespace Tnb.QcMgr
|
||||
tasktime = a.tasktime ?? "",
|
||||
exectime = a.exectime ?? "",
|
||||
execuser = e.RealName ?? "",
|
||||
mo_task_code = a.mo_task_code,
|
||||
batch = a.batch,
|
||||
qty = a.qty
|
||||
}).OrderByDescending(a => DateTime.Parse(a.tasktime)).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
foreach (QcCheckExecHOut? item in result.list)
|
||||
{
|
||||
@@ -111,12 +129,33 @@ namespace Tnb.QcMgr
|
||||
List<QcErrorCause> QcErrorCauses = await db.Queryable<QcErrorCause>().ToListAsync();
|
||||
List<QcErrorLevel> QcErrorLevels = await db.Queryable<QcErrorLevel>().ToListAsync();
|
||||
|
||||
PrdMoTask moTask = await db.Queryable<PrdMoTask>().Where(x => x.mo_task_code == QcCheckExecH.mo_task_code).FirstAsync();
|
||||
if (moTask == null)
|
||||
{
|
||||
throw Oops.Bah($"未找到任务单{QcCheckExecH.mo_task_code}");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(QcCheckExecH.report_id))
|
||||
{
|
||||
throw Oops.Bah($"未找到提报记录{QcCheckExecH.report_id}");
|
||||
}
|
||||
BasMaterial basMaterial = await db.Queryable<BasMaterial>().Where(x=>x.id==moTask.material_id).FirstAsync();
|
||||
PrdReport prdReport = await db.Queryable<PrdReport>().SingleAsync(x => x.id == QcCheckExecH.report_id);
|
||||
UserEntity userEntity = await db.Queryable<UserEntity>().SingleAsync(x => x.Id == prdReport.create_id);
|
||||
CheckTaskOut CheckTaskOut = new()
|
||||
{
|
||||
mainid = id,
|
||||
wareid = QcCheckExecH.wareid!,
|
||||
workid = QcCheckExecH.workid!,
|
||||
status = QcCheckExecH.status!
|
||||
status = QcCheckExecH.status!,
|
||||
mo_task_code = QcCheckExecH.mo_task_code,
|
||||
material_id = moTask.material_id,
|
||||
material_code = basMaterial.code,
|
||||
material_name = basMaterial.name,
|
||||
checknum = !string.IsNullOrEmpty(QcCheckExecH.checknum) ? int.Parse(QcCheckExecH.checknum) : 0,
|
||||
worker_name = userEntity?.RealName ?? "",
|
||||
bill_code = QcCheckExecH.bill_code,
|
||||
carry_code = prdReport.material_box_code,
|
||||
};
|
||||
if (!string.IsNullOrEmpty(CheckTaskOut.workid))
|
||||
{
|
||||
@@ -204,13 +243,14 @@ namespace Tnb.QcMgr
|
||||
try
|
||||
{
|
||||
Dictionary<string, int> dic = new()
|
||||
{
|
||||
{ "ok", 1 },
|
||||
{ "no", 2 },
|
||||
{ "barelyOk", 4 },
|
||||
{ "await", 8 },
|
||||
{ "temporarily", 16 }
|
||||
};
|
||||
{
|
||||
{ "ok", 1 },
|
||||
{ "no", 2 },
|
||||
{ "barelyOk", 4 },
|
||||
{ "await", 8 },
|
||||
{ "temporarily", 16 },
|
||||
{ "checking", 32 },
|
||||
};
|
||||
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();
|
||||
@@ -219,7 +259,11 @@ namespace Tnb.QcMgr
|
||||
QcCheckExecH.result = CheckTaskInput.result;
|
||||
QcCheckExecH.execuser = _userManager.UserId;
|
||||
QcCheckExecH.exectime = DateTime.Now.ToString();
|
||||
QcCheckExecH.check_type = CheckTaskInput.check_type;
|
||||
QcCheckExecH.remark = CheckTaskInput.remark;
|
||||
List<QcCheckExecD> QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == CheckTaskInput.mainid).ToListAsync();
|
||||
|
||||
int rqty = 0;
|
||||
List<QcCheckExecD> QcCheckExecDdel = new();
|
||||
List<QcCheckExecD> QcCheckExecDinsert = new();
|
||||
if (CheckTaskInput.checktypes?.Count > 0)
|
||||
@@ -268,9 +312,12 @@ namespace Tnb.QcMgr
|
||||
create_time = QcCheckExecD.create_time,
|
||||
postdata = item.postItemForm,
|
||||
result = item.result,
|
||||
checkindex = (i + 1).ToString()
|
||||
checkindex = (i + 1).ToString(),
|
||||
qty = item.qty
|
||||
};
|
||||
QcCheckExecDinsert.Add(insert);
|
||||
|
||||
rqty += item.qty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,6 +325,7 @@ namespace Tnb.QcMgr
|
||||
}
|
||||
}
|
||||
await db.Ado.BeginTranAsync();
|
||||
QcCheckExecH.qty = int.Parse(CheckTaskInput.checknum) - rqty;
|
||||
_ = await db.Updateable(QcCheckExecH).ExecuteCommandAsync();
|
||||
_ = await db.Deleteable(QcCheckExecDdel).ExecuteCommandAsync();
|
||||
_ = await db.Insertable(QcCheckExecDinsert).ExecuteCommandAsync();
|
||||
@@ -296,12 +344,39 @@ namespace Tnb.QcMgr
|
||||
mesCheckdCallbackUpinput.maintableid = QcCheckExecH.extras;
|
||||
mesCheckdCallbackUpinput.check_conclusion = dic.Where(p => p.Key == CheckTaskInput.result).Any() ? dic.Where(p => p.Key == CheckTaskInput.result).First().Value : 0;
|
||||
await _wmsPurchaseService.MesCheckdPurchaseCallback(mesCheckdCallbackUpinput);
|
||||
}else if (QcCheckExecH.checktype == WmsWareHouseConst.LINGBUJIANZUIZHONGJIANYAN_ID)
|
||||
{
|
||||
PrdReport prdReport = await db.Queryable<PrdReport>().SingleAsync(x=>x.id==QcCheckExecH.report_id);
|
||||
int pqty = prdReport.reported_qty.Value - rqty;
|
||||
if (rqty > Decimal.Parse(QcCheckExecH.checknum))
|
||||
{
|
||||
throw Oops.Bah("不合格数不能大于抽样数");
|
||||
}
|
||||
|
||||
if (CheckTaskInput.result != "await")
|
||||
{
|
||||
string isCheck = dic[CheckTaskInput.result].ToString();
|
||||
await db.Updateable<WmsCarryH>()
|
||||
.SetColumns(x => x.is_check == isCheck)
|
||||
.Where(x => x.carry_code == prdReport.material_box_code)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
_prdMoTaskService.ReportInstock(new CheckCompleteInput()
|
||||
{
|
||||
report_id = QcCheckExecH.report_id,
|
||||
pqty = pqty,
|
||||
rqty = rqty,
|
||||
check_result = ((EnumCheckConclusion)dic[CheckTaskInput.result]).ToString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
await db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Oops.Oh("执行失败");
|
||||
await db.Ado.RollbackTranAsync();
|
||||
Log.Error(e.Message,e);
|
||||
throw Oops.Oh("执行失败:"+e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user