|
@@ -9,6 +9,7 @@ import com.persagy.apm.alarmservice.project.alarmrule.service.IProjectAlarmRuleS
|
|
|
import com.persagy.apm.alarmservice.project.alarmruleobjrel.model.ProjectAlarmRuleObjRel;
|
|
|
import com.persagy.apm.alarmservice.project.alarmruleobjrel.service.IProjectAlarmRuleObjRelService;
|
|
|
import com.persagy.common.enums.ResponseCode;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -30,10 +31,11 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 项目报警规则控制层
|
|
|
+ *
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021-09-08 22:46:16
|
|
|
*/
|
|
|
-@Api(tags = "项目报警规则")
|
|
|
+@Api(tags = "项目报警规则")
|
|
|
@Validated
|
|
|
@RestController
|
|
|
@RequestMapping("projectAlarmRules")
|
|
@@ -45,10 +47,10 @@ public class ProjectAlarmRuleController {
|
|
|
@Autowired
|
|
|
private ProjectAlarmRuleMapper projectAlarmRuleMapper;
|
|
|
|
|
|
- @ApiOperation(value = "创建项目报警规则")
|
|
|
- @PostMapping("/create")
|
|
|
- public CommonResult<ApmResponseUpsertVO> createProjectAlarmRule(
|
|
|
- @Valid @RequestBody AddProjectAlarmRuleDTO addProjectAlarmRuleDTO) {
|
|
|
+ @ApiOperation(value = "创建项目报警规则")
|
|
|
+ @PostMapping("/create")
|
|
|
+ public CommonResult<ApmResponseUpsertVO> createProjectAlarmRule(
|
|
|
+ @Valid @RequestBody AddProjectAlarmRuleDTO addProjectAlarmRuleDTO) {
|
|
|
String id = null;
|
|
|
try {
|
|
|
id = projectAlarmRuleService.createProjectAlarmRule(addProjectAlarmRuleDTO);
|
|
@@ -57,9 +59,9 @@ public class ProjectAlarmRuleController {
|
|
|
return ResultHelper.failure(ResponseCode.B0001.getCode(), e.getMessage());
|
|
|
}
|
|
|
return ResultHelper.single(new ApmResponseUpsertVO(id));
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "项目报警规则详情")
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "项目报警规则详情")
|
|
|
@PostMapping("/get")
|
|
|
@ApiIgnore
|
|
|
public CommonResult<ProjectAlarmRuleItemVO> queryProjectAlarmRuleDetail(
|
|
@@ -107,7 +109,7 @@ public class ProjectAlarmRuleController {
|
|
|
List<ProjectAlarmRuleListItemVO> resultList = ConvertProjectAlarmRuleTool.INSTANCE.convert2List(projectAlarmRuleList);
|
|
|
return ResultHelper.multi(resultList);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@ApiOperation(value = "项目报警规则列表, 分页查询")
|
|
|
@PostMapping("/queryPage")
|
|
|
public CommonResult<PageList<ProjectAlarmRuleListItemVO>> queryProjectAlarmRule(
|
|
@@ -116,41 +118,26 @@ public class ProjectAlarmRuleController {
|
|
|
int page = pageQueryProjectAlarmRuleDTO.getPage();
|
|
|
int size = pageQueryProjectAlarmRuleDTO.getSize();
|
|
|
pageQueryProjectAlarmRuleDTO.setStartIndex((page - 1) * size);
|
|
|
- int count = projectAlarmRuleMapper.queryCount(pageQueryProjectAlarmRuleDTO);
|
|
|
+// int count = projectAlarmRuleMapper.queryCount(pageQueryProjectAlarmRuleDTO);
|
|
|
List<ProjectAlarmRuleListItemVO> projectAlarmRuleListItemVOS = projectAlarmRuleMapper.queryList(pageQueryProjectAlarmRuleDTO);
|
|
|
+ List<ProjectAlarmRuleListItemVO> result = new ArrayList<>();
|
|
|
for (ProjectAlarmRuleListItemVO projectAlarmRuleListItemVO : projectAlarmRuleListItemVOS) {
|
|
|
List<ProjectAlarmRuleObjRel> query = projectAlarmRuleObjRelService.query(projectAlarmRuleListItemVO.getId());
|
|
|
- projectAlarmRuleListItemVO.setRelListItemList(query);
|
|
|
+ String equipName = pageQueryProjectAlarmRuleDTO.getEquipName();
|
|
|
+ if (StringUtils.isNotBlank(equipName)) {
|
|
|
+ for (ProjectAlarmRuleObjRel projectAlarmRuleObjRel : query) {
|
|
|
+ if (StringUtils.isNotBlank(projectAlarmRuleObjRel.getObjName()) && projectAlarmRuleObjRel.getObjName().equals(equipName)) {
|
|
|
+ projectAlarmRuleListItemVO.setRelListItemList(query);
|
|
|
+ result.add(projectAlarmRuleListItemVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ projectAlarmRuleListItemVO.setRelListItemList(query);
|
|
|
+ result.add(projectAlarmRuleListItemVO);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- return ResultHelper.multi(projectAlarmRuleListItemVOS, count);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-// IPage<ProjectAlarmRule> pagedList = projectAlarmRuleService.pageQueryProjectAlarmRule(pageQueryProjectAlarmRuleDTO);
|
|
|
-// if(pagedList.getRecords().size()>0){
|
|
|
-// List<String> projectIds = pagedList.getRecords().stream().map(ProjectAlarmRule::getProjectId).collect(Collectors.toList());
|
|
|
-// List<ProjectAlarmRuleObjRel> relationList = projectAlarmRuleObjRelService.queryRelationListByProjectIds(projectIds);
|
|
|
-// Map<String, ProjectAlarmRuleObjRel> relationMap = relationList.stream().collect(Collectors.toMap(ProjectAlarmRuleObjRel::getProjectId, rule -> rule));
|
|
|
-// IPage<ProjectAlarmRuleListItemVO> pagedResultList = pagedList.convert(item -> {
|
|
|
-// try {
|
|
|
-// return ConvertProjectAlarmRuleTool.INSTANCE.convert2ResponseListItemDTO(item);
|
|
|
-// } catch (Exception e) {
|
|
|
-// throw new IllegalArgumentException("分页查询,ProjectAlarmRule实体类转换为列表对象发生异常", e);
|
|
|
-// }
|
|
|
-// });
|
|
|
-// pagedResultList.getRecords().forEach(projectAlarmRuleListItemVO -> {
|
|
|
-// String projectId = projectAlarmRuleListItemVO.getProjectId();
|
|
|
-// if(relationMap.containsKey(projectId)){
|
|
|
-// projectAlarmRuleListItemVO.setRelListItemList((List<ProjectAlarmRuleObjRel>) relationMap.get(projectId));
|
|
|
-// }
|
|
|
-// });
|
|
|
-// return ResultHelper.multi(pagedResultList);
|
|
|
-// }
|
|
|
-// return ResultHelper.multi(new ArrayList<>());
|
|
|
+ List<ProjectAlarmRuleListItemVO> resultList = projectAlarmRuleService.pageBySubList(result, size, page);
|
|
|
+ return ResultHelper.multi(resultList, result.size());
|
|
|
}
|
|
|
}
|
|
|
|