|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
package com.op.device.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
@ -54,7 +53,6 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
private EquPlanEquMapper equPlanEquMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquPlanEquSpareMapper equPlanEquSpareMapper;
|
|
|
|
|
// 备件mapper
|
|
|
|
|
@Autowired
|
|
|
|
|
private SparePartsLedgerMapper sparePartsLedgerMapper;
|
|
|
|
|
|
|
|
|
@ -79,6 +77,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<EquPlan> selectEquPlanList(EquPlan equPlan) {
|
|
|
|
|
// 创建时间列表不为空
|
|
|
|
|
if (equPlan.getCreateTimeArray() != null) {
|
|
|
|
|
// 设置创建日期开始和结束值
|
|
|
|
|
if (equPlan.getCreateTimeArray().size() == 2) {
|
|
|
|
@ -87,6 +86,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
equPlan.setCreateTimeEnd(formatter.format(equPlan.getCreateTimeArray().get(1)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 更新时间列表不为空
|
|
|
|
|
if (equPlan.getUpdateTimeArray() != null) {
|
|
|
|
|
// 设置更新日期开始和结束
|
|
|
|
|
if (equPlan.getUpdateTimeArray().size() == 2) {
|
|
|
|
@ -95,30 +95,28 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
equPlan.setUpdateTimeEnd(formatter.format(equPlan.getUpdateTimeArray().get(1)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 循环开始时间列表不为空
|
|
|
|
|
if (equPlan.getLoopStartArray() != null) {
|
|
|
|
|
equPlan.setLoopStart(equPlan.getLoopStartArray().get(0));
|
|
|
|
|
equPlan.setLoopEnd(equPlan.getLoopStartArray().get(1));
|
|
|
|
|
}
|
|
|
|
|
// 循环结束时间列表不为空
|
|
|
|
|
if (equPlan.getLoopEndArray() != null) {
|
|
|
|
|
equPlan.setLoopEndArrayStart(equPlan.getLoopEndArray().get(0));
|
|
|
|
|
equPlan.setGetLoopEndArrayEnd(equPlan.getLoopEndArray().get(1));
|
|
|
|
|
}
|
|
|
|
|
// 查询计划信息列表
|
|
|
|
|
List<EquPlan> equPlans = equPlanMapper.selectEquPlanList(equPlan);
|
|
|
|
|
|
|
|
|
|
//获取当前所选工厂
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
List<WorkCenter> workCenters = equPlanMapper.selectWorkCenter(factory);
|
|
|
|
|
|
|
|
|
|
// 获取工作中心
|
|
|
|
|
List<WorkCenter> workCenters = getWorkCenterCommon();
|
|
|
|
|
|
|
|
|
|
// 处理计划信息
|
|
|
|
|
for (EquPlan plan : equPlans) {
|
|
|
|
|
for (WorkCenter center : workCenters) {
|
|
|
|
|
// 工作中心(车间)一致
|
|
|
|
|
if (plan.getPlanWorkshop().equals(center.getFactoryCode())) {
|
|
|
|
|
plan.setWorkCenterName(center.getFactoryName());
|
|
|
|
|
plan.setWorkCenterName(center.getFactoryName());// 置入工作中心名称
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -135,7 +133,6 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult insertEquPlan(EquPlan equPlan) {
|
|
|
|
|
// 处理计划信息
|
|
|
|
|
// 获取计划流水号
|
|
|
|
|
String planSerialNum = String.format("%03d", equPlanMapper.selectSerialNumber());
|
|
|
|
|
|
|
|
|
@ -146,13 +143,13 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
int index = str.indexOf("_");
|
|
|
|
|
String factory = str.substring(index + 1);
|
|
|
|
|
|
|
|
|
|
equPlan.setPlanId(IdUtils.fastSimpleUUID());
|
|
|
|
|
equPlan.setPlanCode((DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + planSerialNum));
|
|
|
|
|
equPlan.setPlanId(IdUtils.fastSimpleUUID());// 计划id
|
|
|
|
|
equPlan.setPlanCode((DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + planSerialNum));// 计划编码
|
|
|
|
|
if (equPlan.getPlanTimeArray().size() > 0) {
|
|
|
|
|
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
|
|
|
|
|
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
|
|
|
|
|
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));// 计划循环周期开始时间
|
|
|
|
|
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));// 计划循环周期结束时间
|
|
|
|
|
}
|
|
|
|
|
equPlan.setFactoryCode(factory);
|
|
|
|
|
equPlan.setFactoryCode(factory);// 工厂编码
|
|
|
|
|
equPlan.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
equPlan.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
equPlan.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
@ -176,17 +173,21 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult updateEquPlan(EquPlan equPlan) {
|
|
|
|
|
// 更新巡检计划
|
|
|
|
|
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
|
|
|
|
|
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
|
|
|
|
|
// 设置循环范围时间
|
|
|
|
|
if (equPlan.getPlanTimeArray().size() != 0) {
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
//获取当前所选工厂
|
|
|
|
|
// 删除该计划下设备、人员、检查项、标准、备件
|
|
|
|
|
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));
|
|
|
|
@ -211,13 +212,12 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
// 逻辑删除信息
|
|
|
|
|
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());
|
|
|
|
|
// TODO 有问题没有删除成功
|
|
|
|
|
equPlanEquSpareMapper.delEquPlanEquSpareByPlanCode(equPlan.getPlanCode());
|
|
|
|
|
equPlanMapper.delEquPlanByPlanCode(equPlan.getPlanCode());// 计划
|
|
|
|
|
equPlanPersonMapper.delEquPlanPersonByPlanCode(equPlan.getPlanCode());// 人员
|
|
|
|
|
equPlanDetailMapper.delEquPlanDetailByPlanCode(equPlan.getPlanCode());// 检查项
|
|
|
|
|
equPlanEquMapper.delEquPlanEquByPlanCode(equPlan.getPlanCode());// 设备
|
|
|
|
|
equPlanStandardMapper.delEquPlanStandardByPlanCode(equPlan.getPlanCode());// 标准
|
|
|
|
|
equPlanEquSpareMapper.delEquPlanEquSpareByPlanCode(equPlan.getPlanCode());// TODO 备件(没有删除成功?)
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
@ -255,46 +255,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
@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(),"inspection");
|
|
|
|
|
if (equCheckItemList.size() > 0) {
|
|
|
|
|
List<EquPlanDetail> detailList = new ArrayList<>();
|
|
|
|
|
for (EquCheckItem checkItem : equCheckItemList) {
|
|
|
|
|
// 只需要循环周期一致的检查项
|
|
|
|
|
if(checkItem.getItemLoop() == data.getItemLoop() && checkItem.getItemLoopType().equals(data.getItemLoopType())) {
|
|
|
|
|
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);
|
|
|
|
|
return formatEquItemCommon(equPlanEquList, "inspection", "存在未设置巡检项!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -317,14 +278,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult getWorkCenter() {
|
|
|
|
|
//获取当前所选工厂
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
return success(equPlanMapper.selectWorkCenter(factory));
|
|
|
|
|
return success(getWorkCenterCommon());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -337,9 +291,9 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult initUpdatePlanInfo(EquPlan equPlan) {
|
|
|
|
|
|
|
|
|
|
// 获取计划信息
|
|
|
|
|
// 通过计划编码获取计划信息
|
|
|
|
|
EquPlan plan = equPlanMapper.selectEquPlanByPlanCode(equPlan.getPlanCode());
|
|
|
|
|
// 处理计划信息
|
|
|
|
|
// 处理计划循环时间信息(用于前端)
|
|
|
|
|
List<Date> planTimeArray = new ArrayList<>();
|
|
|
|
|
if (plan.getPlanLoopStart() != null) {
|
|
|
|
|
planTimeArray.add(plan.getPlanLoopStart());
|
|
|
|
@ -348,138 +302,146 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取人员信息
|
|
|
|
|
// 通过计划编码获取人员信息列表
|
|
|
|
|
List<EquPlanPerson> personList = equPlanPersonMapper.selectEquPlanPersonByPlanCode(equPlan.getPlanCode());
|
|
|
|
|
|
|
|
|
|
// 处理人员信息列表信息用于前端穿梭框信息回填
|
|
|
|
|
List<Long> persons = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (EquPlanPerson person : personList) {
|
|
|
|
|
persons.add(person.getUserId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取设备信息
|
|
|
|
|
// 通过计划编码获取设备信息列表
|
|
|
|
|
List<EquPlanEqu> equipmentList = equPlanEquMapper.selectEquPlanEquByPlanCode(equPlan.getPlanCode());
|
|
|
|
|
|
|
|
|
|
// 处理设备信息
|
|
|
|
|
for (EquPlanEqu equipment : equipmentList) {
|
|
|
|
|
// 获取检查项list
|
|
|
|
|
// 通过设备表id获取检查项列表
|
|
|
|
|
List<EquPlanDetail> detailList = equPlanDetailMapper.selectEquPlanDetailListByParentCode(equipment.getId());
|
|
|
|
|
for (EquPlanDetail detail : detailList) {
|
|
|
|
|
// 获取标准list
|
|
|
|
|
// 通过检查项id获取标准信息列表
|
|
|
|
|
List<EquPlanStandard> standardList = equPlanStandardMapper.selectEquPlanStandardListByParentCode(detail.getId());
|
|
|
|
|
// 处理标准信息
|
|
|
|
|
for (EquPlanStandard standard : standardList) {
|
|
|
|
|
standard.setShowFlag(true);
|
|
|
|
|
standard.setItemLoop(detail.getItemLoop());
|
|
|
|
|
standard.setItemLoopType(detail.getItemLoopType());
|
|
|
|
|
standard.setShowFlag(true);// 设置默认值(用于前端)
|
|
|
|
|
standard.setItemLoop(detail.getItemLoop());// 设置循环周期(用于前端)
|
|
|
|
|
standard.setItemLoopType(detail.getItemLoopType());// 设置循环周期类型(用于前端)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 置入标准
|
|
|
|
|
// 将处理好的标准列表置入检查项
|
|
|
|
|
detail.setEquPlanStandardList(standardList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 置入检查项
|
|
|
|
|
// 将处理好的检查项列表置入设备
|
|
|
|
|
equipment.setEquPlanDetailList(detailList);
|
|
|
|
|
|
|
|
|
|
EquPlanEquSpare spare = new EquPlanEquSpare();
|
|
|
|
|
spare.setParentCode(equipment.getId());
|
|
|
|
|
// 备件信息
|
|
|
|
|
List<EquPlanEquSpare> spareList = equPlanEquSpareMapper.selectEquPlanEquSpareList(spare);
|
|
|
|
|
// 创建备件搜索临时对象
|
|
|
|
|
EquPlanEquSpare spareSelectTemp = new EquPlanEquSpare();
|
|
|
|
|
spareSelectTemp.setParentCode(equipment.getId());// 设置parentCode(设备表id)
|
|
|
|
|
// 通过临时搜索对象查询备件信息列表
|
|
|
|
|
List<EquPlanEquSpare> spareList = equPlanEquSpareMapper.selectEquPlanEquSpareList(spareSelectTemp);
|
|
|
|
|
if (spareList.size() > 0) {
|
|
|
|
|
// 处理备件信息
|
|
|
|
|
for (EquPlanEquSpare equSpare : spareList) {
|
|
|
|
|
// 通过备件编码查询备件库存信息(总量-冻结)
|
|
|
|
|
equSpare.setAmount(sparePartsLedgerMapper.selectRealAmountByMaterialCode(equSpare.getMaterialCode()));
|
|
|
|
|
// 通过备件编码查询备件库存、冻结数量信息信息
|
|
|
|
|
EquPlanEquSpare spareTemp = sparePartsLedgerMapper.selectRealAmountByMaterialCode(equSpare.getMaterialCode());
|
|
|
|
|
equSpare.setAmount(spareTemp.getAmount());// 设置库存数量信息
|
|
|
|
|
equSpare.setStorageAmount(spareTemp.getStorageAmount());// 设置冻结数量信息
|
|
|
|
|
}
|
|
|
|
|
// 将处理好的备件信息列表置入设备
|
|
|
|
|
equipment.setSpareList(spareList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将处理好的设备信息列表置入计划
|
|
|
|
|
plan.setEquipmentItem(equipmentList);
|
|
|
|
|
// 将处理好的人员信息列表置入计划
|
|
|
|
|
plan.setPersonListVO(persons);
|
|
|
|
|
|
|
|
|
|
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.setId(IdUtils.fastSimpleUUID());// id
|
|
|
|
|
equPlanPerson.setUserId(user.getUserId());// 用户id
|
|
|
|
|
equPlanPerson.setPlanCode(equPlan.getPlanCode());// 计划编码
|
|
|
|
|
equPlanPerson.setFactoryCode(factory);// 工厂code
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
// 处理设备信息
|
|
|
|
|
for (EquPlanEqu equipment : equipmentItemList) {
|
|
|
|
|
equipment.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
equipment.setPlanCode(equPlan.getPlanCode());
|
|
|
|
|
equipment.setParentCode(equPlan.getPlanId());
|
|
|
|
|
equipment.setFactoryCode(factory);
|
|
|
|
|
equipment.setId(IdUtils.fastSimpleUUID());// id
|
|
|
|
|
equipment.setPlanCode(equPlan.getPlanCode());// 计划编码
|
|
|
|
|
equipment.setParentCode(equPlan.getPlanId());// 计划id
|
|
|
|
|
equipment.setFactoryCode(factory);// 工厂
|
|
|
|
|
equipment.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
equipment.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
equipment.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
equipment.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 处理检查项信息
|
|
|
|
|
// 获取检查项信息列表
|
|
|
|
|
List<EquPlanDetail> detailList = equipment.getEquPlanDetailList();
|
|
|
|
|
// 处理检查项信息
|
|
|
|
|
if (detailList != null) {
|
|
|
|
|
|
|
|
|
|
for (EquPlanDetail item : detailList) {
|
|
|
|
|
|
|
|
|
|
if (item != null) {
|
|
|
|
|
item.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
item.setPlanCode(equPlan.getPlanCode());
|
|
|
|
|
item.setParentCode(equipment.getId());
|
|
|
|
|
item.setId(IdUtils.fastSimpleUUID());// id
|
|
|
|
|
item.setPlanCode(equPlan.getPlanCode());// 计划编码
|
|
|
|
|
item.setParentCode(equipment.getId());// 设备表id
|
|
|
|
|
item.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
item.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
item.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
item.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 处理标准
|
|
|
|
|
// 获取标准信息列表
|
|
|
|
|
List<EquPlanStandard> standardList = item.getEquPlanStandardList();
|
|
|
|
|
|
|
|
|
|
// 判断是否插入检查项
|
|
|
|
|
boolean checkInsert = false;
|
|
|
|
|
|
|
|
|
|
for (EquPlanStandard standard : standardList) {
|
|
|
|
|
|
|
|
|
|
if (standard.getShowFlag()) {
|
|
|
|
|
|
|
|
|
|
checkInsert = true;
|
|
|
|
|
|
|
|
|
|
standard.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
standard.setParentCode(item.getId());
|
|
|
|
|
standard.setPlanCode(equPlan.getPlanCode());
|
|
|
|
|
checkInsert = true;// 只要存在标准信息,则checkInsert设置为true
|
|
|
|
|
standard.setId(IdUtils.fastSimpleUUID());// id
|
|
|
|
|
standard.setParentCode(item.getId());// 检查项id
|
|
|
|
|
standard.setPlanCode(equPlan.getPlanCode());// 计划编码
|
|
|
|
|
standard.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
standard.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
standard.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
standard.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 详情插入数据库
|
|
|
|
|
// 标准信息插入数据库(可优化)
|
|
|
|
|
equPlanStandardMapper.insertEquPlanStandard(standard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查项详情为空则不生成检查项信息-检查项插入数据库
|
|
|
|
|
// 存在标准信息则该检查项插入数据库
|
|
|
|
|
if (checkInsert) {
|
|
|
|
|
equPlanDetailMapper.insertEquPlanDetail(item);
|
|
|
|
|
}
|
|
|
|
@ -487,11 +449,111 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设备插入数据库
|
|
|
|
|
// 设备信息插入数据库(可优化)
|
|
|
|
|
equPlanEquMapper.insertEquPlanEqu(equipment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保养逻辑-备件信息处理
|
|
|
|
|
if (equPlan.getPlanType().equals("maintenance")) {
|
|
|
|
|
// 获取备件信息列表
|
|
|
|
|
List<EquPlanEquSpare> spareList = equipment.getSpareList();
|
|
|
|
|
if (spareList != null) {
|
|
|
|
|
for (EquPlanEquSpare spare : spareList) {
|
|
|
|
|
spare.setId(IdUtils.fastSimpleUUID());// id
|
|
|
|
|
spare.setPlanCode(equPlan.getPlanCode());// 计划编码
|
|
|
|
|
spare.setParentCode(equipment.getId());// 设备id
|
|
|
|
|
spare.setFactoryCode(factory);// 工厂
|
|
|
|
|
spare.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
spare.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
spare.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
spare.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 备件信息插入数据库(可优化)
|
|
|
|
|
equPlanEquSpareMapper.insertEquPlanEquSpare(spare);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理计划-设备信息公共方法
|
|
|
|
|
*
|
|
|
|
|
* @param equPlanEquList
|
|
|
|
|
* @param planType
|
|
|
|
|
* @param message
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private AjaxResult formatEquItemCommon(List<EquPlanEqu> equPlanEquList, String planType, String message) {
|
|
|
|
|
for (EquPlanEqu data : equPlanEquList) {
|
|
|
|
|
|
|
|
|
|
// 检查项名称临时对象
|
|
|
|
|
StringBuilder itemTempName = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
// 通过设备编码、计划类型,获取检查项信息列表
|
|
|
|
|
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(), planType);
|
|
|
|
|
if (equCheckItemList.size() > 0) {
|
|
|
|
|
// 创建检查项列表返回对象
|
|
|
|
|
List<EquPlanDetail> detailList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 处理检查项信息
|
|
|
|
|
for (EquCheckItem checkItem : equCheckItemList) {
|
|
|
|
|
// 获取循环周期一致的检查项
|
|
|
|
|
if (checkItem.getItemLoop() == data.getItemLoop() && checkItem.getItemLoopType().equals(data.getItemLoopType())) {
|
|
|
|
|
// 创建检查项返回对象
|
|
|
|
|
EquPlanDetail detail = new EquPlanDetail();
|
|
|
|
|
BeanUtils.copyProperties(checkItem, detail);
|
|
|
|
|
|
|
|
|
|
if (!detail.getItemCode().isEmpty()) {
|
|
|
|
|
// 累加检查项名称(前端信息回显)
|
|
|
|
|
itemTempName.append(detail.getItemName()).append(",");
|
|
|
|
|
// 通过检查项code获取标准信息列表
|
|
|
|
|
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, message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success(equPlanEquList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取工作中心列表公共方法
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<WorkCenter> getWorkCenterCommon() {
|
|
|
|
|
//获取当前所选工厂
|
|
|
|
|
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);
|
|
|
|
|
// 根据当前工厂获取该工厂下的所有工作中心
|
|
|
|
|
List<WorkCenter> workCenters = equPlanMapper.selectWorkCenter(factory);
|
|
|
|
|
return workCenters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|