bug修复

This commit is contained in:
caozehui
2025-04-08 10:10:12 +08:00
parent 42701db2d5
commit c7a45b5500
24 changed files with 170 additions and 78 deletions

View File

@@ -22,6 +22,7 @@ import java.util.List;
public class PqDevParam {
@ApiModelProperty(value = "名称", required = true)
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
private String name;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@@ -40,8 +41,9 @@ public class PqDevParam {
@ApiModelProperty(value = "出厂日期", required = true)
private String createDate;
@ApiModelProperty(value = "设备序列", required = true)
@ApiModelProperty(value = "装置编", required = true)
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_CREATE_ID_REGEX, message = DetectionValidMessage.DEV_CREATE_ID_FORMAT_ERROR)
private String createId;
@ApiModelProperty(value = "固件版本", required = true)

View File

@@ -23,7 +23,7 @@ public class CNDevExcel {
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX_IMPORT, message = DetectionValidMessage.CN_DEV_NAME_FORMAT_ERROR)
private String name;
@Excel(name = "设备类型*", width = 20, orderNum = "3")

View File

@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.poi.PullDown;
@@ -31,11 +32,7 @@ import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.monitor.pojo.po.PqMonitor;
import com.njcn.gather.monitor.service.IPqMonitorService;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.report.pojo.DevReportParam;
import com.njcn.gather.report.service.IPqReportService;
import com.njcn.gather.storage.service.DetectionDataDealService;
import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
@@ -49,7 +46,6 @@ import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.PoiUtil;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
@@ -61,6 +57,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@@ -113,15 +110,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
PqDev pqDev = new PqDev();
BeanUtil.copyProperties(pqDevParam, pqDev);
if (pqDevParam.getEncryptionFlag() == 1) {
if (StrUtil.isNotBlank(pqDevParam.getSeries()) && StrUtil.isNotBlank(pqDevParam.getDevKey())) {
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
} else {
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
if ("1".equals(sysTestConfigService.getCurrrentScene())) {
String currrentScene = sysTestConfigService.getCurrrentScene();
this.checkParams(pqDev, currrentScene);
if (SceneEnum.LEAVE_FACTORY_TEST.getValue().equals(currrentScene)) {
pqDev.setManufacturer("8fa73802c9e1abab973adcbeb0d58567"); // 南京灿能字典项目对应的id
}
// 新增时默认设置
@@ -143,13 +135,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
return this.save(pqDev);
}
@Override
@Transactional
public boolean updatePqDev(PqDevParam.UpdateParam updateParam) {
this.checkRepeat(updateParam, true);
PqDev pqDev = new PqDev();
BeanUtil.copyProperties(updateParam, pqDev);
/**
* 校验参数
*
* @param pqDev
* @param currrentScene
*/
private void checkParams(PqDev pqDev, String currrentScene) {
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
if (pqDev.getEncryptionFlag() == 1) {
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
@@ -158,6 +151,34 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
switch (sceneEnum) {
case PROVINCE_PLATFORM:
if(!Pattern.matches(PatternRegex.PROVINCE_DEV_NAME_REGEX, pqDev.getName())){
throw new BusinessException(DetectionResponseEnum.PROVINCE_DEV_NAME_FORMAT_ERROR);
}
break;
case LEAVE_FACTORY_TEST:
if (!Pattern.matches(PatternRegex.CN_DEV_NAME_REGEX, pqDev.getName())) {
throw new BusinessException(DetectionResponseEnum.CN_DEV_NAME_FORMAT_ERROR);
}
break;
case SELF_TEST:
break;
default:
break;
}
}
@Override
@Transactional
public boolean updatePqDev(PqDevParam.UpdateParam updateParam) {
this.checkRepeat(updateParam, true);
PqDev pqDev = new PqDev();
BeanUtil.copyProperties(updateParam, pqDev);
String currrentScene = sysTestConfigService.getCurrrentScene();
this.checkParams(pqDev, currrentScene);
// 比对式设备修改监测点
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(updateParam.getPattern()).getCode())) {
if (ObjectUtil.isNotEmpty(updateParam.getMonitorList())) {
@@ -344,23 +365,22 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, devIds).update();
List<PqDev> list = this.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getId, devIds));
//判断是否有处了未检的其他设备
List<Integer> notUnchecked = list.stream().map(PqDev::getCheckState).filter(x -> !x.equals(CheckStateEnum.UNCHECKED.getValue())).distinct().collect(Collectors.toList());
List<String> notUnchecked = list.stream().filter(x -> !CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDev::getId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(notUnchecked)) {
List<Integer> unchecked = list.stream().map(PqDev::getCheckState).filter(x -> x.equals(CheckStateEnum.UNCHECKED.getValue())).distinct().collect(Collectors.toList());
List<String> unchecked = list.stream().filter(x -> CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDev::getId).distinct().collect(Collectors.toList());
//计划未检测
if (CollUtil.isNotEmpty(unchecked)) {
return CheckStateEnum.CHECKING.getValue();
}
//计划检测中
List<String> checking = list.stream().filter(x -> CheckStateEnum.CHECKING.getValue().equals(x.getCheckState()) ||
CheckStateEnum.CHECKED.getValue().equals(x.getCheckState()) ||
List<String> checking = list.stream().filter(x -> x.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) &&
!DevDocumentStateEnum.DOCUMENTED.getValue().equals(x.getReportState())
).map(PqDev::getId).distinct().collect(Collectors.toList());
if (checking.size() == notUnchecked.size()) {
return CheckStateEnum.CHECKING.getValue();
}
//检测完成
List<Integer> checked = list.stream().map(PqDev::getCheckState).filter(x -> x.equals(CheckStateEnum.DOCUMENTED.getValue())).distinct().collect(Collectors.toList());
List<String> checked = list.stream().filter(x -> CheckStateEnum.DOCUMENTED.getValue().equals(x.getCheckState())).map(PqDev::getId).distinct().collect(Collectors.toList());
if (checked.size() == notUnchecked.size()) {
return CheckStateEnum.CHECKED.getValue();
}
@@ -499,7 +519,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
}
@Override
public boolean updateResult(List<String> ids, List<String> valueType, String code,String userId) {
public boolean updateResult(List<String> ids, List<String> valueType, String code, String userId) {
if (CollUtil.isNotEmpty(ids)) {
SysTestConfig config = sysTestConfigService.getOneConfig();
Map<String, Integer> result = detectionDataDealService.devResult(ids, valueType, code);
@@ -903,8 +923,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
// 是否支持系数校准
pullDown = new PullDown();
pullDown.setFirstCol(startCol + 8);
pullDown.setLastCol(startCol + 8);
pullDown.setFirstCol(startCol + 7);
pullDown.setLastCol(startCol + 7);
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);

View File

@@ -21,7 +21,7 @@ public class PqErrSysParam {
@ApiModelProperty(value = "参照标准名称", required = true)
@NotBlank(message = DetectionValidMessage.STANDARD_NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DetectionValidMessage.STANDARD_NAME_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.ERR_SYS_NAME_REGEX, message = DetectionValidMessage.STANDARD_NAME_FORMAT_ERROR)
private String standardName;
@ApiModelProperty(value = "标准实施年份", required = true)

View File

@@ -125,8 +125,8 @@ public class AdPlanController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadTemplate")
@ApiOperation("下载检测计划导出模板")
public void downloadTemplate() {
adPlanService.downloadTemplate();
public void downloadTemplate(@RequestBody String patternId) {
adPlanService.downloadTemplate(patternId);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)

View File

@@ -78,7 +78,7 @@ public class AdPlanParam {
@ApiModelProperty(value = "模式,字典表(数字、模拟、比对)")
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
private String pattern;
private String patternId;
@ApiModelProperty(value = "检测状态")
@Min(value = 0, message = DetectionValidMessage.TEST_STATE_FORMAT_ERROR)

View File

@@ -111,8 +111,10 @@ public interface IAdPlanService extends IService<AdPlan> {
/**
* 下载检测计划模板
*
* @param patternId
*/
void downloadTemplate();
void downloadTemplate(String patternId);
/**
* 导入检测计划数据

View File

@@ -476,15 +476,15 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
}
@Override
public void downloadTemplate() {
public void downloadTemplate(String patternId) {
String currrentScene = sysTestConfigService.getCurrrentScene();
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
switch (sceneEnum) {
case PROVINCE_PLATFORM:
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM), ProvincePlanExcel.class, Collections.emptyList());
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM, patternId), ProvincePlanExcel.class, Collections.emptyList());
break;
case LEAVE_FACTORY_TEST:
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST), CNPlanExcel.class, Collections.emptyList());
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST, patternId), CNPlanExcel.class, Collections.emptyList());
break;
case SELF_TEST:
break;
@@ -531,7 +531,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
List<ProvinceDevExcel> deviceExportData = BeanUtil.copyToList(pqDevs, ProvinceDevExcel.class);
planExcelList.get(i).setDevices(deviceExportData);
}
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM), ProvincePlanExcel.class, planExcelList);
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM,queryParam.getPatternId()), ProvincePlanExcel.class, planExcelList);
}
/**
@@ -554,7 +554,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
List<CNDevExcel> deviceExportData = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
planExcelList.get(i).setDevices(deviceExportData);
}
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST), CNPlanExcel.class, planExcelList);
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST,queryParam.getPatternId()), CNPlanExcel.class, planExcelList);
}
@Transactional
@@ -607,9 +607,6 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
Integer code = this.generateCode();
adPlans.get(i).setCode(code);
tableGenService.deleteTable(Arrays.asList(code.toString()));
tableGenService.genAdNonHarmonicTable(code.toString());
String source = planExcel.getSource();
String[] sourceNames = source.split(StrUtil.COMMA);
// 若非比对模式检测源、数据源有2个以上时不导入
@@ -629,6 +626,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
List<CNDevExcel> cnDevExcelList = planExcel.getDevices();
pqDevService.importCNDev(cnDevExcelList, patternId, planId);
tableGenService.deleteTable(Arrays.asList(code.toString()));
tableGenService.genAdNonHarmonicTable(code.toString());
}
// 逆向可视化
this.reverseVisualize(adPlans);
@@ -721,7 +721,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
private Wrapper getQueryWrapper(AdPlanParam.QueryParam queryParam) {
QueryWrapper<AdPlan> queryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(queryParam)) {
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPattern()), "ad_plan.pattern", queryParam.getPattern())
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPatternId()), "ad_plan.pattern", queryParam.getPatternId())
.like(StrUtil.isNotBlank(queryParam.getName()), "ad_plan.name", queryParam.getName())
.eq(ObjectUtil.isNotNull(queryParam.getTestState()), "ad_plan.Test_State", queryParam.getTestState())
.eq(ObjectUtil.isNotNull(queryParam.getReportState()), "ad_plan.Report_State", queryParam.getReportState())
@@ -1019,10 +1019,19 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
}
}
private List<PullDown> getPullDownList(SceneEnum scene) {
private List<PullDown> getPullDownList(SceneEnum scene, String patternId) {
List<PullDown> pullDowns = new ArrayList<>();
PullDown pullDown = null;
// List<Map<String, Object>> maps = pqSourceService.listAllPqSource(patternId);
// if (ObjectUtil.isNotEmpty(maps)) {
// pullDown = new PullDown();
// pullDown.setFirstCol(1);
// pullDown.setLastCol(1);
// pullDown.setStrings(maps.stream().map(m -> (String) m.get("name")).collect(Collectors.toList()));
// pullDowns.add(pullDown);
// }
// 数据源
DictType dictType = dictTypeService.getByCode("Datasource");
if (ObjectUtil.isNotNull(dictType)) {

View File

@@ -10,9 +10,9 @@ public interface DetectionValidMessage {
String ID_NOT_BLANK = "id不能为空请检查id参数";
String ID_FORMAT_ERROR = "id格式错误请检查id参数";
String NAME_NOT_BLANK = "名称不能为空";
String ICD_NAME_FORMAT_ERROR = "名称格式错误只能包含字母、数字、中文、下划线、中划线、点号长度为1-50个字符";
String ICD_NAME_FORMAT_ERROR = "名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格长度为1-32个字符";
String ICD_PATH_NOT_BLANK = "icd存储路径不能为空";
String ICD_PATH_FORMAT_ERROR = "ICD路径格式错误";
String ICD_PATH_FORMAT_ERROR = "ICD路径格式错误只能包含字母、数字、下划线、中划线、空格长度为1-50个字符";
String ICD_NOT_BLANK = "ICD不能为空";
String POWER_NOT_BLANK = "工作电源不能为空";
String VOLT_NOT_BLANK = "额定电压不能为空";
@@ -21,14 +21,14 @@ public interface DetectionValidMessage {
String DEV_CHNS_RANGE_ERROR = "通道数格式错误";
String INDEX_NOT_NULL = "index不能为空";
String VALUE_TYPE_NOT_BLANK = "脚本值类型不能为空";
String SCRIPT_NAME_FORMAT_ERROR = "脚本名称格式错误只能包含字母、数字、中文、下划线、中划线、点号长度为1-50个字符";
String SCRIPT_NAME_FORMAT_ERROR = "脚本名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格长度为1-32个字符";
String SCRIPT_VOLT_FORMAT_ERROR = "检测脚本额定电压格式错误请检查ratedVolt参数";
String SCRIPT_CURR_FORMAT_ERROR = "检测脚本额定电流格式错误请检查ratedCurr参数";
String PORT_RANGE_ERROR = "端口号范围错误请检查port参数";
String NAME_FORMAT_ERROR = "名称格式错误,请检查name参数";
String NAME_FORMAT_ERROR = "名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格长度为1-32个字符";
String PATTERN_NOT_BLANK = "模式不能为空请检查pattern参数";
String PATTERN_NOT_BLANK = "模式不能为空请检查patternId参数";
String DEV_TYPE_NOT_BLANK = "设备类型不能为空";
@@ -62,7 +62,7 @@ public interface DetectionValidMessage {
String RECHECK_NUM_FORMAT_ERROR = "检测次数格式错误请检查recheckNum参数";
String PATTERN_FORMAT_ERROR = "模式格式错误请检查pattern参数";
String PATTERN_FORMAT_ERROR = "模式格式错误请检查patternId参数";
String SOURCE_IDS_NOT_EMPTY = "检测源ID不能为空请检查sourceIds参数";
@@ -76,15 +76,15 @@ public interface DetectionValidMessage {
String PLAN_ID_FORMAT_ERROR = "检测计划ID格式错误请检查planId参数";
String STANDARD_TIME_FORMAT_ERROR = "标准推行时间格式错误请检查standardTime参数";
String STANDARD_TIME_FORMAT_ERROR = "标准推行年份格式错误请检查standardTime参数";
String SCRIPT_TYPE_NOT_BLANK = "检测脚本类型不能为空请检查scriptType参数";
String STANDARD_NAME_NOT_BLANK = "参照标准名称不能为空请检查standardName参数";
String STANDARD_NAME_NOT_BLANK = "标准号不能为空请检查standardName参数";
String STANDARD_NAME_FORMAT_ERROR = "参照标准名称格式错误请检查standardName参数";
String STANDARD_NAME_FORMAT_ERROR = "标准号格式错误只能包含字母、数字、中文、下划线、中划线、点号、空格长度为1-32个字符";
String STANDARD_TIME_NOT_BLANK = "标准推行时间不能为空请检查standardTime参数";
String STANDARD_TIME_NOT_BLANK = "标准推行年份不能为空请检查standardTime参数";
String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误请检查scriptType参数";
@@ -174,4 +174,9 @@ public interface DetectionValidMessage {
String SORT_NOT_NULL = "排序不能为空";
String PREINVESTMENT_PLAN_NOT_BLANK = "预投资计划不能为空";
String TIMECHECK_NOT_NULL = "是否做守时检测不能为空";
String CN_DEV_NAME_FORMAT_ERROR = "设备名称格式错误只能包含数字、中划线长度为1-32个字符";
String DEV_CREATE_ID_FORMAT_ERROR = "装置编号格式错误只能包含字母、数字、中文、下划线、中划线、空格长度为1-32位";
String DEV_TYPE_NAME_FORMAT_ERROR = "设备类型名称格式错误只能包含字母、数字、中文、下划线、中划线、点号、空格长度为1-32个字符";
String REPORT_NAME_NOT_BLANK = "报告模板不能为空";
}

View File

@@ -26,6 +26,7 @@ public enum DetectionResponseEnum {
ICD_PATH_NAME_REPEAT("A02012", "icd名称重复"),
ERR_SYS_BOUND_NOT_DELETE("A02013", "误差体系已被计划所绑定,无法删除!"),
ERR_SYS_REPEAT("A02014", "已存在相同标准号、标准推行年份、适用设备等级的误差体系!"),
SCRIPT_NAME_REPEAT("A02015","脚本名称重复"),
IMPORT_DATA_FAIL("A02040", "导入数据失败"),
@@ -46,7 +47,9 @@ public enum DetectionResponseEnum {
DEVICE_DIS_ERROR("A02055", "装置配置异常"),
DEVICE_DELETE("A02056", "设备无法删除,已绑定计划!"),
CREATE_DIRECTORY_FAILED("A02057", "创建目录失败"),
DELETE_DIRECTORY_FAILED("A02058", "删除目录失败");
DELETE_DIRECTORY_FAILED("A02058", "删除目录失败"),
CN_DEV_NAME_FORMAT_ERROR("A02059","设备名称格式错误只能包含数字长度为1-32位"),
PROVINCE_DEV_NAME_FORMAT_ERROR("A02060","设备名称格式错误只能包含字母、数字、下划线、中划线、空格长度为1-32位" );
private final String code;

View File

@@ -20,8 +20,8 @@ public enum ReportResponseEnum {
REPORT_TEMPLATE_NOT_EXIST("A012009", "报告模板缺失,请联系管理员!"),
NO_CHECK_DATA("A012010", "没有检测数据,无法生成报告!"),
FILE_RENAME_FAILED("A012011", "文件重命名失败"),
REPORT_NAME_PATTERN_ERROR("A012012","报告名称格式错误,可包含中文、字母、数字、中划线,长度不能超过50个字符"),
REPORT_VERSION_PATTERN_ERROR("A012013","报告版本号格式错误,可包含中文、字母、数字、中划线点号,长度不能超过50个字符"),
REPORT_NAME_PATTERN_ERROR("A012012","报告名称格式错误,可包含中文、字母、数字、中划线、点号、空格,长度不能超过32个字符"),
REPORT_VERSION_PATTERN_ERROR("A012013","报告版本号格式错误,可包含中文、字母、数字、中划线点号、空格,长度不能超过32个字符"),
FILE_SIZE_ERROR("A012014","文件大小不能超过5MB" );
private String code;

View File

@@ -699,7 +699,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
} else {
baseModelMap.put("${manufacturer}", "未知");
}
baseModelMap.put("${sample_id}", pqDevVO.getSampleId());
baseModelMap.put("${sample_id}", String.valueOf(pqDevVO.getSampleId()));
baseModelMap.put("${arrived_date}", String.valueOf(pqDevVO.getArrivedDate()));
baseModelMap.put("${check_date}", String.valueOf(pqDevVO.getCheckTime()).substring(0, 10));
baseModelMap.put("${tested_by}", user.getName());

View File

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.plan.pojo.param.AdPlanParam;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.script.mapper.PqScriptMapper;
import com.njcn.gather.script.pojo.param.PqScriptParam;
@@ -59,6 +60,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
@Override
@Transactional
public Boolean addPqScript(PqScriptParam param) {
this.checkRepeat(param, false);
PqScript pqScript = new PqScript();
BeanUtils.copyProperties(param, pqScript);
pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
@@ -69,6 +71,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
@Override
@Transactional
public boolean updatePqScript(PqScriptParam.UpdateParam param) {
this.checkRepeat(param, true);
PqScript pqScript = new PqScript();
BeanUtils.copyProperties(param, pqScript);
pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
@@ -118,4 +121,24 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
public PqScript getPqScriptByName(String name) {
return this.lambdaQuery().eq(PqScript::getName, name).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).one();
}
/**
* 检查脚本是否重复
*
* @param param 计划参数
* @param isExcludeSelf 是否排除自己
*/
private void checkRepeat(PqScriptParam param, boolean isExcludeSelf) {
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("name", param.getName());
if (isExcludeSelf) {
if(param instanceof PqScriptParam.UpdateParam){
wrapper.ne("id", ((PqScriptParam.UpdateParam) param).getId());
}
}
int count = this.count(wrapper);
if (count > 0) {
throw new BusinessException(DetectionResponseEnum.SCRIPT_NAME_REPEAT);
}
}
}

View File

@@ -20,6 +20,7 @@ import javax.validation.constraints.Pattern;
public class DevTypeParam {
@ApiModelProperty(value = "名称", required = true)
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_TYPE_NAME_REGEX, message = DetectionValidMessage.DEV_TYPE_NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty(value = "设备关联的ICD", required = true)
@@ -44,7 +45,7 @@ public class DevTypeParam {
private Integer devChns;
@ApiModelProperty(value = "报告模板")
// @NotBlank(message = "报告模板不能为空")
@NotBlank(message = DetectionValidMessage.REPORT_NAME_NOT_BLANK)
private String reportName;
/**

View File

@@ -26,13 +26,13 @@ public class DictDataParam {
@ApiModelProperty("名称")
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
// @Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.DICT_DATA_NAME_REGEX, message = SystemValidMessage.DICT_DATA_NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty("编码")
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
// @Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.CODE_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.DICT_DATA_CODE_REGEX, message = SystemValidMessage.DICT_DATA_CODE_FORMAT_ERROR)
private String code;

View File

@@ -15,7 +15,7 @@ public class DictPqParam {
@ApiModelProperty("名称")
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.DICT_TYPE_NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty("相别")
@@ -27,9 +27,11 @@ public class DictPqParam {
private String dataType;
@ApiModelProperty("别名,默认与名称相同")
@Pattern(regexp = PatternRegex.DICT_PQ_OTHER_NAME_REGEX, message = SystemValidMessage.DICT_PQ_OTHER_NAME_FORMAT_ERROR)
private String otherName;
@ApiModelProperty("显示名称")
@Pattern(regexp = PatternRegex.DICT_PQ_OTHER_NAME_REGEX, message = SystemValidMessage.DICT_PQ_SHOW_NAME_FORMAT_ERROR)
private String showName;
@ApiModelProperty("排序")

View File

@@ -19,12 +19,12 @@ public class DictTypeParam {
@ApiModelProperty("名称")
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.DICT_TYPE_NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty("编码")
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
@Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.CODE_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.DICT_TYPE_CODE_FORMAT_ERROR)
private String code;

View File

@@ -21,7 +21,8 @@ public interface SystemValidMessage {
String NAME_NOT_BLANK = "名称不能为空请检查name参数";
String NAME_FORMAT_ERROR = "名称格式错误,请检查name参数";
String DICT_TYPE_NAME_FORMAT_ERROR = "名称格式错误,只能包含字母、数字、中文、下划线、中划线、空格长度为1~32个字符";
String DICT_TYPE_CODE_FORMAT_ERROR = "编码格式错误只能包含字母、数字、下划线长度为1~30个字符";
String INDUSTRY_NOT_BLANK = "行业不能为空请检查industry参数";
String INDUSTRY_FORMAT_ERROR = "行业格式错误请检查industry参数";
@@ -29,8 +30,6 @@ public interface SystemValidMessage {
String CODE_NOT_BLANK = "编码不能为空请检查code参数";
String CODE_FORMAT_ERROR = "编码格式错误请检查code参数";
String SORT_NOT_NULL = "排序不能为空请检查sort参数";
String SORT_FORMAT_ERROR = "排序范围在1至999请检查sort参数";
@@ -88,4 +87,8 @@ public interface SystemValidMessage {
String AUTO_GENERATE_FORMAT_ERROR = "是否自动生成格式错误请检查autoGenerate参数";
String USER_ID_FORMAT_ERROR = "用户id格式错误请检查userId参数";
String DICT_DATA_NAME_FORMAT_ERROR = "字典数据名称格式错误只能包含字母、数字、中文、下划线、中划线、空格、点、斜线、反斜线、百分号、摄氏度符号长度为1~32个字符";
String DICT_DATA_CODE_FORMAT_ERROR = "字典数据编码格式错误只能包含字母、数字、中文、下划线、中划线、空格、点、斜线、反斜线、百分号、摄氏度符号长度为1~30个字符";
String DICT_PQ_OTHER_NAME_FORMAT_ERROR = "别名格式错误只能包含字母、数字、中文、下划线、中划线、空格长度最大为32个字符";
String DICT_PQ_SHOW_NAME_FORMAT_ERROR = "显示名称格式错误只能包含字母、数字、中文、下划线、中划线、空格长度最大为32个字符";
}

View File

@@ -44,4 +44,6 @@ public interface UserValidMessage {
String LOGIN_FAILED = "登录失败,用户名或密码错误";
String FUNCTION_NAME_FORMAT_ERROR = "菜单名称格式错误只能包含字母、数字、中文、下划线、中划线、空格长度为1-32个字符";
String FUNCTION_CODE_FORMAT_ERROR = "菜单编码格式错误只能包含字母、数字、下划线、中划线、空格长度为1-32个字符";
}

View File

@@ -13,18 +13,19 @@ public enum UserResponseEnum {
USER_NAME_REPEAT("A010003", "用户名重复请检查name参数"),
REGISTER_EMAIL_FAIL("A010004", "该邮箱已被注册"),
NAME_OR_CODE_REPEAT("A010005", "名称或编码已存在"),
EXISTS_SAME_MENU_CHILDREN("A010006", "当前菜单下已存在相同的菜单"),
EXISTS_SAME_MENU_CHILDREN("A010006", "该层级下已存在相同名称或相同编码或相同路径或相同组件地址的菜单"),
EXISTS_CHILDREN_NOT_UPDATE("A010008", "该菜单下存在子节点,无法将菜单修改为按钮"),
EXISTS_CHILDREN_NOT_DELETE("A010007", "该节点下存在子节点,无法删除"),
SUPER_ADMINSTRATOR_ROLE_CANNOT_UPDATE("A010009", "禁止修改超级管理员角色"),
SUPER_ADMINSTRATOR_ROLE_CANNOT_DELETE("A010009", "禁止删除超级管理员角色"),
SUPER_ADMIN_CANNOT_DELETE("A010010", "禁止删除超级管理员用户"),
COMPONENT_NOT_BLANK("A010011", "组件地址不能为空"),
FUNCTION_PATH_FORMAT_ERROR("A010012", "路由地址格式错误"),
FUNCTION_PATH_FORMAT_ERROR("A010012", "菜单路由地址格式错误只能包含字母、数字、下划线、中划线、空格、斜线、反斜线长度为1-32个字符"),
FUNCTION_COMPONENT_FORMAT_ERROR("A010013","菜单组件地址格式错误只能包含字母、数字、下划线、中划线、空格、斜线、反斜线长度为1-32个字符" ),
SUPER_ADMIN_REPEAT("A010013","超级管理员已存在,请勿重复添加" ),
RSA_DECRYT_ERROR("A010014","RSA解密失败" ),
PASSWORD_SAME("A010015", "新密码不能与旧密码相同"),
OLD_PASSWORD_ERROR("A010016", "旧密码错误");
OLD_PASSWORD_ERROR("A010016", "旧密码错误"), ;
private String code;
private String message;

View File

@@ -25,11 +25,12 @@ public class SysFunctionParam {
@ApiModelProperty("名称")
@NotBlank(message = UserValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.FUNCTION_NAME, message = UserValidMessage.NAME_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.FUNCTION_NAME_REGEX, message = UserValidMessage.FUNCTION_NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty("编码")
@NotBlank(message = UserValidMessage.CODE_NOT_BLANK)
@Pattern(regexp = PatternRegex.FUNCTION_CODE_REGEX, message = UserValidMessage.FUNCTION_CODE_FORMAT_ERROR)
private String code;
@ApiModelProperty("路径")
@@ -58,7 +59,7 @@ public class SysFunctionParam {
@EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam {
@ApiModelProperty("名称")
@Pattern(regexp = PatternRegex.FUNCTION_NAME, message = UserValidMessage.NAME_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.FUNCTION_NAME_REGEX, message = UserValidMessage.FUNCTION_NAME_FORMAT_ERROR)
private String name;
}

View File

@@ -73,7 +73,7 @@ public class SysRoleParam {
@Data
public static class RoleBindFunction {
@ApiModelProperty("角色id")
@NotNull(message = UserValidMessage.ID_NOT_BLANK)
@NotBlank(message = UserValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = UserValidMessage.ID_FORMAT_ERROR)
private String roleId;

View File

@@ -48,6 +48,8 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
@Override
@Transactional
public boolean addFunction(SysFunctionParam functionParam) {
functionParam.setPath(functionParam.getPath().trim());
functionParam.setComponent(functionParam.getComponent().trim());
checkFunctionParam(functionParam, false);
SysFunction function = new SysFunction();
BeanUtil.copyProperties(functionParam, function);
@@ -70,6 +72,8 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
@Transactional
public boolean updateFunction(SysFunctionParam.UpdateParam param) {
boolean result = false;
param.setPath(param.getPath().trim());
param.setComponent(param.getComponent().trim());
checkFunctionParam(param, true);
SysFunction oldFunction = this.lambdaQuery().eq(SysFunction::getId, param.getId()).eq(SysFunction::getState, DataStateEnum.ENABLE.getCode()).one();
List<SysFunction> childrenList = this.lambdaQuery().eq(SysFunction::getPid, param.getId()).eq(SysFunction::getState, DataStateEnum.ENABLE.getCode()).list();
@@ -168,13 +172,23 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
if (StrUtil.isBlank(functionParam.getComponent())) {
throw new BusinessException(UserResponseEnum.COMPONENT_NOT_BLANK);
}
if (StrUtil.isBlank(functionParam.getPath()) || !Pattern.matches(PatternRegex.FUNCTION_URL, functionParam.getPath())) {
if (StrUtil.isBlank(functionParam.getPath()) || !Pattern.matches(PatternRegex.FUNCTION_PATH_REGEX, functionParam.getPath())) {
throw new BusinessException(UserResponseEnum.FUNCTION_PATH_FORMAT_ERROR);
}
if(StrUtil.isBlank(functionParam.getComponent()) || !Pattern.matches(PatternRegex.FUNCTION_COMPONENT_REGEX, functionParam.getComponent())){
throw new BusinessException(UserResponseEnum.FUNCTION_COMPONENT_FORMAT_ERROR);
}
}
LambdaQueryWrapper<SysFunction> functionLambdaQueryWrapper = new LambdaQueryWrapper<>();
// 同一个pid下名称、编码、路径、组件地址不能重复
functionLambdaQueryWrapper.eq(SysFunction::getName, functionParam.getName()).eq(SysFunction::getCode, functionParam.getCode()).eq(SysFunction::getPath, functionParam.getPath()).eq(SysFunction::getComponent, functionParam.getComponent()).eq(SysFunction::getPid, functionParam.getPid()).eq(SysFunction::getState, DataStateEnum.ENABLE.getCode());
functionLambdaQueryWrapper
.eq(SysFunction::getPid, functionParam.getPid())
.eq(SysFunction::getState, DataStateEnum.ENABLE.getCode())
.and(obj -> obj.eq(SysFunction::getName, functionParam.getName()).or()
.eq(SysFunction::getCode, functionParam.getCode()).or()
.eq(SysFunction::getPath, functionParam.getPath()).or()
.eq(SysFunction::getComponent, functionParam.getComponent())
);
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (functionParam instanceof SysFunctionParam.UpdateParam) {

View File

@@ -43,7 +43,11 @@ public class SysRoleFunctionServiceImpl extends ServiceImpl<SysRoleFunctionMappe
roleFunction.setFunctionId(functionId);
roleFunctions.add(roleFunction);
});
return this.saveBatch(roleFunctions);
if (CollectionUtil.isEmpty(roleFunctions)) {
return true;
} else {
return this.saveBatch(roleFunctions);
}
}
@Override