|
|
|
@ -16,6 +16,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static com.op.common.core.web.domain.AjaxResult.error;
|
|
|
|
@ -101,10 +102,147 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
|
|
|
|
|
// 主计划插入数据库
|
|
|
|
|
equPlanMapper.insertEquPlan(equPlan);
|
|
|
|
|
|
|
|
|
|
// 处理设备信息
|
|
|
|
|
insertCommonInfo(equPlan,factory);
|
|
|
|
|
|
|
|
|
|
return success(equPlan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改保养计划
|
|
|
|
|
*
|
|
|
|
|
* @param equPlan 保养计划
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
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());
|
|
|
|
|
equPlanEquSpareMapper.deleteEquPlanEquSpareByPlanCode(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("修改成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除保养计划
|
|
|
|
|
*
|
|
|
|
|
* @param planIds 需要删除的保养计划主键
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int deleteEquPlanByPlanIds(String[] planIds) {
|
|
|
|
|
return equPlanMapper.deleteEquPlanByPlanIds(planIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除保养计划信息
|
|
|
|
|
*
|
|
|
|
|
* @param planId 保养计划主键
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int deleteEquPlanByPlanId(String planId) {
|
|
|
|
|
return equPlanMapper.deleteEquPlanByPlanId(planId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理计划-设备信息
|
|
|
|
|
*
|
|
|
|
|
* @param equPlanEquList
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult formatEquItem(List<EquPlanEqu> equPlanEquList) {
|
|
|
|
|
for (EquPlanEqu data : equPlanEquList) {
|
|
|
|
|
|
|
|
|
|
StringBuilder itemTempName = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
// 获取检查项list
|
|
|
|
|
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(),"maintenance");
|
|
|
|
|
if (equCheckItemList.size() > 0) {
|
|
|
|
|
List<EquPlanDetail> detailList = new ArrayList<>();
|
|
|
|
|
for (EquCheckItem checkItem : equCheckItemList) {
|
|
|
|
|
EquPlanDetail detail = new EquPlanDetail();
|
|
|
|
|
BeanUtils.copyProperties(checkItem,detail);
|
|
|
|
|
|
|
|
|
|
if (!detail.getItemCode().isEmpty()) {
|
|
|
|
|
itemTempName.append(detail.getItemName()).append(",");
|
|
|
|
|
// 获取检查项详情list
|
|
|
|
|
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(detail.getItemCode());
|
|
|
|
|
if (equCheckItemList.size() > 0) {
|
|
|
|
|
List<EquPlanStandard> standardList = new ArrayList<>();
|
|
|
|
|
for (EquCheckItemDetail standardTemp : equCheckItemDetailList) {
|
|
|
|
|
EquPlanStandard standard = new EquPlanStandard();
|
|
|
|
|
BeanUtils.copyProperties(standardTemp,standard);
|
|
|
|
|
|
|
|
|
|
standard.setShowFlag(true);
|
|
|
|
|
standardList.add(standard);
|
|
|
|
|
}
|
|
|
|
|
detail.setEquPlanStandardList(standardList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
detailList.add(detail);
|
|
|
|
|
}
|
|
|
|
|
data.setEquPlanDetailList(detailList);
|
|
|
|
|
data.setItemTempName(itemTempName.toString());
|
|
|
|
|
}else {
|
|
|
|
|
return error(500,"存在设备未设置保养项!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success(equPlanEquList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO 修改未改动:(有问题)插入设备、人员、检查项、标准、备件
|
|
|
|
|
*
|
|
|
|
|
* @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());
|
|
|
|
@ -117,28 +255,25 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
|
|
|
|
|
equipment.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 处理检查项信息
|
|
|
|
|
List<EquCheckItem> equCheckItemList = equipment.getEquCheckItemList();
|
|
|
|
|
if (equCheckItemList != null) {
|
|
|
|
|
List<EquPlanDetail> detailList = equipment.getEquPlanDetailList();
|
|
|
|
|
if (detailList != null) {
|
|
|
|
|
// 计划检查项流水号
|
|
|
|
|
int itemCodeTemp = 0;
|
|
|
|
|
|
|
|
|
|
for (EquCheckItem item : equCheckItemList) {
|
|
|
|
|
for (EquPlanDetail item : detailList) {
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
item.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
item.setPlanCode(equPlan.getPlanCode());
|
|
|
|
|
item.setCode("C" + equPlan.getPlanCode() + String.format("%02d", ++itemCodeTemp));
|
|
|
|
|
item.setParentCode(equipment.getCode());
|
|
|
|
|
item.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
item.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
item.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
item.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 处理标准
|
|
|
|
|
List<EquCheckItemDetail> equCheckItemDetailList = item.getEquCheckItemDetailList();
|
|
|
|
|
List<EquPlanStandard> standardList = item.getEquPlanStandardList();
|
|
|
|
|
|
|
|
|
|
// 检查项详情流水号
|
|
|
|
|
int detailCodeTemp = 0;
|
|
|
|
@ -146,33 +281,30 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
|
|
|
|
|
// 判断是否插入检查项
|
|
|
|
|
boolean checkInsert = false;
|
|
|
|
|
|
|
|
|
|
for (EquCheckItemDetail detail : equCheckItemDetailList) {
|
|
|
|
|
for (EquPlanStandard standard : standardList) {
|
|
|
|
|
|
|
|
|
|
if (detail.getShowFlag()) {
|
|
|
|
|
if (standard.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());
|
|
|
|
|
standard.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
standard.setParentCode(item.getCode());
|
|
|
|
|
standard.setPlanCode(equPlan.getPlanCode());
|
|
|
|
|
standard.setCode("D" + equPlan.getPlanCode() + String.format("%02d", ++detailCodeTemp));
|
|
|
|
|
standard.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
standard.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
standard.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
standard.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 详情插入数据库
|
|
|
|
|
equPlanStandardMapper.insertEquPlanStandard(planStandard);
|
|
|
|
|
equPlanStandardMapper.insertEquPlanStandard(standard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查项详情为空则不生成检查项信息-检查项插入数据库
|
|
|
|
|
if (checkInsert) {
|
|
|
|
|
equPlanDetailMapper.insertEquPlanDetail(planDetail);
|
|
|
|
|
equPlanDetailMapper.insertEquPlanDetail(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -189,9 +321,9 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
|
|
|
|
|
if (spareList != null) {
|
|
|
|
|
for (EquPlanEquSpare spare : spareList) {
|
|
|
|
|
spare.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
spare.setCode("S" + equPlan.getPlanCode() + String.format("%02d", ++equipmentCodeTemp));
|
|
|
|
|
spare.setCode("S" + equPlan.getPlanCode() + String.format("%02d", ++spareCodeTemp));
|
|
|
|
|
spare.setPlanCode(equPlan.getPlanCode());
|
|
|
|
|
spare.setParentCode(equPlan.getPlanCode());
|
|
|
|
|
spare.setParentCode(equipment.getCode());
|
|
|
|
|
spare.setFactoryCode(factory);
|
|
|
|
|
spare.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
spare.setCreateTime(DateUtils.getNowDate());
|
|
|
|
@ -201,99 +333,8 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
|
|
|
|
|
equPlanEquSpareMapper.insertEquPlanEquSpare(spare);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 处理人员信息
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success(equPlan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改保养计划
|
|
|
|
|
*
|
|
|
|
|
* @param equPlan 保养计划
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int updateEquPlan(EquPlan equPlan) {
|
|
|
|
|
equPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
return equPlanMapper.updateEquPlan(equPlan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除保养计划
|
|
|
|
|
*
|
|
|
|
|
* @param planIds 需要删除的保养计划主键
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int deleteEquPlanByPlanIds(String[] planIds) {
|
|
|
|
|
return equPlanMapper.deleteEquPlanByPlanIds(planIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除保养计划信息
|
|
|
|
|
*
|
|
|
|
|
* @param planId 保养计划主键
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int deleteEquPlanByPlanId(String planId) {
|
|
|
|
|
return equPlanMapper.deleteEquPlanByPlanId(planId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理计划-设备信息
|
|
|
|
|
*
|
|
|
|
|
* @param equPlanEquList
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult formatEquItem(List<EquPlanEqu> equPlanEquList) {
|
|
|
|
|
for (EquPlanEqu data : equPlanEquList) {
|
|
|
|
|
|
|
|
|
|
StringBuilder itemTempName = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
// 获取检查项list
|
|
|
|
|
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(),"maintenance");
|
|
|
|
|
if (equCheckItemList.size() > 0) {
|
|
|
|
|
for (EquCheckItem checkItem : equCheckItemList) {
|
|
|
|
|
if (!checkItem.getItemCode().isEmpty()) {
|
|
|
|
|
itemTempName.append(checkItem.getItemName()).append(",");
|
|
|
|
|
// 获取检查项详情list
|
|
|
|
|
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(checkItem.getItemCode());
|
|
|
|
|
if (equCheckItemList.size() > 0) {
|
|
|
|
|
for (EquCheckItemDetail detail : equCheckItemDetailList) {
|
|
|
|
|
detail.setShowFlag(true);
|
|
|
|
|
}
|
|
|
|
|
checkItem.setEquCheckItemDetailList(equCheckItemDetailList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
data.setEquCheckItemList(equCheckItemList);
|
|
|
|
|
data.setItemTempName(itemTempName.toString());
|
|
|
|
|
}else {
|
|
|
|
|
return error(500,"存在设备未设置保养项!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success(equPlanEquList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|