保养计划-修改

highway
wws 1 year ago
parent c7e42f4045
commit 86a39d613c

@ -95,7 +95,7 @@ public class EquUpkeepController extends BaseController {
@Log(title = "保养计划", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EquPlan equPlan) {
return toAjax(equUpkeepService.updateEquPlan(equPlan));
return equUpkeepService.updateEquPlan(equPlan);
}
/**

@ -76,6 +76,16 @@ public class EquPlanStandard extends BaseEntity {
private String standardTypeName;
private Boolean showFlag;
public Boolean getShowFlag() {
return showFlag;
}
public void setShowFlag(Boolean showFlag) {
this.showFlag = showFlag;
}
public String getStandardTypeName() {
return standardTypeName;
}

@ -58,4 +58,10 @@ public interface EquPlanEquSpareMapper {
* @return
*/
public int deleteEquPlanEquSpareByIds(String[] ids);
/**
*
* @param planCode
*/
void deleteEquPlanEquSpareByPlanCode(String planCode);
}

@ -44,7 +44,7 @@ public interface IEquUpkeepService {
* @param equPlan
* @return
*/
public int updateEquPlan(EquPlan equPlan);
public AjaxResult updateEquPlan(EquPlan equPlan);
/**
*

@ -51,6 +51,8 @@ public class EquPlanServiceImpl implements IEquPlanService {
private EquPlanDetailMapper equPlanDetailMapper;
@Autowired
private EquPlanEquMapper equPlanEquMapper;
@Autowired
private EquPlanEquSpareMapper equPlanEquSpareMapper;
/**
*
@ -244,20 +246,30 @@ public class EquPlanServiceImpl implements IEquPlanService {
// 获取检查项list
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(),"inspection");
if (equCheckItemList.size() > 0) {
List<EquPlanDetail> detailList = new ArrayList<>();
for (EquCheckItem checkItem : equCheckItemList) {
if (!checkItem.getItemCode().isEmpty()) {
itemTempName.append(checkItem.getItemName()).append(",");
EquPlanDetail detail = new EquPlanDetail();
BeanUtils.copyProperties(checkItem,detail);
if (!detail.getItemCode().isEmpty()) {
itemTempName.append(detail.getItemName()).append(",");
// 获取检查项详情list
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(checkItem.getItemCode());
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(detail.getItemCode());
if (equCheckItemList.size() > 0) {
for (EquCheckItemDetail detail : equCheckItemDetailList) {
detail.setShowFlag(true);
List<EquPlanStandard> standardList = new ArrayList<>();
for (EquCheckItemDetail standardTemp : equCheckItemDetailList) {
EquPlanStandard standard = new EquPlanStandard();
BeanUtils.copyProperties(standardTemp,standard);
standard.setShowFlag(true);
standardList.add(standard);
}
checkItem.setEquCheckItemDetailList(equCheckItemDetailList);
detail.setEquPlanStandardList(standardList);
}
}
detailList.add(detail);
}
data.setEquCheckItemList(equCheckItemList);
data.setEquPlanDetailList(detailList);
data.setItemTempName(itemTempName.toString());
}else {
return error(500,"存在设备未设置巡检项!");
@ -310,9 +322,11 @@ public class EquPlanServiceImpl implements IEquPlanService {
EquPlan plan = equPlanMapper.selectEquPlanByPlanCode(equPlan.getPlanCode());
// 处理计划信息
List<Date> planTimeArray = new ArrayList<>();
planTimeArray.add(plan.getPlanLoopStart());
planTimeArray.add(plan.getPlanLoopEnd());
plan.setPlanTimeArray(planTimeArray);
if (plan.getPlanLoopStart() != null) {
planTimeArray.add(plan.getPlanLoopStart());
planTimeArray.add(plan.getPlanLoopEnd());
plan.setPlanTimeArray(planTimeArray);
}
// 获取人员信息
@ -339,6 +353,9 @@ public class EquPlanServiceImpl implements IEquPlanService {
selectStandard.setParentCode(detail.getCode());
selectStandard.setPlanCode(equPlan.getPlanCode());
List<EquPlanStandard> standardList = equPlanStandardMapper.selectEquPlanStandardList(selectStandard);
for (EquPlanStandard standard : standardList) {
standard.setShowFlag(true);
}
// 置入标准
detail.setEquPlanStandardList(standardList);
@ -346,6 +363,14 @@ public class EquPlanServiceImpl implements IEquPlanService {
// 置入检查项
equipment.setEquPlanDetailList(detailList);
EquPlanEquSpare spare = new EquPlanEquSpare();
spare.setParentCode(equipment.getCode());
List<EquPlanEquSpare> spareList = equPlanEquSpareMapper.selectEquPlanEquSpareList(spare);
if (spareList.size() > 0) {
equipment.setSpareList(spareList);
}
}
plan.setEquipmentItem(equipmentList);
@ -398,28 +423,25 @@ public class EquPlanServiceImpl implements IEquPlanService {
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;
@ -427,33 +449,30 @@ public class EquPlanServiceImpl implements IEquPlanService {
// 判断是否插入检查项
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);
}
}

@ -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);
}
}

@ -125,4 +125,8 @@
#{id}
</foreach>
</delete>
<delete id="deleteEquPlanEquSpareByPlanCode">
delete from equ_plan_equ_spare where plan_code = #{planCode}
</delete>
</mapper>
Loading…
Cancel
Save