整理代码
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
package com.njcn.gather.plan.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
@@ -13,22 +9,18 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.FileUtil;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.utils.PoiUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.gather.plan.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-01-16
|
||||
*/
|
||||
@Getter
|
||||
public enum PlanResponseEnum {
|
||||
PLAN_REPEATED("A003014", "当前模式下,该计划已存在"),
|
||||
PLAN_NOT_EXIST("A003015", "该计划不存在"),
|
||||
SCRIPT_RELATE_DICT_NOT_EXIST("A003016","脚本关联的字典不存在"),
|
||||
NOT_CHECKED_PLAN_CANNOT_ANALYSE("A003017","只有检测状态为检测完成的计划才能进行统计分析" ),
|
||||
CANNOT_CHANGE_SCRIPT_WHEN_CHECKING("A003018","只有检测状态为未检时,才能修改检测脚本" ),
|
||||
CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING("A003019","只有检测状态为未检时,才能修改误差体系" ),
|
||||
CANNOT_CHANGE_REPORT_WHEN_CHECKING("A003020","只有检测状态为未检时,才能修改绑定报告模板");
|
||||
|
||||
private final String message;
|
||||
private final String code;
|
||||
|
||||
|
||||
PlanResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import com.njcn.gather.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum;
|
||||
import com.njcn.gather.plan.pojo.enums.PlanResponseEnum;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
@@ -37,6 +36,7 @@ import com.njcn.gather.plan.pojo.vo.CNPlanExcel;
|
||||
import com.njcn.gather.plan.pojo.vo.ProvincePlanExcel;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.report.pojo.po.PqReport;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
@@ -194,7 +194,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
String reportId = this.baseMapper.getReportIdByNameAndVersion(split[0], split[1]);
|
||||
if (plan1.getTestState() != CheckStateEnum.UNCHECKED.getValue()) {
|
||||
if (!reportId.equals(plan1.getReportTemplateId())) {
|
||||
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||
throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(reportId)) {
|
||||
@@ -204,13 +204,13 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
|
||||
if (plan1.getTestState() != CheckStateEnum.UNCHECKED.getValue()) {
|
||||
if (!plan1.getScriptId().equals(param.getScriptId())) {
|
||||
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_SCRIPT_WHEN_CHECKING);
|
||||
throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_SCRIPT_WHEN_CHECKING);
|
||||
}
|
||||
if (!plan1.getErrorSysId().equals(param.getErrorSysId())) {
|
||||
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING);
|
||||
throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING);
|
||||
}
|
||||
if (param.getAssociateReport() != null && param.getAssociateReport() != plan1.getAssociateReport()) {
|
||||
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||
throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||
queryParam.setPlanId(id);
|
||||
if (ObjectUtils.isNotEmpty(pqDevService.listByPlanId(queryParam))) {
|
||||
throw new BusinessException(DevResponseEnum.PLAN_HAS_DEVICE_BIND);
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_HAS_DEVICE_BIND);
|
||||
}
|
||||
}
|
||||
// 删除检测计划、检测源关联
|
||||
@@ -308,7 +308,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
AdPlan adPlan = this.getById(planId);
|
||||
if (ObjectUtil.isNull(adPlan)) {
|
||||
throw new BusinessException(PlanResponseEnum.PLAN_NOT_EXIST);
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_NOT_EXIST);
|
||||
}
|
||||
String scriptId = adPlan.getScriptId();
|
||||
|
||||
@@ -345,7 +345,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
map.put("code", dictTree.getCode());
|
||||
map.put("scriptName", dictTree.getName());
|
||||
} else {
|
||||
throw new BusinessException(PlanResponseEnum.SCRIPT_RELATE_DICT_NOT_EXIST);
|
||||
throw new BusinessException(DetectionResponseEnum.SCRIPT_RELATE_DICT_NOT_EXIST);
|
||||
}
|
||||
result.add(map);
|
||||
});
|
||||
@@ -408,7 +408,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
|
||||
planList.forEach(plan -> {
|
||||
if (!CheckStateEnum.CHECKED.getValue().equals(plan.getTestState())) {
|
||||
throw new BusinessException(PlanResponseEnum.NOT_CHECKED_PLAN_CANNOT_ANALYSE);
|
||||
throw new BusinessException(DetectionResponseEnum.NOT_CHECKED_PLAN_CANNOT_ANALYSE);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -576,7 +576,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
planExcelList = excelImportResult.getList();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(planExcelList)) {
|
||||
this.importCNPlan(planExcelList, patternId);
|
||||
@@ -614,14 +614,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
String[] sourceNames = source.split(StrUtil.COMMA);
|
||||
// 若非比对模式,检测源、数据源有2个以上时,不导入
|
||||
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && sourceNames.length > 1) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_SOURCE_ERROR);
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_SOURCE_ERROR);
|
||||
}
|
||||
|
||||
String datasource = planExcel.getDatasourceId();
|
||||
String[] datasourceIds = datasource.split(StrUtil.COMMA);
|
||||
// 若非比对模式,数据源有2个以上时,不导入
|
||||
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATASOURCE_ERROR);
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_DATASOURCE_ERROR);
|
||||
}
|
||||
|
||||
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
|
||||
@@ -654,7 +654,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
planExcelList = excelImportResult.getList();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(planExcelList)) {
|
||||
this.importProvincePlan(planExcelList, patternId);
|
||||
@@ -691,14 +691,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
String[] sourceNames = source.split(StrUtil.COMMA);
|
||||
// 若非比对模式,检测源、数据源有2个以上时,不导入
|
||||
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && sourceNames.length > 1) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_SOURCE_ERROR);
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_SOURCE_ERROR);
|
||||
}
|
||||
|
||||
String datasource = planExcel.getDatasourceId();
|
||||
String[] datasourceIds = datasource.split(StrUtil.COMMA);
|
||||
// 若非比对模式,数据源有2个以上时,不导入
|
||||
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATASOURCE_ERROR);
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_DATASOURCE_ERROR);
|
||||
}
|
||||
|
||||
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
|
||||
@@ -864,7 +864,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
int count = this.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(PlanResponseEnum.PLAN_REPEATED);
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_REPEATED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user