|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.persagy.dmp.starter.alarm.communication.mq.DmpMessage;
|
|
import com.persagy.dmp.starter.alarm.communication.mq.DmpMessage;
|
|
import com.persagy.dmp.starter.alarm.feign.AlarmUrlParam;
|
|
import com.persagy.dmp.starter.alarm.feign.AlarmUrlParam;
|
|
import com.persagy.dmp.starter.alarm.feign.DmpResult;
|
|
import com.persagy.dmp.starter.alarm.feign.DmpResult;
|
|
|
|
+import com.persagy.dmp.starter.alarm.feign.client.AlarmClient;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -26,7 +27,7 @@ import java.util.stream.Collectors;
|
|
@Slf4j
|
|
@Slf4j
|
|
public abstract class NettyAlarmService {
|
|
public abstract class NettyAlarmService {
|
|
@Autowired
|
|
@Autowired
|
|
- AlarmService alarmService;
|
|
|
|
|
|
+ AlarmClient alarmClient;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @description: 参数校验
|
|
* @description: 参数校验
|
|
@@ -62,12 +63,22 @@ public abstract class NettyAlarmService {
|
|
* @version: V1.0
|
|
* @version: V1.0
|
|
*/
|
|
*/
|
|
public AlarmUrlParam getAlarmUrlParam(JSONObject obj) throws Exception {
|
|
public AlarmUrlParam getAlarmUrlParam(JSONObject obj) throws Exception {
|
|
|
|
+ String projectId = obj.getString("projectId");
|
|
|
|
+ // 如果projectId为空,设置为0,查询集团下所有项目的数据
|
|
|
|
+ if (StringUtils.isEmpty(projectId)) {
|
|
|
|
+ obj.put("projectId", "0");
|
|
|
|
+ }
|
|
|
|
+ // 如果projectId为多个项目(用逗号分隔), param中projectId传0
|
|
|
|
+ String[] projectIds = projectId.split(",");
|
|
|
|
+ if (projectIds.length > 1) {
|
|
|
|
+ obj.put("projectId", "0");
|
|
|
|
+ }
|
|
this.checkRequestParam(obj);
|
|
this.checkRequestParam(obj);
|
|
|
|
|
|
return new AlarmUrlParam(
|
|
return new AlarmUrlParam(
|
|
obj.getString("userId"),
|
|
obj.getString("userId"),
|
|
obj.getString("groupCode"),
|
|
obj.getString("groupCode"),
|
|
- obj.getString("projectId"),
|
|
|
|
|
|
+ projectId,
|
|
obj.getString("appId")
|
|
obj.getString("appId")
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -110,6 +121,16 @@ public abstract class NettyAlarmService {
|
|
criteria.remove("page");
|
|
criteria.remove("page");
|
|
criteria.remove("size");
|
|
criteria.remove("size");
|
|
}
|
|
}
|
|
|
|
+ /* 如果查询条件中包含projectId,进行如下处理 */
|
|
|
|
+ String projectId = criteria.getString("projectId");
|
|
|
|
+ // 如果projectId为空或是0,从查询条件中移除
|
|
|
|
+ if (StringUtils.isEmpty(projectId) || "0".equals(projectId)) {
|
|
|
|
+ criteria.remove("projectId");
|
|
|
|
+ } else {
|
|
|
|
+ // 将projectId转换为数组,适配projectId为多个项目(用逗号分隔)的情况
|
|
|
|
+ String[] projectIds = projectId.split(",");
|
|
|
|
+ criteria.put("projectId", projectIds);
|
|
|
|
+ }
|
|
|
|
|
|
requestBody.put("criteria", criteria);
|
|
requestBody.put("criteria", criteria);
|
|
return requestBody;
|
|
return requestBody;
|
|
@@ -126,7 +147,7 @@ public abstract class NettyAlarmService {
|
|
* @version: V1.0
|
|
* @version: V1.0
|
|
*/
|
|
*/
|
|
public JSONArray queryAlarmConfig(JSONObject data) throws Exception {
|
|
public JSONArray queryAlarmConfig(JSONObject data) throws Exception {
|
|
- DmpResult<JSONArray> queryResult = alarmService.queryAlarmConfig(getAlarmUrlParam(data), getRequestBody(data));
|
|
|
|
|
|
+ DmpResult<JSONArray> queryResult = alarmClient.queryAlarmConfig(getAlarmUrlParam(data), getRequestBody(data));
|
|
JSONArray alarmConfigs = queryResult.getData();
|
|
JSONArray alarmConfigs = queryResult.getData();
|
|
// 报警定义中的信息点转换为表号、功能号
|
|
// 报警定义中的信息点转换为表号、功能号
|
|
initAlarmConfigInfoCodes(alarmConfigs);
|
|
initAlarmConfigInfoCodes(alarmConfigs);
|
|
@@ -236,7 +257,7 @@ public abstract class NettyAlarmService {
|
|
data.put("name", getAlarmName(objId));
|
|
data.put("name", getAlarmName(objId));
|
|
data.put("remark", getAlarmRemark(objId));
|
|
data.put("remark", getAlarmRemark(objId));
|
|
|
|
|
|
- DmpResult<JSONObject> alarmRecord = alarmService.createAlarmRecord(getAlarmUrlParam(data), data);
|
|
|
|
|
|
+ DmpResult<JSONObject> alarmRecord = alarmClient.createAlarmRecord(getAlarmUrlParam(data), data);
|
|
return alarmRecord.getData().getString("id");
|
|
return alarmRecord.getData().getString("id");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -251,7 +272,7 @@ public abstract class NettyAlarmService {
|
|
* @version: V1.0
|
|
* @version: V1.0
|
|
*/
|
|
*/
|
|
public void updateAlarmRecord(JSONObject data) throws Exception {
|
|
public void updateAlarmRecord(JSONObject data) throws Exception {
|
|
- alarmService.updateAlarmRecord(getAlarmUrlParam(data), data);
|
|
|
|
|
|
+ alarmClient.updateAlarmRecord(getAlarmUrlParam(data), data);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -295,7 +316,7 @@ public abstract class NettyAlarmService {
|
|
data.put("itemCode", jsonObject.getString("itemCode"));
|
|
data.put("itemCode", jsonObject.getString("itemCode"));
|
|
data.put("objId", jsonObject.getString("objId"));
|
|
data.put("objId", jsonObject.getString("objId"));
|
|
data.put("userId", "system");
|
|
data.put("userId", "system");
|
|
- DmpResult<JSONArray> alarmConfigQueryResult = alarmService.queryAlarmConfig(getAlarmUrlParam(data), getRequestBody(data));
|
|
|
|
|
|
+ DmpResult<JSONArray> alarmConfigQueryResult = alarmClient.queryAlarmConfig(getAlarmUrlParam(data), getRequestBody(data));
|
|
JSONArray tmpAlarmConfigArr = alarmConfigQueryResult.getData();
|
|
JSONArray tmpAlarmConfigArr = alarmConfigQueryResult.getData();
|
|
if (!CollectionUtils.isEmpty(tmpAlarmConfigArr)) {
|
|
if (!CollectionUtils.isEmpty(tmpAlarmConfigArr)) {
|
|
// 报警定义中的信息点转换为表号、功能号
|
|
// 报警定义中的信息点转换为表号、功能号
|