This commit is contained in:
caozehui
2025-03-26 08:52:14 +08:00
parent 22028fe7eb
commit 4ef5c982de
15 changed files with 54 additions and 154 deletions

View File

@@ -85,8 +85,6 @@ public interface DevValidMessage {
String STANDARD_TIME_NOT_BLANK = "标准推行时间不能为空请检查standardTime参数";
String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误请检查scriptType参数";
String SCRIPT_VOLT_FORMAT_ERROR = "检测脚本额定电压格式错误请检查scriptType参数";
String SCRIPT_CURR_FORMAT_ERROR = "检测脚本额定电流格式错误请检查scriptType参数";
String DEV_LEVEL_NOT_BLANK = "设备等级不能为空请检查devLevel参数";

View File

@@ -22,8 +22,6 @@ import java.util.List;
public class PqDevParam {
@ApiModelProperty(value = "名称", required = true)
//@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
//@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@@ -37,13 +35,9 @@ public class PqDevParam {
private String devType;
@ApiModelProperty(value = "设备厂家,字典表", required = true)
//@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MANUFACTURER_FORMAT_ERROR)
private String manufacturer;
@ApiModelProperty(value = "出厂日期", required = true)
//@NotBlank(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
//@DateTimeStrValid(format = "yyyy-MM-dd", message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
private String createDate;
@ApiModelProperty(value = "设备序列号", required = true)
@@ -51,11 +45,9 @@ public class PqDevParam {
private String createId;
@ApiModelProperty(value = "固件版本", required = true)
//@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion;
@ApiModelProperty(value = "软件版本", required = true)
//@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion;
@ApiModelProperty(value = "通讯协议", required = true)
@@ -123,9 +115,6 @@ public class PqDevParam {
@ApiModelProperty("icdId")
private String icdId;
//
// @ApiModelProperty("power")
// private String power;
@ApiModelProperty("预投计划")
private String preinvestmentPlan;
@@ -141,26 +130,6 @@ public class PqDevParam {
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
private String id;
// @ApiModelProperty("检测状态")
// @Min(value = 0, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
// @Max(value = 3, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
// private Integer checkState;
//
// @ApiModelProperty("检测结果")
// @Min(value = 0, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
// @Max(value = 2, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
// private Integer checkResult;
//
// @ApiModelProperty("报告状态")
// @Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
// @Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
// private Integer reportState;
//
// @ApiModelProperty("归档状态")
// @Min(value = 0, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR)
// @Max(value = 1, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR)
// private Integer documentState;
}
/**
@@ -170,7 +139,6 @@ public class PqDevParam {
@EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam {
@ApiModelProperty("名称")
// @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)")
@@ -180,7 +148,6 @@ public class PqDevParam {
private String manufacturer;
@ApiModelProperty("检测计划ID")
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
private String planId;
@ApiModelProperty("检测状态列表")

View File

@@ -32,6 +32,7 @@ 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.storage.service.DetectionDataDealService;
import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
@@ -591,13 +592,16 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
public void exportDev(PqDevParam.QueryParam queryParam) {
String currrentScene = sysTestConfigService.getCurrrentScene();
switch (currrentScene) {
case "0":
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
switch (sceneEnum) {
case PROVINCE_PLATFORM:
this.exportProvinceDev(queryParam);
break;
case "1":
case LEAVE_FACTORY_TEST:
this.exportCNDev(queryParam);
break;
case SELF_TEST:
break;
default:
break;
}
@@ -606,13 +610,16 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
public void downloadTemplate() {
String currrentScene = sysTestConfigService.getCurrrentScene();
switch (currrentScene) {
case "0":
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
switch (sceneEnum) {
case PROVINCE_PLATFORM:
this.downloadProvinceDevTemplate();
break;
case "1":
case LEAVE_FACTORY_TEST:
this.downloadCNDevTemplate();
break;
case SELF_TEST:
break;
default:
break;
}
@@ -622,13 +629,16 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
public void importDev(MultipartFile file, String patternId, String planId, HttpServletResponse response) {
String currrentScene = sysTestConfigService.getCurrrentScene();
switch (currrentScene) {
case "0":
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
switch (sceneEnum) {
case PROVINCE_PLATFORM:
this.importProvinceDev(file, patternId, planId, response);
break;
case "1":
case LEAVE_FACTORY_TEST:
this.importCNDev(file, patternId, planId, response);
break;
case SELF_TEST:
break;
default:
break;
}

View File

@@ -9,4 +9,6 @@ public interface PqIcdPathValidMessage {
String ID_FORMAT_ERROR = "id格式错误请检查id参数";
String NAME_NOT_BLANK = "名称不能为空";
String PATH_NOT_BLANK = "icd存储路径不能为空";
String NAME_FORMAT_ERROR = "名称格式错误只能包含字母、数字、中文、下划线、中划线、点号长度为1-50个字符";
String PATH_FORMAT_ERROR = "ICD路径格式错误";
}

View File

@@ -19,10 +19,12 @@ import javax.validation.constraints.Pattern;
public class PqIcdPathParam {
@ApiModelProperty(value = "名称", required = true)
@NotBlank(message = PqIcdPathValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ICD_NAME_REGEX, message = PqIcdPathValidMessage.NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty(value = "存储路径", required = true)
@NotBlank(message = PqIcdPathValidMessage.PATH_NOT_BLANK)
@Pattern(regexp = PatternRegex.ICD_PATH_REGEX, message = PqIcdPathValidMessage.PATH_FORMAT_ERROR)
private String path;
/**

View File

@@ -105,33 +105,6 @@ public class AdPlanParam {
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
private String id;
/**
* 检测状态,字典表(未检、检测中、检测完成)
*/
// @ApiModelProperty(value = "检测状态")
// @NotNull(message = DeviceValidMessage.TEST_STATE_NOT_NULL)
// @Min(value = 0, message = DeviceValidMessage.TEST_STATE_FORMAT_ERROR)
// @Max(value = 2, message = DeviceValidMessage.TEST_STATE_FORMAT_ERROR)
// private Integer testState;
/**
* 报告生成状态,字典表(未生成、部分生成、全部生成)
*/
// @ApiModelProperty(value = "报告生成状态")
// @NotNull(message = DeviceValidMessage.REPORT_STATE_NOT_NULL)
// @Min(value = 0, message = DeviceValidMessage.REPORT_STATE_FORMAT_ERROR)
// @Max(value = 2, message = DeviceValidMessage.REPORT_STATE_FORMAT_ERROR)
// private Integer reportState;
/**
* 检测结果,字典表(符合、不符合、/
*/
// @ApiModelProperty(value = "检测结果")
// @NotNull(message = DeviceValidMessage.CHECK_RESULT_STATE_NOT_NULL)
// @Min(value = 0, message = DeviceValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
// @Max(value = 2, message = DeviceValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
// private Integer result;
}
@Data

View File

@@ -8,4 +8,10 @@ public interface PqScriptValidMessage {
String INDEX_NOT_NULL = "index不能为空";
String VALUE_TYPE_NOT_BLANK = "脚本值类型不能为空";
String NAME_FORMAT_ERROR = "脚本名称格式错误只能包含字母、数字、中文、下划线、中划线、点号长度为1-50个字符";
String SCRIPT_VOLT_FORMAT_ERROR = "检测脚本额定电压格式错误请检查ratedVolt参数";
String SCRIPT_CURR_FORMAT_ERROR = "检测脚本额定电流格式错误请检查ratedCurr参数";
}

View File

@@ -2,6 +2,7 @@ package com.njcn.gather.script.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage;
import com.njcn.gather.script.pojo.constant.PqScriptValidMessage;
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam;
@@ -20,6 +21,7 @@ public class PqScriptParam {
@ApiModelProperty("名称")
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.SCRIPT_NAME_REGEX, message = PqScriptValidMessage.NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty("类型")
@@ -44,7 +46,6 @@ public class PqScriptParam {
@ApiModelProperty("参照标准名称")
@NotBlank(message = DevValidMessage.STANDARD_NAME_NOT_BLANK)
//@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DevValidMessage.STANDARD_NAME_FORMAT_ERROR)
private String standardName;
@@ -59,8 +60,8 @@ public class PqScriptParam {
*/
@ApiModelProperty("额定电压")
@NotNull(message = DevValidMessage.SCRIPT_TYPE_NOT_BLANK)
@Min(value = 0, message = DevValidMessage.SCRIPT_VOLT_FORMAT_ERROR)
@Max(value = 380, message = DevValidMessage.SCRIPT_VOLT_FORMAT_ERROR)
@Min(value = 0, message = PqScriptValidMessage.SCRIPT_VOLT_FORMAT_ERROR)
@Max(value = 380, message = PqScriptValidMessage.SCRIPT_VOLT_FORMAT_ERROR)
private Double ratedVolt;
/**
@@ -68,8 +69,8 @@ public class PqScriptParam {
*/
@ApiModelProperty("额定电流")
@NotNull(message = DevValidMessage.SCRIPT_TYPE_NOT_BLANK)
@Min(value = 0, message = DevValidMessage.SCRIPT_CURR_FORMAT_ERROR)
@Max(value = 20, message = DevValidMessage.SCRIPT_CURR_FORMAT_ERROR)
@Min(value = 0, message = PqScriptValidMessage.SCRIPT_CURR_FORMAT_ERROR)
@Max(value = 20, message = PqScriptValidMessage.SCRIPT_CURR_FORMAT_ERROR)
private Double ratedCurr;

View File

@@ -51,8 +51,6 @@ public class PqSourceParam {
@ApiModelProperty("源参数")
private String parameter;
// @ApiModelProperty("源参数")
// private List<PqSourceParameterParam> parameterList;
@Data
public static class QueryParam extends BaseParam {

View File

@@ -169,34 +169,6 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
.collect(Collectors.toList());
}
// private List<SourceParam> filterTree(List<SourceParam> tree, String keyword) {
// if (CollectionUtils.isEmpty(tree) || StrUtil.isBlank(keyword)) {
// return tree;
// }
// filter(tree, keyword);
// return tree;
// }
// private void filter(List<SourceParam> list, String keyword) {
// for (int i = list.size() - 1; i >= 0; i--) {
// SourceParam sourceParam = list.get(i);
// List<SourceParam> children = sourceParam.getChildren();
// if (!keyword.equals(sourceParam.getType())) {
// if (!CollectionUtils.isEmpty(children)) {
// filter(children, keyword);
// }
// if (CollectionUtils.isEmpty(sourceParam.getChildren())) {
// list.remove(i);
// }
// }
// else {
// if (!CollectionUtils.isEmpty(children)) {
// filter(children, keyword);
// }
// }
// }
// }
/**
* 生成检测源名称(检测源类型+设备类型+数字)

View File

@@ -121,7 +121,7 @@ public class LogAdvice implements ApplicationListener<ContextRefreshedEvent> {
if (apiOperation != null) {
//注解上的描述
String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
sysLogAudit.setRemark(username + "用户:" + now + " " + apiOperation.value() + " " + resultStr);
sysLogAudit.setRemark(username + ":" + now + " " + apiOperation.value() + " " + resultStr);
}
//Object[] args = joinPoint.getArgs();
logQueue.add(sysLogAudit);

View File

@@ -22,7 +22,9 @@ public enum UserResponseEnum {
COMPONENT_NOT_BLANK("A010011", "组件地址不能为空"),
FUNCTION_PATH_FORMAT_ERROR("A010012", "路由地址格式错误"),
SUPER_ADMIN_REPEAT("A010013","超级管理员已存在,请勿重复添加" ),
RSA_DECRYT_ERROR("A010014","RSA解密失败" );
RSA_DECRYT_ERROR("A010014","RSA解密失败" ),
PASSWORD_SAME("A010015", "新密码不能与旧密码相同"),
OLD_PASSWORD_ERROR("A010016", "旧密码错误");
private String code;
private String message;

View File

@@ -4,13 +4,10 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.constant.SecurityConstants;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.JwtUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.user.pojo.constant.UserValidMessage;
import com.njcn.gather.user.user.pojo.param.SysUserParam;
import com.njcn.gather.user.user.pojo.po.SysUser;
import com.njcn.gather.user.user.service.ISysUserService;
@@ -22,11 +19,9 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@@ -120,21 +115,12 @@ public class SysUserController extends BaseController {
public HttpResult<Object> updatePassword(@RequestBody @Validated SysUserParam.SysUserUpdatePasswordParam param) {
String methodDescribe = getMethodDescribe("updatePassword");
LogUtil.njcnDebug(log, "{}用户id:{},用户旧密码:{},新密码:{}", methodDescribe, param.getId(), param.getOldPassword(), param.getNewPassword());
if (param.getOldPassword().equals(param.getNewPassword())) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "新密码不能与旧密码相同", methodDescribe);
}
boolean result = sysUserService.oldPwdConfirm(param.getId(), param.getOldPassword());
boolean result = sysUserService.updatePassword(param);
if (!result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "原密码错误", methodDescribe);
} else {
result = sysUserService.updatePassword(param.getId(), param.getNewPassword());
if (!result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "修改密码失败", methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
}
}
}
}

View File

@@ -82,22 +82,11 @@ public interface ISysUserService extends IService<SysUser> {
*/
boolean updateUser(SysUserParam.SysUserUpdateParam updateUserParam);
/**
* 原密码确认
*
* @param userId 用户ID
* @param oldPassword 原密码
* @return 结果true表示确认成功false表示确认失败
*/
boolean oldPwdConfirm(String userId, String oldPassword);
/**
* 修改密码
* @param userId
* @param newPassword
* @return 结果true表示修改成功false表示修改失败
*/
boolean updatePassword(String userId, String newPassword);
boolean updatePassword(SysUserParam.SysUserUpdatePasswordParam param);
/**
* 批量删除用户

View File

@@ -144,28 +144,22 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return this.updateById(sysUser);
}
@Override
public boolean oldPwdConfirm(String userId, String oldPassword) {
SysUser user = lambdaQuery().ne(SysUser::getState, UserConst.STATE_DELETE).eq(SysUser::getId, userId).one();
if (ObjectUtil.isNotNull(user)) {
String secretkey = Sm4Utils.globalSecretKey;
Sm4Utils sm4 = new Sm4Utils(secretkey);
if (sm4.encryptData_ECB(oldPassword).equals(user.getPassword())) {
return true;
}
}
return false;
}
@Override
@Transactional
public boolean updatePassword(String userId, String newPassword) {
SysUser user = lambdaQuery().ne(SysUser::getState, UserConst.STATE_DELETE).eq(SysUser::getId, userId).one();
public boolean updatePassword(SysUserParam.SysUserUpdatePasswordParam param) {
if (param.getOldPassword().equals(param.getNewPassword())) {
throw new BusinessException(UserResponseEnum.PASSWORD_SAME);
}
SysUser user = lambdaQuery().ne(SysUser::getState, UserConst.STATE_DELETE).eq(SysUser::getId, param.getId()).one();
if (ObjectUtil.isNotNull(user)) {
String secretkey = Sm4Utils.globalSecretKey;
Sm4Utils sm4 = new Sm4Utils(secretkey);
user.setPassword(sm4.encryptData_ECB(newPassword));
if (sm4.encryptData_ECB(param.getOldPassword()).equals(user.getPassword())) {
user.setPassword(sm4.encryptData_ECB(param.getNewPassword()));
return this.updateById(user);
}else {
throw new BusinessException(UserResponseEnum.OLD_PASSWORD_ERROR);
}
}
return false;
}