外包装入库申请

This commit is contained in:
2023-11-09 10:58:15 +08:00
parent 68efc42e31
commit 746e7f425d
12 changed files with 586 additions and 10 deletions

View File

@@ -1,8 +1,10 @@
using JNPF.Common.Extension;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Filter;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
@@ -17,6 +19,7 @@ using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
using Tnb.ProductionMgr.Entities.Entity;
using Tnb.ProductionMgr.Interfaces;
using Tnb.ProductionMgr.Entities.Dto;
namespace Tnb.ProductionMgr
@@ -487,5 +490,144 @@ namespace Tnb.ProductionMgr
BasQrcode basQrcode = await _db.Queryable<BasQrcode>().Where(x => x.source_name == "TOOL_MOLDS" && x.code == input.mold_qrcode).FirstAsync();
return prdMoTask != null && basQrcode != null ? prdMoTask.mold_id == basQrcode.source_id : (dynamic)false;
}
/// <summary>
/// 外包装喷码校验
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<dynamic> OutPackMarkCheck(MarkingLabelInput input)
{
string[] arr = input.mark_code.Split("/");
if (arr.Length > 1)
{
string mo_task_code = arr[0];
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().Where(x => x.mo_task_code == mo_task_code).FirstAsync();
if (prdMoTask == null) throw Oops.Bah("未找到对应任务单");
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().Where(x => x.id == prdMoTask.material_id).FirstAsync();
DictionaryDataEntity unit = await _db.Queryable<DictionaryTypeEntity>()
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode == basMaterial.unit_id)
.Select((x, y) => y).FirstAsync();
PrdOutPackMarkLabel prdOutPackMarkLabel = await _db.Queryable<PrdOutPackMarkLabel>().Where(x=>x.mo_task_code==mo_task_code && x.status=="0" && x.is_mark==0).OrderByDescending(x=>x.create_time).FirstAsync();
if (prdOutPackMarkLabel != null)
{
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
{
if (prdOutPackMarkLabel.is_label == 1)
{
PrdReport prdReport = new PrdReport()
{
mo_task_id = prdMoTask.id,
mo_task_code = prdMoTask.mo_task_code,
create_id = DictConst.DEFAULTUSERID,
create_time = DateTime.Now,
reported_qty = 1,
unit_id = unit?.Id ?? "",
barcode = mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(),
equip_id = prdMoTask.eqp_id,
mbom_process_id = prdMoTask.mbom_process_id,
station = prdMoTask.workstation_id,
status=0,
material_id = prdMoTask.material_id,
process_id = prdMoTask.process_id,
};
await _db.Updateable<PrdOutPackMarkLabel>()
.SetColumns(x=>x.is_mark==1)
.SetColumns(x=>x.status=="1")
.SetColumns(x=>x.report_id==prdReport.id)
.ExecuteCommandAsync();
await _db.Insertable<PrdReport>(prdReport).ExecuteCommandAsync();
}
else
{
await _db.Updateable<PrdOutPackMarkLabel>().SetColumns(x=>x.is_mark==1).ExecuteCommandAsync();
}
});
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "校验成功" : result.ErrorMessage;
}
else
{
throw Oops.Bah("校验失败");
}
}
throw Oops.Bah("校验失败");
}
/// <summary>
/// 外包装贴标校验
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<dynamic> OutPackLabelCheck(MarkingLabelInput input)
{
string[] arr = input.mark_code.Split("/");
if (arr.Length > 1)
{
string mo_task_code = arr[0];
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().Where(x => x.mo_task_code == mo_task_code).FirstAsync();
if (prdMoTask == null) throw Oops.Bah("未找到对应任务单");
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().Where(x => x.id == prdMoTask.material_id).FirstAsync();
DictionaryDataEntity unit = await _db.Queryable<DictionaryTypeEntity>()
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode == basMaterial.unit_id)
.Select((x, y) => y).FirstAsync();
PrdOutPackMarkLabel prdOutPackMarkLabel = await _db.Queryable<PrdOutPackMarkLabel>().Where(x=>x.mo_task_code==mo_task_code && x.status=="0" && x.is_label==0).OrderByDescending(x=>x.create_time).FirstAsync();
if (prdOutPackMarkLabel != null)
{
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
{
if (prdOutPackMarkLabel.is_mark == 1)
{
PrdReport prdReport = new PrdReport()
{
mo_task_id = prdMoTask.id,
mo_task_code = prdMoTask.mo_task_code,
create_id = DictConst.DEFAULTUSERID,
create_time = DateTime.Now,
reported_qty = 1,
unit_id = unit?.Id ?? "",
barcode = mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(),
equip_id = prdMoTask.eqp_id,
mbom_process_id = prdMoTask.mbom_process_id,
station = prdMoTask.workstation_id,
status=0,
material_id = prdMoTask.material_id,
process_id = prdMoTask.process_id,
};
await _db.Updateable<PrdOutPackMarkLabel>()
.SetColumns(x=>x.is_label==1)
.SetColumns(x=>x.status=="1")
.SetColumns(x=>x.report_id==prdReport.id)
.ExecuteCommandAsync();
await _db.Insertable<PrdReport>(prdReport).ExecuteCommandAsync();
}
else
{
await _db.Updateable<PrdOutPackMarkLabel>().SetColumns(x=>x.is_label==1).ExecuteCommandAsync();
}
});
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "校验成功" : result.ErrorMessage;
}
else
{
throw Oops.Bah("校验失败");
}
}
throw Oops.Bah("校验失败");
}
}
}