Commit 8af34682 authored by xinglei's avatar xinglei

*)增加消息常量

parent 7656d9cb
......@@ -2,11 +2,14 @@ package com.yeejoin.amos.boot.biz.common.constants;
/**
* @Author: xl
* @Description: 终端标识
* @Description: 规则常量
* @Date: 2021/11/17 11:40
*/
public class TerminalConstant {
public class RuleConstant {
public final static String APP = "APP";
public final static String WEB = "WEB";
public final static String APP_WEB = "APP/WEB";
public final static Integer TASK = 0; // 任务
public final static Integer NOTIFY = 1; // 通知
}
package com.yeejoin.amos.boot.biz.common.enums;
import com.yeejoin.amos.boot.biz.common.constants.TerminalConstant;
import com.yeejoin.amos.boot.biz.common.constants.RuleConstant;
/**
* 规则请求枚举
......@@ -10,15 +10,15 @@ import com.yeejoin.amos.boot.biz.common.constants.TerminalConstant;
public enum RuleTypeEnum {
// 防火监督
计划提交("计划提交", "addPlan","auditPage", TerminalConstant.WEB),
计划审核("计划审核", "planAudit", "auditPage", TerminalConstant.APP_WEB),
计划审核完成("计划审核完成", "planAuditAll", "formulatePage", TerminalConstant.APP_WEB),
计划生成("计划生成", "addPlanTask", null, TerminalConstant.APP),
计划完成("计划完成", "planCompleted", null, TerminalConstant.APP_WEB),
计划提交("计划提交", "addPlan","auditPage", RuleConstant.WEB, RuleConstant.TASK),
计划审核("计划审核", "planAudit", "auditPage", RuleConstant.APP_WEB, RuleConstant.TASK),
计划审核完成("计划审核完成", "planAuditAll", "formulatePage", RuleConstant.APP_WEB, RuleConstant.NOTIFY),
计划生成("计划生成", "addPlanTask", null, RuleConstant.APP, RuleConstant.TASK),
计划完成("计划完成", "planCompleted", null, RuleConstant.APP_WEB, RuleConstant.NOTIFY),
// 隐患
隐患第一次提交("隐患提交", "addLatentDanger", null, null),
隐患审核("隐患审核", "dangerAudit", null, null);
隐患第一次提交("隐患提交", "addLatentDanger", null, null, RuleConstant.TASK),
隐患审核("隐患审核", "dangerAudit", null, null, RuleConstant.TASK);
/**
* 名称,描述
......@@ -36,6 +36,10 @@ public enum RuleTypeEnum {
* 终端标识
*/
private String terminal;
/**
* 类别
*/
private Integer category;
public String getName() {
return name;
......@@ -69,11 +73,20 @@ public enum RuleTypeEnum {
this.terminal = terminal;
}
RuleTypeEnum(String name, String code, String url, String terminal) {
public Integer getCategory() {
return category;
}
public void setCategory(Integer category) {
this.category = category;
}
RuleTypeEnum(String name, String code, String url, String terminal, Integer category) {
this.name = name;
this.code = code;
this.url = url;
this.terminal = terminal;
this.category = category;
}
public static RuleTypeEnum getEnumByCode(String field){
......
......@@ -61,6 +61,9 @@ public class LatentDangerRo implements Serializable {
@Label(value = "终端标识")
private String terminal;
@Label(value = "类别")
private Integer category;
@Label(value = "扩展参数")
private Map<String, String> extras;
}
package com.yeejoin.amos.latentdanger.business.service.impl;
import com.yeejoin.amos.boot.biz.common.constants.RuleConstant;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
......@@ -30,16 +31,12 @@ public class RuleDangerService {
private final String packageId = "消息/addDangerRule";
private final String msgType = "danger";
private final String APP = "APP";
private final String WEB = "WEB";
private final String APP_WEB = "APP/WEB";
@Autowired
private RuleTrigger ruleTrigger;
public Boolean addLatentDangerRule(LatentDanger latentDanger, String ruleType, String roleName) throws Exception {
LatentDangerRo latentDangerRo = buildLatentDangerRo(latentDanger, ruleType);
latentDangerRo.setTerminal(APP);
latentDangerRo.setTerminal(RuleConstant.APP);
List<RoleModel> result = Privilege.roleClient.queryRoleList(roleName, null).getResult();
if (result.size() > 0) {
List<AgencyUserModel> userModels = Privilege.agencyUserClient.queryByRoleId(String.valueOf(result.get(0).getSequenceNbr()), null).getResult();
......@@ -61,7 +58,7 @@ public class RuleDangerService {
latentDangerRo.setExcuteStateName(excuteStateName);
latentDangerRo.setIsSendWeb(true);
latentDangerRo.setRecivers(userIds);
latentDangerRo.setTerminal(APP_WEB);
latentDangerRo.setTerminal(RuleConstant.APP_WEB);
//触发规则
ruleTrigger.publish(latentDangerRo, packageId, new String[0]);
return true;
......@@ -73,6 +70,7 @@ public class RuleDangerService {
latentDangerRo.setMsgType(msgType);
latentDangerRo.setIsSendApp(true);
latentDangerRo.setRuleType(ruleType);
latentDangerRo.setCategory(RuleConstant.TASK);
latentDangerRo.setRelationId(String.valueOf(latentDanger.getId()));
latentDangerRo.setSendTime(DateUtil.date2LongStr(new Date()));
......
......@@ -17,7 +17,7 @@ import java.util.Map;
@RuleFact(value = "巡检计划",project = "消息规则")
public class PlanRo implements Serializable {
private static final long serialVersionUID = -3493714205659077324L;
private static final long serialVersionUID = -493916718753345180L;
@Label("计划名称")
private String name;
......@@ -52,6 +52,9 @@ public class PlanRo implements Serializable {
@Label(value = "终端标识")
private String terminal;
@Label(value = "类别")
private Integer category;
@Label(value = "扩展参数")
private Map<String, String> extras;
}
package com.yeejoin.amos.supervision.business.service.impl;
import com.yeejoin.amos.boot.biz.common.constants.TerminalConstant;
import com.yeejoin.amos.boot.biz.common.constants.RuleConstant;
import com.yeejoin.amos.boot.biz.common.enums.RuleTypeEnum;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.supervision.business.dto.PlanRo;
......@@ -56,6 +56,7 @@ public class RulePlanService {
planRo.setRuleType(ruleType.getCode());
planRo.setRelationId(String.valueOf(plan.getId()));
planRo.setTerminal(ruleType.getTerminal());
planRo.setCategory(ruleType.getCategory());
Map<String, String> map = new HashMap<>();
map.put("planId", String.valueOf(plan.getId()));
......@@ -63,11 +64,11 @@ public class RulePlanService {
map.put("url", ruleType.getUrl());
}
if (TerminalConstant.WEB.equals(ruleType.getTerminal())){
if (RuleConstant.WEB.equals(ruleType.getTerminal())){
planRo.setIsSendWeb(true);
} else if (TerminalConstant.APP.equals(ruleType.getTerminal())){
} else if (RuleConstant.APP.equals(ruleType.getTerminal())){
planRo.setIsSendApp(true);
} else if (TerminalConstant.APP_WEB.equals(ruleType.getTerminal())){
} else if (RuleConstant.APP_WEB.equals(ruleType.getTerminal())){
planRo.setIsSendWeb(true);
planRo.setIsSendApp(true);
}
......
......@@ -210,7 +210,7 @@
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>1.6.4-SNAPSHOT</version>
<version>1.6.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment