bug
This commit is contained in:
@@ -303,7 +303,7 @@ namespace Tnb.ProductionMgr
|
||||
mo_task_qty = SqlFunc.Subqueryable<PrdMoTask>().Where(a => a.mo_id == moId).Count(),
|
||||
estimated_start_date = a.estimated_start_date,
|
||||
estimated_end_date = a.estimated_end_date,
|
||||
plan_qty = b.plan_qty,
|
||||
plan_qty = a.scheduled_qty,
|
||||
complete_qty = a.complete_qty,
|
||||
process_code = SqlFunc.Subqueryable<BasProcess>().Where(it => it.id == a.process_id).Select(it => it.process_code),
|
||||
process_name = SqlFunc.Subqueryable<BasProcess>().Where(it => it.id == a.process_id).Select(it => it.process_name),
|
||||
@@ -1103,6 +1103,56 @@ namespace Tnb.ProductionMgr
|
||||
row = await db.Updateable(icmoItem).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// 生产提报
|
||||
// /// </summary>
|
||||
// /// <param name="input"></param>
|
||||
// /// <remarks>
|
||||
// /// input:
|
||||
// /// <br/>{
|
||||
// /// <br/> icmo_id:生产任务ID
|
||||
// /// <br/> icmo_code:任务单号
|
||||
// /// <br/> prd_qty:生产数量
|
||||
// /// <br/> reported_work_qty:已报工数量
|
||||
// /// <br/> reported_qty:提报数量
|
||||
// /// <br/> icmo_qty:生产任务量
|
||||
// /// <br/>}
|
||||
// /// </remarks>
|
||||
// [HttpPost]
|
||||
// public async Task<dynamic> PrdReport(PrdReportCrInput input)
|
||||
// {
|
||||
// var row = -1;
|
||||
// var db = _repository.AsSugarClient();
|
||||
// var report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
//
|
||||
// //if (report is not null)
|
||||
// //{
|
||||
// // report.mo_task_code = input.mo_task_code;
|
||||
// // report.mo_task_id = input.mo_task_id;
|
||||
// // report.reported_work_qty += input.reported_qty;
|
||||
// // report.prd_qty += input.reported_qty;
|
||||
// //}
|
||||
// //else
|
||||
// {
|
||||
// report = input.Adapt<PrdReport>();
|
||||
// report.id = SnowflakeIdHelper.NextId();
|
||||
// report.reported_qty = input.reported_qty;
|
||||
// report.create_id = _userManager.UserId;
|
||||
// report.create_time = DateTime.Now;
|
||||
//
|
||||
// }
|
||||
// row = await db.Insertable(report).ExecuteCommandAsync();
|
||||
// var master = await db.Queryable<PrdReportRecord>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
// if (master != null)
|
||||
// {
|
||||
// master.reported_work_qty += input.reported_qty;
|
||||
// master.completed_qty += input.reported_qty;
|
||||
// await db.Updateable(master).ExecuteCommandAsync();
|
||||
// }
|
||||
// return row > 0;
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// 生产提报
|
||||
/// </summary>
|
||||
@@ -1121,36 +1171,49 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdReport(PrdReportCrInput input)
|
||||
{
|
||||
var row = -1;
|
||||
var db = _repository.AsSugarClient();
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
|
||||
//if (report is not null)
|
||||
//{
|
||||
// report.mo_task_code = input.mo_task_code;
|
||||
// report.mo_task_id = input.mo_task_id;
|
||||
// report.reported_work_qty += input.reported_qty;
|
||||
// report.prd_qty += input.reported_qty;
|
||||
//}
|
||||
//else
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var row = -1;
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
|
||||
report = input.Adapt<PrdReport>();
|
||||
report.id = SnowflakeIdHelper.NextId();
|
||||
report.reported_qty = input.reported_qty;
|
||||
report.create_id = _userManager.UserId;
|
||||
report.create_time = DateTime.Now;
|
||||
|
||||
}
|
||||
row = await db.Insertable(report).ExecuteCommandAsync();
|
||||
var master = await db.Queryable<PrdReportRecord>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
if (master != null)
|
||||
{
|
||||
master.reported_work_qty += input.reported_qty;
|
||||
master.completed_qty += input.reported_qty;
|
||||
await db.Updateable(master).ExecuteCommandAsync();
|
||||
}
|
||||
return row > 0;
|
||||
row = await db.Insertable(report).ExecuteCommandAsync();
|
||||
|
||||
var prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||
if (prdMoTask.reported_work_qty == null)
|
||||
{
|
||||
await db.Updateable<PrdMoTask>()
|
||||
// .SetColumns(x => x.complete_qty == x.complete_qty + input.reported_qty)
|
||||
.SetColumns(x => x.reported_work_qty == input.reported_qty)
|
||||
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMoTask>()
|
||||
// .SetColumns(x => x.complete_qty == x.complete_qty + input.reported_qty)
|
||||
.SetColumns(x => x.reported_work_qty == x.reported_work_qty + input.reported_qty)
|
||||
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
var master = await db.Queryable<PrdReportRecord>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
if (master != null)
|
||||
{
|
||||
master.reported_work_qty += input.reported_qty;
|
||||
master.completed_qty += input.reported_qty;
|
||||
await db.Updateable(master).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
});
|
||||
return result.IsSuccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自检报废提交
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user