Browse Source

Merge branch 'v3.0.0' of http://39.106.8.246:3003/apm/energy-alarm-service into v3.0.0

lixing 2 years ago
parent
commit
89a2a291b9

+ 5 - 0
src/main/java/com/persagy/apm/dmpalarm/controller/AlarmCommentController.java

@@ -44,6 +44,11 @@ public class AlarmCommentController {
         return alarmCommentService.create(param);
     }
 
+    @PostMapping("/delete")
+    public MapResponse delete(@RequestBody AlarmComment param) {
+        return alarmCommentService.delete(param);
+    }
+
     @PostMapping("/sendMessage")
     public MapResponse update(@RequestBody AlarmComment param) {
         for (int i = 0; i < 2000; i++) {

+ 53 - 0
src/main/java/com/persagy/apm/dmpalarm/controller/AlarmEventTypeController.java

@@ -0,0 +1,53 @@
+/**
+ * 
+ */
+package com.persagy.apm.dmpalarm.controller;
+
+import javax.annotation.Resource;
+
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.persagy.apm.dmpalarm.criteria.JsonCriteria;
+import com.persagy.apm.dmpalarm.model.AlarmEventType;
+import com.persagy.apm.dmpalarm.service.IAlarmEventTypeService;
+import com.persagy.apm.dmpalarm.web.MapResponse;
+import com.persagy.apm.dmpalarm.web.PagedResponse;
+
+import io.swagger.annotations.Api;
+
+/**
+ * @author gaoyu
+ *
+ */
+@Api(tags = "报警原因事件类型")
+@Validated
+@RestController("dmpAlarmEvent")
+@RequestMapping("/alarm/event")
+public class AlarmEventTypeController {
+	
+    @Resource(name="dmpAlarmEventTypeService")
+    private IAlarmEventTypeService alarmEventTypeService;
+
+    @PostMapping("/query")
+    public PagedResponse<AlarmEventType> query(@RequestBody JsonCriteria criteria) {
+        return alarmEventTypeService.query(criteria);
+    }
+
+    @PostMapping("/create")
+    public MapResponse create(@RequestBody AlarmEventType param){
+        return alarmEventTypeService.create(param);
+    }
+
+    @PostMapping("/update")
+    public MapResponse update(@RequestBody AlarmEventType param){
+        return alarmEventTypeService.update(param);
+    }
+    @PostMapping("/delete")
+    public MapResponse delete(@RequestBody AlarmEventType param){
+        return alarmEventTypeService.delete(param);
+    }
+}

+ 1 - 1
src/main/java/com/persagy/apm/dmpalarm/criteria/CriteriaUtils.java

@@ -16,7 +16,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.gson.JsonArray;
 import com.persagy.apm.dmpalarm.criteria.JsonCriteria.Order;
 import com.persagy.apm.dmpalarm.utils.UtilsTools;
 import com.persagy.apm.dmpalarm.web.PagedResponse;
@@ -138,6 +137,7 @@ public class CriteriaUtils {
 		} else {
 			Page<T> page = baseMapper.selectPage(new Page<>(criteria.getPage(), criteria.getSize()), queryWrapper);
 			pagedResponse.setCount(page.getTotal());
+			System.out.println(queryWrapper.getCustomSqlSegment());
 			pagedResponse.setData(page.getRecords());
 		}
 		return pagedResponse;

+ 18 - 0
src/main/java/com/persagy/apm/dmpalarm/dao/AlarmEventTypeMapper.java

@@ -0,0 +1,18 @@
+/**
+ * 
+ */
+package com.persagy.apm.dmpalarm.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.persagy.apm.dmpalarm.model.AlarmEventType;
+
+/**
+ * @author gaoyu
+ *
+ */
+@Mapper
+public interface AlarmEventTypeMapper extends BaseMapper<AlarmEventType> {
+
+}

+ 4 - 4
src/main/java/com/persagy/apm/dmpalarm/model/AlarmComment.java

@@ -44,10 +44,10 @@ public class AlarmComment implements Serializable {
     
     @ApiModelProperty("更新人")
     private String updateUser;
-
-    private int valid;
+    private Integer valid;
+    @ApiModelProperty("alarm_event 外键")
+    private String eventTypeId;
     
-
     public static String PROP_RECORD_ID = "record_id";
     public static String PROP_CONTENT = "content";
     public static String PROP_CREATE_USER = "create_user";
@@ -56,5 +56,5 @@ public class AlarmComment implements Serializable {
     public static String PROP_CREATE_TIME = "create_time";
     public static String PROP_UPDATE_TIME = "update_time";
     public static String PROP_UPDATE_USER = "update_user";
-
+    public static String PROP_EVENT_TYPE_ID = "event_type_id";
 }

+ 31 - 0
src/main/java/com/persagy/apm/dmpalarm/model/AlarmEventType.java

@@ -0,0 +1,31 @@
+package com.persagy.apm.dmpalarm.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+ /**
+  * 
+  * @author gaoyu
+  *
+  */
+@Data
+@ApiModel(description = "报警原因事件类型")
+@TableName(autoResultMap = true)
+public class AlarmEventType implements Serializable {
+    private static final long serialVersionUID = -25604656657950729L;
+    private String id;
+    private Integer eventId;
+    private String eventName;
+    private String category; 
+    private Date ts;
+    private String creator;
+    private Date creationTime;
+    private String  modifier;
+    private Date modifiedTime; 
+    private Integer valid;
+}

+ 2 - 0
src/main/java/com/persagy/apm/dmpalarm/service/IAlarmCommentService.java

@@ -16,4 +16,6 @@ public interface IAlarmCommentService  {
     public PagedResponse<AlarmComment> query(JsonCriteria criteria);
 
     public MapResponse create(AlarmComment param);
+
+    public  MapResponse delete(AlarmComment param);
 }

+ 50 - 0
src/main/java/com/persagy/apm/dmpalarm/service/IAlarmEventTypeService.java

@@ -0,0 +1,50 @@
+/**
+ * 
+ */
+package com.persagy.apm.dmpalarm.service;
+
+import com.persagy.apm.dmpalarm.criteria.JsonCriteria;
+import com.persagy.apm.dmpalarm.model.AlarmEventType;
+import com.persagy.apm.dmpalarm.web.MapResponse;
+import com.persagy.apm.dmpalarm.web.PagedResponse;
+
+/**
+ * @author gaoyu
+ *
+ */
+public interface IAlarmEventTypeService {
+
+	/**
+	 *<p>分页查询</p>
+	 * @param criteria
+	 * @return    参数
+	 * @return PagedResponse<AlarmItem>    返回类型
+	 */
+	PagedResponse<AlarmEventType> query(JsonCriteria criteria);
+
+	/**
+	 *<p>更新</p>
+	 * @param param
+	 * @return    参数
+	 * @return MapResponse    返回类型
+	 */
+	MapResponse update(AlarmEventType param);
+
+	/**
+	 *<p>新增</p>
+	 * @param param
+	 * @return    参数
+	 * @return MapResponse    返回类型
+	 */
+	MapResponse create(AlarmEventType param);
+
+	/**
+	 *<p>删除</p>
+	 * @param param
+	 * @return    参数
+	 * @return MapResponse    返回类型
+	 */
+	MapResponse delete(AlarmEventType param);
+
+	 
+}

+ 10 - 2
src/main/java/com/persagy/apm/dmpalarm/service/impl/AlarmCommentServiceImpl.java

@@ -30,8 +30,7 @@ import lombok.extern.slf4j.Slf4j;
 @Service("dmpAlarmCommentService")
 @Slf4j
 public class AlarmCommentServiceImpl extends BaseServiceImpl<BaseMapper<AlarmComment>, AlarmComment> implements IAlarmCommentService {
-    @Resource
-    private CriteriaUtils criteriaUtils;
+ 
 
     public PagedResponse<AlarmComment> query(JsonCriteria criteria) {
         QueryWrapper<AlarmComment> queryWrapper = criteriaUtils.handleAlarmConditions(criteria, AlarmComment.class);
@@ -65,4 +64,13 @@ public class AlarmCommentServiceImpl extends BaseServiceImpl<BaseMapper<AlarmCom
         response.add("id", entity.getId());
         return response;
     }
+
+    @Override
+    public MapResponse delete(AlarmComment param) {
+        MapResponse response = new MapResponse();
+        boolean b=removeById(param.getId());
+        response.add("result", b);
+        return response;
+    }
+
 }

+ 1 - 2
src/main/java/com/persagy/apm/dmpalarm/service/impl/AlarmConfigServiceImpl.java

@@ -50,8 +50,7 @@ public class AlarmConfigServiceImpl extends BaseServiceImpl<BaseMapper<AlarmConf
     private IAlarmTargetService alarmTargetService;
     @Resource
     private IPhysicalWorldService physicalWorldService;
-    @Resource
-    private CriteriaUtils criteriaUtils;
+ 
 
     public PagedResponse<AlarmConfig> query(JsonCriteria criteria) {
         QueryWrapper<AlarmConfig> queryWrapper = criteriaUtils.handleAlarmConditions(criteria, AlarmConfig.class);

+ 99 - 0
src/main/java/com/persagy/apm/dmpalarm/service/impl/AlarmEventTypeServiceImpl.java

@@ -0,0 +1,99 @@
+/**
+ * 
+ */
+package com.persagy.apm.dmpalarm.service.impl;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.persagy.apm.dmpalarm.criteria.CriteriaUtils;
+import com.persagy.apm.dmpalarm.criteria.JsonCriteria;
+import com.persagy.apm.dmpalarm.model.AlarmEventType;
+import com.persagy.apm.dmpalarm.service.IAlarmEventTypeService;
+import com.persagy.apm.dmpalarm.utils.CheckRequiredParam;
+import com.persagy.apm.dmpalarm.web.MapResponse;
+import com.persagy.apm.dmpalarm.web.PagedResponse;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @author gaoyu
+ *
+ */
+@Slf4j
+@Service("dmpAlarmEventTypeService")
+public class AlarmEventTypeServiceImpl extends BaseServiceImpl<BaseMapper<AlarmEventType>, AlarmEventType>
+		implements IAlarmEventTypeService {
+ 
+	@Override
+	public PagedResponse<AlarmEventType> query(JsonCriteria criteria) {
+		QueryWrapper<AlarmEventType> queryWrapper = criteriaUtils.handleAlarmConditions(criteria, AlarmEventType.class);
+		try {
+			return criteriaUtils.getPagedResponse(criteria, AlarmEventType.class, queryWrapper, getBaseMapper());
+		} catch (Exception e) {
+			log.error("alarmEventType query page error JsonCriteria is  {}", criteria.toString(), e);
+		}
+		return new PagedResponse<>();
+	}
+
+	@Override
+	public MapResponse update(AlarmEventType entity) {
+		MapResponse response = new MapResponse();
+		AlarmParam alarmParam = prepareParam(response);
+		String checkResult = CheckRequiredParam.check(entity, "id", "eventId", "eventName", "category");
+		if (!StringUtils.isEmpty(checkResult)) {
+			response.setFail(checkResult);
+			return response;
+		}
+		if (alarmParam == null) {
+			return response;
+		}
+		entity.setModifier(alarmParam.userId);
+		entity.setModifiedTime(new Date());
+		saveOrUpdate(entity);
+		return response;
+	}
+
+	@Override
+	public MapResponse create(AlarmEventType entity) {
+		MapResponse response = new MapResponse();
+		AlarmParam alarmParam = prepareParam(response);
+		if (alarmParam == null) {
+			return response;
+		}
+		// 必填项校验
+		String checkResult = CheckRequiredParam.check(entity, "eventId", "eventName", "category");
+		if (!StringUtils.isEmpty(checkResult)) {
+			response.setFail(checkResult);
+			return response;
+		}
+		entity.setId(UUID.randomUUID().toString());
+		entity.setCreator(alarmParam.userId);
+		entity.setCreationTime(new Date());
+		entity.setValid(0);
+		save(entity);
+		response.setResult(entity.getId());
+		return response;
+	}
+
+	@Override
+	public MapResponse delete(AlarmEventType entity) {
+		MapResponse response = new MapResponse();
+		String checkResult = CheckRequiredParam.check(entity, "id");
+		if (!StringUtils.isEmpty(checkResult)) {
+			response.setFail(checkResult);
+			return response;
+		}
+		entity.setValid(1);
+		updateById(entity);
+		return response;
+	}
+
+}

+ 0 - 3
src/main/java/com/persagy/apm/dmpalarm/service/impl/AlarmItemServiceImpl.java

@@ -42,9 +42,6 @@ import lombok.extern.slf4j.Slf4j;
 @Slf4j
 public class AlarmItemServiceImpl extends BaseServiceImpl<BaseMapper<AlarmItem>, AlarmItem>
         implements IAlarmItemService {
-    @Resource
-    private CriteriaUtils criteriaUtils;
-
 
     @Override
     public PagedResponse<AlarmItem> query(JsonCriteria criteria) {

+ 35 - 12
src/main/java/com/persagy/apm/dmpalarm/service/impl/AlarmRecordServiceImpl.java

@@ -1,12 +1,32 @@
 package com.persagy.apm.dmpalarm.service.impl;
 
-import cn.hutool.core.date.DateUtil;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.persagy.apm.dmpalarm.config.DmpParameterStorage;
 import com.persagy.apm.dmpalarm.criteria.JsonCriteria;
-import com.persagy.apm.dmpalarm.enumeration.*;
+import com.persagy.apm.dmpalarm.enumeration.AlarmLogType;
+import com.persagy.apm.dmpalarm.enumeration.EnumAlarmListType;
+import com.persagy.apm.dmpalarm.enumeration.EnumAlarmMessageType;
+import com.persagy.apm.dmpalarm.enumeration.EnumAlarmRecordWithColumns;
+import com.persagy.apm.dmpalarm.enumeration.EnumAlarmState;
+import com.persagy.apm.dmpalarm.enumeration.EnumAlarmTreatState;
 import com.persagy.apm.dmpalarm.json.JacksonMapper;
 import com.persagy.apm.dmpalarm.model.AlarmLog;
 import com.persagy.apm.dmpalarm.model.AlarmRecord;
@@ -18,15 +38,10 @@ import com.persagy.apm.dmpalarm.utils.CheckRequiredParam;
 import com.persagy.apm.dmpalarm.utils.DatePatternStyle;
 import com.persagy.apm.dmpalarm.web.MapResponse;
 import com.persagy.apm.dmpalarm.web.PagedResponse;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
 
-import javax.annotation.Resource;
-import java.util.*;
-import java.util.Map.Entry;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.text.CharSequenceUtil;
+import lombok.extern.slf4j.Slf4j;
 
 /**
  * 报警记录(AlarmRecord) service层
@@ -43,7 +58,8 @@ public class AlarmRecordServiceImpl extends BaseServiceImpl<BaseMapper<AlarmReco
     @Resource
     private IShardingService shardingService;
 
-    @Override
+    @SuppressWarnings("unchecked")
+	@Override
     public PagedResponse<AlarmRecord> query(JsonCriteria jsonCriteria) {
         try {
             QueryWrapper<AlarmRecord> queryWrapper = criteriaUtils.handleAlarmConditions(jsonCriteria,
@@ -68,7 +84,14 @@ public class AlarmRecordServiceImpl extends BaseServiceImpl<BaseMapper<AlarmReco
             JSONObject supplementJsonObject = jsonCriteria.getCriteria().getJSONObject("supplement");
             if (null != supplementJsonObject && !supplementJsonObject.isEmpty()) {
                 for (Entry<String, Object> entry : supplementJsonObject.entrySet()) {
-                    queryWrapper.eq("supplement ->'$." + entry.getKey() + "'", entry.getValue());
+                	List<Object> param=new ArrayList<>();
+    				if (entry.getValue() instanceof List) {
+    					param = (List<Object>) entry.getValue() ;
+    				}else {
+    					param.add(entry.getValue());
+    				}
+    				String strArray =CharSequenceUtil.join("\",\"", param);
+                    queryWrapper.apply("JSON_CONTAINS( JSON_ARRAY(\""+strArray+"\"), JSON_ARRAY(supplement->'$."+entry.getKey()+"'))") ;
                 }
             }
             PagedResponse<AlarmRecord> resp = shardingService.selectShardingPageList(AlarmRecord.class, queryWrapper,

+ 1 - 1
src/main/resources/bootstrap.yml

@@ -32,7 +32,7 @@ spring:
     password: ${persagy.rabbitmq.password}
     virtual-host: ${persagy.rabbitmq.virtual-host}
 
-feign:
+feign: 
   compression:
     response:
       # feign返回结果不压缩