策略代码提交

This commit is contained in:
wurui
2023-03-21 16:28:46 +08:00
parent 883524e182
commit f36bb0dc4d
12 changed files with 138 additions and 72 deletions

View File

@@ -34,6 +34,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -86,7 +87,7 @@ implements RMpPwAlarmDetailDService{
//配网监测点id集合 //配网监测点id集合
List<String> pwMonitorIds = pwMonitorList.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList()); List<String> pwMonitorIds = pwMonitorList.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList());
//配网监测点Map集合 //配网监测点Map集合
Map<String, PwPmsMonitorDTO> pwMonitorMap = pwMonitorList.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, item -> item)); Map<String, PwPmsMonitorDTO> pwMonitorMap = pwMonitorList.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, Function.identity(),(Key1, kye2) -> Key1));
//合并主网配网监测点id集合并去重 //合并主网配网监测点id集合并去重

View File

@@ -18,7 +18,8 @@ public enum ProcessResponseEnum {
PROCESS_COMMON_ERROR("A00550","监督管理模块异常"), PROCESS_COMMON_ERROR("A00550","监督管理模块异常"),
ARCHIVE_ERROR("A00552","不满足归档调节,操作失败!"), ARCHIVE_ERROR("A00552","不满足归档调节,操作失败!"),
PROCESS_ERROR("A00553","当前流程未审核通过,操作失败!"), PROCESS_ERROR("A00553","当前流程未审核通过,操作失败!"),
QUERY_IS_EMPTY("A00554","当前未查询到当前策略信息,无法删除!"),
ENABLED_CANNOT_BE_DELETED("A00555","策略为启用状态不能删除!"),
; ;
private final String code; private final String code;

View File

@@ -28,6 +28,10 @@ public class ExcessiveParam extends IssuesParam {
@NotNull(message = "监测点ID不可为空") @NotNull(message = "监测点ID不可为空")
private String measurementPointId; private String measurementPointId;
@ApiModelProperty(name = "measurementPointId",value = "监测点ID")
@NotNull(message = "监测点ID不可为空")
private String measurementPointName;
@ApiModelProperty(name = "warnLastTime",value = "告警持续时间") @ApiModelProperty(name = "warnLastTime",value = "告警持续时间")
@NotNull(message = "告警持续时间不可为空") @NotNull(message = "告警持续时间不可为空")
private String warnLastTime; private String warnLastTime;

View File

@@ -37,7 +37,7 @@ public class StrategyParam {
private String name; private String name;
@ApiModelProperty("等级0一级1二级2三级") @ApiModelProperty("等级0一级1二级2三级")
private String grade; private Integer grade;
@ApiModelProperty(value = "区分预警单/告警单0预警单 1告警单") @ApiModelProperty(value = "区分预警单/告警单0预警单 1告警单")
private Integer type; private Integer type;
@@ -71,7 +71,7 @@ public class StrategyParam {
private String id; private String id;
@ApiModelProperty(value = "关系01只存在于指标类型中") @ApiModelProperty(value = "关系01只存在于指标类型中")
@TableField("Operation") @NotNull(message = "id不能为空")
private Integer operation; private Integer operation;
@ApiModelProperty(value = "监测点标签") @ApiModelProperty(value = "监测点标签")
@@ -84,7 +84,23 @@ public class StrategyParam {
} }
@Data @Data
public static class StrategyUpdateParam { public static class StrategyUpdateParam extends StrategyUpParam{
@ApiModelProperty(value = "关系01只存在于指标类型中")
private Integer operation;
@ApiModelProperty(value = "监测点标签")
@NotBlank(message = "监测点标签不能为空")
private List<String> monitorTag;
@ApiModelProperty(value = "指标类型")
@NotEmpty(message = "指标类型集合不能为空")
private List<String> indicatorTypes;
}
@Data
public static class StrategyUpParam {
@ApiModelProperty(value = "预警单id") @ApiModelProperty(value = "预警单id")
private String id; private String id;
@@ -96,18 +112,6 @@ public class StrategyParam {
@NotNull(message = "等级不能为空") @NotNull(message = "等级不能为空")
private Integer grade; private Integer grade;
@ApiModelProperty(value = "关系01只存在于指标类型中")
@TableField("Operation")
private Integer operation;
@ApiModelProperty(value = "监测点标签")
@NotBlank(message = "监测点标签不能为空")
private String monitorTag;
@ApiModelProperty(value = "指标类型")
@NotEmpty(message = "指标类型集合不能为空")
private List<String> indicatorTypes;
} }
@Data @Data
@@ -116,7 +120,7 @@ public class StrategyParam {
@NotBlank(message = "id不能为空") @NotBlank(message = "id不能为空")
private String id; private String id;
@ApiModelProperty(value = "0.删除 1.正常") @ApiModelProperty(value = "0.删除 1.启用 2.关闭")
private Integer state; private Integer state;
} }

View File

@@ -45,6 +45,11 @@ public class RMpOnlineMonitorOverproofProblem implements Serializable {
*/ */
private String measurementPointId; private String measurementPointId;
/**
* 监测点ID
*/
private String measurementPointName;
/** /**
* 操作时间 * 操作时间
*/ */

View File

@@ -45,9 +45,8 @@ public class ThsWarnStrategy extends BaseEntity implements Serializable {
@ApiModelProperty(value = "区分预警单还是告警单(0预警单1告警单)") @ApiModelProperty(value = "区分预警单还是告警单(0预警单1告警单)")
private Integer type; private Integer type;
@ApiModelProperty(value = "0.删除 1.正常") @ApiModelProperty(value = "0.删除 1.启用 2.关闭")
@TableField("State") @TableField("State")
@TableLogic
private Integer state; private Integer state;
@TableField("Create_By") @TableField("Create_By")

View File

@@ -78,7 +78,7 @@ public class ThsWarnStrategyController extends BaseController {
@PostMapping("/updateStrategy") @PostMapping("/updateStrategy")
@ApiOperation(value = "预警单/告警单修改") @ApiOperation(value = "预警单/告警单修改")
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
public HttpResult<Boolean> updateStrategy(@RequestBody @Validated StrategyParam.StrategyUpdateParam param) { public HttpResult<Boolean> updateStrategy(@RequestBody @Validated StrategyParam.StrategyUpParam param) {
String methodDescribe = getMethodDescribe("updateStrategy"); String methodDescribe = getMethodDescribe("updateStrategy");
Boolean flag = thsWarnStrategyService.updateStrategy(param); Boolean flag = thsWarnStrategyService.updateStrategy(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
@@ -96,7 +96,7 @@ public class ThsWarnStrategyController extends BaseController {
@PostMapping("/getMonitor") @PostMapping("/getMonitor")
@ApiOperation(value = "监测点查询接口") @ApiOperation(value = "监测点查询接口")
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
public HttpResult<List<StrategyParam.MonitorTree>> getMonitor(@Param("monitorTag") String monitorTag, @Param("orgId") String orgId) { public HttpResult<List<StrategyParam.MonitorTree>> getMonitor(@Param("monitorTag") List<String> monitorTag, @Param("orgId") String orgId) {
String methodDescribe = getMethodDescribe("getMonitor"); String methodDescribe = getMethodDescribe("getMonitor");
List<StrategyParam.MonitorTree> monitor = thsWarnStrategyService.getMonitor(monitorTag, orgId); List<StrategyParam.MonitorTree> monitor = thsWarnStrategyService.getMonitor(monitorTag, orgId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, monitor, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, monitor, methodDescribe);
@@ -114,7 +114,7 @@ public class ThsWarnStrategyController extends BaseController {
@PostMapping("/delStrategy") @PostMapping("/delStrategy")
@ApiOperation(value = "预警单/告警单信息删除") @ApiOperation(value = "预警单/告警单信息删除")
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
public HttpResult<Boolean> bindStrategy(@RequestBody List<String> ids) { public HttpResult<Boolean> delStrategy(String ids) {
String methodDescribe = getMethodDescribe("delStrategy"); String methodDescribe = getMethodDescribe("delStrategy");
Boolean flag = thsWarnStrategyService.delStrategy(ids); Boolean flag = thsWarnStrategyService.delStrategy(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);

View File

@@ -37,6 +37,15 @@ public interface ThsWarnStrategyMapper extends BaseMapper<ThsWarnStrategy> {
*/ */
List<String> getStrategyDetail(@Param("id") String id); List<String> getStrategyDetail(@Param("id") String id);
/***
* 获取监测点标签id
* @author wr
* @date 2023-03-10 13:46
* @param id
* @return List<String>
*/
List<String> getMonitorTagDetail(@Param("id") String id);
/** /**
* 查询所有部门的策略列表 * 查询所有部门的策略列表
* *

View File

@@ -21,7 +21,11 @@
<result column="Name" property="name" /> <result column="Name" property="name" />
<result column="Grade" property="grade" /> <result column="Grade" property="grade" />
<result column="Operation" property="operation" /> <result column="Operation" property="operation" />
<result column="monitorTag" property="monitorTag" /> <collection
property="monitorTag"
column="{id = id}"
select="com.njcn.process.mapper.ThsWarnStrategyMapper.getMonitorTagDetail">
</collection>
<collection <collection
property="indicatorTypes" property="indicatorTypes"
column="{id = id}" column="{id = id}"
@@ -33,12 +37,9 @@
ts.Id AS id, ts.Id AS id,
ts.NAME AS NAME, ts.NAME AS NAME,
ts.Grade AS grade, ts.Grade AS grade,
ts.Operation AS operation, ts.Operation AS operation
ta.Ass_Id AS monitorTag
FROM FROM
ths_warn_strategy ts ths_warn_strategy ts
INNER JOIN ths_warn_strategy_ass ta ON ts.Id = ta.Warn_Id
AND ta.Type = 0
WHERE WHERE
id = #{id} id = #{id}
</select> </select>
@@ -67,5 +68,13 @@
tws.State = 1 and tws.Grade in(0,2) tws.State = 1 and tws.Grade in(0,2)
</select> </select>
<select id="getMonitorTagDetail" resultType="java.lang.String">
SELECT
Ass_Id
FROM
ths_warn_strategy_ass ts
WHERE
Warn_Id = #{id} and ts.Type=0
</select>
</mapper> </mapper>

View File

@@ -63,7 +63,7 @@ public interface ThsWarnStrategyService extends IService<ThsWarnStrategy> {
* @param param * @param param
* @return Boolean * @return Boolean
*/ */
Boolean updateStrategy(StrategyParam.StrategyUpdateParam param); Boolean updateStrategy(StrategyParam.StrategyUpParam param);
/*** /***
* 预警单/告警单修改状态 * 预警单/告警单修改状态
@@ -81,7 +81,7 @@ public interface ThsWarnStrategyService extends IService<ThsWarnStrategy> {
* @param monitorTag * @param monitorTag
* @return List<PmsMonitorInfoDTO> * @return List<PmsMonitorInfoDTO>
*/ */
List<StrategyParam.MonitorTree> getMonitor(String monitorTag, String orgId); List<StrategyParam.MonitorTree> getMonitor(List<String> monitorTag, String orgId);
/*** /***
@@ -101,5 +101,5 @@ public interface ThsWarnStrategyService extends IService<ThsWarnStrategy> {
* @param ids * @param ids
* @return Boolean * @return Boolean
*/ */
Boolean delStrategy(List<String> ids); Boolean delStrategy(String ids);
} }

View File

@@ -284,9 +284,12 @@ public class IssuesServiceImpl implements IssuesService {
ExcessiveDetailVO detail = new ExcessiveDetailVO(); ExcessiveDetailVO detail = new ExcessiveDetailVO();
BeanUtil.copyProperties(issuesSelectOne(powerQualityProblemNo), detail); BeanUtil.copyProperties(issuesSelectOne(powerQualityProblemNo), detail);
detail.setOrgName(deptFeignClient.getDeptById(detail.getOrgNo()).getData().getName()); detail.setOrgName(deptFeignClient.getDeptById(detail.getOrgNo()).getData().getName());
LambdaQueryWrapper<RMpOnlineMonitorOverproofProblem> excessiveQuery = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RMpOnlineMonitorOverproofProblem> excessiveQuery = new LambdaQueryWrapper<>();
excessiveQuery.eq(RMpOnlineMonitorOverproofProblem::getPowerQualityProblemNo, powerQualityProblemNo); excessiveQuery.eq(RMpOnlineMonitorOverproofProblem::getPowerQualityProblemNo, powerQualityProblemNo);
RMpOnlineMonitorOverproofProblem excessiveOut = excessiveMapper.selectOne(excessiveQuery); RMpOnlineMonitorOverproofProblem excessiveOut = excessiveMapper.selectOne(excessiveQuery);
BeanUtil.copyProperties(excessiveOut, detail); BeanUtil.copyProperties(excessiveOut, detail);
RMpElectricQualityProblemFlowDetails flowDetails = flowDetailSelectOne(powerQualityProblemNo); RMpElectricQualityProblemFlowDetails flowDetails = flowDetailSelectOne(powerQualityProblemNo);
BeanUtil.copyProperties(processFlowDetail(flowDetails), detail); BeanUtil.copyProperties(processFlowDetail(flowDetails), detail);
@@ -484,7 +487,7 @@ public class IssuesServiceImpl implements IssuesService {
*/ */
@Override @Override
public String uploadFile(MultipartFile issuesFile) { public String uploadFile(MultipartFile issuesFile) {
return fileStorageUtil.uploadMultipart(issuesFile, OssPath.ELECTRICITY_QUALITY); return fileStorageUtil.getFileUrl( fileStorageUtil.uploadMultipart(issuesFile, OssPath.ELECTRICITY_QUALITY));
} }
/** /**
@@ -661,6 +664,7 @@ public class IssuesServiceImpl implements IssuesService {
toMap(PvTerminalTreeVO::getId, toMap(PvTerminalTreeVO::getId,
PvTerminalTreeVO::getName)); PvTerminalTreeVO::getName));
List<RStatElectricQualityProblemLogVO> rStatElectricQualityProblemLogVOList = rStatElectricQualityProblemLogMapper.selectByProblemNo(powerQualityProblemNo); List<RStatElectricQualityProblemLogVO> rStatElectricQualityProblemLogVOList = rStatElectricQualityProblemLogMapper.selectByProblemNo(powerQualityProblemNo);
rStatElectricQualityProblemLogVOList.stream ().forEach (temp->temp.setOrgName (pvTerminalTreeVOMap.get (temp.getOrgName ()))); rStatElectricQualityProblemLogVOList.stream ().forEach (temp->temp.setOrgName (pvTerminalTreeVOMap.get (temp.getOrgName ())));
return rStatElectricQualityProblemLogVOList; return rStatElectricQualityProblemLogVOList;

View File

@@ -7,11 +7,14 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient; import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.enums.PmsDeviceResponseEnum; import com.njcn.device.pms.enums.PmsDeviceResponseEnum;
import com.njcn.device.pms.pojo.dto.PmsMonitorDTO; import com.njcn.device.pms.pojo.dto.PmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PmsMonitorParam; import com.njcn.device.pms.pojo.param.PmsMonitorParam;
import com.njcn.device.pms.pojo.po.DistributionMonitor;
import com.njcn.process.enums.ProcessResponseEnum;
import com.njcn.process.pojo.param.StrategyParam; import com.njcn.process.pojo.param.StrategyParam;
import com.njcn.process.pojo.po.PmsTerminalDetection; import com.njcn.process.pojo.po.PmsTerminalDetection;
import com.njcn.process.pojo.po.ThsDeptAlarm; import com.njcn.process.pojo.po.ThsDeptAlarm;
@@ -27,6 +30,7 @@ import com.njcn.web.utils.RequestUtil;
import com.njcn.web.utils.WebUtil; import com.njcn.web.utils.WebUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -54,12 +58,14 @@ public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMappe
, new LambdaQueryWrapper<ThsWarnStrategy>() , new LambdaQueryWrapper<ThsWarnStrategy>()
.like(StrUtil.isNotBlank(param.getName()), ThsWarnStrategy::getName, param.getName()) .like(StrUtil.isNotBlank(param.getName()), ThsWarnStrategy::getName, param.getName())
.eq(param.getGrade() != null, ThsWarnStrategy::getGrade, param.getGrade()) .eq(param.getGrade() != null, ThsWarnStrategy::getGrade, param.getGrade())
.le(param.getType() != null, ThsWarnStrategy::getType, param.getType()) .eq(param.getType() != null, ThsWarnStrategy::getType, param.getType())
.ne(ThsWarnStrategy::getState, DataStateEnum.DELETED.getCode())
); );
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class})
public Boolean insertStrategy(StrategyParam.StrategyInsertParam param) { public Boolean insertStrategy(StrategyParam.StrategyInsertParam param) {
int count = this.count(new LambdaQueryWrapper<ThsWarnStrategy>() int count = this.count(new LambdaQueryWrapper<ThsWarnStrategy>()
.eq(ThsWarnStrategy::getName, param.getName()) .eq(ThsWarnStrategy::getName, param.getName())
@@ -68,14 +74,18 @@ public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMappe
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT); throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT);
} }
ThsWarnStrategy thsWarnStrategy = BeanUtil.copyProperties(param, ThsWarnStrategy.class); ThsWarnStrategy thsWarnStrategy = BeanUtil.copyProperties(param, ThsWarnStrategy.class);
thsWarnStrategy.setCreateBy(RequestUtil.getLoginName()); thsWarnStrategy.setCreateBy(RequestUtil.getUserNickname());
thsWarnStrategy.setState(1); thsWarnStrategy.setState(2);
return this.save(thsWarnStrategy); return this.save(thsWarnStrategy);
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class})
public Boolean bindStrategy(StrategyParam.BindParam param) { public Boolean bindStrategy(StrategyParam.BindParam param) {
List<ThsWarnStrategyAss> assList = new ArrayList<>(); List<ThsWarnStrategyAss> assList = new ArrayList<>();
//删除之前绑定信息
thsWarnStrategyAssService.removeById(param.getId());
//监测点标签绑定 //监测点标签绑定
add(assList, param.getId(), 0, param.getMonitorTag()); add(assList, param.getId(), 0, param.getMonitorTag());
//指标类型绑定 //指标类型绑定
@@ -88,6 +98,85 @@ public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMappe
return this.updateById(warnStrategy); return this.updateById(warnStrategy);
} }
@Override
public StrategyParam.StrategyUpdateParam getUpdateStrategy(String id) {
return this.baseMapper.selectUpdateStrategy(id);
}
@Override
public Boolean updateStrategy(StrategyParam.StrategyUpParam param) {
ThsWarnStrategy one = this.getOne(new LambdaQueryWrapper<ThsWarnStrategy>()
.ne(ThsWarnStrategy::getId, param.getId())
.and(wrapper ->
wrapper.eq(ThsWarnStrategy::getName, param.getName())
)
);
if (ObjectUtil.isNotNull(one)) {
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT);
}
ThsWarnStrategy thsWarnStrategy = BeanUtil.copyProperties(param, ThsWarnStrategy.class);
thsWarnStrategy.setUpdateBy(RequestUtil.getUserNickname());
return this.updateById(thsWarnStrategy);
}
@Override
@Transactional(rollbackFor = {Exception.class})
public Boolean updateStrategyState(StrategyParam.StrategyStateParam param) {
ThsWarnStrategy thsWarnStrategy = new ThsWarnStrategy();
thsWarnStrategy.setId(param.getId());
thsWarnStrategy.setState(param.getState());
return this.updateById(thsWarnStrategy);
}
@Override
public List<StrategyParam.MonitorTree> getMonitor(List<String> monitorTag, String orgId) {
PmsMonitorParam param = new PmsMonitorParam();
param.setMonitorTags(monitorTag);
List<PmsMonitorDTO> data = monitorClient.getMonitorInfoListByCond(param).getData();
//获取部门结构
List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(orgId, WebUtil.filterDeptType()).getData();
List<DeptDTO> deptDTOS = deptInfos.stream().filter(org -> org.getId().equals(orgId)).collect(Collectors.toList());
//递归监测点信息
List<StrategyParam.MonitorTree> monitorTrees = new ArrayList<>();
StrategyParam.MonitorTree tree = new StrategyParam.MonitorTree();
tree.setId(deptDTOS.get(0).getId());
tree.setName(deptDTOS.get(0).getName());
tree.setChildPower(getPowers(deptDTOS.get(0).getCode(), data));
tree.setChildren(recursionSelectList(orgId, deptInfos, data));
monitorTrees.add(tree);
return monitorTrees;
}
@Override
@Transactional(rollbackFor = {Exception.class})
public Boolean bindMonitor(List<ThsDeptAlarm> param) {
//删除之前数据
LambdaQueryWrapper<ThsDeptAlarm> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ThsDeptAlarm::getDeptId, param.get(0).getDeptId());
lambdaQueryWrapper.in(ThsDeptAlarm::getAlarmId, param.get(0).getDeptId());
lambdaQueryWrapper.in(ThsDeptAlarm::getType, param.get(0).getType());
thsDeptAlarmService.remove(lambdaQueryWrapper);
return thsDeptAlarmService.saveBatch(param);
}
@Override
@Transactional(rollbackFor = {Exception.class})
public Boolean delStrategy(String ids) {
Assert.isTrue(StrUtil.isNotBlank(ids), "id为空,不能删除");
ThsWarnStrategy byId = this.getById(ids);
if(ObjectUtil.isNull(byId)){
throw new BusinessException(ProcessResponseEnum.QUERY_IS_EMPTY);
}
if(byId.getState() == 1){
throw new BusinessException(ProcessResponseEnum.ENABLED_CANNOT_BE_DELETED);
}
thsWarnStrategyAssService.removeById(ids);
return this.removeById(ids);
}
/*** /***
* 告警单 监测点标签或指标类型绑定 * 告警单 监测点标签或指标类型绑定
* @author wr * @author wr
@@ -107,54 +196,6 @@ public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMappe
assList.add(ass); assList.add(ass);
} }
} }
@Override
public StrategyParam.StrategyUpdateParam getUpdateStrategy(String id) {
return this.baseMapper.selectUpdateStrategy(id);
}
@Override
public Boolean updateStrategy(StrategyParam.StrategyUpdateParam param) {
ThsWarnStrategy one = this.getOne(new LambdaQueryWrapper<ThsWarnStrategy>()
.ne(ThsWarnStrategy::getId, param.getId())
.and(wrapper ->
wrapper.eq(ThsWarnStrategy::getName, param.getName())
)
);
if (ObjectUtil.isNotNull(one)) {
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT);
}
ThsWarnStrategy thsWarnStrategy = BeanUtil.copyProperties(param, ThsWarnStrategy.class);
return this.updateById(thsWarnStrategy);
}
@Override
public Boolean updateStrategyState(StrategyParam.StrategyStateParam param) {
ThsWarnStrategy thsWarnStrategy = new ThsWarnStrategy();
thsWarnStrategy.setId(param.getId());
thsWarnStrategy.setState(param.getState());
return this.updateById(thsWarnStrategy);
}
@Override
public List<StrategyParam.MonitorTree> getMonitor(String monitorTag, String orgId) {
PmsMonitorParam param = new PmsMonitorParam();
param.setMonitorTags(Arrays.asList(monitorTag));
List<PmsMonitorDTO> data = monitorClient.getMonitorInfoListByCond(param).getData();
//获取部门结构
List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(orgId, WebUtil.filterDeptType()).getData();
List<DeptDTO> deptDTOS = deptInfos.stream().filter(org -> org.getId().equals(orgId)).collect(Collectors.toList());
List<StrategyParam.MonitorTree> monitorTrees = new ArrayList<>();
StrategyParam.MonitorTree tree = new StrategyParam.MonitorTree();
tree.setId(deptDTOS.get(0).getId());
tree.setName(deptDTOS.get(0).getName());
tree.setChildPower(getPowers(deptDTOS.get(0).getCode(), data));
tree.setChildren(recursionSelectList(orgId, deptInfos, data));
monitorTrees.add(tree);
return monitorTrees;
}
/** /**
* 递归生成监测点树 * 递归生成监测点树
@@ -215,15 +256,4 @@ public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMappe
return powers; return powers;
} }
@Override
public Boolean bindMonitor(List<ThsDeptAlarm> param) {
return thsDeptAlarmService.saveBatch(param);
}
@Override
public Boolean delStrategy(List<String> ids) {
Assert.isTrue(CollectionUtil.isNotEmpty(ids), "id为空,不能删除");
thsWarnStrategyAssService.removeByIds(ids);
return this.removeByIds(ids);
}
} }