|
@@ -1,22 +1,35 @@
|
|
package com.persagy.apm.alarmservice.project.monitorindicatorconfig.service.impl;
|
|
package com.persagy.apm.alarmservice.project.monitorindicatorconfig.service.impl;
|
|
|
|
|
|
-import com.persagy.apm.common.context.AppContext;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+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.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.service.IProjectMonitorIndicatorConfigService;
|
|
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.BoolEnum;
|
|
import com.persagy.apm.common.constant.enums.ValidEnum;
|
|
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.persagy.apm.common.context.AppContext;
|
|
|
|
+import com.persagy.apm.common.context.poems.PoemsContext;
|
|
|
|
+import com.persagy.apm.model.dto.GroupManagementDTO;
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 项目监测指标配置(ProjectMonitorIndicatorConfig) service层
|
|
* 项目监测指标配置(ProjectMonitorIndicatorConfig) service层
|
|
*
|
|
*
|
|
@@ -24,15 +37,23 @@ import org.springframework.util.CollectionUtils;
|
|
* @version V1.0 2021-09-08 22:46:56
|
|
* @version V1.0 2021-09-08 22:46:56
|
|
*/
|
|
*/
|
|
@Service
|
|
@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
|
|
@Override
|
|
public String createProjectMonitorIndicatorConfig(AddProjectMonitorIndicatorConfigDTO addProjectMonitorIndicatorConfigDTO) {
|
|
public String createProjectMonitorIndicatorConfig(AddProjectMonitorIndicatorConfigDTO addProjectMonitorIndicatorConfigDTO) {
|
|
ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig = ConvertProjectMonitorIndicatorConfigTool.INSTANCE.convertAddDto2Entity(addProjectMonitorIndicatorConfigDTO);
|
|
ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig = ConvertProjectMonitorIndicatorConfigTool.INSTANCE.convertAddDto2Entity(addProjectMonitorIndicatorConfigDTO);
|
|
@@ -41,7 +62,7 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
save(projectMonitorIndicatorConfig);
|
|
save(projectMonitorIndicatorConfig);
|
|
return projectMonitorIndicatorConfig.getId();
|
|
return projectMonitorIndicatorConfig.getId();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 如果某些字段没有赋值,使用默认的值
|
|
* 如果某些字段没有赋值,使用默认的值
|
|
*
|
|
*
|
|
@@ -52,16 +73,17 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
private void setDefaultValue(ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig) {
|
|
private void setDefaultValue(ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig) {
|
|
projectMonitorIndicatorConfig.setCreator(AppContext.getContext().getAccountId());
|
|
projectMonitorIndicatorConfig.setCreator(AppContext.getContext().getAccountId());
|
|
// todo 其他默认的属性
|
|
// todo 其他默认的属性
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 项目监测指标配置详情
|
|
|
|
- * @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
|
|
@Override
|
|
public ProjectMonitorIndicatorConfig queryProjectMonitorIndicatorConfigDetail(String id) {
|
|
public ProjectMonitorIndicatorConfig queryProjectMonitorIndicatorConfigDetail(String id) {
|
|
ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig = getById(id);
|
|
ProjectMonitorIndicatorConfig projectMonitorIndicatorConfig = getById(id);
|
|
@@ -70,20 +92,25 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
}
|
|
}
|
|
return projectMonitorIndicatorConfig;
|
|
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
|
|
@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.setCaculateMethodId(updateProjectMonitorIndicatorConfigDTO.getCalculateMethodId());
|
|
projectMonitorIndicatorConfig.setModifier(AppContext.getContext().getAccountId());
|
|
projectMonitorIndicatorConfig.setModifier(AppContext.getContext().getAccountId());
|
|
updateById(projectMonitorIndicatorConfig);
|
|
updateById(projectMonitorIndicatorConfig);
|
|
|
|
+ return projectMonitorIndicatorConfig.getId();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 校验项目监测指标配置是否可删除
|
|
* 校验项目监测指标配置是否可删除
|
|
*
|
|
*
|
|
@@ -105,13 +132,14 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
|
|
|
|
return projectMonitorIndicatorConfig;
|
|
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
|
|
@Override
|
|
public void deleteProjectMonitorIndicatorConfig(String id) {
|
|
public void deleteProjectMonitorIndicatorConfig(String id) {
|
|
// 校验是否可删除
|
|
// 校验是否可删除
|
|
@@ -120,92 +148,147 @@ public class ProjectMonitorIndicatorConfigServiceImpl extends ServiceImpl<Projec
|
|
projectMonitorIndicatorConfig.setValid(ValidEnum.FALSE.getType());
|
|
projectMonitorIndicatorConfig.setValid(ValidEnum.FALSE.getType());
|
|
updateById(projectMonitorIndicatorConfig);
|
|
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
|
|
@Override
|
|
- public List<ProjectMonitorIndicatorConfig> queryProjectMonitorIndicatorConfigList(QueryProjectMonitorIndicatorConfigDTO queryProjectMonitorIndicatorConfigDTO) {
|
|
|
|
|
|
+ public List<ProjectMonitorIndicatorConfig> queryProjectMonitorIndicatorConfigList(
|
|
|
|
+ QueryProjectMonitorIndicatorConfigDTO queryProjectMonitorIndicatorConfigDTO) {
|
|
QueryWrapper<ProjectMonitorIndicatorConfig> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ProjectMonitorIndicatorConfig> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.eq(ProjectMonitorIndicatorConfig.PROP_VALID, ValidEnum.TRUE.getType());
|
|
queryWrapper.eq(ProjectMonitorIndicatorConfig.PROP_VALID, ValidEnum.TRUE.getType());
|
|
// 默认按创建时间倒序排序
|
|
// 默认按创建时间倒序排序
|
|
queryWrapper.orderBy(true, false, ProjectMonitorIndicatorConfig.PROP_CREATIONTIME);
|
|
queryWrapper.orderBy(true, false, ProjectMonitorIndicatorConfig.PROP_CREATIONTIME);
|
|
-
|
|
|
|
|
|
+
|
|
if (queryProjectMonitorIndicatorConfigDTO != null) {
|
|
if (queryProjectMonitorIndicatorConfigDTO != null) {
|
|
-
|
|
|
|
|
|
+
|
|
// todo 需判断使用like还是eq
|
|
// todo 需判断使用like还是eq
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getObjId())) {
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getObjId())) {
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_OBJ_ID, queryProjectMonitorIndicatorConfigDTO.getObjId());
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_OBJ_ID, queryProjectMonitorIndicatorConfigDTO.getObjId());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// todo 需判断使用like还是eq
|
|
// todo 需判断使用like还是eq
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId())) {
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId())) {
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_MONITOR_INDICATOR_ID, queryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId());
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_MONITOR_INDICATOR_ID, queryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// todo 需判断使用like还是eq
|
|
// todo 需判断使用like还是eq
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getCaculateMethodId())) {
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getCaculateMethodId())) {
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_CACULATE_METHOD_ID, queryProjectMonitorIndicatorConfigDTO.getCaculateMethodId());
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_CACULATE_METHOD_ID, queryProjectMonitorIndicatorConfigDTO.getCaculateMethodId());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// todo 需判断使用like还是eq
|
|
// todo 需判断使用like还是eq
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getProjectId())) {
|
|
if (StringUtils.isNotEmpty(queryProjectMonitorIndicatorConfigDTO.getProjectId())) {
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_PROJECT_ID, queryProjectMonitorIndicatorConfigDTO.getProjectId());
|
|
queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_PROJECT_ID, queryProjectMonitorIndicatorConfigDTO.getProjectId());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return list(queryWrapper);
|
|
return list(queryWrapper);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 分页查询项目监测指标配置
|
|
|
|
- * @return IPage<ProjectMonitorIndicatorConfig>
|
|
|
|
- * @author lixing
|
|
|
|
- * @version V1.0 2021-09-08 22:46:56
|
|
|
|
- */
|
|
|
|
|
|
+ * 分页查询项目监测指标配置
|
|
|
|
+ *
|
|
|
|
+ * @return IPage<ProjectMonitorIndicatorConfig>
|
|
|
|
+ * @author lixing
|
|
|
|
+ * @version V1.0 2021-09-08 22:46:56
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
- public IPage<ProjectMonitorIndicatorConfig> pageQueryProjectMonitorIndicatorConfig(PageQueryProjectMonitorIndicatorConfigDTO pageQueryProjectMonitorIndicatorConfigDTO) {
|
|
|
|
- QueryWrapper<ProjectMonitorIndicatorConfig> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.eq(ProjectMonitorIndicatorConfig.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
|
- // 这里认为pageQueryDTO是经过校验的,肯定包含分页信息
|
|
|
|
- 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<ProjectMonitorIndicatorConfig> pageQueryProjectMonitorIndicatorConfig(
|
|
|
|
+ PageQueryProjectMonitorIndicatorConfigDTO pageQueryProjectMonitorIndicatorConfigDTO) {
|
|
|
|
+ // TODO: 2021/9/17
|
|
|
|
+ // 获取分组下的监测指标,查询条件:设备类+监测指标id列表
|
|
|
|
+ List<MonitorIndicator> monitorIndicators = queryGroupIndicators(
|
|
|
|
+ pageQueryProjectMonitorIndicatorConfigDTO.getClassCode(),
|
|
|
|
+ pageQueryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId());
|
|
|
|
+ // 查询分组下的设备, 查询条件:分组id+项目id+设备名称(模糊)
|
|
|
|
+ String groupId = pageQueryProjectMonitorIndicatorConfigDTO.getGroupId();
|
|
|
|
+ if (StringUtils.isBlank(groupId)) {
|
|
|
|
+ throw new IllegalArgumentException("分组id不能为空");
|
|
}
|
|
}
|
|
-
|
|
|
|
- // todo 需判断使用like还是eq
|
|
|
|
- if (StringUtils.isNotEmpty(pageQueryProjectMonitorIndicatorConfigDTO.getObjId())) {
|
|
|
|
- queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_OBJ_ID, pageQueryProjectMonitorIndicatorConfigDTO.getObjId());
|
|
|
|
|
|
+ String projectId = PoemsContext.getContext().getProjectId();
|
|
|
|
+ GroupManagementDTO groupManagementDTO = new GroupManagementDTO();
|
|
|
|
+ groupManagementService.equipsQuery(managementDTO);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取分组下的监测指标
|
|
|
|
+ *
|
|
|
|
+ * @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不能为空");
|
|
}
|
|
}
|
|
-
|
|
|
|
- // todo 需判断使用like还是eq
|
|
|
|
- if (StringUtils.isNotEmpty(pageQueryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId())) {
|
|
|
|
- queryWrapper.like(ProjectMonitorIndicatorConfig.PROP_MONITOR_INDICATOR_ID, pageQueryProjectMonitorIndicatorConfigDTO.getMonitorIndicatorId());
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 根据监测对象id和监测指标id,获取设备监测指标的配置信息
|
|
|
|
+ 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);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // todo 需判断使用like还是eq
|
|
|
|
- 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不能为空");
|
|
}
|
|
}
|
|
-
|
|
|
|
- // todo 需判断使用like还是eq
|
|
|
|
- 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);
|
|
}
|
|
}
|
|
}
|
|
}
|