diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceTaskServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceTaskServiceImpl.java index c9f1eecb..14e72515 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceTaskServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceTaskServiceImpl.java @@ -54,11 +54,6 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { @Autowired private EquPlanDetailMapper equPlanDetailMapper; - @Autowired - private EquPlanEquMapper equPlanEquMapper; - @Autowired - private EquOrderEquMapper equOrderEquMapper; - @Autowired private EquPlanEquSpareMapper equPlanEquSpareMapper; @Autowired @@ -229,6 +224,8 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { }else if("0".equals(plan.getCalculationRule())){ //根据createTime//0按固定周期 hasTask = deviceTaskMapper.getNewTaskOrder(plan); + }else if("2".equals(plan.getCalculationRule())){ + //单次生成保养计划 } if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){ @@ -260,50 +257,27 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { /**equ_order**/ sce = equOrderMapper.insertEquOrder(order); System.out.println(plan.getPlanCode()+"========equ_order:"+sce); - - /**equ_plan_equ->equ_order_equ*************************************************************/ - EquPlanEqu equPlanEqu = new EquPlanEqu(); - equPlanEqu.setId(plan.getPlanEquId()); - List equs = equPlanEquMapper.selectEquPlanEquList(equPlanEqu); - if(CollectionUtils.isEmpty(equs)){ - return 0; - } - String orderEquId = IdUtils.fastSimpleUUID(); - //equs一定就一个实值 - for(EquPlanEqu equ:equs){ - equ.setId(orderEquId); - equ.setCreateTime(nowtime); - equ.setCreateBy(createBy); - equ.setDelFlag("0"); - equ.setCode(orderCode); - } - sce = equOrderEquMapper.insertEquOrderEqus(equs); - System.out.println(plan.getPlanCode()+"========equ_order_equ:"+sce); /**equ_plan_equ_spare->equ_order_equ_spare*************************************************************/ EquPlanEquSpare equPlanEquSpare = new EquPlanEquSpare(); equPlanEquSpare.setParentCode(plan.getPlanEquId()); List spares = equPlanEquSpareMapper.selectEquPlanEquSpareList(equPlanEquSpare); - if(CollectionUtils.isEmpty(spares)){ - return 0; - } for(EquPlanEquSpare spare:spares){ spare.setId(IdUtils.fastSimpleUUID()); spare.setCreateTime(nowtime); spare.setCreateBy(createBy); spare.setDelFlag("0"); spare.setCode(orderCode); - spare.setParentCode(plan.getPlanEquId()); } - sce = equOrderEquSpareMapper.insertEquOrderEquSpares(spares); - System.out.println(plan.getPlanCode()+"========equ_order_equ_spare:"+sce); + if(!CollectionUtils.isEmpty(spares)){ + sce = equOrderEquSpareMapper.insertEquOrderEquSpares(spares); + System.out.println(plan.getPlanCode()+"========equ_order_equ_spare:"+sce); + } + /**equ_plan_detail->equ_order_detail*******************************************************/ EquPlanDetail itqo = new EquPlanDetail(); itqo.setParentCode(plan.getPlanEquId()); itqo.setDelFlag("0"); List details = equPlanDetailMapper.selectEquPlanDetailList(itqo); - if(CollectionUtils.isEmpty(details)){ - return 0; - } List standards = new ArrayList<>(); List standards0 = null; @@ -327,23 +301,21 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { itme.setCreateTime(nowtime); itme.setCreateBy(createBy); itme.setDelFlag("0"); - itme.setParentCode(orderEquId); + itme.setParentCode(orderCode); + } + if(!CollectionUtils.isEmpty(details)) { + sce = equOrderDetailMapper.insertEquOrderDetails(details); + System.out.println(plan.getPlanCode() + "========equ_order_detail:" + sce); } - sce = equOrderDetailMapper.insertEquOrderDetails(details); - System.out.println(plan.getPlanCode()+"========equ_order_detail:"+sce); /**equ_plan_standard->equ_order_standard*******************************************************/ - if(CollectionUtils.isEmpty(standards)){ - return 0; + if(!CollectionUtils.isEmpty(standards)) { + sce = equOrderStandardMapper.insertEquOrderStandards(standards); + System.out.println(plan.getPlanCode() + "========equ_order_detail:" + sce); } - sce = equOrderStandardMapper.insertEquOrderStandards(standards); - System.out.println(plan.getPlanCode()+"========equ_order_detail:"+sce); /**equ_plan_person->equ_order_standard*********************************************************/ EquPlanPerson equPlanPerson = new EquPlanPerson(); equPlanPerson.setPlanCode(plan.getPlanCode()); List persons = equPlanPersonMapper.selectEquPlanPersonList(equPlanPerson); - if(CollectionUtils.isEmpty(persons)){ - return 0; - } for(EquPlanPerson person:persons){ person.setId(IdUtils.fastSimpleUUID()); @@ -352,8 +324,10 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { person.setDelFlag("0"); person.setPlanCode(orderCode); } - sce = equOrderPersonMapper.insertEquOrderPlans(persons); - System.out.println(plan.getPlanCode()+"========equ_order_standard:"+sce); + if(!CollectionUtils.isEmpty(persons)) { + sce = equOrderPersonMapper.insertEquOrderPlans(persons); + System.out.println(plan.getPlanCode() + "========equ_order_standard:" + sce); + } return sce; } } diff --git a/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml index f09d1784..7e4ae2e6 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml @@ -17,6 +17,7 @@ ep.plan_outsource planOutsource, ep.calculation_rule calculationRule, ep.shut_down as 'shutDown', + ep.upkeep, epe.equipment_code equipmentCode, epe.equipment_name equipmentName, epe.id planEquId @@ -25,7 +26,7 @@ where ep.del_flag = '0' and epe.del_flag = '0' and ep.plan_status = '0' and ep.plan_type = #{planType} and CONVERT(varchar(10),GETDATE(), 120) >= CONVERT(varchar(10),ep.plan_loop_start, 120) - + and CONVERT(varchar(10),ep.plan_loop_end, 120) >= CONVERT(varchar(10),GETDATE(), 120) @@ -38,7 +39,7 @@ DATEDIFF (month, create_time, GETDATE())/3 days DATEDIFF (year, create_time, GETDATE()) days from equ_order - where plan_type = #{planType} and plan_code = #{planCode} + where plan_type = #{planType} and plan_code = #{planCode} and equipment_code = #{equipmentCode} order by create_time desc diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquOrderDetailMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquOrderDetailMapper.xml index 0371c3b6..3c8a2a6f 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquOrderDetailMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquOrderDetailMapper.xml @@ -112,7 +112,7 @@ insert into equ_order_detail ( - id, parent_code, + id, order_code, item_code, item_name, item_method, item_type, item_type_name, factory_code, del_flag, create_by, create_time diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquOrderEquSpareMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquOrderEquSpareMapper.xml index f82967f2..25c42457 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquOrderEquSpareMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquOrderEquSpareMapper.xml @@ -107,23 +107,19 @@ insert into equ_order_equ_spare( - id, order_code, parent_code, material_code, material_desc, + id, order_code, material_code, material_desc, spare_type, apply_num, factory_code, del_flag, - create_by, create_time, - )values + create_by, create_time + ) + VALUES ( - #{item.id},#{item.code},#{item.parentCode},#{item.materialCode},#{item.materialDesc}, + #{item.id},#{item.code},#{item.materialCode},#{item.materialDesc}, #{item.spareType},#{item.applyNum},#{item.factoryCode},#{item.delFlag}, #{item.createBy},#{item.createTime} ) - - select id, code, order_code, parent_code, material_code, material_desc, - spare_type, apply_num, factory_code, attr1, attr2, attr3, del_flag, - create_by, create_time, update_by, update_time - from