|
@@ -1,22 +1,44 @@
|
|
|
package com.persagy.apm.alarmservice.project.monitorindicatorconfig.service.impl;
|
|
|
|
|
|
-import com.persagy.apm.common.context.AppContext;
|
|
|
-import com.persagy.apm.alarmservice.project.monitorindicatorconfig.dao.ProjectMonitorIndicatorConfigMapper;
|
|
|
-import com.persagy.apm.alarmservice.project.monitorindicatorconfig.service.IProjectMonitorIndicatorConfigService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-import com.persagy.apm.common.constant.enums.ValidEnum;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.*;
|
|
|
-import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.dto.*;
|
|
|
-import java.util.List;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.google.common.base.CaseFormat;
|
|
|
-import com.persagy.apm.common.model.dto.Sort;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.persagy.apm.alarmservice.calculatemethod.model.CalculateMethod;
|
|
|
+import com.persagy.apm.alarmservice.calculatemethod.model.dto.QueryCalculateMethodDTO;
|
|
|
+import com.persagy.apm.alarmservice.calculatemethod.service.ICalculateMethodService;
|
|
|
+import com.persagy.apm.alarmservice.group.management.service.GroupManagementService;
|
|
|
+import com.persagy.apm.alarmservice.monitorindicator.model.MonitorIndicator;
|
|
|
+import com.persagy.apm.alarmservice.monitorindicator.model.dto.QueryMonitorIndicatorDTO;
|
|
|
+import com.persagy.apm.alarmservice.monitorindicator.service.IMonitorIndicatorService;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.dao.ProjectMonitorIndicatorConfigMapper;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.ConvertProjectMonitorIndicatorConfigTool;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.ProjectMonitorIndicatorConfig;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.dto.AddProjectMonitorIndicatorConfigDTO;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.dto.PageQueryProjectMonitorIndicatorConfigDTO;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.dto.QueryProjectMonitorIndicatorConfigDTO;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.dto.UpdateProjectMonitorIndicatorConfigDTO;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.model.vo.ProjectMonitorIndicatorConfigListItemVO;
|
|
|
+import com.persagy.apm.alarmservice.project.monitorindicatorconfig.service.IProjectMonitorIndicatorConfigService;
|
|
|
+import com.persagy.apm.common.constant.enums.BoolEnum;
|
|
|
+import com.persagy.apm.common.constant.enums.ValidEnum;
|
|
|
+import com.persagy.apm.common.context.AppContext;
|
|
|
+import com.persagy.apm.common.context.poems.PoemsContext;
|
|
|
+import com.persagy.apm.common.model.vo.SimpleObjVO;
|
|
|
+import com.persagy.apm.model.dto.GroupManagementDTO;
|
|
|
+import com.persagy.apm.model.vo.GroupManagementVo;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.assertj.core.util.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.text.Collator;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
|
|
|
* 项目监测指标配置(ProjectMonitorIndicatorConfig) service层
|
|
|
*
|
|
@@ -24,15 +46,23 @@ import org.springframework.util.CollectionUtils;
|
|
|
* @version V1.0 2021-09-08 22:46:56
|
|
|
*/
|
|
|
@Service
|
|
|
-public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<ProjectMonitorIndicatorConfigMapper, ProjectMonitorIndicatorConfig>
|
|
|
- implements IProjectMonitorIndicatorConfigService {
|
|
|
-
|
|
|
+public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<ProjectMonitorIndicatorConfigMapper, ProjectMonitorIndicatorConfig>
|
|
|
+ implements IProjectMonitorIndicatorConfigService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IMonitorIndicatorService monitorIndicatorService;
|
|
|
+ @Autowired
|
|
|
+ ICalculateMethodService calculateMethodService;
|
|
|
+ @Autowired
|
|
|
+ GroupManagementService groupManagementService;
|
|
|
+
|
|
|
|
|
|
- * 创建项目监测指标配置
|
|
|
- * @return 项目监测指标配置主键
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-09-08 22:46:56
|
|
|
- */
|
|
|
+ * 创建项目监测指标配置
|
|
|
+ *
|
|
|
+ * @return 项目监测指标配置主键
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-09-08 22:46:56
|
|
|
+ */
|
|
|
@Override
|
|
|
public String createProjectMonitorIndicatorConfig(AddProjectMonitorIndicatorConfigDTO addProjectMonitorIndicatorConfigDTO) {
|
|
|
ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig = ConvertProjectMonitorIndicatorConfigTool.INSTANCE.convertAddDto2Entity(addProjectMonitorIndicatorConfigDTO);
|
|
@@ -41,7 +71,7 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
|
save(projectMonitorIndicatorConfig);
|
|
|
return projectMonitorIndicatorConfig.getId();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
* 如果某些字段没有赋值,使用默认的值
|
|
|
*
|
|
@@ -52,16 +82,17 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
|
private void setDefaultValue(ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig) {
|
|
|
projectMonitorIndicatorConfig.setCreator(AppContext.getContext().getAccountId());
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- * 项目监测指标配置详情
|
|
|
- * @param id 主键
|
|
|
- * @return 部门do类
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-09-08 22:46:56
|
|
|
- */
|
|
|
+ * 项目监测指标配置详情
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 部门do类
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-09-08 22:46:56
|
|
|
+ */
|
|
|
@Override
|
|
|
public ProjectMonitorIndicatorConfig queryProjectMonitorIndicatorConfigDetail(String id) {
|
|
|
ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig = getById(id);
|
|
@@ -70,20 +101,25 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
|
}
|
|
|
return projectMonitorIndicatorConfig;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- * 更新项目监测指标配置
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-09-08 22:46:56
|
|
|
- */
|
|
|
+ * 更新项目监测指标配置
|
|
|
+ *
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-09-08 22:46:56
|
|
|
+ */
|
|
|
@Override
|
|
|
- public void updateProjectMonitorIndicatorConfig(UpdateProjectMonitorIndicatorConfigDTO updateProjectMonitorIndicatorConfigDTO) {
|
|
|
- ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig = getById(updateProjectMonitorIndicatorConfigDTO.getId());
|
|
|
- projectMonitorIndicatorConfig = ConvertProjectMonitorIndicatorConfigTool.INSTANCE.convertUpdateDto2Entity(projectMonitorIndicatorConfig, updateProjectMonitorIndicatorConfigDTO);
|
|
|
+ public String updateProjectMonitorIndicatorConfig(UpdateProjectMonitorIndicatorConfigDTO updateProjectMonitorIndicatorConfigDTO) {
|
|
|
+ ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig =
|
|
|
+ getConfigByObjAndIndicator(
|
|
|
+ updateProjectMonitorIndicatorConfigDTO.getObjId(),
|
|
|
+ updateProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId());
|
|
|
+ projectMonitorIndicatorConfig.setCalculateMethodId(updateProjectMonitorIndicatorConfigDTO.getCalculateMethodId());
|
|
|
projectMonitorIndicatorConfig.setModifier(AppContext.getContext().getAccountId());
|
|
|
updateById(projectMonitorIndicatorConfig);
|
|
|
+ return projectMonitorIndicatorConfig.getId();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
* 校验项目监测指标配置是否可删除
|
|
|
*
|
|
@@ -105,13 +141,14 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
|
|
|
|
return projectMonitorIndicatorConfig;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- * 删除项目监测指标配置
|
|
|
- * @param id 主键
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-09-08 22:46:56
|
|
|
- */
|
|
|
+ * 删除项目监测指标配置
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-09-08 22:46:56
|
|
|
+ */
|
|
|
@Override
|
|
|
public void deleteProjectMonitorIndicatorConfig(String id) {
|
|
|
|
|
@@ -120,92 +157,255 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
|
projectMonitorIndicatorConfig.setValid(ValidEnum.FALSE.getType());
|
|
|
updateById(projectMonitorIndicatorConfig);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- * 查询项目监测指标配置
|
|
|
- * @return List<ProjectMonitorIndicatorConfig>
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-09-08 22:46:56
|
|
|
- */
|
|
|
+ * 查询项目监测指标配置
|
|
|
+ *
|
|
|
+ * @return List<ProjectMonitorIndicatorConfig>
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-09-08 22:46:56
|
|
|
+ */
|
|
|
@Override
|
|
|
- public List<ProjectMonitorIndicatorConfig> queryProjectMonitorIndicatorConfigList(QueryProjectMonitorIndicatorConfigDTO queryProjectMonitorIndicatorConfigDTO) {
|
|
|
+ public List<ProjectMonitorIndicatorConfig> queryProjectMonitorIndicatorConfigList(
|
|
|
+ QueryProjectMonitorIndicatorConfigDTO queryProjectMonitorIndicatorConfigDTO) {
|
|
|
QueryWrapper<ProjectMonitorIndicatorConfig> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq(ProjectMonitorIndicatorConfig.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
|
|
|
queryWrapper.orderBy(true, false, ProjectMonitorIndicatorConfig.PROP_CREATIONTIME);
|
|
|
-
|
|
|
+
|
|
|
if (queryProjectMonitorIndicatorConfigDTO != null) {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getObjId())) {
|
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_OBJ_ID, queryProjectMonitorIndicatorConfigDTO.getObjId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId())) {
|
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_MONITOR_INDICATOR_ID, queryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getCaculateMethodId())) {
|
|
|
- queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_CACULATE_METHOD_ID, queryProjectMonitorIndicatorConfigDTO.getCaculateMethodId());
|
|
|
+ if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getCalculateMethodId())) {
|
|
|
+ queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_CACULATE_METHOD_ID, queryProjectMonitorIndicatorConfigDTO.getCalculateMethodId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getProjectId())) {
|
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_PROJECT_ID, queryProjectMonitorIndicatorConfigDTO.getProjectId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return list(queryWrapper);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- * 分页查询项目监测指标配置
|
|
|
- * @return IPage<ProjectMonitorIndicatorConfig>
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-09-08 22:46:56
|
|
|
- */
|
|
|
+ * 分页查询项目监测指标配置
|
|
|
+ *
|
|
|
+ * @return IPage<ProjectMonitorIndicatorConfigListItemVO>
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-09-08 22:46:56
|
|
|
+ */
|
|
|
@Override
|
|
|
- public IPage<ProjectMonitorIndicatorConfig> pageQueryProjectMonitorIndicatorConfig(PageQueryProjectMonitorIndicatorConfigDTO pageQueryProjectMonitorIndicatorConfigDTO) {
|
|
|
- QueryWrapper<ProjectMonitorIndicatorConfig> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq(ProjectMonitorIndicatorConfig.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
-
|
|
|
- IPage<ProjectMonitorIndicatorConfig> pageParam = new Page<>(pageQueryProjectMonitorIndicatorConfigDTO.getPage(), pageQueryProjectMonitorIndicatorConfigDTO.getSize(),true);
|
|
|
-
|
|
|
- if(CollectionUtils.isEmpty(pageQueryProjectMonitorIndicatorConfigDTO.getOrders())){
|
|
|
-
|
|
|
- queryWrapper.orderBy(true, false, ProjectMonitorIndicatorConfig.PROP_CREATIONTIME);
|
|
|
- }else {
|
|
|
- List<Sort> orders = pageQueryProjectMonitorIndicatorConfigDTO.getOrders();
|
|
|
- for(Sort sort: orders) {
|
|
|
-
|
|
|
- sort.setColumn(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,sort.getColumn()));
|
|
|
- queryWrapper.orderBy(true, sort.isAsc(), sort.getColumn());
|
|
|
+ public IPage<ProjectMonitorIndicatorConfigListItemVO> pageQueryProjectMonitorIndicatorConfig(
|
|
|
+ PageQueryProjectMonitorIndicatorConfigDTO pageQueryProjectMonitorIndicatorConfigDTO) {
|
|
|
+
|
|
|
+ IPage<ProjectMonitorIndicatorConfigListItemVO> result = new Page<>();
|
|
|
+ result.setRecords(Lists.newArrayList());
|
|
|
+ result.setTotal(0);
|
|
|
+
|
|
|
+
|
|
|
+ List<MonitorIndicator> monitorIndicators = queryGroupIndicators(
|
|
|
+ pageQueryProjectMonitorIndicatorConfigDTO.getClassCode(),
|
|
|
+ pageQueryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId());
|
|
|
+ if (CollectionUtils.isEmpty(monitorIndicators)) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ monitorIndicators = monitorIndicators.stream().sorted(Comparator.comparing(MonitorIndicator::getName,
|
|
|
+ Collator.getInstance(java.util.Locale.CHINA))).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ List<GroupManagementVo> objList = queryEquipList(pageQueryProjectMonitorIndicatorConfigDTO);
|
|
|
+ if (CollectionUtils.isEmpty(objList)) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ objList = objList.stream().sorted(Comparator.comparing(GroupManagementVo::getLocalName,
|
|
|
+ Collator.getInstance(java.util.Locale.CHINA))).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ List<ProjectMonitorIndicatorConfigListItemVO> recordList = combineResult(monitorIndicators, objList);
|
|
|
+
|
|
|
+
|
|
|
+ List<ProjectMonitorIndicatorConfigListItemVO> resultRecordList = subResultByPageInfo(
|
|
|
+ pageQueryProjectMonitorIndicatorConfigDTO, recordList);
|
|
|
+
|
|
|
+
|
|
|
+ resultRecordList.forEach(this::addCalculateMethodInfo);
|
|
|
+
|
|
|
+ result.setRecords(resultRecordList);
|
|
|
+ result.setTotal(recordList.size());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 给项目监测指标配置添加计算方式信息
|
|
|
+ *
|
|
|
+ * @param record 项目监测指标配置
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/9/17 9:49 下午
|
|
|
+ */
|
|
|
+ private void addCalculateMethodInfo(ProjectMonitorIndicatorConfigListItemVO record) {
|
|
|
+ if (record.getObj() == null || record.getMonitorIndicator() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ProjectMonitorIndicatorConfig configByObjAndIndicator = getConfigByObjAndIndicator(
|
|
|
+ record.getObj().getId(), record.getMonitorIndicator().getId());
|
|
|
+ String calculateMethodId = configByObjAndIndicator.getCalculateMethodId();
|
|
|
+
|
|
|
+ String methodName = calculateMethodService.getMethodName(calculateMethodId);
|
|
|
+ record.setCalculateMethod(new SimpleObjVO(calculateMethodId, methodName));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 根据分页信息截取项目监测指标配置列表
|
|
|
+ *
|
|
|
+ * @param pageQueryProjectMonitorIndicatorConfigDTO 分页查询条件
|
|
|
+ * @param recordList 全部项目监测指标配置列表
|
|
|
+ * @return 截取后的项目监测指标配置列表
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/9/17 9:29 下午
|
|
|
+ */
|
|
|
+ private List<ProjectMonitorIndicatorConfigListItemVO> subResultByPageInfo(
|
|
|
+ PageQueryProjectMonitorIndicatorConfigDTO pageQueryProjectMonitorIndicatorConfigDTO, List<ProjectMonitorIndicatorConfigListItemVO> recordList) {
|
|
|
+ Integer page = pageQueryProjectMonitorIndicatorConfigDTO.getPage();
|
|
|
+ Integer size = pageQueryProjectMonitorIndicatorConfigDTO.getSize();
|
|
|
+
|
|
|
+ if (page == null || size == null) {
|
|
|
+ throw new IllegalArgumentException("缺少分页条件");
|
|
|
+ }
|
|
|
+ return recordList.subList((page - 1) * size, page * size);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 监测对象+设备组合成成项目监测指标配置列表
|
|
|
+ *
|
|
|
+ * @param monitorIndicators 监测对象列表
|
|
|
+ * @param objList 设备列表
|
|
|
+ * @return 项目监测指标配置列表
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/9/17 9:27 下午
|
|
|
+ */
|
|
|
+ private List<ProjectMonitorIndicatorConfigListItemVO> combineResult(
|
|
|
+ List<MonitorIndicator> monitorIndicators, List<GroupManagementVo> objList) {
|
|
|
+ List<ProjectMonitorIndicatorConfigListItemVO> recordList = new ArrayList<>();
|
|
|
+ for (MonitorIndicator monitorIndicator : monitorIndicators) {
|
|
|
+ for (GroupManagementVo obj : objList) {
|
|
|
+ ProjectMonitorIndicatorConfigListItemVO projectMonitorIndicatorConfigListItemVO =
|
|
|
+ new ProjectMonitorIndicatorConfigListItemVO();
|
|
|
+ projectMonitorIndicatorConfigListItemVO.setObj(new SimpleObjVO(obj.getId(), obj.getLocalName()));
|
|
|
+ projectMonitorIndicatorConfigListItemVO.setMonitorIndicator(
|
|
|
+ new SimpleObjVO(monitorIndicator.getId(), monitorIndicator.getName()));
|
|
|
+ recordList.add(projectMonitorIndicatorConfigListItemVO);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(pageQueryProjectMonitorIndicatorConfigDTO.getObjId())) {
|
|
|
- queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_OBJ_ID, pageQueryProjectMonitorIndicatorConfigDTO.getObjId());
|
|
|
+ return recordList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 根据项目监测指标配置查询条件获取应该加载的设备
|
|
|
+ *
|
|
|
+ * @param pageQueryProjectMonitorIndicatorConfigDTO 项目监测指标配置查询条件
|
|
|
+ * @return 设备列表
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/9/17 9:03 下午
|
|
|
+ */
|
|
|
+ private List<GroupManagementVo> queryEquipList(PageQueryProjectMonitorIndicatorConfigDTO pageQueryProjectMonitorIndicatorConfigDTO) {
|
|
|
+ String projectId = PoemsContext.getContext().getProjectId();
|
|
|
+ GroupManagementDTO groupManagementDTO = new GroupManagementDTO();
|
|
|
+ groupManagementDTO.setClassCode(pageQueryProjectMonitorIndicatorConfigDTO.getClassCode());
|
|
|
+ groupManagementDTO.setCondition(pageQueryProjectMonitorIndicatorConfigDTO.getCondition());
|
|
|
+ groupManagementDTO.setProjectId(projectId);
|
|
|
+ groupManagementDTO.setLocalName(pageQueryProjectMonitorIndicatorConfigDTO.getObjName());
|
|
|
+ return groupManagementService.getEquipList(groupManagementDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取分组下的监测指标
|
|
|
+ *
|
|
|
+ * @param classCode 分组设备编码
|
|
|
+ * @param indicatorIds 监测指标id列表
|
|
|
+ * @return 分组下的监测指标
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/9/17 7:49 下午
|
|
|
+ */
|
|
|
+ private List<MonitorIndicator> queryGroupIndicators(String classCode, List<String> indicatorIds) {
|
|
|
+ QueryMonitorIndicatorDTO queryMonitorIndicatorDTO = new QueryMonitorIndicatorDTO();
|
|
|
+ queryMonitorIndicatorDTO.setClassCode(classCode);
|
|
|
+ queryMonitorIndicatorDTO.setIds(indicatorIds);
|
|
|
+ return monitorIndicatorService.queryMonitorIndicatorList(queryMonitorIndicatorDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ProjectMonitorIndicatorConfig getConfigByObjAndIndicator(String objId, String monitorIndicatorId) {
|
|
|
+ String projectId = PoemsContext.getContext().getProjectId();
|
|
|
+ if (StringUtils.isBlank(objId) || StringUtils.isBlank(monitorIndicatorId)
|
|
|
+ || StringUtils.isBlank(projectId)) {
|
|
|
+ throw new IllegalArgumentException("" +
|
|
|
+ "ProjectMonitorIndicatorConfigServiceImpl.getConfigByObjAndIndicator:监测对象id、监测指标id、项目id不能为空");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(pageQueryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId())) {
|
|
|
- queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_MONITOR_INDICATOR_ID, pageQueryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ QueryProjectMonitorIndicatorConfigDTO queryProjectMonitorIndicatorConfigDTO =
|
|
|
+ new QueryProjectMonitorIndicatorConfigDTO();
|
|
|
+ queryProjectMonitorIndicatorConfigDTO.setObjId(objId);
|
|
|
+ queryProjectMonitorIndicatorConfigDTO.setMonitorIndicatorId(monitorIndicatorId);
|
|
|
+
|
|
|
+ queryProjectMonitorIndicatorConfigDTO.setProjectId(projectId);
|
|
|
+ List<ProjectMonitorIndicatorConfig> projectMonitorIndicatorConfigs =
|
|
|
+ queryProjectMonitorIndicatorConfigList(queryProjectMonitorIndicatorConfigDTO);
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(projectMonitorIndicatorConfigs)) {
|
|
|
+ return projectMonitorIndicatorConfigs.get(0);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(pageQueryProjectMonitorIndicatorConfigDTO.getCaculateMethodId())) {
|
|
|
- queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_CACULATE_METHOD_ID, pageQueryProjectMonitorIndicatorConfigDTO.getCaculateMethodId());
|
|
|
+
|
|
|
+
|
|
|
+ return getDefaultConfig(objId, monitorIndicatorId, projectId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取设备监测指标的默认取值
|
|
|
+ *
|
|
|
+ * @param objId 监测对象id
|
|
|
+ * @param monitorIndicatorId 监测指标id
|
|
|
+ * @param projectId 项目id
|
|
|
+ * @return 设备监测指标的默认取值
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/9/17 2:57 下午
|
|
|
+ */
|
|
|
+ private ProjectMonitorIndicatorConfig getDefaultConfig(String objId, String monitorIndicatorId, String projectId) {
|
|
|
+ if (StringUtils.isBlank(objId) || StringUtils.isBlank(monitorIndicatorId) ||
|
|
|
+ StringUtils.isBlank(projectId)) {
|
|
|
+ throw new IllegalArgumentException("" +
|
|
|
+ "ProjectMonitorIndicatorConfigServiceImpl.getDefaultConfig:监测对象id、监测指标id、项目id不能为空");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(pageQueryProjectMonitorIndicatorConfigDTO.getProjectId())) {
|
|
|
- queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_PROJECT_ID, pageQueryProjectMonitorIndicatorConfigDTO.getProjectId());
|
|
|
+
|
|
|
+
|
|
|
+ QueryCalculateMethodDTO queryCalculateMethodDTO = new QueryCalculateMethodDTO();
|
|
|
+ queryCalculateMethodDTO.setMonitorIndicatorId(monitorIndicatorId);
|
|
|
+ queryCalculateMethodDTO.setIsDefault(BoolEnum.TRUE.getType());
|
|
|
+ List<CalculateMethod> calculateMethods = calculateMethodService.queryCalculateMethodList(queryCalculateMethodDTO);
|
|
|
+ String calculateMethodId = null;
|
|
|
+ if (!CollectionUtils.isEmpty(calculateMethods)) {
|
|
|
+ calculateMethodId = calculateMethods.get(0).getId();
|
|
|
}
|
|
|
-
|
|
|
- return getBaseMapper().selectPage(pageParam, queryWrapper);
|
|
|
+
|
|
|
+ return new ProjectMonitorIndicatorConfig(
|
|
|
+ objId, monitorIndicatorId, calculateMethodId, projectId);
|
|
|
}
|
|
|
}
|