|
@@ -1,21 +1,36 @@
|
|
|
package com.persagy.apm.dmpalarm.service.impl;
|
|
|
|
|
|
-import com.persagy.apm.common.context.poems.PoemsContext;
|
|
|
-import com.persagy.apm.dmpalarm.dao.AlarmRecordMapper;
|
|
|
-import com.persagy.apm.dmpalarm.service.IAlarmRecordService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
-import com.persagy.apm.common.constant.enums.ValidEnum;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.persagy.apm.dmpalarm.model.*;
|
|
|
-import com.persagy.apm.dmpalarm.model.dto.*;
|
|
|
-import java.util.List;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.base.CaseFormat;
|
|
|
+import com.persagy.apm.common.constant.enums.ValidEnum;
|
|
|
import com.persagy.apm.common.model.dto.Sort;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
+import com.persagy.apm.dmpalarm.criteria.CriteriaUtils;
|
|
|
+import com.persagy.apm.dmpalarm.criteria.JsonCriteria;
|
|
|
+import com.persagy.apm.dmpalarm.dao.AlarmRecordMapper;
|
|
|
+import com.persagy.apm.dmpalarm.enumeration.EnumAlarmListType;
|
|
|
+import com.persagy.apm.dmpalarm.enumeration.EnumAlarmState;
|
|
|
+import com.persagy.apm.dmpalarm.enumeration.EnumAlarmTreatState;
|
|
|
+import com.persagy.apm.dmpalarm.model.AlarmRecord;
|
|
|
+import com.persagy.apm.dmpalarm.model.ConvertAlarmRecordTool;
|
|
|
+import com.persagy.apm.dmpalarm.model.dto.AddAlarmRecordDTO;
|
|
|
+import com.persagy.apm.dmpalarm.model.dto.PageQueryAlarmRecordDTO;
|
|
|
+import com.persagy.apm.dmpalarm.model.dto.QueryAlarmRecordDTO;
|
|
|
+import com.persagy.apm.dmpalarm.model.dto.UpdateAlarmRecordDTO;
|
|
|
+import com.persagy.apm.dmpalarm.service.IAlarmRecordService;
|
|
|
+import com.persagy.apm.dmpalarm.web.PagedResponse;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
/**
|
|
|
* 报警记录(AlarmRecord) service层
|
|
@@ -23,409 +38,439 @@ import org.springframework.util.CollectionUtils;
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021-12-09 10:44:19
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
-public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, AlarmRecord>
|
|
|
- implements IAlarmRecordService {
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建报警记录
|
|
|
- * @return 报警记录主键
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-12-09 10:44:19
|
|
|
- */
|
|
|
- @Override
|
|
|
- public String createAlarmRecord(AddAlarmRecordDTO addAlarmRecordDTO) {
|
|
|
- AlarmRecord alarmRecord = ConvertAlarmRecordTool.INSTANCE.convertAddDto2Entity(addAlarmRecordDTO);
|
|
|
- // 设置默认值
|
|
|
- setDefaultValue(alarmRecord);
|
|
|
- save(alarmRecord);
|
|
|
- return alarmRecord.getId();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 如果某些字段没有赋值,使用默认的值
|
|
|
- *
|
|
|
- * @param alarmRecord 报警记录实体
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021/3/12 12:29 下午
|
|
|
- */
|
|
|
- private void setDefaultValue(AlarmRecord alarmRecord) {
|
|
|
- alarmRecord.setCreator(PoemsContext.getContext().getUserId());
|
|
|
- // todo 其他默认的属性
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 报警记录详情
|
|
|
- * @param id 主键
|
|
|
- * @return 部门do类
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-12-09 10:44:19
|
|
|
- */
|
|
|
- @Override
|
|
|
- public AlarmRecord queryAlarmRecordDetail(String id) {
|
|
|
- AlarmRecord alarmRecord = getById(id);
|
|
|
- if (alarmRecord == null) {
|
|
|
- throw new IllegalArgumentException("查看AlarmRecord详情时发生异常,找不到要查看的记录,id=" + id);
|
|
|
- }
|
|
|
- return alarmRecord;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新报警记录
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-12-09 10:44:19
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void updateAlarmRecord(UpdateAlarmRecordDTO updateAlarmRecordDTO) {
|
|
|
- AlarmRecord alarmRecord = getById(updateAlarmRecordDTO.getId());
|
|
|
- alarmRecord = ConvertAlarmRecordTool.INSTANCE.convertUpdateDto2Entity(alarmRecord, updateAlarmRecordDTO);
|
|
|
- alarmRecord.setModifier(PoemsContext.getContext().getUserId());
|
|
|
- updateById(alarmRecord);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 校验报警记录是否可删除
|
|
|
- *
|
|
|
- * @param id 报警记录主键
|
|
|
- * @return 报警记录do类
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-12-09 10:44:19
|
|
|
- */
|
|
|
- public AlarmRecord checkDeletable(String id) {
|
|
|
- if (id == null) {
|
|
|
- throw new IllegalArgumentException("删除AlarmRecord时发生异常,主键为空");
|
|
|
- }
|
|
|
-
|
|
|
- AlarmRecord alarmRecord = getById(id);
|
|
|
-
|
|
|
- if (alarmRecord == null) {
|
|
|
- throw new IllegalArgumentException("删除AlarmRecord时发生异常,找不到要删除的数据,id:" + id);
|
|
|
- }
|
|
|
-
|
|
|
- return alarmRecord;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除报警记录
|
|
|
- * @param id 主键
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-12-09 10:44:19
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void deleteAlarmRecord(String id) {
|
|
|
- // 校验是否可删除
|
|
|
- AlarmRecord alarmRecord = checkDeletable(id);
|
|
|
-
|
|
|
- alarmRecord.setValid(ValidEnum.FALSE.getType());
|
|
|
- updateById(alarmRecord);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询报警记录
|
|
|
- * @return List<AlarmRecord>
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-12-09 10:44:19
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<AlarmRecord> queryAlarmRecordList(QueryAlarmRecordDTO queryAlarmRecordDTO) {
|
|
|
- QueryWrapper<AlarmRecord> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
- // 默认按创建时间倒序排序
|
|
|
- queryWrapper.orderBy(true, false, AlarmRecord.PROP_CREATIONTIME);
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO != null) {
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getItemCode())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_ITEM_CODE, queryAlarmRecordDTO.getItemCode());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getProjectId())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_PROJECT_ID, queryAlarmRecordDTO.getProjectId());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getObjId())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_OBJ_ID, queryAlarmRecordDTO.getObjId());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getClassCode())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_CLASS_CODE, queryAlarmRecordDTO.getClassCode());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getLevel())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_LEVEL, queryAlarmRecordDTO.getLevel());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getRemark())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_REMARK, queryAlarmRecordDTO.getRemark());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getCreateUser())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_CREATE_USER, queryAlarmRecordDTO.getCreateUser());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getCreateTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_CREATE_TIME, queryAlarmRecordDTO.getCreateTime());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getUpdateUser())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_UPDATE_USER, queryAlarmRecordDTO.getUpdateUser());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getUpdateTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_UPDATE_TIME, queryAlarmRecordDTO.getUpdateTime());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getName())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_NAME, queryAlarmRecordDTO.getName());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getCategory())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_CATEGORY, queryAlarmRecordDTO.getCategory());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getConcern() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_CONCERN, queryAlarmRecordDTO.getConcern());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getState() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_STATE, queryAlarmRecordDTO.getState());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getEffectStartTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_EFFECT_START_TIME, queryAlarmRecordDTO.getEffectStartTime());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getEffectEndTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_EFFECT_END_TIME, queryAlarmRecordDTO.getEffectEndTime());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getNature() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_NATURE, queryAlarmRecordDTO.getNature());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getTreatMode() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_TREAT_MODE, queryAlarmRecordDTO.getTreatMode());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getTreatState() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_TREAT_STATE, queryAlarmRecordDTO.getTreatState());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getGroupCode())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_GROUP_CODE, queryAlarmRecordDTO.getGroupCode());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getCondition() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_CONDITION, queryAlarmRecordDTO.getCondition());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getTriggerInfo() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_TRIGGER_INFO, queryAlarmRecordDTO.getTriggerInfo());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getEndInfo() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_END_INFO, queryAlarmRecordDTO.getEndInfo());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getTriggerTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_TRIGGER_TIME, queryAlarmRecordDTO.getTriggerTime());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getEndTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_END_TIME, queryAlarmRecordDTO.getEndTime());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getOrderId())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_ORDER_ID, queryAlarmRecordDTO.getOrderId());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getOrderState())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_ORDER_STATE, queryAlarmRecordDTO.getOrderState());
|
|
|
- }
|
|
|
-
|
|
|
- if (queryAlarmRecordDTO.getSupplement() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_SUPPLEMENT, queryAlarmRecordDTO.getSupplement());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getTargetId())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_TARGET_ID, queryAlarmRecordDTO.getTargetId());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return list(queryWrapper);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页查询报警记录
|
|
|
- * @return IPage<AlarmRecord>
|
|
|
- * @author lixing
|
|
|
- * @version V1.0 2021-12-09 10:44:19
|
|
|
- */
|
|
|
- @Override
|
|
|
- public IPage<AlarmRecord> pageQueryAlarmRecord(PageQueryAlarmRecordDTO pageQueryAlarmRecordDTO) {
|
|
|
- QueryWrapper<AlarmRecord> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
- // 这里认为pageQueryDTO是经过校验的,肯定包含分页信息
|
|
|
- IPage<AlarmRecord> pageParam = new Page<>(pageQueryAlarmRecordDTO.getPage(), pageQueryAlarmRecordDTO.getSize(),true);
|
|
|
- // 排序信息
|
|
|
- if(CollectionUtils.isEmpty(pageQueryAlarmRecordDTO.getOrders())){
|
|
|
- // 默认按创建时间倒序排序
|
|
|
- queryWrapper.orderBy(true, false, AlarmRecord.PROP_CREATIONTIME);
|
|
|
- }else {
|
|
|
- List<Sort> orders = pageQueryAlarmRecordDTO.getOrders();
|
|
|
- for(Sort sort: orders) {
|
|
|
- // 将驼峰转换为下划线格式
|
|
|
- sort.setColumn(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,sort.getColumn()));
|
|
|
- queryWrapper.orderBy(true, sort.isAsc(), sort.getColumn());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getItemCode())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_ITEM_CODE, pageQueryAlarmRecordDTO.getItemCode());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getProjectId())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_PROJECT_ID, pageQueryAlarmRecordDTO.getProjectId());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getObjId())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_OBJ_ID, pageQueryAlarmRecordDTO.getObjId());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getClassCode())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_CLASS_CODE, pageQueryAlarmRecordDTO.getClassCode());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getLevel())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_LEVEL, pageQueryAlarmRecordDTO.getLevel());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getRemark())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_REMARK, pageQueryAlarmRecordDTO.getRemark());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getCreateUser())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_CREATE_USER, pageQueryAlarmRecordDTO.getCreateUser());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getCreateTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_CREATE_TIME, pageQueryAlarmRecordDTO.getCreateTime());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getUpdateUser())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_UPDATE_USER, pageQueryAlarmRecordDTO.getUpdateUser());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getUpdateTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_UPDATE_TIME, pageQueryAlarmRecordDTO.getUpdateTime());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getName())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_NAME, pageQueryAlarmRecordDTO.getName());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getCategory())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_CATEGORY, pageQueryAlarmRecordDTO.getCategory());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getConcern() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_CONCERN, pageQueryAlarmRecordDTO.getConcern());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getState() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_STATE, pageQueryAlarmRecordDTO.getState());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getEffectStartTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_EFFECT_START_TIME, pageQueryAlarmRecordDTO.getEffectStartTime());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getEffectEndTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_EFFECT_END_TIME, pageQueryAlarmRecordDTO.getEffectEndTime());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getNature() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_NATURE, pageQueryAlarmRecordDTO.getNature());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getTreatMode() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_TREAT_MODE, pageQueryAlarmRecordDTO.getTreatMode());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getTreatState() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_TREAT_STATE, pageQueryAlarmRecordDTO.getTreatState());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getGroupCode())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_GROUP_CODE, pageQueryAlarmRecordDTO.getGroupCode());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getCondition() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_CONDITION, pageQueryAlarmRecordDTO.getCondition());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getTriggerInfo() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_TRIGGER_INFO, pageQueryAlarmRecordDTO.getTriggerInfo());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getEndInfo() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_END_INFO, pageQueryAlarmRecordDTO.getEndInfo());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getTriggerTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_TRIGGER_TIME, pageQueryAlarmRecordDTO.getTriggerTime());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getEndTime() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_END_TIME, pageQueryAlarmRecordDTO.getEndTime());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getOrderId())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_ORDER_ID, pageQueryAlarmRecordDTO.getOrderId());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getOrderState())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_ORDER_STATE, pageQueryAlarmRecordDTO.getOrderState());
|
|
|
- }
|
|
|
-
|
|
|
- if (pageQueryAlarmRecordDTO.getSupplement() != null) {
|
|
|
- queryWrapper.eq(AlarmRecord.PROP_SUPPLEMENT, pageQueryAlarmRecordDTO.getSupplement());
|
|
|
- }
|
|
|
-
|
|
|
- // todo 需判断使用like还是eq
|
|
|
- if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getTargetId())) {
|
|
|
- queryWrapper.like(AlarmRecord.PROP_TARGET_ID, pageQueryAlarmRecordDTO.getTargetId());
|
|
|
- }
|
|
|
-
|
|
|
- return getBaseMapper().selectPage(pageParam, queryWrapper);
|
|
|
- }
|
|
|
+public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, AlarmRecord> implements IAlarmRecordService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CriteriaUtils criteriaUtils;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建报警记录
|
|
|
+ *
|
|
|
+ * @return 报警记录主键
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-12-09 10:44:19
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String createAlarmRecord(AddAlarmRecordDTO addAlarmRecordDTO) {
|
|
|
+ AlarmRecord alarmRecord = ConvertAlarmRecordTool.INSTANCE.convertAddDto2Entity(addAlarmRecordDTO);
|
|
|
+ // 设置默认值
|
|
|
+ save(alarmRecord);
|
|
|
+ return alarmRecord.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报警记录详情
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 部门do类
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-12-09 10:44:19
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AlarmRecord queryAlarmRecordDetail(String id) {
|
|
|
+ AlarmRecord alarmRecord = getById(id);
|
|
|
+ if (alarmRecord == null) {
|
|
|
+ throw new IllegalArgumentException("查看AlarmRecord详情时发生异常,找不到要查看的记录,id=" + id);
|
|
|
+ }
|
|
|
+ return alarmRecord;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新报警记录
|
|
|
+ *
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-12-09 10:44:19
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updateAlarmRecord(UpdateAlarmRecordDTO updateAlarmRecordDTO) {
|
|
|
+ AlarmRecord alarmRecord = getById(updateAlarmRecordDTO.getId());
|
|
|
+ alarmRecord = ConvertAlarmRecordTool.INSTANCE.convertUpdateDto2Entity(alarmRecord, updateAlarmRecordDTO);
|
|
|
+ updateById(alarmRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验报警记录是否可删除
|
|
|
+ *
|
|
|
+ * @param id 报警记录主键
|
|
|
+ * @return 报警记录do类
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-12-09 10:44:19
|
|
|
+ */
|
|
|
+ public AlarmRecord checkDeletable(String id) {
|
|
|
+ if (id == null) {
|
|
|
+ throw new IllegalArgumentException("删除AlarmRecord时发生异常,主键为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ AlarmRecord alarmRecord = getById(id);
|
|
|
+
|
|
|
+ if (alarmRecord == null) {
|
|
|
+ throw new IllegalArgumentException("删除AlarmRecord时发生异常,找不到要删除的数据,id:" + id);
|
|
|
+ }
|
|
|
+
|
|
|
+ return alarmRecord;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除报警记录
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-12-09 10:44:19
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void deleteAlarmRecord(String id) {
|
|
|
+ // 校验是否可删除
|
|
|
+ AlarmRecord alarmRecord = checkDeletable(id);
|
|
|
+
|
|
|
+ alarmRecord.setValid(ValidEnum.FALSE.getType());
|
|
|
+ updateById(alarmRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询报警记录
|
|
|
+ *
|
|
|
+ * @return List<AlarmRecord>
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-12-09 10:44:19
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<AlarmRecord> queryAlarmRecordList(QueryAlarmRecordDTO queryAlarmRecordDTO) {
|
|
|
+ QueryWrapper<AlarmRecord> queryWrapper = new QueryWrapper<>();
|
|
|
+ // 默认按创建时间倒序排序
|
|
|
+ if (queryAlarmRecordDTO != null) {
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getItemCode())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_ITEM_CODE, queryAlarmRecordDTO.getItemCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getProjectId())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_PROJECT_ID, queryAlarmRecordDTO.getProjectId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getObjId())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_OBJ_ID, queryAlarmRecordDTO.getObjId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getClassCode())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_CLASS_CODE, queryAlarmRecordDTO.getClassCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getLevel())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_LEVEL, queryAlarmRecordDTO.getLevel());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getRemark())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_REMARK, queryAlarmRecordDTO.getRemark());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getCreateUser())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_CREATE_USER, queryAlarmRecordDTO.getCreateUser());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getCreateTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_CREATE_TIME, queryAlarmRecordDTO.getCreateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getUpdateUser())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_UPDATE_USER, queryAlarmRecordDTO.getUpdateUser());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getUpdateTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_UPDATE_TIME, queryAlarmRecordDTO.getUpdateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getName())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_NAME, queryAlarmRecordDTO.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getCategory())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_CATEGORY, queryAlarmRecordDTO.getCategory());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getConcern() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_CONCERN, queryAlarmRecordDTO.getConcern());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getState() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_STATE, queryAlarmRecordDTO.getState());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getEffectStartTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_EFFECT_START_TIME, queryAlarmRecordDTO.getEffectStartTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getEffectEndTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_EFFECT_END_TIME, queryAlarmRecordDTO.getEffectEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getNature() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_NATURE, queryAlarmRecordDTO.getNature());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getTreatMode() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_TREAT_MODE, queryAlarmRecordDTO.getTreatMode());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getTreatState() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_TREAT_STATE, queryAlarmRecordDTO.getTreatState());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getGroupCode())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_GROUP_CODE, queryAlarmRecordDTO.getGroupCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getCondition() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_CONDITION, queryAlarmRecordDTO.getCondition());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getTriggerInfo() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_TRIGGER_INFO, queryAlarmRecordDTO.getTriggerInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getEndInfo() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_END_INFO, queryAlarmRecordDTO.getEndInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getTriggerTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_TRIGGER_TIME, queryAlarmRecordDTO.getTriggerTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getEndTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_END_TIME, queryAlarmRecordDTO.getEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getOrderId())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_ORDER_ID, queryAlarmRecordDTO.getOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getOrderState())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_ORDER_STATE, queryAlarmRecordDTO.getOrderState());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryAlarmRecordDTO.getSupplement() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_SUPPLEMENT, queryAlarmRecordDTO.getSupplement());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(queryAlarmRecordDTO.getTargetId())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_TARGET_ID, queryAlarmRecordDTO.getTargetId());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return list(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询报警记录
|
|
|
+ *
|
|
|
+ * @return IPage<AlarmRecord>
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-12-09 10:44:19
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<AlarmRecord> pageQueryAlarmRecord(PageQueryAlarmRecordDTO pageQueryAlarmRecordDTO) {
|
|
|
+ QueryWrapper<AlarmRecord> queryWrapper = new QueryWrapper<>();
|
|
|
+ // 这里认为pageQueryDTO是经过校验的,肯定包含分页信息
|
|
|
+ IPage<AlarmRecord> pageParam = new Page<>(pageQueryAlarmRecordDTO.getPage(), pageQueryAlarmRecordDTO.getSize(),
|
|
|
+ true);
|
|
|
+ // 排序信息
|
|
|
+ if (CollectionUtils.isEmpty(pageQueryAlarmRecordDTO.getOrders())) {
|
|
|
+ // 默认按创建时间倒序排序
|
|
|
+ } else {
|
|
|
+ List<Sort> orders = pageQueryAlarmRecordDTO.getOrders();
|
|
|
+ for (Sort sort : orders) {
|
|
|
+ // 将驼峰转换为下划线格式
|
|
|
+ sort.setColumn(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sort.getColumn()));
|
|
|
+ queryWrapper.orderBy(true, sort.isAsc(), sort.getColumn());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getItemCode())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_ITEM_CODE, pageQueryAlarmRecordDTO.getItemCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getProjectId())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_PROJECT_ID, pageQueryAlarmRecordDTO.getProjectId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getObjId())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_OBJ_ID, pageQueryAlarmRecordDTO.getObjId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getClassCode())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_CLASS_CODE, pageQueryAlarmRecordDTO.getClassCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getLevel())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_LEVEL, pageQueryAlarmRecordDTO.getLevel());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getRemark())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_REMARK, pageQueryAlarmRecordDTO.getRemark());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getCreateUser())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_CREATE_USER, pageQueryAlarmRecordDTO.getCreateUser());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getCreateTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_CREATE_TIME, pageQueryAlarmRecordDTO.getCreateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getUpdateUser())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_UPDATE_USER, pageQueryAlarmRecordDTO.getUpdateUser());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getUpdateTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_UPDATE_TIME, pageQueryAlarmRecordDTO.getUpdateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getName())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_NAME, pageQueryAlarmRecordDTO.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getCategory())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_CATEGORY, pageQueryAlarmRecordDTO.getCategory());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getConcern() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_CONCERN, pageQueryAlarmRecordDTO.getConcern());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getState() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_STATE, pageQueryAlarmRecordDTO.getState());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getEffectStartTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_EFFECT_START_TIME, pageQueryAlarmRecordDTO.getEffectStartTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getEffectEndTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_EFFECT_END_TIME, pageQueryAlarmRecordDTO.getEffectEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getNature() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_NATURE, pageQueryAlarmRecordDTO.getNature());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getTreatMode() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_TREAT_MODE, pageQueryAlarmRecordDTO.getTreatMode());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getTreatState() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_TREAT_STATE, pageQueryAlarmRecordDTO.getTreatState());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getGroupCode())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_GROUP_CODE, pageQueryAlarmRecordDTO.getGroupCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getCondition() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_CONDITION, pageQueryAlarmRecordDTO.getCondition());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getTriggerInfo() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_TRIGGER_INFO, pageQueryAlarmRecordDTO.getTriggerInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getEndInfo() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_END_INFO, pageQueryAlarmRecordDTO.getEndInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getTriggerTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_TRIGGER_TIME, pageQueryAlarmRecordDTO.getTriggerTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getEndTime() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_END_TIME, pageQueryAlarmRecordDTO.getEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getOrderId())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_ORDER_ID, pageQueryAlarmRecordDTO.getOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getOrderState())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_ORDER_STATE, pageQueryAlarmRecordDTO.getOrderState());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageQueryAlarmRecordDTO.getSupplement() != null) {
|
|
|
+ queryWrapper.eq(AlarmRecord.PROP_SUPPLEMENT, pageQueryAlarmRecordDTO.getSupplement());
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需判断使用like还是eq
|
|
|
+ if (StringUtils.isNotEmpty(pageQueryAlarmRecordDTO.getTargetId())) {
|
|
|
+ queryWrapper.like(AlarmRecord.PROP_TARGET_ID, pageQueryAlarmRecordDTO.getTargetId());
|
|
|
+ }
|
|
|
+
|
|
|
+ return getBaseMapper().selectPage(pageParam, queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PagedResponse<AlarmRecord> query(JsonCriteria jsonCriteria) {
|
|
|
+ QueryWrapper<AlarmRecord> queryWrapper = criteriaUtils.handleAlarmConditions(jsonCriteria, AlarmRecord.class);
|
|
|
+ this.addAlarmQueryCondition(jsonCriteria.getCriteria(), queryWrapper);
|
|
|
+ PagedResponse<AlarmRecord> pagedResponse = new PagedResponse<>();
|
|
|
+ if (jsonCriteria.isOnlyCount()) {
|
|
|
+ Integer count = baseMapper.selectCount(queryWrapper);
|
|
|
+ pagedResponse.setCount(count.longValue());
|
|
|
+ } else {
|
|
|
+ Page<AlarmRecord> page = baseMapper.selectPage(new Page<>(jsonCriteria.getPage(), jsonCriteria.getSize()),
|
|
|
+ queryWrapper);
|
|
|
+ pagedResponse.setCount(page.getTotal());
|
|
|
+ pagedResponse.setData(page.getRecords());
|
|
|
+ }
|
|
|
+ return pagedResponse;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加查询报警条件 CURRENT 当前报警 HISTORY 历史报警
|
|
|
+ *
|
|
|
+ * @param jsonObject
|
|
|
+ * @param alarmRecordWrappers
|
|
|
+ */
|
|
|
+ private void addAlarmQueryCondition(JSONObject criteria, QueryWrapper<?> queryWrappers) {
|
|
|
+ String listType = criteria.getString("listType");
|
|
|
+ if (EnumAlarmListType.CURRENT.name().equals(listType)) {
|
|
|
+ queryWrappers.eq(AlarmRecord.PROP_STATE, EnumAlarmState.UN_HANDLE.getType());
|
|
|
+ queryWrappers.and(andWrapper -> andWrapper
|
|
|
+ .eq(AlarmRecord.PROP_TREAT_STATE, EnumAlarmTreatState.UN_HANDLE.getType()).or(orWrapper -> orWrapper
|
|
|
+ .eq(AlarmRecord.PROP_TREAT_STATE, EnumAlarmTreatState.HANDLING.getType())));
|
|
|
+ }
|
|
|
+ if (EnumAlarmListType.HISTORY.name().equals(listType)) {
|
|
|
+ queryWrappers.eq(AlarmRecord.PROP_STATE, EnumAlarmState.END.getType()).or(orWrapper -> orWrapper
|
|
|
+ .eq(AlarmRecord.PROP_STATE, EnumAlarmState.EXPIRE.getType())
|
|
|
+ .or(or2Wrapper -> or2Wrapper.eq(AlarmRecord.PROP_TREAT_STATE, EnumAlarmTreatState.DONE.getType())));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|