|
|
@ -9,14 +9,19 @@ import java.util.List;
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
|
|
|
import com.op.common.core.utils.StringUtils;
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
|
|
|
|
import com.op.common.security.utils.SecurityUtils;
|
|
|
|
import com.op.device.domain.*;
|
|
|
|
import com.op.device.domain.*;
|
|
|
|
import com.op.device.domain.dto.EquCheckItemDTO;
|
|
|
|
import com.op.device.domain.dto.EquCheckItemDTO;
|
|
|
|
import com.op.device.domain.dto.SummaryReportDTO;
|
|
|
|
import com.op.device.domain.dto.SummaryReportDTO;
|
|
|
|
|
|
|
|
import com.op.device.domain.vo.EquCheckItemImportVO;
|
|
|
|
import com.op.device.domain.vo.EquCheckItemVO;
|
|
|
|
import com.op.device.domain.vo.EquCheckItemVO;
|
|
|
|
import com.op.device.mapper.EquCheckItemDetailMapper;
|
|
|
|
import com.op.device.mapper.EquCheckItemDetailMapper;
|
|
|
|
import com.op.device.mapper.EquItemEquipmentMapper;
|
|
|
|
import com.op.device.mapper.EquItemEquipmentMapper;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@ -47,6 +52,7 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private EquItemEquipmentMapper equItemEquipmentMapper;
|
|
|
|
private EquItemEquipmentMapper equItemEquipmentMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询检查项维护
|
|
|
|
* 查询检查项维护
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -357,7 +363,6 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
|
|
|
|
return success(workCenterList);
|
|
|
|
return success(workCenterList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 点检、巡检、保养计划工单匹配检查项
|
|
|
|
* 点检、巡检、保养计划工单匹配检查项
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -371,4 +376,202 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
|
|
|
|
List<SummaryReportDTO> matchList = equCheckItemMapper.selectMatchListByEquipmentCode(summaryReportDTO);
|
|
|
|
List<SummaryReportDTO> matchList = equCheckItemMapper.selectMatchListByEquipmentCode(summaryReportDTO);
|
|
|
|
return success(matchList);
|
|
|
|
return success(matchList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 处理设备基础信息
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param equCheckItemImportVO
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
|
|
|
public AjaxResult importFile(List<EquCheckItemImportVO> equCheckItemImportVO) {
|
|
|
|
|
|
|
|
EquCheckItem example = null;
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
|
|
|
|
AjaxResult checkResult = checkImportFile(equCheckItemImportVO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (EquCheckItemImportVO table : equCheckItemImportVO) {
|
|
|
|
|
|
|
|
table.setItemId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
table.setDetailId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
table.setParentCode(table.getItemCode()); //父code
|
|
|
|
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
|
|
|
|
String key = "#header.poolName";
|
|
|
|
|
|
|
|
table.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_", "")); //工厂号
|
|
|
|
|
|
|
|
table.setCreateBy(SecurityUtils.getUsername()); //创建人
|
|
|
|
|
|
|
|
table.setCreateTime(DateUtils.getNowDate()); //创建时间
|
|
|
|
|
|
|
|
table.setUpdateBy(SecurityUtils.getUsername()); //创建人
|
|
|
|
|
|
|
|
table.setUpdateTime(DateUtils.getNowDate()); //创建时间
|
|
|
|
|
|
|
|
table.setDelFlag("0"); //删除标志
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果数据校验成功
|
|
|
|
|
|
|
|
if (checkResult.isSuccess()) {
|
|
|
|
|
|
|
|
String info = syncImportFunc(equCheckItemImportVO);
|
|
|
|
|
|
|
|
return success("信息导入完成。检查项表中检查编码作为主键,导入编码重复。其中导入失败检查项:" + info);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 校验失败
|
|
|
|
|
|
|
|
return checkResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 校验导入检查项信息
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param equCheckItemImportVO
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public AjaxResult checkImportFile(List<EquCheckItemImportVO> equCheckItemImportVO) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 传入对象不能为空
|
|
|
|
|
|
|
|
if (equCheckItemImportVO.size() == 0 || StringUtils.isNull(equCheckItemImportVO)) {
|
|
|
|
|
|
|
|
return error(500, "导入的检查项信息不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 循环遍历校验数据是否为空
|
|
|
|
|
|
|
|
for (EquCheckItemImportVO table : equCheckItemImportVO) {
|
|
|
|
|
|
|
|
// 检查项编码
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getItemCode()) || table.getItemCode() == null ||table.getItemCode().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "检查项编码不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//检查项详情编码
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getDetailCode()) || table.getDetailCode() == null ||table.getDetailCode().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "检查项详情编码不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 部位
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getItemName()) || table.getItemName() == null||table.getItemName().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "部位(检查项名称)不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 方法
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getItemMethod()) || table.getItemMethod() == null||table.getItemMethod().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "方法不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 工具
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getItemTools()) || table.getItemTools() == null||table.getItemTools().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "工具不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 周期
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getItemLoop()) || table.getItemLoop() == null||table.getItemLoop().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "周期不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 周期类型
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getItemLoopType()) || table.getItemLoopType() == null ||table.getItemLoopType().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "周期类型不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(!(table.getItemLoopType().equals("日") || table.getItemLoopType().equals("周") || table.getItemLoopType().equals("月") || table.getItemLoopType().equals("季") || table.getItemLoopType().equals("年"))){
|
|
|
|
|
|
|
|
return error(500, "周期类型录入格式错误!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// // 维护类型编码
|
|
|
|
|
|
|
|
// if (table.getItemType().isEmpty() || table.getItemType() == null) {
|
|
|
|
|
|
|
|
// return error(500, "维护类型编码不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
// }else{
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 维护类型名称
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getItemTypeName()) || table.getItemTypeName() == null ||table.getItemTypeName().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "维护类型名称不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(!(table.getItemTypeName().equals("点检") || table.getItemTypeName().equals("巡检") || table.getItemTypeName().equals("保养"))){
|
|
|
|
|
|
|
|
return error(500, "维护类型名称格式录入错误!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 标准类型
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getStandardType()) || table.getStandardType() == null ||table.getStandardType().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "标准类型不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(!(table.getStandardType().equals("定性") || table.getStandardType().equals("定量"))){
|
|
|
|
|
|
|
|
return error(500, "标准类型名称格式录入错误!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 标准名称
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getStandardName()) || table.getStandardName() == null ||table.getStandardName().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "标准名称不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//定量的判断
|
|
|
|
|
|
|
|
if(table.getStandardType().equals("定量")){
|
|
|
|
|
|
|
|
// 上限
|
|
|
|
|
|
|
|
if (table.getDetailUpLimit() == null) {
|
|
|
|
|
|
|
|
return error(500, "定量的标准上限不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 下限
|
|
|
|
|
|
|
|
if (table.getDetailDownLimit() == null) {
|
|
|
|
|
|
|
|
return error(500, "定量的标准下限不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 单位
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(table.getDetailUnit()) || table.getDetailUnit() == null ||table.getDetailUnit().equals("")) {
|
|
|
|
|
|
|
|
return error(500, "定量的单位不能为空!信息导入失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return success();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String syncImportFunc(List<EquCheckItemImportVO> equCheckItemImportVO) {
|
|
|
|
|
|
|
|
String failCheckItem = "";
|
|
|
|
|
|
|
|
for (EquCheckItemImportVO table : equCheckItemImportVO) {
|
|
|
|
|
|
|
|
String msg = syncFunc(table);
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(msg)) {
|
|
|
|
|
|
|
|
failCheckItem += msg + ",";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return failCheckItem;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public String syncFunc(EquCheckItemImportVO table) {
|
|
|
|
|
|
|
|
String failCheckItem = "";
|
|
|
|
|
|
|
|
EquCheckItem itemExist = equCheckItemMapper.selectExistByItemCode(table.getItemCode());
|
|
|
|
|
|
|
|
EquCheckItemDetail detailExist = equCheckItemDetailMapper.selectExistByDetailCode(table.getDetailCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//主对象
|
|
|
|
|
|
|
|
EquCheckItem equCheckItem = new EquCheckItem();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(table,equCheckItem);
|
|
|
|
|
|
|
|
if(equCheckItem.getItemTypeName().equals("点检")){
|
|
|
|
|
|
|
|
equCheckItem.setItemType("spotInspection");
|
|
|
|
|
|
|
|
}else if(equCheckItem.getItemTypeName().equals("巡检")){
|
|
|
|
|
|
|
|
equCheckItem.setItemType("inspection");
|
|
|
|
|
|
|
|
}else if(equCheckItem.getItemTypeName().equals("保养")){
|
|
|
|
|
|
|
|
equCheckItem.setItemType("maintenance");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//周期类型
|
|
|
|
|
|
|
|
if(equCheckItem.getItemLoopType().equals("日")){
|
|
|
|
|
|
|
|
equCheckItem.setItemLoopType("day");
|
|
|
|
|
|
|
|
}else if(equCheckItem.getItemLoopType().equals("周")){
|
|
|
|
|
|
|
|
equCheckItem.setItemLoopType("week");
|
|
|
|
|
|
|
|
}else if(equCheckItem.getItemTypeName().equals("月")){
|
|
|
|
|
|
|
|
equCheckItem.setItemLoopType("month");
|
|
|
|
|
|
|
|
}else if(equCheckItem.getItemLoopType().equals("季")){
|
|
|
|
|
|
|
|
equCheckItem.setItemLoopType("season");
|
|
|
|
|
|
|
|
}else if(equCheckItem.getItemTypeName().equals("年")){
|
|
|
|
|
|
|
|
equCheckItem.setItemLoopType("year");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
equCheckItem.setItemLoop(Integer.valueOf(table.getItemLoop()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//详情对象
|
|
|
|
|
|
|
|
EquCheckItemDetail equCheckItemDetail = new EquCheckItemDetail();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(table,equCheckItemDetail);
|
|
|
|
|
|
|
|
if(equCheckItemDetail.getStandardType().equals("定性")){
|
|
|
|
|
|
|
|
equCheckItemDetail.setStandardType("qualitative");
|
|
|
|
|
|
|
|
}else if(equCheckItemDetail.getStandardType().equals("定量")){
|
|
|
|
|
|
|
|
equCheckItemDetail.setStandardType("quantify");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//不存在就插入
|
|
|
|
|
|
|
|
if (itemExist == null) {
|
|
|
|
|
|
|
|
equCheckItemMapper.insertEquCheckItem(equCheckItem);
|
|
|
|
|
|
|
|
logger.info("=======检查项[" + table.getItemCode() + "]=======导入成功");
|
|
|
|
|
|
|
|
if(detailExist == null){
|
|
|
|
|
|
|
|
equCheckItemDetailMapper.insertEquCheckItemDetail(equCheckItemDetail);
|
|
|
|
|
|
|
|
logger.info("=======检查项[" + table.getItemCode() +"]的["+ table.getDetailCode() + "]=======导入成功");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
failCheckItem = '['+table.getItemCode() + "]的[" + table.getDetailCode() + "]";
|
|
|
|
|
|
|
|
logger.info("=======检查项[" + table.getItemCode() +"]的["+ table.getDetailCode() + "]=======导入失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
failCheckItem = '['+table.getItemCode() + ']';
|
|
|
|
|
|
|
|
logger.info("=======检查项[" + failCheckItem + "]=======导入失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return failCheckItem;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|