diff --git a/detection/src/main/java/com/njcn/gather/plan/controller/AdPlanController.java b/detection/src/main/java/com/njcn/gather/plan/controller/AdPlanController.java index 010fd26f..20f7bd56 100644 --- a/detection/src/main/java/com/njcn/gather/plan/controller/AdPlanController.java +++ b/detection/src/main/java/com/njcn/gather/plan/controller/AdPlanController.java @@ -148,9 +148,9 @@ public class AdPlanController extends BaseController { @ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true), @ApiImplicitParam(name = "pattern", value = "模式Id", required = true) }) - public HttpResult importData(@RequestParam("file") MultipartFile file, @RequestParam("pattern") String pattern, HttpServletResponse response) { + public HttpResult importData(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) { String methodDescribe = getMethodDescribe("importData"); - LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为:{}", methodDescribe, file.getOriginalFilename(), pattern); + LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为:{}", methodDescribe, file.getOriginalFilename(), patternId); ImportParams params = new ImportParams(); params.setHeadRows(2); @@ -166,25 +166,25 @@ public class AdPlanController extends BaseController { } else { List adPlanExcelList = adPlanExcelResult.getList(); if (ObjectUtil.isNotEmpty(adPlanExcelList)) { - adPlanService.importData(pattern,adPlanExcelList); + adPlanService.importData(patternId,adPlanExcelList); } } } catch (Exception e) { - throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL); + throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL, e.getMessage()); } return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } - @OperateInfo - @GetMapping("/getPieData") - @ApiOperation("获取饼状图数据") - @ApiImplicitParam(name = "id", value = "检测计划id", required = true) - public HttpResult>>> getPieData(@RequestParam("planId") String planId) { - String methodDescribe = getMethodDescribe("getPieData"); - LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId); - List>> result = pqDevService.getPieData(planId); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); - } +// @OperateInfo +// @GetMapping("/getPieData") +// @ApiOperation("获取饼状图数据") +// @ApiImplicitParam(name = "id", value = "检测计划id", required = true) +// public HttpResult>>> getPieData(@RequestParam("planId") String planId) { +// String methodDescribe = getMethodDescribe("getPieData"); +// LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId); +// List>> result = pqDevService.getPieData(planId); +// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); +// } } diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanExcel.java b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanExcel.java index dc8620ee..4b30d654 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanExcel.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanExcel.java @@ -25,19 +25,19 @@ public class AdPlanExcel { @NotBlank(message = DevValidMessage.NAME_NOT_BLANK) private String name; - @Excel(name = "检测源", width = 40, needMerge = true, orderNum = "2") + @Excel(name = "检测源", width = 40, needMerge = true, orderNum = "1") @NotBlank(message = DevValidMessage.SOURC_NOT_BLANK) private String source; - @Excel(name = "数据源", width = 20, needMerge = true, orderNum = "4") + @Excel(name = "数据源", width = 20, needMerge = true, orderNum = "2") @NotBlank(message = DevValidMessage.DATASOURCE_NOT_BLANK) private String datasourceId; - @Excel(name = "脚本", width = 50, needMerge = true, orderNum = "5") + @Excel(name = "脚本", width = 50, needMerge = true, orderNum = "3") @NotBlank(message = DevValidMessage.SCRIPT_NOT_BLANK) private String scriptId; - @Excel(name = "误差体系", width = 30, needMerge = true, orderNum = "6") + @Excel(name = "误差体系", width = 30, needMerge = true, orderNum = "4") @NotBlank(message = DevValidMessage.ERRORSYS_NOT_BLANK) private String errorSysId; @@ -45,40 +45,52 @@ public class AdPlanExcel { @Data @EqualsAndHashCode(callSuper = true) public static class ExportData extends AdPlanExcel { - @Excel(name = "模式", width = 20, needMerge = true, orderNum = "1") - @NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK) - private String pattern; +// @Excel(name = "模式", width = 20, needMerge = true, orderNum = "1") +// @NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK) +// private String pattern; - @Excel(name = "父计划id", width = 25, needMerge = true, orderNum = "3") - private String fatherPlanId; +// @Excel(name = "父计划id", width = 25, needMerge = true, orderNum = "3") +// private String fatherPlanId; - @Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7") + @Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5") private Integer timeCheck; - @Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "8") + @Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6") private Integer testState; - @Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "9") + @Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7") private Integer reportState; - @Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "10") + @Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8") private Integer result; - @Excel(name = "数据表后缀", width = 20, needMerge = true, orderNum = "11") - private Integer code; +// @Excel(name = "数据表后缀", width = 20, needMerge = true, orderNum = "11") +// private Integer code; - @ExcelCollection(name = "绑定的设备", orderNum = "12") + @ExcelCollection(name = "绑定的设备", orderNum = "9") private List devices; } @Data @EqualsAndHashCode(callSuper = true) public static class ImportData extends AdPlanExcel { - @Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7") - @NotNull(message = DevValidMessage.TIMECHECK_NOT_BLANK) + @Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5") + @NotBlank(message = DevValidMessage.TIMECHECK_NOT_BLANK) private String timeCheck; - @ExcelCollection(name = "绑定的设备", orderNum = "13") + @Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6") + @NotBlank(message = DevValidMessage.TEST_STATE_NOT_NULL) + private String testState; + + @Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7") + @NotBlank(message = DevValidMessage.REPORT_STATE_NOT_NULL) + private String reportState; + + @Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8") + @NotBlank(message = DevValidMessage.CHECK_RESULT_STATE_NOT_NULL) + private String result; + + @ExcelCollection(name = "绑定的设备", orderNum = "9") private List devices; } diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index 783f593f..62f83058 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -82,6 +82,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addAdPlan(AdPlanParam param) { AdPlan adPlan = new AdPlan(); BeanUtil.copyProperties(param, adPlan); @@ -115,6 +116,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updateAdPlan(AdPlanParam.UpdateParam param) { AdPlan adPlan = new AdPlan(); BeanUtil.copyProperties(param, adPlan); @@ -123,18 +125,14 @@ public class AdPlanServiceImpl extends ServiceImpl impleme // 修改检测计划、检测源关联 adPlanSourceService.updateAdPlanSource(param.getId(), param.getSourceIds()); - // 修改时,只有未检测过的设备才可以修改绑定设备 - List unCheckedIds = pqDevService.listUnchecked().stream().map(PqDev::getId).collect(Collectors.toList()); - if (unCheckedIds.containsAll(param.getDevIds())) { - pqDevService.bind(param.getId(), param.getDevIds()); - } else { - throw new BusinessException(DevResponseEnum.HAS_NOT_UNCHECKED_DEVICE); - } + + pqDevService.bind(param.getId(), param.getDevIds()); return this.updateById(adPlan); } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deleteAdPlan(List ids) { for (String id : ids) { PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam(); @@ -274,14 +272,14 @@ public class AdPlanServiceImpl extends ServiceImpl impleme */ private void visualize(List planList) { planList.forEach(adPlan -> { - if (StrUtil.isNotBlank(adPlan.getPattern())) { - adPlan.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName()); - } - if (CommonEnum.FATHER_ID.getValue().equals(adPlan.getFatherPlanId())) { - adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getMsg()); - } else { - adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getName()); - } +// if (StrUtil.isNotBlank(adPlan.getPattern())) { +// adPlan.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName()); +// } +// if (CommonEnum.FATHER_ID.getValue().equals(adPlan.getFatherPlanId())) { +// adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getMsg()); +// } else { +// adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getName()); +// } if (StrUtil.isNotBlank(adPlan.getDatasourceId())) { String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA); adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> DataSourceEnum.getMsgByValue(id)).collect(Collectors.joining(StrUtil.COMMA))); diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanSourceServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanSourceServiceImpl.java index a54fae35..9d24b729 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanSourceServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanSourceServiceImpl.java @@ -9,6 +9,7 @@ import com.njcn.gather.device.source.pojo.po.PqSource; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; @@ -31,6 +32,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl sourceIds) { List adPlanSourceList = new ArrayList<>(); for (String sourceId : sourceIds) { @@ -40,6 +42,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl planIds) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.in("ad_plan_source.Plan_Id", planIds); @@ -47,6 +50,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl sourceIds) { this.deleteAdPlanSourceByPlanIds(Collections.singletonList(planId)); this.addAdPlanSource(planId, sourceIds); diff --git a/device/src/main/java/com/njcn/gather/device/device/controller/PqDevController.java b/device/src/main/java/com/njcn/gather/device/device/controller/PqDevController.java index a7217ae7..319f199c 100644 --- a/device/src/main/java/com/njcn/gather/device/device/controller/PqDevController.java +++ b/device/src/main/java/com/njcn/gather/device/device/controller/PqDevController.java @@ -39,7 +39,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -215,6 +214,21 @@ public class PqDevController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE) + @GetMapping("/documented") + @ApiOperation("设备归档") + @ApiImplicitParam(name = "id", value = "设备id", required = true) + public HttpResult> documented(@RequestParam String id) { + String methodDescribe = getMethodDescribe("documented"); + LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, id); + boolean result = pqDevService.documented(id); + if (result) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } else { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); + } + } + // @OperateInfo(operateType = OperateType.UPDATE) // @PostMapping("/bindDev") // @ApiOperation("检测计划绑定设备") @@ -229,15 +243,4 @@ public class PqDevController extends BaseController { // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); // } // } - -// @OperateInfo(info = LogEnum.BUSINESS_COMMON) -// @PostMapping("/listUnDocumentByPlanId") -// @ApiOperation("根据检测计划id查询出所有已绑定(未归档)的设备") -// @ApiImplicitParam(name = "planId", value = "计划id", required = true) -// public HttpResult> listUnDocumentByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) { -// String methodDescribe = getMethodDescribe("listUnDocumentByPlanId"); -// LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param); -// List result = pqDevService.listUnDocumentByPlanId(param); -// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); -// } } diff --git a/device/src/main/java/com/njcn/gather/device/device/pojo/param/PqDevParam.java b/device/src/main/java/com/njcn/gather/device/device/pojo/param/PqDevParam.java index 53ef44fb..024c98af 100644 --- a/device/src/main/java/com/njcn/gather/device/device/pojo/param/PqDevParam.java +++ b/device/src/main/java/com/njcn/gather/device/device/pojo/param/PqDevParam.java @@ -196,6 +196,12 @@ public class PqDevParam { @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; + } @Data diff --git a/device/src/main/java/com/njcn/gather/device/device/pojo/vo/PqDevExcel.java b/device/src/main/java/com/njcn/gather/device/device/pojo/vo/PqDevExcel.java index 11cd0f79..80021001 100644 --- a/device/src/main/java/com/njcn/gather/device/device/pojo/vo/PqDevExcel.java +++ b/device/src/main/java/com/njcn/gather/device/device/pojo/vo/PqDevExcel.java @@ -81,10 +81,10 @@ public class PqDevExcel implements Serializable { @NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL) private Integer encryptionFlag; - @Excel(name = "识别码", width = 30, orderNum = "15", needMerge = true) + @Excel(name = "识别码(当为加密版本时必填)", width = 30, orderNum = "15", needMerge = true) private String series; - @Excel(name = "秘钥", width = 30, orderNum = "16", needMerge = true) + @Excel(name = "秘钥(当为加密版本时必填)", width = 30, orderNum = "16", needMerge = true) private String devKey; @Excel(name = "所属地市名称", width = 20, orderNum = "19", needMerge = true) diff --git a/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java b/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java index 647e2adc..99fb61ae 100644 --- a/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java +++ b/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java @@ -126,7 +126,7 @@ public interface IPqDevService extends IService { * @param planId 检测计划id * @return 饼图数据 */ - List>> getPieData(String planId); + //List>> getPieData(String planId); /** * 根据id获取被检设备信息 @@ -165,4 +165,10 @@ public interface IPqDevService extends IService { */ List getDevInfo(@Param("devIds") List devIds); + /** + * 设备归档操作 + * @param id 设备id + * @return 归档成功返回true,否则返回false + */ + boolean documented(String id); } diff --git a/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java b/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java index 5cbf29f3..d6ddbabb 100644 --- a/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java @@ -31,6 +31,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; @@ -62,6 +63,7 @@ public class PqDevServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addPqDev(PqDevParam pqDevParam) { this.checkRepeat(pqDevParam, false); @@ -95,6 +97,7 @@ public class PqDevServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updatePqDev(PqDevParam.UpdateParam updateParam) { this.checkRepeat(updateParam, true); @@ -116,6 +119,7 @@ public class PqDevServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deletePqDev(PqDevParam.DeleteParam param) { if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(param.getPattern()).getCode())) { for (String id : param.getIds()) { @@ -128,6 +132,7 @@ public class PqDevServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updatePqDevTimeCheckResult(List ids, TimeCheckResultEnum result) { return this.lambdaUpdate().set(PqDev::getTimeCheckResult, result.getValue()).in(PqDev::getId, ids).update(); } @@ -169,6 +174,7 @@ public class PqDevServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = {Exception.class}) public void importContrastData(List pqDevExcelList) { List devList = new ArrayList<>(); List monitorList = new ArrayList<>(); @@ -207,6 +213,7 @@ public class PqDevServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = {Exception.class}) public void importSimulateAndDigitalData(List pqDevExcelList) { List pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class); //逆向可视化 @@ -230,9 +237,11 @@ public class PqDevServiceImpl extends ServiceImpl implements public List listByPlanId(PqDevParam.QueryParam param) { List pqDevList = this.lambdaQuery() .eq(StrUtil.isNotBlank(param.getPlanId()), PqDev::getPlanId, param.getPlanId()) - .eq(StrUtil.isNotBlank(param.getName()), PqDev::getName, param.getName()) + .like(StrUtil.isNotBlank(param.getName()), PqDev::getName, param.getName()) .in(ObjectUtil.isNotEmpty(param.getCheckStateList()), PqDev::getCheckState, param.getCheckStateList()) .eq(ObjectUtil.isNotNull(param.getCheckResult()), PqDev::getCheckResult, param.getCheckResult()) + .eq(ObjectUtil.isNotNull(param.getCheckResult()), PqDev::getCheckResult, param.getCheckResult()) + .eq(ObjectUtil.isNotNull(param.getReportState()), PqDev::getReportState, param.getReportState()) .eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list(); // List> result = pqDevList.stream().map(pqDev -> { // Map map = new HashMap<>(); @@ -244,6 +253,7 @@ public class PqDevServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean bind(String planId, List devIds) { this.lambdaUpdate().set(PqDev::getPlanId, null).eq(PqDev::getPlanId, planId).update(); @@ -254,23 +264,23 @@ public class PqDevServiceImpl extends ServiceImpl implements return true; } - @Override - public List getPieData(String planId) { - List pqDevList = this.lambdaQuery().eq(PqDev::getPlanId, planId).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list(); - Map checkStateMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getCheckState, Collectors.counting())); - Map checkResultMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getCheckResult, Collectors.counting())); - Map reportStateMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getReportState, Collectors.counting())); - - List> checkStateData = getCheckStatePieData(checkStateMap); - List> checkResultData = getCheckResultPieData(checkResultMap); - List> reportStateData = getReportStatePieData(reportStateMap); - - List>> result = new ArrayList<>(); - result.add(checkStateData); - result.add(checkResultData); - result.add(reportStateData); - return result; - } +// @Override +// public List getPieData(String planId) { +// List pqDevList = this.lambdaQuery().eq(PqDev::getPlanId, planId).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list(); +// Map checkStateMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getCheckState, Collectors.counting())); +// Map checkResultMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getCheckResult, Collectors.counting())); +// Map reportStateMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getReportState, Collectors.counting())); +// +// List> checkStateData = getCheckStatePieData(checkStateMap); +// List> checkResultData = getCheckResultPieData(checkResultMap); +// List> reportStateData = getReportStatePieData(reportStateMap); +// +// List>> result = new ArrayList<>(); +// result.add(checkStateData); +// result.add(checkResultData); +// result.add(reportStateData); +// return result; +// } @Override public PqDevVO getPqDevById(String id) { @@ -396,22 +406,37 @@ public class PqDevServiceImpl extends ServiceImpl implements return this.baseMapper.selectDevInfo(devIds); } + @Override + @Transactional(rollbackFor = {Exception.class}) + public boolean documented(String id) { + // 只有检测完成的设备才可以进行归档 + PqDev pqDev = this.getById(id); + if (ObjectUtil.isNotNull(pqDev) && !pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) { + return this.lambdaUpdate() + .set(PqDev::getDocumentState, DevDocumentStateEnum.DOCUMENTED.getValue()) + .set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue()) + .eq(PqDev::getId, id) + .update(); + } + return false; + } + /** * 获取检测状态饼状图数据 * * @param map 检测状态分组map * @return 检测状态饼状图数据 */ - private List> getCheckStatePieData(Map map) { - List> result = new ArrayList<>(); - for (CheckStateEnum e : CheckStateEnum.values()) { - Map temp = new HashMap<>(); - temp.put("name", e.getMsg()); - temp.put("value", map.getOrDefault(e.getValue(), 0L)); - result.add(temp); - } - return result; - } +// private List> getCheckStatePieData(Map map) { +// List> result = new ArrayList<>(); +// for (CheckStateEnum e : CheckStateEnum.values()) { +// Map temp = new HashMap<>(); +// temp.put("name", e.getMsg()); +// temp.put("value", map.getOrDefault(e.getValue(), 0L)); +// result.add(temp); +// } +// return result; +// } /** * 获取检测结果饼状图数据 @@ -419,16 +444,16 @@ public class PqDevServiceImpl extends ServiceImpl implements * @param map 检测结果分组map * @return 检测结果饼状图数据 */ - private List> getCheckResultPieData(Map map) { - List> result = new ArrayList<>(); - for (CheckResultEnum e : CheckResultEnum.values()) { - Map temp = new HashMap<>(); - temp.put("name", e.getMsg()); - temp.put("value", map.getOrDefault(e.getValue(), 0L)); - result.add(temp); - } - return result; - } +// private List> getCheckResultPieData(Map map) { +// List> result = new ArrayList<>(); +// for (CheckResultEnum e : CheckResultEnum.values()) { +// Map temp = new HashMap<>(); +// temp.put("name", e.getMsg()); +// temp.put("value", map.getOrDefault(e.getValue(), 0L)); +// result.add(temp); +// } +// return result; +// } /** * 获取报告状态饼状图数据 @@ -436,16 +461,16 @@ public class PqDevServiceImpl extends ServiceImpl implements * @param map 报告状态分组map * @return 报告状态饼状图数据 */ - private List> getReportStatePieData(Map map) { - List> result = new ArrayList<>(); - for (DevReportStateEnum e : DevReportStateEnum.values()) { - Map temp = new HashMap<>(); - temp.put("name", e.getMsg()); - temp.put("value", map.getOrDefault(e.getValue(), 0L)); - result.add(temp); - } - return result; - } +// private List> getReportStatePieData(Map map) { +// List> result = new ArrayList<>(); +// for (DevReportStateEnum e : DevReportStateEnum.values()) { +// Map temp = new HashMap<>(); +// temp.put("name", e.getMsg()); +// temp.put("value", map.getOrDefault(e.getValue(), 0L)); +// result.add(temp); +// } +// return result; +// } /** * 检查设备是否重复 diff --git a/device/src/main/java/com/njcn/gather/device/err/service/impl/PqErrSysDtlsServiceImpl.java b/device/src/main/java/com/njcn/gather/device/err/service/impl/PqErrSysDtlsServiceImpl.java index 9809583e..a3e6e836 100644 --- a/device/src/main/java/com/njcn/gather/device/err/service/impl/PqErrSysDtlsServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/err/service/impl/PqErrSysDtlsServiceImpl.java @@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; @@ -30,6 +31,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl list) { List data = new ArrayList<>(); for (PqErrSysDtlsParam param : list) { @@ -42,6 +44,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl list) { //先按照pqErrSysId全部删除 this.deletePqErrSysDtlsByPqErrSysId(Collections.singletonList(pqErrSysId)); @@ -51,6 +54,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl pqErrSysIds) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.in("pq_err_sys_dtls.Error_Sys_Id", pqErrSysIds); diff --git a/device/src/main/java/com/njcn/gather/device/err/service/impl/PqErrSysServiceImpl.java b/device/src/main/java/com/njcn/gather/device/err/service/impl/PqErrSysServiceImpl.java index c7fa8b6a..3a97aaab 100644 --- a/device/src/main/java/com/njcn/gather/device/err/service/impl/PqErrSysServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/err/service/impl/PqErrSysServiceImpl.java @@ -25,6 +25,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.util.*; @@ -63,6 +64,7 @@ public class PqErrSysServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addPqErrSys(PqErrSysParam param) { PqErrSys pqErrSys = new PqErrSys(); BeanUtils.copyProperties(param, pqErrSys); @@ -77,6 +79,7 @@ public class PqErrSysServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) { PqErrSys pqErrSys = new PqErrSys(); BeanUtils.copyProperties(param, pqErrSys); @@ -88,6 +91,7 @@ public class PqErrSysServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deletePqErrSys(List ids) { pqErrSysDtlsService.deletePqErrSysDtlsByPqErrSysId(ids); this.lambdaUpdate().in(PqErrSys::getId, ids).set(PqErrSys::getState, DataStateEnum.DELETED.getCode()).update(); @@ -112,6 +116,7 @@ public class PqErrSysServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public List> listAllPqErrSys() { List pqErrSysList = this.lambdaQuery().eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).list(); List> result = pqErrSysList.stream().map(pqErrSys -> { diff --git a/device/src/main/java/com/njcn/gather/device/monitor/service/impl/PqMonitorServiceImpl.java b/device/src/main/java/com/njcn/gather/device/monitor/service/impl/PqMonitorServiceImpl.java index 02ef5046..d55a0051 100644 --- a/device/src/main/java/com/njcn/gather/device/monitor/service/impl/PqMonitorServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/monitor/service/impl/PqMonitorServiceImpl.java @@ -15,6 +15,7 @@ import com.njcn.gather.system.dictionary.service.IDictDataService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; @@ -38,6 +39,7 @@ public class PqMonitorServiceImpl extends ServiceImpl pqMonitorParamList) { List pqMonitorList = BeanUtil.copyToList(pqMonitorParamList, PqMonitor.class); pqMonitorList.forEach(pqMonitor -> pqMonitor.setDevId(devId)); @@ -45,6 +47,7 @@ public class PqMonitorServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("pq_monitor.Dev_Id", devId); @@ -52,6 +55,7 @@ public class PqMonitorServiceImpl extends ServiceImpl paramList) { // 先删除原有数据 this.deletePqMonitorByDevId(devId); diff --git a/device/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java b/device/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java index c7a81a96..d49a881b 100644 --- a/device/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java +++ b/device/src/main/java/com/njcn/gather/device/pojo/constant/DevValidMessage.java @@ -196,7 +196,7 @@ public interface DevValidMessage { String ERRORSYS_NOT_BLANK = "误差体系不能为空"; - String TIMECHECK_NOT_BLANK = "守时检测不能为空"; + String TIMECHECK_NOT_BLANK = "是否做守时检测不能为空"; String FACTOR_FLAG_NOT_BLANK = "是否支持系数校准不能为空"; } diff --git a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java index f2a50b06..d2ef1149 100644 --- a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java @@ -17,6 +17,7 @@ import com.njcn.gather.device.script.service.IPqScriptDtlsService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; @@ -45,11 +46,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl ids) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(PqScriptDtls::getId, ids); @@ -57,6 +60,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl scriptIds) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(PqScriptDtls::getScriptId, scriptIds); @@ -64,6 +68,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addPqScript(PqScriptParam param) { PqScript pqScript = new PqScript(); BeanUtils.copyProperties(param, pqScript); @@ -63,6 +65,7 @@ public class PqScriptServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updatePqScript(PqScriptParam.UpdateParam param) { PqScript pqScript = new PqScript(); BeanUtils.copyProperties(param, pqScript); @@ -71,6 +74,7 @@ public class PqScriptServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deletePqScript(List ids) { //删除对应的脚本详情 pqScriptDtlsService.deletePqScriptDtlsByScriptId(ids); @@ -81,6 +85,7 @@ public class PqScriptServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean upgradeToTemplate(String id) { PqScript pqScript = this.lambdaQuery().eq(PqScript::getId, id).one(); if (pqScript != null) { diff --git a/device/src/main/java/com/njcn/gather/device/source/service/impl/PqSourceServiceImpl.java b/device/src/main/java/com/njcn/gather/device/source/service/impl/PqSourceServiceImpl.java index 7eb2411b..212fb3ab 100644 --- a/device/src/main/java/com/njcn/gather/device/source/service/impl/PqSourceServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/source/service/impl/PqSourceServiceImpl.java @@ -24,6 +24,7 @@ import com.njcn.web.factory.PageFactory; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; @@ -59,6 +60,7 @@ public class PqSourceServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addPqSource(PqSourceParam param) { PqSource pqSource = new PqSource(); BeanUtil.copyProperties(param, pqSource); @@ -69,6 +71,7 @@ public class PqSourceServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updatePqSource(PqSourceParam.UpdateParam param) { PqSource pqSource = new PqSource(); BeanUtil.copyProperties(param, pqSource); @@ -77,6 +80,7 @@ public class PqSourceServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deletePqSource(List ids) { return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update(); } diff --git a/system/src/main/java/com/njcn/gather/system/config/service/impl/SysTestConfigServiceImpl.java b/system/src/main/java/com/njcn/gather/system/config/service/impl/SysTestConfigServiceImpl.java index e3ce90fd..7ea157b5 100644 --- a/system/src/main/java/com/njcn/gather/system/config/service/impl/SysTestConfigServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/config/service/impl/SysTestConfigServiceImpl.java @@ -11,6 +11,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * @author caozehui @@ -27,6 +28,7 @@ public class SysTestConfigServiceImpl extends ServiceImpl i @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addDictData(DictDataParam dictDataParam) { checkDicDataName(dictDataParam, false); DictData dictData = new DictData(); @@ -76,6 +78,7 @@ public class DictDataServiceImpl extends ServiceImpl i @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updateDictData(DictDataParam.UpdateParam updateParam) { checkDicDataName(updateParam, true); DictData dictData = new DictData(); @@ -84,6 +87,7 @@ public class DictDataServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deleteDictData(List ids) { return this.lambdaUpdate() .set(DictData::getState, DataStateEnum.DELETED.getCode()) @@ -146,6 +150,7 @@ public class DictDataServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public void exportDictData(DictDataParam.QueryParam queryParam) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtil.isNotNull(queryParam)) { @@ -167,11 +172,9 @@ public class DictDataServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deleteDictDataByDictTypeId(List ids) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("sys_dict_data.type_id", ids) - .ne("sys_dict_data.state", DataStateEnum.DELETED.getCode()); - return this.remove(queryWrapper); + return this.lambdaUpdate().in(DictData::getTypeId, ids).set(DictData::getState, DataStateEnum.DELETED.getCode()).update(); } diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictPqServiceImpl.java b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictPqServiceImpl.java index 1d02829f..a442246c 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictPqServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictPqServiceImpl.java @@ -19,6 +19,7 @@ import com.njcn.gather.system.pojo.enums.SystemResponseEnum; import com.njcn.web.factory.PageFactory; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -55,6 +56,7 @@ public class DictPqServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addDictPq(DictPqParam dictPqParam) { checkDicPqName(dictPqParam, false); DictPq dictPq = new DictPq(); @@ -65,6 +67,7 @@ public class DictPqServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updateDictPq(DictPqParam.UpdateParam updateParam) { checkDicPqName(updateParam, true); DictPq dictPq = new DictPq(); @@ -73,6 +76,7 @@ public class DictPqServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deleteDictPq(List ids) { dictDataService.deleteDictDataByDictTypeId(ids); return this.lambdaUpdate() diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTreeServiceImpl.java b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTreeServiceImpl.java index f1bedb14..2758739d 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTreeServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTreeServiceImpl.java @@ -71,6 +71,7 @@ public class DictTreeServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updateDictTree(DictTreeParam.UpdateParam param) { boolean result; DictTree dictTree = new DictTree(); @@ -83,6 +84,7 @@ public class DictTreeServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deleteDictTree(String id) { boolean result = false; List childrenList = this.lambdaQuery().eq(DictTree::getState, DictConst.ENABLE).eq(DictTree::getPid, id).list(); diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTypeServiceImpl.java b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTypeServiceImpl.java index 6682d0b9..b5c429c7 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTypeServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTypeServiceImpl.java @@ -21,6 +21,7 @@ import com.njcn.web.factory.PageFactory; import com.njcn.web.utils.ExcelUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -54,6 +55,7 @@ public class DictTypeServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addDictType(DictTypeParam dictTypeParam) { checkDicTypeName(dictTypeParam, false); DictType dictType = new DictType(); @@ -64,6 +66,7 @@ public class DictTypeServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updateDictType(DictTypeParam.UpdateParam updateParam) { checkDicTypeName(updateParam, true); DictType dictType = new DictType(); @@ -72,6 +75,7 @@ public class DictTypeServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deleteDictType(List ids) { dictDataService.deleteDictDataByDictTypeId(ids); return this.lambdaUpdate() diff --git a/system/src/main/java/com/njcn/gather/system/reg/service/impl/SysRegResServiceImpl.java b/system/src/main/java/com/njcn/gather/system/reg/service/impl/SysRegResServiceImpl.java index 53ea0590..ae0f7e87 100644 --- a/system/src/main/java/com/njcn/gather/system/reg/service/impl/SysRegResServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/reg/service/impl/SysRegResServiceImpl.java @@ -11,6 +11,7 @@ import com.njcn.gather.system.reg.service.ISysRegResService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.Map; @@ -30,6 +31,7 @@ public class SysRegResServiceImpl extends ServiceImpl functionIds) { List roleFunctions = new ArrayList<>(); if (!CollectionUtil.isEmpty(functionIds)) { @@ -44,6 +46,7 @@ public class SysRoleFunctionServiceImpl extends ServiceImpl functionIds) { //删除原有关系 this.deleteRoleFunctionByRoleIds(Collections.singletonList(roleId)); @@ -59,6 +62,7 @@ public class SysRoleFunctionServiceImpl extends ServiceImpl roleIds) { LambdaQueryWrapper lambdaQuery = new LambdaQueryWrapper<>(); lambdaQuery.in(SysRoleFunction::getRoleId, roleIds); @@ -66,6 +70,7 @@ public class SysRoleFunctionServiceImpl extends ServiceImpl functionIds) { LambdaQueryWrapper lambdaQuery = new LambdaQueryWrapper<>(); lambdaQuery.in(SysRoleFunction::getFunctionId, functionIds); diff --git a/user/src/main/java/com/njcn/gather/user/user/service/impl/SysRoleServiceImpl.java b/user/src/main/java/com/njcn/gather/user/user/service/impl/SysRoleServiceImpl.java index e6458e2b..32db09b7 100644 --- a/user/src/main/java/com/njcn/gather/user/user/service/impl/SysRoleServiceImpl.java +++ b/user/src/main/java/com/njcn/gather/user/user/service/impl/SysRoleServiceImpl.java @@ -21,6 +21,7 @@ import com.njcn.web.factory.PageFactory; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -52,6 +53,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addRole(SysRoleParam sysRoleParam) { checkRepeat(sysRoleParam, false); SysRole role = new SysRole(); @@ -62,6 +64,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updateRole(SysRoleParam.UpdateParam updateParam) { checkRepeat(updateParam, true); //不能修改超级管理员角色 @@ -77,6 +80,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deleteRole(List ids) { //不能删除超级管理员角色 Integer count = this.lambdaQuery() diff --git a/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserRoleServiceImpl.java b/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserRoleServiceImpl.java index 7251a608..5788df26 100644 --- a/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserRoleServiceImpl.java +++ b/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserRoleServiceImpl.java @@ -10,6 +10,7 @@ import com.njcn.gather.user.user.service.ISysUserRoleService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; @@ -30,6 +31,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl roleIds) { List userRoles = new ArrayList<>(); if (!CollectionUtil.isEmpty(roleIds)) { @@ -44,6 +46,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl roleIds) { //删除原有关系 this.deleteUserRoleByUserIds(Collections.singletonList(userId)); @@ -59,6 +62,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl userIds) { LambdaQueryWrapper lambdaQuery = new LambdaQueryWrapper<>(); lambdaQuery.in(SysUserRole::getUserId, userIds); @@ -66,6 +70,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl roleIds) { LambdaQueryWrapper lambdaQuery = new LambdaQueryWrapper<>(); lambdaQuery.in(SysUserRole::getRoleId, roleIds); diff --git a/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserServiceImpl.java b/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserServiceImpl.java index 2a38684d..803384ae 100644 --- a/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserServiceImpl.java +++ b/user/src/main/java/com/njcn/gather/user/user/service/impl/SysUserServiceImpl.java @@ -25,6 +25,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Collections; import java.util.List; @@ -111,6 +112,7 @@ public class SysUserServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean addUser(SysUserParam.SysUserAddParam addUserParam) { if (UserConst.SUPER_ADMIN.equals(addUserParam.getLoginName())) { throw new BusinessException(UserResponseEnum.SUPER_ADMIN_REPEAT); @@ -134,6 +136,7 @@ public class SysUserServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updateUser(SysUserParam.SysUserUpdateParam updateUserParam) { checkRepeat(updateUserParam, true, updateUserParam.getId()); SysUser sysUser = new SysUser(); @@ -156,6 +159,7 @@ public class SysUserServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean updatePassword(String userId, String newPassword) { SysUser user = lambdaQuery().ne(SysUser::getState, UserConst.STATE_DELETE).eq(SysUser::getId, userId).one(); if (ObjectUtil.isNotNull(user)) { @@ -168,6 +172,7 @@ public class SysUserServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = {Exception.class}) public boolean deleteUser(List ids) { for (String id : ids) { List sysRoles = sysUserRoleService.listRoleByUserId(id);