diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index 11e85654..ab870c7d 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -83,6 +83,14 @@ public static class DictConst /// public const string MoStatusPauseCode = "Pause"; /// + /// 任务单状态码-异常 + /// + public const string MoStatusExceptionCode = "Exception"; + /// + /// 任务单状态码-撤销 + /// + public const string MoStatusRevokeCode = "Revoke"; + /// /// 模具维修状态码-待维修 /// public const string MaintainStatusDWXCode = "DWX"; diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskManageListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskManageListOutput.cs new file mode 100644 index 00000000..6bea2d0d --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskManageListOutput.cs @@ -0,0 +1,17 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class PrdTaskManageListOutput + { + public string id { get; set; } + public string mo_task_code { get; set; } + public string material_id { get; set; } + public string mold_id { get; set; } + public string eqp_id { get; set; } + public string plan_start_date { get; set; } + public string plan_end_date { get; set; } + public int? plan_qty { get; set; } + public int? complete_qty { get; set; } + public string mo_task_status { get; set; } + public string schedule_type { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs index 663cdb9d..7d4dfe1e 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs @@ -78,6 +78,11 @@ public partial class PrdMoTask : BaseEntity /// 已完工数量 /// public int? complete_qty { get; set; } + + /// + /// 已报工数量 + /// + public int? reported_work_qty { get; set; } /// /// 报废数量 diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs index 77b52b81..44fc1766 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs @@ -38,11 +38,6 @@ namespace Tnb.ProductionMgr.Entities [SugarColumn(IsIgnore = true)] public int? icmo_qty { get; set; } /// - /// 已报工数量 - /// - [SugarColumn(IsIgnore = true)] - public int? reported_work_qty { get; set; } - /// /// 提报数 /// [SugarColumn(IsIgnore = true)] diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 202897f4..d77872ee 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -303,7 +303,7 @@ namespace Tnb.ProductionMgr mo_task_qty = SqlFunc.Subqueryable().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().Where(it => it.id == a.process_id).Select(it => it.process_code), process_name = SqlFunc.Subqueryable().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); } + + // /// + // /// 生产提报 + // /// + // /// + // /// + // /// input: + // ///
{ + // ///
icmo_id:生产任务ID + // ///
icmo_code:任务单号 + // ///
prd_qty:生产数量 + // ///
reported_work_qty:已报工数量 + // ///
reported_qty:提报数量 + // ///
icmo_qty:生产任务量 + // ///
} + // ///
+ // [HttpPost] + // public async Task PrdReport(PrdReportCrInput input) + // { + // var row = -1; + // var db = _repository.AsSugarClient(); + // var report = await db.Queryable().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(); + // 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().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; + // } + /// /// 生产提报 /// @@ -1121,36 +1171,49 @@ namespace Tnb.ProductionMgr [HttpPost] public async Task PrdReport(PrdReportCrInput input) { - var row = -1; var db = _repository.AsSugarClient(); - var report = await db.Queryable().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 result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => { + var row = -1; + var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id); + report = input.Adapt(); 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().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().SingleAsync(x => x.id == input.mo_task_id); + if (prdMoTask.reported_work_qty == null) + { + await db.Updateable() + // .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() + // .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().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; } + /// /// 自检报废提交 /// diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index 3571b851..2bb31058 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -22,9 +22,12 @@ using Aspose.Cells.Drawing; using Microsoft.AspNetCore.Mvc; using DbModels; using JNPF.Common.Extension; +using JNPF.Common.Filter; using Tnb.ProductionMgr.Entities.Dto.PrdManage; using NPOI.OpenXmlFormats; using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; +using Newtonsoft.Json; using Tnb.BasicData; namespace Tnb.ProductionMgr @@ -58,57 +61,179 @@ namespace Tnb.ProductionMgr } + // private async Task GetList(VisualDevModelListQueryInput input) + // { + // var db = _repository.AsSugarClient(); + // VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + // var data = await _runService.GetListResult(templateEntity, input); + // if (data?.list?.Count > 0) + // { + // var statusField = "mo_task_status"; + // var scheduledTypeField = nameof(PrdMoTask.schedule_type); + // data.list = data.list.Where(it => it.ContainsKey(statusField) && + // it[statusField].IsNotEmptyOrNull() && it[statusField].ToString() != "待下发" && + // it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1 + // ).ToList(); + // foreach (var row in data.list) + // { + // var dic = row.ToDictionary(x => x.Key, x => x.Value); + // var pkName = "material_id"; + // if (dic.ContainsKey(pkName)) + // { + // var materialId = dic[pkName]?.ToString(); + // var material = await db.Queryable().FirstAsync(it => it.id == materialId); + // if (material != null) + // { + // row[pkName] = $"{material.code}/{material.name}"; + // } + // } + // //模具 + // if (dic.ContainsKey("mold_id")) + // { + // var moldId = dic["mold_id"]?.ToString(); + // var mold = await db.Queryable().FirstAsync(it => it.id == moldId); + // if (mold != null) + // { + // row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; + // } + // } + // //设备 + // if (dic.ContainsKey("eqp_id")) + // { + // var eqpId = dic["eqp_id"]?.ToString(); + // var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); + // if (eqp != null) + // { + // row["eqp_id"] = $"{eqp.code}/{eqp.name}"; + // } + // } + // + // } + // } + // return data!; + // } + private async Task GetList(VisualDevModelListQueryInput input) { var db = _repository.AsSugarClient(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); - var data = await _runService.GetListResult(templateEntity, input); - if (data?.list?.Count > 0) + Dictionary queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject>(input.queryJson) : null; + string moTaskCode = queryJson!=null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + Dictionary dic = new Dictionary() { - var statusField = "mo_task_status"; - var scheduledTypeField = nameof(PrdMoTask.schedule_type); - data.list = data.list.Where(it => it.ContainsKey(statusField) && - it[statusField].IsNotEmptyOrNull() && it[statusField].ToString() != "待下发" && - it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1 - ).ToList(); - foreach (var row in data.list) + [DictConst.ToBeStartedEnCode] = "待开工", + [DictConst.InProgressEnCode] = "进行中", + [DictConst.ClosedEnCode] = "关闭", + [DictConst.ComplatedEnCode] = "完工", + [DictConst.ToBeScheduledEncode] = "待排产", + [DictConst.MoStatusPauseCode] = "暂停", + [DictConst.MoStatusExceptionCode] = "异常", + [DictConst.MoStatusRevokeCode] = "撤销", + }; + var result = await db.Queryable() + .LeftJoin((a, b) => a.eqp_id == b.id) + .LeftJoin((a, b, c) => a.material_id == c.id) + .LeftJoin((a, b, c, d) => a.mold_id == d.id) + //.Where((a,b,c,d)=>(a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_status==DictConst.InProgressEnCode || a.mo_task_status==DictConst.MoStatusExceptionCode)) + .Where((a,b,c,d)=>a.schedule_type==1) + .WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c,d)=>a.mo_task_code.Contains(moTaskCode)) + .OrderByDescending((a, b, c, d) => a.create_time) + .Select((a, b, c, d) => new PrdTaskManageListOutput() { - var dic = row.ToDictionary(x => x.Key, x => x.Value); - var pkName = "material_id"; - if (dic.ContainsKey(pkName)) - { - var materialId = dic[pkName]?.ToString(); - var material = await db.Queryable().FirstAsync(it => it.id == materialId); - if (material != null) - { - row[pkName] = $"{material.code}/{material.name}"; - } - } - //模具 - if (dic.ContainsKey("mold_id")) - { - var moldId = dic["mold_id"]?.ToString(); - var mold = await db.Queryable().FirstAsync(it => it.id == moldId); - if (mold != null) - { - row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; - } - } - //设备 - if (dic.ContainsKey("eqp_id")) - { - var eqpId = dic["eqp_id"]?.ToString(); - var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); - if (eqp != null) - { - row["eqp_id"] = $"{eqp.code}/{eqp.name}"; - } - } - - } - } - return data!; + id = a.id, + mo_task_code = a.mo_task_code, + material_id = c.code+"/"+c.name, + mold_id = d.mold_code+"/"+d.mold_name, + eqp_id = b.code+"/"+b.name, + plan_start_date = a.plan_start_date.Value.ToString("yyyy-MM-dd"), + plan_end_date = a.plan_end_date.Value.ToString("yyyy-MM-dd"), + plan_qty = a.scheduled_qty, + complete_qty = a.complete_qty, + mo_task_status = a.mo_task_status, + schedule_type = a.schedule_type.ToString() + + }) + .Mapper(x=>x.mo_task_status=dic[x.mo_task_status]) + .ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); } + + + // /// + // /// 根据任务单号获取提报记录明细 + // /// + // /// 任务单号 + // /// + // /// returns: + // ///
{ + // ///
icmo_qty:任务计划数量 + // ///
reported_work_qty:已报工数量 + // ///
reported_qty:报工数量 + // ///
prd_qty:生产数量 + // ///
} + // ///
+ // [HttpGet] + // public async Task GetPrdReportByIcmoCode([FromRoute] string mo_task_code) + // { + // var db = _repository.AsSugarClient(); + // var prdTask = await db.Queryable().FirstAsync(it => it.mo_task_code == mo_task_code); + // var eqpCode = ""; + // var moldCode = ""; + // var materialCode = ""; + // var materialName = ""; + // var materialProp = ""; + // if (prdTask != null) + // { + // var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); + // var eqp = await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id); + // var mold = await db.Queryable().FirstAsync(it => it.id == prdTask.mold_id); + // var material = await db.Queryable().FirstAsync(it => it.id == prdTask.material_id); + // eqpCode = eqp != null ? eqp.code : ""; + // moldCode = mold != null ? mold.mold_code : ""; + // materialCode = material != null ? material.code : ""; + // materialName = material != null ? material.name : ""; + // materialProp = material != null ? material.material_property : ""; + // prdTask.workline_code = (await db.Queryable().Where(it => it.Id == prdTask.workline_id && it.Category == "workline").FirstAsync())?.EnCode; + // prdTask.process_code = (await db.Queryable().Where(it => it.id == prdTask.process_id).FirstAsync())?.process_code; + // if (dic.ContainsKey(prdTask.mo_task_status)) + // { + // prdTask.mo_task_status = dic[prdTask.mo_task_status]?.ToString(); + // } + // + // } + // var res = await db.Queryable().Where(it => it.mo_task_code == mo_task_code) + // .Select(it => new PrdReportOutput + // { + // icmo_qty = it.icmo_qty, + // reported_work_qty = it.reported_work_qty, + // reported_qty = it.reported_qty, + // prd_qty = it.prd_qty, + // scrap_qty = SqlFunc.Subqueryable().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(pmtd => pmtd.scrap_qty), + // }) + // .Mapper(it => + // { + // it.icmo_qty = it.icmo_qty ?? ( + // db.Queryable().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty < 1 ? 0 : + // (it.icmo_qty ?? db.Queryable().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty ?? 0)); + // it.reported_work_qty = it.reported_work_qty ?? 0; + // it.reported_qty = it.reported_qty ?? 0; + // it.prd_qty = it.prd_qty ?? 0; + // it.scrap_qty = it.scrap_qty ?? 0; + // }) + // .FirstAsync(); + // prdTask.eqp_code = eqpCode; + // prdTask.mold_code = moldCode; + // prdTask.material_code = materialCode; + // prdTask.material_name = materialName; + // prdTask.icmo_qty = res?.icmo_qty; + // prdTask.reported_work_qty = res?.reported_work_qty ?? 0; + // prdTask.reported_qty = res?.reported_qty ?? 0; + // prdTask.prd_qty = res?.prd_qty ?? 0; + // prdTask.scrap_qty = res?.scrap_qty ?? 0; + // + // return prdTask; + // } + + /// /// 根据任务单号获取提报记录明细 /// @@ -126,60 +251,34 @@ namespace Tnb.ProductionMgr public async Task GetPrdReportByIcmoCode([FromRoute] string mo_task_code) { var db = _repository.AsSugarClient(); - var prdTask = await db.Queryable().FirstAsync(it => it.mo_task_code == mo_task_code); - var eqpCode = ""; - var moldCode = ""; - var materialCode = ""; - var materialName = ""; - var materialProp = ""; - if (prdTask != null) - { - var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); - var eqp = await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id); - var mold = await db.Queryable().FirstAsync(it => it.id == prdTask.mold_id); - var material = await db.Queryable().FirstAsync(it => it.id == prdTask.material_id); - eqpCode = eqp != null ? eqp.code : ""; - moldCode = mold != null ? mold.mold_code : ""; - materialCode = material != null ? material.code : ""; - materialName = material != null ? material.name : ""; - materialProp = material != null ? material.material_property : ""; - prdTask.workline_code = (await db.Queryable().Where(it => it.Id == prdTask.workline_id && it.Category == "workline").FirstAsync())?.EnCode; - prdTask.process_code = (await db.Queryable().Where(it => it.id == prdTask.process_id).FirstAsync())?.process_code; - if (dic.ContainsKey(prdTask.mo_task_status)) + var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); + var prdTask = await db.Queryable() + .LeftJoin((a,b)=>a.material_id==b.id) + .LeftJoin((a,b,c)=>a.mold_id==c.id) + .LeftJoin((a,b,c,d)=>a.eqp_id==d.id) + .LeftJoin((a,b,c,d,e)=>e.DictionaryTypeId==DictConst.PrdTaskStatusTypeId && a.mo_task_status==e.EnCode) + .Where((a,b) => a.mo_task_code == mo_task_code) + .Select((a,b,c,d,e) => new { - prdTask.mo_task_status = dic[prdTask.mo_task_status]?.ToString(); - } - - } - var res = await db.Queryable().Where(it => it.mo_task_code == mo_task_code) - .Select(it => new PrdReportOutput - { - icmo_qty = it.icmo_qty, - reported_work_qty = it.reported_work_qty, - reported_qty = it.reported_qty, - prd_qty = it.prd_qty, - scrap_qty = SqlFunc.Subqueryable().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(pmtd => pmtd.scrap_qty), - }) - .Mapper(it => - { - it.icmo_qty = it.icmo_qty ?? ( - db.Queryable().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty < 1 ? 0 : - (it.icmo_qty ?? db.Queryable().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty ?? 0)); - it.reported_work_qty = it.reported_work_qty ?? 0; - it.reported_qty = it.reported_qty ?? 0; - it.prd_qty = it.prd_qty ?? 0; - it.scrap_qty = it.scrap_qty ?? 0; - }) - .FirstAsync(); - prdTask.eqp_code = eqpCode; - prdTask.mold_code = moldCode; - prdTask.material_code = materialCode; - prdTask.material_name = materialName; - prdTask.icmo_qty = res?.icmo_qty; - prdTask.reported_work_qty = res?.reported_work_qty ?? 0; - prdTask.reported_qty = res?.reported_qty ?? 0; - prdTask.prd_qty = res?.prd_qty ?? 0; - prdTask.scrap_qty = res?.scrap_qty ?? 0; + id = a.id, + mo_task_code = a.mo_task_code, + mo_id = a.mo_id, + material_id = a.material_id, + material_code = b.code, + material_name = b.name, + material_property = b.material_property, + mo_task_status = e.FullName, + plan_qty = a.plan_qty, + scheduled_qty = a.scheduled_qty, + complete_qty = a.reported_work_qty + a.scrap_qty, + scrap_qty = a.scrap_qty, + mold_code = c.mold_code, + // icmo_qty = a.icmo_qty, + reported_work_qty = a.reported_work_qty, + // reported_qty = a.reported_qty, + // prd_qty = a.prd_qty, + eqp_code = d.code, + }).FirstAsync(); return prdTask; } diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs index cf2e9c54..feb1fa21 100644 --- a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs @@ -5,6 +5,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using Aspose.Cells.Drawing; +using JNPF.Common.Dtos.VisualDev; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.VisualDev; @@ -19,6 +20,7 @@ using Tnb.ProductionMgr.Interfaces; using JNPF.Systems.Interfaces.System; using Tnb.BasicData; using JNPF.Common.Extension; +using Newtonsoft.Json.Linq; namespace Tnb.ProductionMgr { @@ -43,7 +45,9 @@ namespace Tnb.ProductionMgr _runService = runService; _visualDevService = visualDevService; OverideFuncs.GetListAsync = GetList; + OverideFuncs.UpdateAsync = AddRecord; _dictionaryDataService = dictionaryDataService; + _repository = repository; } @@ -76,5 +80,39 @@ namespace Tnb.ProductionMgr //} return data!; } + + private async Task AddRecord(string id,VisualDevModelDataUpInput input) + { + var db = _repository.AsSugarClient(); + var result = await db.Ado.UseTranAsync(async () => + { + List prdReports = new List(); + foreach (var item in (JArray)input.data["tablefield107"]) + { + if (item["id"] == null) + { + prdReports.Add(new PrdReport() + { + mo_task_id = input.data["mo_task_id"]?.ToString(), + mo_task_code = input.data["mo_task_code"]?.ToString(), + reported_qty = (int)item["reported_qty"], + create_id = item["create_id"]?.ToString(), + create_time = DateTime.Now, + }); + } + } + + await db.Insertable(prdReports).ExecuteCommandAsync(); + + int? sum = prdReports.Sum(x => x.reported_qty); + await db.Updateable() + .SetColumns(x => x.completed_qty == x.completed_qty + sum) + .SetColumns(x => x.reported_work_qty == x.reported_work_qty + sum) + .Where(x => x.id == input.data["id"].ToString()).ExecuteCommandAsync(); + + }); + + return result.IsSuccess; + } } }