diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 7a503e1e..c40f91e8 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1020,7 +1020,7 @@ namespace Tnb.ProductionMgr .Select((a, b, c, d, e) => new SubBomListOutput { version = a.version, - unit_id = a.unit_id, + unit_id = e.unit_id, route_id = c.id, process_id = b.process_id, material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id), @@ -1059,6 +1059,7 @@ namespace Tnb.ProductionMgr workstation_id = resultList?.FirstOrDefault() ?? "", mo_task_status = DictConst.ToBeScheduledEncode, workroute_id = item.route_id, + unit_id = item.unit_id, workline_id = input.workline_id }; subMoTask.material_id = item.material_id; @@ -1304,6 +1305,67 @@ namespace Tnb.ProductionMgr { throw Oops.Bah("状态错误无法完成"); } + PrdMo prdMo = await db.Queryable().Where(x=>x.id==item.mo_id).FirstAsync(); + if (prdMo.mo_type == DictConst.PrdMoTypeJC) + { + ///完工生成模具保养计划 + ToolMaintainTemMoldH toolMaintainTemMoldH = await db.Queryable() + .Where(x => x.is_start == "1" && x.plan_cycle_unit == "3" && x.mold_id==item.mold_id).FirstAsync(); + ToolMolds toolMolds = await db.Queryable().Where(x=>x.id==item.mold_id).FirstAsync(); + + if (toolMaintainTemMoldH != null && toolMolds!=null) + { + string code = DateTime.Now.Ticks.ToString(); + ToolMoldMaintainRecordH toolMoldMaintainRecordH = new ToolMoldMaintainRecordH() + { + id = SnowflakeIdHelper.NextId(), + code = code, + // equip_type_id = item.equip_type_id, + mold_id = toolMaintainTemMoldH.mold_id, + maintain_tem_mold_id = toolMaintainTemMoldH.id, + plan_run_notice = toolMaintainTemMoldH.plan_run_notice, + plan_run_notice_unit = toolMaintainTemMoldH.plan_run_notice_unit, + plan_delay = toolMaintainTemMoldH.plan_delay, + plan_delay_unit = toolMaintainTemMoldH.plan_delay_unit, + send_post_info_user_id = toolMaintainTemMoldH.send_post_info_user_id, + is_repeat = toolMaintainTemMoldH.is_repeat, + repeat_post_info_user_id = toolMaintainTemMoldH.repeat_post_info_user_id, + is_send = toolMaintainTemMoldH.is_send, + repeat_user_id = toolMaintainTemMoldH.repeat_user_id, + // execute_user_id = toolMaintainTemMoldH.duty_user_id, + execute_user_id = _userManager.UserId, + create_time = DateTime.Now, + status = Tnb.EquipMgr.SpotInsRecordExecutionStatus.TOBEEXECUTED + }; + List insertRecordDs = new List(); + + List spotInsItems = await db.Queryable() + .Where(x => x.maintain_tem_mold_id == toolMaintainTemMoldH.id) + .Select(x => x.maintain_item_id).ToListAsync(); + List tobeCreateItems = await db.Queryable().Where(x => spotInsItems.Contains(x.id)).ToListAsync(); + foreach (var tobeCreateItem in tobeCreateItems) + { + insertRecordDs.Add(new ToolMoldMaintainRecordD() + { + id = SnowflakeIdHelper.NextId(), + maintain_record_id = toolMoldMaintainRecordH.id, + maintain_tem_mold_id = toolMoldMaintainRecordH.maintain_tem_mold_id, + maintain_item_id = tobeCreateItem.id, + code = tobeCreateItem.code, + name = tobeCreateItem.name, + maintain_type = tobeCreateItem.maintain_type, + maintain_content = tobeCreateItem.maintain_content, + descrip = tobeCreateItem.descrip, + remark = tobeCreateItem.remark + }); + } + + await db.Insertable(toolMoldMaintainRecordH).ExecuteCommandAsync(); + await db.Insertable(insertRecordDs).ExecuteCommandAsync(); + } + + } + break; case PrdTaskBehavior.Closed: if (item.mo_task_status == status)