排产代码逻辑调整
This commit is contained in:
@@ -137,29 +137,46 @@ namespace Tnb.ProductionPlanMgr
|
||||
try
|
||||
{
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
row = await db.Storageable(entity).ExecuteCommandAsync();
|
||||
var taskLogEntity = input.Adapt<PrdTaskLog>();
|
||||
taskLogEntity.id ??= SnowflakeIdHelper.NextId();
|
||||
taskLogEntity.task_id = input.id;
|
||||
taskLogEntity.status ??= "ToBeStarted";
|
||||
taskLogEntity.create_id = _userManager.UserId;
|
||||
taskLogEntity.create_time = DateTime.Now;
|
||||
taskLogEntity.operator_name = _userManager.RealName;
|
||||
|
||||
|
||||
//任务状态变更时插入操作记录
|
||||
if (!db.Queryable<PrdTaskLog>().Where(it => it.task_id == input.id && it.status == taskLogEntity.status).Any())
|
||||
{
|
||||
row = await db.Insertable(taskLogEntity).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (row > 0)
|
||||
{
|
||||
//修改工单状态为已排产,同事修改已排产数量
|
||||
var obj = (await db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id));
|
||||
obj.input_qty += entity.scheduled_num;
|
||||
var moStatus = "";
|
||||
//判断,已排产数量>=计划数量时将状态改为 已完成
|
||||
if (obj.input_qty >= obj.plan_qty)
|
||||
{
|
||||
moStatus = "25019252113685";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//修改工单状态为已排产,同事修改已排产数量
|
||||
moStatus = "25019244276501";
|
||||
}
|
||||
row = await db.Updateable<PrdMo>().SetColumns(it => new PrdMo
|
||||
{
|
||||
mo_status = "25019252113685",
|
||||
input_qty = entity.scheduled_num
|
||||
mo_status = moStatus,
|
||||
input_qty = obj.input_qty
|
||||
})
|
||||
.Where(it => it.id == entity.mo_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -231,19 +248,20 @@ namespace Tnb.ProductionPlanMgr
|
||||
/// <summary>
|
||||
/// 查看工单操作记录
|
||||
/// </summary>
|
||||
/// <param name="input">操作记录查询输入参数</param>
|
||||
/// <param name="taskId">任务ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("record/{moId}")]
|
||||
public async Task<dynamic> GetMoOperRecord(PrdTaskOperInput input)
|
||||
[HttpGet("record/{taskId}")]
|
||||
public async Task<dynamic> GetMoOperRecord(string taskId)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTask>().LeftJoin<PrdTaskLog>((a, b) => a.prd_task_id == b.id)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.mo_no), a => a.mo_id == input.mo_no)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.task_no), b => b.prd_task_id == input.task_no)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.item_code), a => a.item_code == input.item_code)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.eqp_code), a => a.eqp_type_code == input.eqp_code)
|
||||
.WhereIF(input.plan_start_date.HasValue, a => a.plan_start_date >= input.plan_start_date!.Value)
|
||||
.WhereIF(input.plan_end_date.HasValue, a => a.plan_end_date <= input.plan_end_date!.Value)
|
||||
.ToListAsync();
|
||||
//var list = await _repository.AsSugarClient().Queryable<PrdTask>().LeftJoin<PrdTaskLog>((a, b) => a.prd_task_id == b.id)
|
||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.mo_no),b=>b.id == input.task_no)
|
||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.task_no), b => b.prd_task_id == input.task_id)
|
||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.item_code), a => a.item_code == input.item_code)
|
||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.eqp_code), a => a.eqp_type_code == input.eqp_code)
|
||||
// .WhereIF(input.plan_start_date.HasValue, a => a.plan_start_date >= input.plan_start_date!.Value)
|
||||
// .WhereIF(input.plan_end_date.HasValue, a => a.plan_end_date <= input.plan_end_date!.Value)
|
||||
// .ToListAsync();
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTaskLog>().Where(it => it.id == taskId).ToListAsync();
|
||||
var data = list.Adapt<List<PrdTaskOperOutput>>();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId("25572555259157");
|
||||
_repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : "");
|
||||
|
||||
Reference in New Issue
Block a user