|
|
|
|
@@ -20,6 +20,7 @@ import com.njcn.oss.enums.OssResponseEnum;
|
|
|
|
|
import com.njcn.oss.utils.FileStorageUtil;
|
|
|
|
|
import com.njcn.poi.excel.ExcelUtil;
|
|
|
|
|
import com.njcn.poi.util.PoiUtil;
|
|
|
|
|
import com.njcn.process.enums.ProcessResponseEnum;
|
|
|
|
|
import com.njcn.process.pojo.dto.excel.TerminalExcel;
|
|
|
|
|
import com.njcn.process.pojo.param.TerminalParam;
|
|
|
|
|
import com.njcn.process.pojo.po.PmsTerminalDetection;
|
|
|
|
|
@@ -110,24 +111,31 @@ public class PmsTerminalDetectionServiceImpl extends ServiceImpl<PmsTerminalDete
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean insertTerminal(TerminalParam.TerminalInsertParam param) {
|
|
|
|
|
public Boolean insertTerminal(TerminalParam.TerminalInsertParam param) {
|
|
|
|
|
Dept data = deptFeignClient.getDeptById(param.getOrgNo()).getData();
|
|
|
|
|
if (ObjectUtil.isNull(data)) {
|
|
|
|
|
throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
|
|
|
|
|
}
|
|
|
|
|
int count = this.count(new LambdaQueryWrapper<PmsTerminalDetection>()
|
|
|
|
|
List<PmsTerminalDetection> list = this.list(new LambdaQueryWrapper<PmsTerminalDetection>()
|
|
|
|
|
.eq(PmsTerminalDetection::getId, param.getId())
|
|
|
|
|
.or(wrapper ->
|
|
|
|
|
wrapper.eq(PmsTerminalDetection::getName, param.getName())
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT, "或终端编号已存在");
|
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
List<String> collect = list.stream().map(PmsTerminalDetection::getName).collect(Collectors.toList());
|
|
|
|
|
if(collect.contains(param.getName())){
|
|
|
|
|
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT);
|
|
|
|
|
}
|
|
|
|
|
throw new BusinessException(ProcessResponseEnum.TERMINAL_ID_REPEAT);
|
|
|
|
|
}
|
|
|
|
|
PmsTerminalDetection detection = BeanUtil.copyProperties(param, PmsTerminalDetection.class);
|
|
|
|
|
detection.setOriginalName(detection.getId() + "-原始数据报告.docx");
|
|
|
|
|
detection.setOrgNo(data.getCode());
|
|
|
|
|
detection.setOrgName(data.getName());
|
|
|
|
|
|
|
|
|
|
LocalDate inspectionTime = param.getInspectionTime();
|
|
|
|
|
detection.setNextInspectionTime(inspectionTime.plusYears(5));
|
|
|
|
|
detection.setTestResults(0);
|
|
|
|
|
detection.setStatus(1);
|
|
|
|
|
return this.save(detection);
|
|
|
|
|
@@ -160,17 +168,21 @@ public class PmsTerminalDetectionServiceImpl extends ServiceImpl<PmsTerminalDete
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean updateTerminal(TerminalParam.TerminalUpdateParam param) {
|
|
|
|
|
PmsTerminalDetection one = this.getOne(new LambdaQueryWrapper<PmsTerminalDetection>()
|
|
|
|
|
List<PmsTerminalDetection> list = this.list(new LambdaQueryWrapper<PmsTerminalDetection>()
|
|
|
|
|
.ne(PmsTerminalDetection::getId, param.getId())
|
|
|
|
|
.and(wrapper ->
|
|
|
|
|
wrapper.eq(PmsTerminalDetection::getName, param.getName())
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
if (ObjectUtil.isNotNull(one)) {
|
|
|
|
|
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
List<String> collect = list.stream().map(PmsTerminalDetection::getName).collect(Collectors.toList());
|
|
|
|
|
if(collect.contains(param.getName())){
|
|
|
|
|
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PmsTerminalDetection detection = BeanUtil.copyProperties(param, PmsTerminalDetection.class);
|
|
|
|
|
LocalDate inspectionTime = param.getInspectionTime();
|
|
|
|
|
detection.setNextInspectionTime(inspectionTime.plusYears(5));
|
|
|
|
|
boolean b = this.updateById(detection);
|
|
|
|
|
if (b) {
|
|
|
|
|
PmsTerminalDetection cc = this.getOne(new LambdaQueryWrapper<PmsTerminalDetection>()
|
|
|
|
|
@@ -243,7 +255,8 @@ public class PmsTerminalDetectionServiceImpl extends ServiceImpl<PmsTerminalDete
|
|
|
|
|
//文件上传的地址
|
|
|
|
|
String path = fileStorageUtil.uploadMultipart(files[i], OssPath.TEST_REPORT);
|
|
|
|
|
detection.setInspectionReport(path);
|
|
|
|
|
detection.setNextInspectionTime(LocalDate.parse(nextInspectionTime));
|
|
|
|
|
detection.setInspectionTime(LocalDate.parse(nextInspectionTime));
|
|
|
|
|
detection.setNextInspectionTime(LocalDate.parse(nextInspectionTime).plusYears(5));
|
|
|
|
|
detection.setInspectionName(originalFilename);
|
|
|
|
|
detection.setId(terminalIds);
|
|
|
|
|
data.add(detection);
|
|
|
|
|
@@ -424,6 +437,8 @@ public class PmsTerminalDetectionServiceImpl extends ServiceImpl<PmsTerminalDete
|
|
|
|
|
detection = BeanUtil.copyProperties(terminalExcel, PmsTerminalDetection.class);
|
|
|
|
|
detection.setOrgNo(deptList.get(0).getCode());
|
|
|
|
|
detection.setOrgName(deptList.get(0).getName());
|
|
|
|
|
LocalDate inspectionTime = detection.getInspectionTime();
|
|
|
|
|
detection.setNextInspectionTime(inspectionTime.plusYears(5));
|
|
|
|
|
detection.setTestResults(0);
|
|
|
|
|
detection.setStatus(1);
|
|
|
|
|
pmsTerminalDetections.add(detection);
|
|
|
|
|
@@ -452,5 +467,4 @@ public class PmsTerminalDetectionServiceImpl extends ServiceImpl<PmsTerminalDete
|
|
|
|
|
msg.setMsg(content);
|
|
|
|
|
terminalExcelMsg.add(msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|