diff --git a/op-modules/op-device/src/main/java/com/op/device/controller/EquPlanController.java b/op-modules/op-device/src/main/java/com/op/device/controller/EquPlanController.java index 0b765b92..6e4177a6 100644 --- a/op-modules/op-device/src/main/java/com/op/device/controller/EquPlanController.java +++ b/op-modules/op-device/src/main/java/com/op/device/controller/EquPlanController.java @@ -38,6 +38,7 @@ public class EquPlanController extends BaseController { /** * 修改计划初始化信息 + * * @param equPlan * @return */ @@ -48,6 +49,7 @@ public class EquPlanController extends BaseController { /** * 获取工作中心 + * * @return */ @GetMapping("/getWorkCenter") @@ -76,18 +78,19 @@ public class EquPlanController extends BaseController { return equPlanService.formatEquItem(equPlanEquList); } - /** - * 获取设备信息list - * @param equEquipment - * @return - */ - @RequiresPermissions("device:plan:list") - @GetMapping("/getEquList") - public TableDataInfo getEquList(EquEquipment equEquipment) { - startPage(); - List list = equPlanService.getEquList(equEquipment); - return getDataTable(list); - } + /** + * 获取设备信息list + * + * @param equEquipment + * @return + */ + @RequiresPermissions("device:plan:list") + @GetMapping("/getEquList") + public TableDataInfo getEquList(EquEquipment equEquipment) { + startPage(); + List list = equPlanService.getEquList(equEquipment); + return getDataTable(list); + } /** * 查询计划列表 @@ -138,7 +141,7 @@ public class EquPlanController extends BaseController { @Log(title = "计划", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody EquPlan equPlan) { - return toAjax(equPlanService.updateEquPlan(equPlan)); + return equPlanService.updateEquPlan(equPlan); } /** @@ -148,6 +151,6 @@ public class EquPlanController extends BaseController { @Log(title = "计划", businessType = BusinessType.DELETE) @DeleteMapping("/{planIds}") public AjaxResult remove(@PathVariable String[] planIds) { - return toAjax(equPlanService.deleteEquPlanByPlanIds(planIds)); + return equPlanService.deleteEquPlanByPlanIds(planIds); } } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanDetailMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanDetailMapper.java index 377ed81d..6253ac2b 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanDetailMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanDetailMapper.java @@ -65,4 +65,16 @@ public interface EquPlanDetailMapper { * @return */ List selectEquPlanDetailByPlanCode(String planCode); + + /** + * 通过主计划code删除检查项详情 + * @param planCode + */ + void deleteEquPlanDetailByPlanCode(String planCode); + + /** + * 逻辑删除 + * @param planCode + */ + void delEquPlanDetailByPlanCode(String planCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanEquMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanEquMapper.java index 4d17bbec..7b498dca 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanEquMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanEquMapper.java @@ -65,4 +65,16 @@ public interface EquPlanEquMapper { * @return */ List selectEquPlanEquByPlanCode(String planCode); + + /** + * 通过主计划code删除设备信息 + * @param planCode + */ + void deleteEquPlanEquByPlanCode(String planCode); + + /** + * 逻辑删除 + * @param planCode + */ + void delEquPlanEquByPlanCode(String planCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanMapper.java index 79ecec5a..2eebf552 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanMapper.java @@ -83,4 +83,10 @@ public interface EquPlanMapper { * @return */ EquPlan selectEquPlanByPlanCode(String planCode); + + /** + * 逻辑删除 + * @param planCode + */ + void delEquPlanByPlanCode(String planCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanPersonMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanPersonMapper.java index b8d6fa5b..4229cb74 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanPersonMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanPersonMapper.java @@ -65,4 +65,16 @@ public interface EquPlanPersonMapper { * @return */ List selectEquPlanPersonByPlanCode(String planCode); + + /** + * 通过主计划code删除人员信息 + * @param planCode + */ + void deleteEquPlanPersonByPlanCode(String planCode); + + /** + * 逻辑删除 + * @param planCode + */ + void delEquPlanPersonByPlanCode(String planCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanStandardMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanStandardMapper.java index 9ca77828..561ba164 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanStandardMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquPlanStandardMapper.java @@ -65,4 +65,16 @@ public interface EquPlanStandardMapper { * @return */ List selectEquPlanStandardByPlanCode(String planCode); + + /** + * 通过主计划code删除标准信息 + * @param planCode + */ + void deleteEquPlanStandardByPlanCode(String planCode); + + /** + * 逻辑删除 + * @param planCode + */ + void delEquPlanStandardByPlanCode(String planCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/IEquPlanService.java b/op-modules/op-device/src/main/java/com/op/device/service/IEquPlanService.java index fdf66a66..6948032b 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/IEquPlanService.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/IEquPlanService.java @@ -46,7 +46,7 @@ public interface IEquPlanService { * @param equPlan 计划 * @return 结果 */ - public int updateEquPlan(EquPlan equPlan); + public AjaxResult updateEquPlan(EquPlan equPlan); /** * 批量删除计划 @@ -54,7 +54,7 @@ public interface IEquPlanService { * @param planIds 需要删除的计划主键集合 * @return 结果 */ - public int deleteEquPlanByPlanIds(String[] planIds); + public AjaxResult deleteEquPlanByPlanIds(String[] planIds); /** * 删除计划信息 diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquPlanServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquPlanServiceImpl.java index 73364e12..a779aa4c 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquPlanServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquPlanServiceImpl.java @@ -121,113 +121,11 @@ public class EquPlanServiceImpl implements IEquPlanService { equPlan.setUpdateBy(SecurityContextHolder.getUserName()); equPlan.setUpdateTime(DateUtils.getNowDate()); - // 处理计划-巡检人员信息 - List personList = equPlan.getPersonList(); - - for (SysUser user : personList) { - EquPlanPerson equPlanPerson = new EquPlanPerson(); - - equPlanPerson.setId(IdUtils.fastSimpleUUID()); - equPlanPerson.setUserId(user.getUserId()); - equPlanPerson.setPlanCode(equPlan.getPlanCode()); - equPlanPerson.setFactoryCode(factory); - equPlanPerson.setCreateBy(SecurityContextHolder.getUserName()); - equPlanPerson.setCreateTime(DateUtils.getNowDate()); - equPlanPerson.setUpdateBy(SecurityContextHolder.getUserName()); - equPlanPerson.setUpdateTime(DateUtils.getNowDate()); - - equPlanPersonMapper.insertEquPlanPerson(equPlanPerson); - System.out.println("人员信息插入数据库成功"); - } - - // 处理计划1-n设备信息 - List equipmentItemList = equPlan.getEquipmentItem(); - - // 计划-设备流水号 - int equipmentCodeTemp = 0; - - for (EquPlanEqu equipment : equipmentItemList) { - equipment.setId(IdUtils.fastSimpleUUID()); - equipment.setPlanCode(equPlan.getPlanCode()); - equipment.setCode("E" + equPlan.getPlanCode() + String.format("%02d", ++equipmentCodeTemp)); - equipment.setParentCode(equPlan.getPlanCode()); - equipment.setFactoryCode(factory); - equipment.setCreateBy(SecurityContextHolder.getUserName()); - equipment.setCreateTime(DateUtils.getNowDate()); - equipment.setUpdateBy(SecurityContextHolder.getUserName()); - equipment.setUpdateTime(DateUtils.getNowDate()); - - // 处理检查项信息 - List equCheckItemList = equipment.getEquCheckItemList(); - - // 计划检查项流水号 - int itemCodeTemp = 0; - - for (EquCheckItem item : equCheckItemList) { - - EquPlanDetail planDetail = new EquPlanDetail(); - BeanUtils.copyProperties(item, planDetail); - - planDetail.setId(IdUtils.fastSimpleUUID()); - planDetail.setPlanCode(equPlan.getPlanCode()); - planDetail.setCode("C" + equPlan.getPlanCode() + String.format("%02d", ++itemCodeTemp)); - planDetail.setParentCode(equipment.getCode()); - planDetail.setCreateBy(SecurityContextHolder.getUserName()); - planDetail.setCreateTime(DateUtils.getNowDate()); - planDetail.setUpdateBy(SecurityContextHolder.getUserName()); - planDetail.setUpdateTime(DateUtils.getNowDate()); - - // 处理标准 - List equCheckItemDetailList = item.getEquCheckItemDetailList(); - - // 检查项详情流水号 - int detailCodeTemp = 0; - - // 判断是否插入检查项 - boolean checkInsert = false; - - for (EquCheckItemDetail detail : equCheckItemDetailList) { - - if (detail.getShowFlag()) { - - checkInsert = true; - - EquPlanStandard planStandard = new EquPlanStandard(); - BeanUtils.copyProperties(detail, planStandard); - - planStandard.setId(IdUtils.fastSimpleUUID()); - planStandard.setParentCode(planDetail.getCode()); - planStandard.setPlanCode(equPlan.getPlanCode()); - planStandard.setCode("D" + equPlan.getPlanCode() + String.format("%02d", ++detailCodeTemp)); - planStandard.setCreateBy(SecurityContextHolder.getUserName()); - planStandard.setCreateTime(DateUtils.getNowDate()); - planStandard.setUpdateBy(SecurityContextHolder.getUserName()); - planStandard.setUpdateTime(DateUtils.getNowDate()); - - // 详情插入数据库 - equPlanStandardMapper.insertEquPlanStandard(planStandard); - System.out.println("检查项详情插入数据库成功"); - } - - } - - // 检查项详情为空则不生成检查项信息-检查项插入数据库 - if (checkInsert) { - equPlanDetailMapper.insertEquPlanDetail(planDetail); - System.out.println("检查项插入数据库成功"); - } - - } - - // 设备插入数据库 - equPlanEquMapper.insertEquPlanEqu(equipment); - System.out.println("设备信息插入数据库成功"); - - } + // 插入设备、人员、检查项、标准信息 + insertCommonInfo(equPlan, factory); // 主计划插入数据库 equPlanMapper.insertEquPlan(equPlan); - System.out.println("巡检主计划插入数据库成功"); return success(); } @@ -240,9 +138,28 @@ public class EquPlanServiceImpl implements IEquPlanService { */ @Override @DS("#header.poolName") - public int updateEquPlan(EquPlan equPlan) { - equPlan.setUpdateTime(DateUtils.getNowDate()); - return equPlanMapper.updateEquPlan(equPlan); + public AjaxResult updateEquPlan(EquPlan equPlan) { + // 更新巡检计划 + equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0)); + equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1)); + equPlanMapper.updateEquPlan(equPlan); + // 删除该计划下设备、人员、检查项、标准 + equPlanPersonMapper.deleteEquPlanPersonByPlanCode(equPlan.getPlanCode()); + equPlanDetailMapper.deleteEquPlanDetailByPlanCode(equPlan.getPlanCode()); + equPlanEquMapper.deleteEquPlanEquByPlanCode(equPlan.getPlanCode()); + equPlanStandardMapper.deleteEquPlanStandardByPlanCode(equPlan.getPlanCode()); + + //获取当前所选工厂 + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String key = "#header.poolName"; + String str = request.getHeader(key.substring(8)); + int index = str.indexOf("_"); + String factory = str.substring(index + 1); + + // 插入设备、人员、检查项、标准信息 + insertCommonInfo(equPlan, factory); + + return success(); } /** @@ -253,8 +170,17 @@ public class EquPlanServiceImpl implements IEquPlanService { */ @Override @DS("#header.poolName") - public int deleteEquPlanByPlanIds(String[] planIds) { - return equPlanMapper.deleteEquPlanByPlanIds(planIds); + public AjaxResult deleteEquPlanByPlanIds(String[] planIds) { + // 逻辑删除信息 + for (String id : planIds) { + EquPlan equPlan = equPlanMapper.selectEquPlanByPlanId(id); + equPlanMapper.delEquPlanByPlanCode(equPlan.getPlanCode()); + equPlanPersonMapper.delEquPlanPersonByPlanCode(equPlan.getPlanCode()); + equPlanDetailMapper.delEquPlanDetailByPlanCode(equPlan.getPlanCode()); + equPlanEquMapper.delEquPlanEquByPlanCode(equPlan.getPlanCode()); + equPlanStandardMapper.delEquPlanStandardByPlanCode(equPlan.getPlanCode()); + } + return success(); } /** @@ -266,7 +192,7 @@ public class EquPlanServiceImpl implements IEquPlanService { @Override @DS("#header.poolName") public int deleteEquPlanByPlanId(String planId) { - return equPlanMapper.deleteEquPlanByPlanId(planId); + return 1; } /** @@ -332,6 +258,7 @@ public class EquPlanServiceImpl implements IEquPlanService { /** * 获取工作中心 + * * @return */ @Override @@ -350,6 +277,7 @@ public class EquPlanServiceImpl implements IEquPlanService { /** * 修改计划初始化信息 + * * @param equPlan * @return */ @@ -404,4 +332,117 @@ public class EquPlanServiceImpl implements IEquPlanService { return success(plan); } + + /** + * 插入设备、人员、检查项、标准 + * + * @param equPlan + * @param factory + */ + private void insertCommonInfo(EquPlan equPlan, String factory) { + + // 处理计划-巡检人员信息 + List personList = equPlan.getPersonList(); + + for (SysUser user : personList) { + EquPlanPerson equPlanPerson = new EquPlanPerson(); + + equPlanPerson.setId(IdUtils.fastSimpleUUID()); + equPlanPerson.setUserId(user.getUserId()); + equPlanPerson.setPlanCode(equPlan.getPlanCode()); + equPlanPerson.setFactoryCode(factory); + equPlanPerson.setCreateBy(SecurityContextHolder.getUserName()); + equPlanPerson.setCreateTime(DateUtils.getNowDate()); + equPlanPerson.setUpdateBy(SecurityContextHolder.getUserName()); + equPlanPerson.setUpdateTime(DateUtils.getNowDate()); + + equPlanPersonMapper.insertEquPlanPerson(equPlanPerson); + } + + // 处理计划1-n设备信息 + List equipmentItemList = equPlan.getEquipmentItem(); + + // 计划-设备流水号 + int equipmentCodeTemp = 0; + + for (EquPlanEqu equipment : equipmentItemList) { + equipment.setId(IdUtils.fastSimpleUUID()); + equipment.setPlanCode(equPlan.getPlanCode()); + equipment.setCode("E" + equPlan.getPlanCode() + String.format("%02d", ++equipmentCodeTemp)); + equipment.setParentCode(equPlan.getPlanCode()); + equipment.setFactoryCode(factory); + equipment.setCreateBy(SecurityContextHolder.getUserName()); + equipment.setCreateTime(DateUtils.getNowDate()); + equipment.setUpdateBy(SecurityContextHolder.getUserName()); + equipment.setUpdateTime(DateUtils.getNowDate()); + + // 处理检查项信息 + List equCheckItemList = equipment.getEquCheckItemList(); + if (equCheckItemList != null) { + // 计划检查项流水号 + int itemCodeTemp = 0; + + for (EquCheckItem item : equCheckItemList) { + + if (item != null) { + EquPlanDetail planDetail = new EquPlanDetail(); + BeanUtils.copyProperties(item, planDetail); + + planDetail.setId(IdUtils.fastSimpleUUID()); + planDetail.setPlanCode(equPlan.getPlanCode()); + planDetail.setCode("C" + equPlan.getPlanCode() + String.format("%02d", ++itemCodeTemp)); + planDetail.setParentCode(equipment.getCode()); + planDetail.setCreateBy(SecurityContextHolder.getUserName()); + planDetail.setCreateTime(DateUtils.getNowDate()); + planDetail.setUpdateBy(SecurityContextHolder.getUserName()); + planDetail.setUpdateTime(DateUtils.getNowDate()); + + // 处理标准 + List equCheckItemDetailList = item.getEquCheckItemDetailList(); + + // 检查项详情流水号 + int detailCodeTemp = 0; + + // 判断是否插入检查项 + boolean checkInsert = false; + + for (EquCheckItemDetail detail : equCheckItemDetailList) { + + if (detail.getShowFlag()) { + + checkInsert = true; + + EquPlanStandard planStandard = new EquPlanStandard(); + BeanUtils.copyProperties(detail, planStandard); + + planStandard.setId(IdUtils.fastSimpleUUID()); + planStandard.setParentCode(planDetail.getCode()); + planStandard.setPlanCode(equPlan.getPlanCode()); + planStandard.setCode("D" + equPlan.getPlanCode() + String.format("%02d", ++detailCodeTemp)); + planStandard.setCreateBy(SecurityContextHolder.getUserName()); + planStandard.setCreateTime(DateUtils.getNowDate()); + planStandard.setUpdateBy(SecurityContextHolder.getUserName()); + planStandard.setUpdateTime(DateUtils.getNowDate()); + + // 详情插入数据库 + equPlanStandardMapper.insertEquPlanStandard(planStandard); + } + + } + + // 检查项详情为空则不生成检查项信息-检查项插入数据库 + if (checkInsert) { + equPlanDetailMapper.insertEquPlanDetail(planDetail); + } + } + + } + + // 设备插入数据库 + equPlanEquMapper.insertEquPlanEqu(equipment); + } + + } + + } } diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquPlanDetailMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquPlanDetailMapper.xml index 9d8c83a0..15ffb1eb 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquPlanDetailMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquPlanDetailMapper.xml @@ -145,4 +145,12 @@ #{id} + + + delete from equ_plan_detail where plan_code = #{planCode} + + + + update equ_plan_detail set del_flag = '1' where plan_code = #{planCode} + \ No newline at end of file diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquPlanEquMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquPlanEquMapper.xml index 0afd147d..8813f53e 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquPlanEquMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquPlanEquMapper.xml @@ -120,4 +120,12 @@ #{id} + + + delete from equ_plan_equ where plan_code = #{planCode} + + + + update equ_plan_equ set del_flag = '1' where plan_code = #{planCode} + \ No newline at end of file diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquPlanMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquPlanMapper.xml index 47ccc983..062eebd7 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquPlanMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquPlanMapper.xml @@ -67,12 +67,13 @@ and CONVERT(date,update_time) >= #{updateTimeStart} and #{updateTimeEnd} >= CONVERT(date,update_time) and update_by like concat('%', #{updateBy}, '%') + and del_flag = '0'