|
|
|
@ -121,113 +121,11 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
equPlan.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
equPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 处理计划-巡检人员信息
|
|
|
|
|
List<SysUser> 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<EquPlanEqu> 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<EquCheckItem> 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<EquCheckItemDetail> 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<SysUser> 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<EquPlanEqu> 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<EquCheckItem> 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<EquCheckItemDetail> 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|