Commit 1f4383c6 authored by maoying's avatar maoying

Merge branch 'dev_upgrade_rule' of 172.16.10.76:station/YeeAmosFireAutoSysRoot…

Merge branch 'dev_upgrade_rule' of 172.16.10.76:station/YeeAmosFireAutoSysRoot into dev_upgrade_rule
parents 0429bf5a afee2bfe
...@@ -13,7 +13,8 @@ import java.util.HashMap; ...@@ -13,7 +13,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -31,13 +32,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -31,13 +32,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.component.rule.MethodParam; import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean; import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod; import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.DeviceRo; import com.yeejoin.amos.fas.business.action.model.DeviceRo;
import com.yeejoin.amos.fas.business.action.model.SetpEnum; import com.yeejoin.amos.fas.business.action.model.SetpEnum;
import com.yeejoin.amos.fas.business.action.mq.StationEnum;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.result.ActionResult; import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult; import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult;
import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage; import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage;
import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher;
import com.yeejoin.amos.fas.business.action.util.StepComparator; import com.yeejoin.amos.fas.business.action.util.StepComparator;
import com.yeejoin.amos.fas.business.feign.IDutyModeServer; import com.yeejoin.amos.fas.business.feign.IDutyModeServer;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService; import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
...@@ -75,7 +80,8 @@ public class ContingencyAction implements CustomerAction { ...@@ -75,7 +80,8 @@ public class ContingencyAction implements CustomerAction {
@Autowired @Autowired
private FireStengthService fireStrengthService; private FireStengthService fireStrengthService;
@Autowired
private ContingencyLogPublisher contingencyLogPublisher;
// private RestTemplate restTemplate = new RestTemplate(); // private RestTemplate restTemplate = new RestTemplate();
// @Value("${bussunis.domain}") // @Value("${bussunis.domain}")
...@@ -167,12 +173,20 @@ public class ContingencyAction implements CustomerAction { ...@@ -167,12 +173,20 @@ public class ContingencyAction implements CustomerAction {
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson()); ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, "yinan","plan"); String topic = String.format("/%s/%s/%s", serviceName, StationEnum.YINAN.getCode(),"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){ } else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, contingency); action.execute(msgType, contingency);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -373,14 +387,31 @@ public class ContingencyAction implements CustomerAction { ...@@ -373,14 +387,31 @@ public class ContingencyAction implements CustomerAction {
content = content.replaceAll("\\$\\{" + field.getName() + "}", value); content = content.replaceAll("\\$\\{" + field.getName() + "}", value);
} }
content = content.replaceAll("\\$\\{", ""); content = getNative(content);
content = content.replaceAll("}", ""); // content = content.replaceAll("\\$\\{", "");
// content = content.replaceAll("}", "");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return content; return content;
} }
public String getNative(String str)
{
Pattern p = Pattern.compile("\\$\\{(.*?)\\}");
Matcher m = p.matcher(str);
while (m.find())
{
String parameter = m.group();
Object parametervalue = ELEvaluationContext
.getValue(parameter.substring(1, parameter.length() - 1));
if(parametervalue != null)
str = str.replace(parameter,
parametervalue != null ? parametervalue.toString() : null);
}
return str;
}
/** /**
* 交互动作 * 交互动作
...@@ -532,7 +563,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -532,7 +563,7 @@ public class ContingencyAction implements CustomerAction {
/** /**
* 地图动作推送 * 地图动作推送
* *
* @param actionName 动作名称标识 * @param actionName 动作名称标识
* @param paramObj 预案对象 * @param paramObj 预案对象
...@@ -544,7 +575,6 @@ public class ContingencyAction implements CustomerAction { ...@@ -544,7 +575,6 @@ public class ContingencyAction implements CustomerAction {
log.error("======================================================================================="); log.error("=======================================================================================");
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
...@@ -554,6 +584,27 @@ public class ContingencyAction implements CustomerAction { ...@@ -554,6 +584,27 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("maparea", paramObj, result); this.sendcmd("maparea", paramObj, result);
} }
@RuleMethod(methodLabel = "地图动画", project = "青海换流站消防预案")
public void mapCartoonAction(
@MethodParam(paramLabel = "动作名称标识") String actionName,
@MethodParam(paramLabel = "动作类型") String actionType,
@MethodParam(paramLabel = "动作类型参数") String paramJSON,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("=======================================================================================");
stopSnapshop(contingencyRo);
String parameter = instedParams(paramJSON, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content",actionType);
tempmap1.put("parameter",parameter);
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
}
/** /**
* 顶部消息提示 * 顶部消息提示
...@@ -738,9 +789,16 @@ public class ContingencyAction implements CustomerAction { ...@@ -738,9 +789,16 @@ public class ContingencyAction implements CustomerAction {
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson()); ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, "yinan","plan"); String topic = String.format("/%s/%s/%s", serviceName, StationEnum.YINAN.getCode(),"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(deviceRo);
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){ } else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, deviceRo); action.execute(msgType, deviceRo);
} }
......
package com.yeejoin.amos.fas.business.action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService;
@Component
public class ContingencyLogListener implements ApplicationListener<ContingencyEvent>{
@Autowired
IRuleRunningSnapshotService ruleRunningSnapshotService;
@Override
public void onApplicationEvent(ContingencyEvent event) {
ruleRunningSnapshotService.reacordPlan(event.getTopic(), event.getMsgType(), event.getMsgBody(), event.getContingency());
}
}
...@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component; ...@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
import com.yeejoin.amos.component.rule.MethodParam; import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean; import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod; import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.amos.fas.business.action.mq.StationEnum;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.result.ActionResult; import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.result.BubbleTipResult; import com.yeejoin.amos.fas.business.action.result.BubbleTipResult;
...@@ -69,7 +70,7 @@ public class RiskSituationAction implements CustomerAction ...@@ -69,7 +70,7 @@ public class RiskSituationAction implements CustomerAction
String msgType = "bubbleTip"; String msgType = "bubbleTip";
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result); ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
String topic = String.format("/%s/%s/%s", serviceName, "yinan","rule"); String topic = String.format("/%s/%s/%s", serviceName, StationEnum.YINAN.getCode(),"rule");
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
} else { } else {
Object obj = action.execute(msgType, bizobj); Object obj = action.execute(msgType, bizobj);
......
...@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; ...@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext; import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
import com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo; import com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo;
import com.yeejoin.amos.fas.business.action.mq.StationEnum;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.result.AbstractActionResult; import com.yeejoin.amos.fas.business.action.result.AbstractActionResult;
import com.yeejoin.amos.fas.business.action.result.ActionResult; import com.yeejoin.amos.fas.business.action.result.ActionResult;
...@@ -77,7 +78,7 @@ public class SimpleTipAction implements CustomerAction ...@@ -77,7 +78,7 @@ public class SimpleTipAction implements CustomerAction
String msgType = "message"; String msgType = "message";
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result); ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
String topic = String.format("/%s/%s/%s", serviceName, "yinan","rule"); String topic = String.format("/%s/%s/%s", serviceName, StationEnum.YINAN.getCode(),"rule");
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
} else { } else {
action.execute(msgType, bizobj); action.execute(msgType, bizobj);
......
package com.yeejoin.amos.fas.business.action.model;
import org.springframework.context.ApplicationEvent;
import lombok.Data;
@Data
public class ContingencyEvent extends ApplicationEvent{
public ContingencyEvent(Object source) {
super(source);
}
/**
*
*/
private static final long serialVersionUID = -5239150129698935970L;
private String topic;
private String msgType;
private String msgBody;
private Object contingency;
}
package com.yeejoin.amos.fas.business.action.mq;
public enum StationEnum {
YINAN("yinan", "沂南站");
String code;
String desc;
private StationEnum(String code, String desc) {
this.desc = desc;
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
package com.yeejoin.amos.fas.business.action.util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
@Component
public class ContingencyLogPublisher {
@Autowired
//注入ApplicationContext用来发布事件
ApplicationContext applicationContext;
//使用ApplicationContext的publishEvent方法来发布
public void publish(ContingencyEvent msg){
applicationContext.publishEvent(msg);
}
}
...@@ -5,10 +5,12 @@ import com.google.common.collect.Maps; ...@@ -5,10 +5,12 @@ import com.google.common.collect.Maps;
import com.yeejoin.amos.fas.business.param.PointListParam; import com.yeejoin.amos.fas.business.param.PointListParam;
import com.yeejoin.amos.fas.business.param.QueryParamUtil; import com.yeejoin.amos.fas.business.param.QueryParamUtil;
import com.yeejoin.amos.fas.business.service.intfc.ICommonService; import com.yeejoin.amos.fas.business.service.intfc.ICommonService;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.business.vo.ReginParams; import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.config.Permission; import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable; import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.request.CommonRequest; import com.yeejoin.amos.fas.core.common.request.CommonRequest;
import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
...@@ -21,6 +23,7 @@ import org.slf4j.LoggerFactory; ...@@ -21,6 +23,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanMap; import org.springframework.cglib.beans.BeanMap;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap; import java.util.HashMap;
...@@ -31,11 +34,13 @@ import java.util.Map; ...@@ -31,11 +34,13 @@ import java.util.Map;
@RequestMapping(value = "/api/common") @RequestMapping(value = "/api/common")
@Api(tags = "公共资源api") @Api(tags = "公共资源api")
public class CommonController extends BaseController { public class CommonController extends BaseController {
private final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired @Autowired
private ICommonService commonService; private ICommonService commonService;
@Autowired
private IRiskSourceService iRiskSourceService;
private final Logger log = LoggerFactory.getLogger(CommonController.class);
/** /**
...@@ -53,19 +58,11 @@ public class CommonController extends BaseController { ...@@ -53,19 +58,11 @@ public class CommonController extends BaseController {
return CommonResponseUtil.failure("公司信息获取失败!"); return CommonResponseUtil.failure("公司信息获取失败!");
} }
List<DepartmentModel> deps = commonService.getDepartment(getToken(),getProduct(),getAppKey(), companyId); List<DepartmentModel> deps = commonService.getDepartment(getToken(),getProduct(),getAppKey(), companyId);
return CommonResponseUtil.success(objectsToMaps(deps)); return CommonResponseUtil.success(objectsToMaps(deps));
} }
public static <T> Map<String, Object> beanToMap(T bean) { public static <T> Map<String, Object> beanToMap(T bean) {
Map<String, Object> map = Maps.newHashMap(); Map<String, Object> map = Maps.newHashMap();
if (bean != null) { if (bean != null) {
...@@ -95,14 +92,7 @@ public class CommonController extends BaseController { ...@@ -95,14 +92,7 @@ public class CommonController extends BaseController {
} }
} }
return list; return list;
} }
/** /**
* 查询巡检点信息 * 查询巡检点信息
...@@ -116,7 +106,6 @@ public class CommonController extends BaseController { ...@@ -116,7 +106,6 @@ public class CommonController extends BaseController {
public CommonResponse getPoints( public CommonResponse getPoints(
@ApiParam(value = "查询条件", required = false) @RequestBody(required = false) List<CommonRequest> queryRequests, @ApiParam(value = "查询条件", required = false) @RequestBody(required = false) List<CommonRequest> queryRequests,
@ApiParam(value = "分页参数", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable commonPageable) { @ApiParam(value = "分页参数", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable commonPageable) {
try { try {
PointListParam params = new PointListParam(); PointListParam params = new PointListParam();
QueryParamUtil.fillPointListParam(queryRequests, commonPageable, params); QueryParamUtil.fillPointListParam(queryRequests, commonPageable, params);
...@@ -180,4 +169,10 @@ public class CommonController extends BaseController { ...@@ -180,4 +169,10 @@ public class CommonController extends BaseController {
List<AgencyUserModel> users = commonService.getAllUser(getToken(),getProduct(),getAppKey(), compCode); List<AgencyUserModel> users = commonService.getAllUser(getToken(),getProduct(),getAppKey(), compCode);
return CommonResponseUtil.success(users); return CommonResponseUtil.success(users);
} }
@ApiOperation(value = "查询公司下的风险模型(厂区、区域、风险点)")
@GetMapping(value = "/riskSource/list/{orgCode}",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public CommonResponse getRiskSourceList(@PathVariable String orgCode){
return CommonResponseUtil.success(iRiskSourceService.findRiskSourceTrees(orgCode));
}
} }
...@@ -26,7 +26,8 @@ public class CurCompanyController extends BaseController { ...@@ -26,7 +26,8 @@ public class CurCompanyController extends BaseController {
map.put("nickName", getUserInfo().getRealName()); map.put("nickName", getUserInfo().getRealName());
map.put("company", getSelectedOrgInfo().getCompany()); map.put("company", getSelectedOrgInfo().getCompany());
map.put("department", getSelectedOrgInfo().getDepartment()); map.put("department", getSelectedOrgInfo().getDepartment());
map.put("role", getSelectedOrgInfo().getRole());
return CommonResponseUtil.success(map); return CommonResponseUtil.success(map);
} }
} }
package com.yeejoin.amos.fas.business.controller; package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam; import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
import com.yeejoin.amos.fas.business.param.RiskFmeaParam; import com.yeejoin.amos.fas.business.param.RiskFmeaParam;
import com.yeejoin.amos.fas.business.service.intfc.IFmeaService; import com.yeejoin.amos.fas.business.service.intfc.IFmeaService;
...@@ -15,18 +31,10 @@ import com.yeejoin.amos.fas.core.util.CommonResponseUtil; ...@@ -15,18 +31,10 @@ import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.Fmea; import com.yeejoin.amos.fas.dao.entity.Fmea;
import com.yeejoin.amos.fas.dao.entity.RiskSource; import com.yeejoin.amos.fas.dao.entity.RiskSource;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
@RestController @RestController
@RequestMapping("/api/riskModel") @RequestMapping("/api/riskModel")
...@@ -37,7 +45,7 @@ public class RiskModelController extends BaseController { ...@@ -37,7 +45,7 @@ public class RiskModelController extends BaseController {
@Autowired @Autowired
private IRiskSourceService riskSourceService; private IRiskSourceService riskSourceService;
@Autowired @Autowired
private IFmeaService fmeaService; private IFmeaService fmeaService;
...@@ -71,6 +79,20 @@ public class RiskModelController extends BaseController { ...@@ -71,6 +79,20 @@ public class RiskModelController extends BaseController {
if (type.equals(2) && isRegion.equals("TRUE")) { if (type.equals(2) && isRegion.equals("TRUE")) {
return CommonResponseUtil.failure("该区域下只能添加风险点"); return CommonResponseUtil.failure("该区域下只能添加风险点");
} }
Long id = param.getId();
if (id == 0) {//新增
} else {
// 更新的话,就放到前面,更新失败直接阻止本地
// 如果对于新增修改有什么约束,请添加到远程同步之前
String synMsg = riskSourceService.saveToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS,
param.getId(), param.getCode(), param.getName(), param.getParentId());
if (synMsg != null) {
return CommonResponseUtil.failure(synMsg);
}
}
AgencyUserModel user = getUserInfo(); AgencyUserModel user = getUserInfo();
ReginParams reginParams =getSelectedOrgInfo(); ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams); String compCode=getOrgCode(reginParams);
...@@ -78,13 +100,27 @@ public class RiskModelController extends BaseController { ...@@ -78,13 +100,27 @@ public class RiskModelController extends BaseController {
map.put("org_code", compCode); map.put("org_code", compCode);
map.put("user_id", user.getUserId()); map.put("user_id", user.getUserId());
map.put("param", param); map.put("param", param);
return CommonResponseUtil.success(riskSourceService.editRiskSource(map));
CommonResponse cr = CommonResponseUtil.success(riskSourceService.editRiskSource(map));
if (id == 0) {//新增 新增的话,只能放到本地之后,因为必须拿到新增之后的ID才行
// 如果对于新增修改有什么约束,请添加到远程同步之前
String synMsg = riskSourceService.saveToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS,
param.getId(), param.getCode(), param.getName(), param.getParentId());
if (synMsg != null) {
//远程新增失败,就把本地删了,有点绕,但是没办法
//由于是刚刚新建的,就直接删除,不做任何不能删校验。
riskSourceService.deleteById(param.getId());
return CommonResponseUtil.failure(synMsg);
}
}
return cr;
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return CommonResponseUtil.failure("风险模型新增及维护失败:" + e.getMessage()); return CommonResponseUtil.failure("风险模型新增及维护失败:" + e.getMessage());
} }
} }
/** /**
* 风险模型删除 * 风险模型删除
*/ */
...@@ -93,7 +129,7 @@ public class RiskModelController extends BaseController { ...@@ -93,7 +129,7 @@ public class RiskModelController extends BaseController {
@RequestMapping(value = "/riskSource/deleteRiskSource", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/riskSource/deleteRiskSource", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse deleteRiskSource(@ApiParam(value = "风险模型id", required = true) @RequestBody Long[] riskSourceId) { public CommonResponse deleteRiskSource(@ApiParam(value = "风险模型id", required = true) @RequestBody Long[] riskSourceId) {
try { try {
riskSourceService.deleteRiskSource(riskSourceId); riskSourceService.deleteRiskSource(getAppKey(), getProduct(), getToken(), SUCCESS, riskSourceId);
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
......
...@@ -15,6 +15,7 @@ import org.springframework.util.ObjectUtils; ...@@ -15,6 +15,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -121,6 +122,23 @@ public class RiskSourceController extends BaseController { ...@@ -121,6 +122,23 @@ public class RiskSourceController extends BaseController {
return CommonResponseUtil.success(getRiskSourcesTree(riskSources)); return CommonResponseUtil.success(getRiskSourcesTree(riskSources));
} }
@Permission
@ApiOperation(value = "远程同步", notes = "将本地 风险模型推送到远程同步")
@PutMapping(value = "/synToEquipManage")
public CommonResponse synToEquipManage() {
ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams);
if(!riskSourceService.isSynEquipManage()) {
return CommonResponseUtil.failure("同步功能未开启");
}
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode);
String synMsg = riskSourceService.synToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS, getRiskSourcesTree(riskSources));
if (synMsg != null) {
return CommonResponseUtil.failure(synMsg);
}
return CommonResponseUtil.success();
}
/** /**
* 获取区域树型结构 * 获取区域树型结构
* *
...@@ -599,7 +617,7 @@ public class RiskSourceController extends BaseController { ...@@ -599,7 +617,7 @@ public class RiskSourceController extends BaseController {
return CommonResponseUtil.success(riskSourceService.processFireEqumtData(deviceData)); return CommonResponseUtil.success(riskSourceService.processFireEqumtData(deviceData));
} }
@Permission // @Permission
@ApiOperation(httpMethod = "POST", value = "上传消防设备数据", notes = "上传消防设备数据") @ApiOperation(httpMethod = "POST", value = "上传消防设备数据", notes = "上传消防设备数据")
@RequestMapping(value = "/data/fireqeuiment/soe", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/data/fireqeuiment/soe", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse postFireEqumentData(@RequestBody AlarmParam alarm) throws Exception { public CommonResponse postFireEqumentData(@RequestBody AlarmParam alarm) throws Exception {
...@@ -608,7 +626,7 @@ public class RiskSourceController extends BaseController { ...@@ -608,7 +626,7 @@ public class RiskSourceController extends BaseController {
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
@Permission // @Permission
@ApiOperation(httpMethod = "POST", value = "上传消防设备数据", notes = "上传消防设备数据") @ApiOperation(httpMethod = "POST", value = "上传消防设备数据", notes = "上传消防设备数据")
@RequestMapping(value = "/data/fireqeuiment/all", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/data/fireqeuiment/all", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse postFireEqumentData(@RequestBody List<AlarmParam> deviceDatas) throws Exception { public CommonResponse postFireEqumentData(@RequestBody List<AlarmParam> deviceDatas) throws Exception {
...@@ -622,7 +640,9 @@ public class RiskSourceController extends BaseController { ...@@ -622,7 +640,9 @@ public class RiskSourceController extends BaseController {
@RequestMapping(value = "/data/patroldata", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT) @RequestMapping(value = "/data/patroldata", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse postPatrolData(@RequestBody ProtalDataRo protalData) throws Exception { public CommonResponse postPatrolData(@RequestBody ProtalDataRo protalData) throws Exception {
log.info("上传巡检数据" + JSONObject.toJSONString(protalData)); log.info("上传巡检数据" + JSONObject.toJSONString(protalData));
riskSourceService.processProtalData(getToken(),getProduct(),getAppKey(),protalData); ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams);
riskSourceService.processProtalData(getToken(),getProduct(),getAppKey(),protalData, compCode);
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
...@@ -46,7 +46,9 @@ public class TimeLineController extends BaseController{ ...@@ -46,7 +46,9 @@ public class TimeLineController extends BaseController{
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@Autowired
private IRuleRunningSnapshotService ruleRunningSnapshotService;
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET",value = "根据批次号查询时间轴", notes = "根据批次号查询时间轴") @ApiOperation(httpMethod = "GET",value = "根据批次号查询时间轴", notes = "根据批次号查询时间轴")
...@@ -96,6 +98,23 @@ public class TimeLineController extends BaseController{ ...@@ -96,6 +98,23 @@ public class TimeLineController extends BaseController{
return CommonResponseUtil.success("SUCCESS"); return CommonResponseUtil.success("SUCCESS");
} }
@Permission
@ApiOperation(httpMethod = "get",value = "预案回放", notes = "预案回放")
@RequestMapping(value = "/fire/replay", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse replay(@RequestParam("batchNo") String batchNo,
@RequestParam("randomNumber") String randomNumber) throws Exception{
ruleRunningSnapshotService.replayPlan(batchNo, randomNumber);
return CommonResponseUtil.success("SUCCESS");
}
@Permission
@ApiOperation(httpMethod = "get",value = "预案回放退出", notes = "预案回放退出")
@RequestMapping(value = "/fire/replay/exit", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse replayExit(@RequestParam("batchNo") String batchNo,
@RequestParam("randomNumber") String randomNumber) throws Exception{
ruleRunningSnapshotService.exitReplayPlan(batchNo, randomNumber);
return CommonResponseUtil.success("SUCCESS");
}
@Scheduled(cron = "*/2 * * * * ?") @Scheduled(cron = "*/2 * * * * ?")
public void runFireQueue() throws Exception public void runFireQueue() throws Exception
...@@ -169,15 +188,6 @@ public class TimeLineController extends BaseController{ ...@@ -169,15 +188,6 @@ public class TimeLineController extends BaseController{
} }
String operate = "{" + String operate = "{" +
" \"type\": \"button\"," + " \"type\": \"button\"," +
" \"operate\": [" + " \"operate\": [" +
......
...@@ -170,7 +170,7 @@ public class View3dController extends BaseController { ...@@ -170,7 +170,7 @@ public class View3dController extends BaseController {
product = getProduct(); product = getProduct();
staticOrgCode = orgCode; staticOrgCode = orgCode;
token = getToken(); token = getToken();
return view3dService.getStatisticsDuty(getAppKey(),getProduct(),orgCode); return view3dService.getStatisticsDuty(getAppKey(),getProduct(),token,orgCode);
} }
@Permission @Permission
...@@ -254,6 +254,7 @@ public class View3dController extends BaseController { ...@@ -254,6 +254,7 @@ public class View3dController extends BaseController {
String product = this.getProduct(); String product = this.getProduct();
return view3dService.retrieveAll(params.getType(), return view3dService.retrieveAll(params.getType(),
params.getRiskSourceId(),
params.getInputText(), params.getInputText(),
params.getCurrent(), params.getCurrent(),
params.getPageSize(), params.getPageSize(),
......
...@@ -145,9 +145,9 @@ public interface View3dMapper extends BaseMapper{ ...@@ -145,9 +145,9 @@ public interface View3dMapper extends BaseMapper{
List<Node3DVoResponse> findViewDataByType(@Param("type")String type,@Param("riskSourceId")Long riskSourceId,@Param("orgCode")String orgCode,@Param("abnormalStatus")Boolean abnormalStatus); List<Node3DVoResponse> findViewDataByType(@Param("type")String type,@Param("riskSourceId")Long riskSourceId,@Param("orgCode")String orgCode,@Param("abnormalStatus")Boolean abnormalStatus);
Long retrieveAllCount(String type, String inputText,String orgCode,String dataLevel,String protectObjName); Long retrieveAllCount(String type, Long riskSourceId, String inputText,String orgCode,String dataLevel,String protectObjName);
List<HashMap<String, Object>> retrieveAll(String type, String inputText, long start, int length,String orgCode,String dataLevel,String protectObjName); List<HashMap<String, Object>> retrieveAll(String type, Long riskSourceId, String inputText, long start, int length,String orgCode,String dataLevel,String protectObjName);
/** /**
* 查询区域下点 * 查询区域下点
......
package com.yeejoin.amos.fas.business.dao.repository;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.fas.business.service.model.RuleRuningSnapshot;
@Repository
public interface IRuleRuningSnapshotDao extends BaseDao<RuleRuningSnapshot, String>{
}
...@@ -6,7 +6,7 @@ import com.yeejoin.amos.fas.core.util.CommonResponseUtil; ...@@ -6,7 +6,7 @@ import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
public class DutyModeServerFallback implements IDutyModeServer{ public class DutyModeServerFallback implements IDutyModeServer{
@Override @Override
public CommonResponse dutyListByDay(String appKey,String product,String orgCode,String dutyDate) { public CommonResponse dutyListByDay(String appKey,String product, String token,String orgCode,String dutyDate) {
return CommonResponseUtil.failure("fegin调用失败!!!"); return CommonResponseUtil.failure("fegin调用失败!!!");
} }
......
package com.yeejoin.amos.fas.business.feign;
import com.yeejoin.amos.fas.core.util.CommonResponse;
public class EquipManageFeignFallback implements IEquipManageFeign{
@Override
public CommonResponse saveWarehouse(String appKey, String product, String token, String param) {
return null;
}
@Override
public CommonResponse delWarehouse(String appKey, String product, String token, String param) {
return null;
}
}
...@@ -13,6 +13,7 @@ public interface IDutyModeServer { ...@@ -13,6 +13,7 @@ public interface IDutyModeServer {
public CommonResponse dutyListByDay( public CommonResponse dutyListByDay(
@RequestHeader(name="appKey",required = true) String appKey, @RequestHeader(name="appKey",required = true) String appKey,
@RequestHeader(name="product",required = true) String product, @RequestHeader(name="product",required = true) String product,
@RequestHeader(name="token",required = true) String token,
@RequestHeader(name="orgCode",required = true) String orgCode, @RequestHeader(name="orgCode",required = true) String orgCode,
@RequestBody String param); @RequestBody String param);
......
package com.yeejoin.amos.fas.business.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.yeejoin.amos.fas.core.util.CommonResponse;
@FeignClient(name="${equipManage.fegin.name}", fallback=MassVisualFallback.class, configuration=FeignConfiguration.class)
public interface IEquipManageFeign {
/**
*
* 远程保存仓库,如果id存在就更新,不存在就新增。
*
* @param appKey
* @param product
* @param token
* @param param
* @return CommonResponse
* @throws <br>
* @author 张展弋
* @date 2020-9-8 15:15:18
*/
@RequestMapping(value = "/equip/warehouse/saveAutoSysSyn", method = RequestMethod.POST,consumes = "application/json")
public CommonResponse saveWarehouse(
@RequestHeader(name="appKey",required = true) String appKey,
@RequestHeader(name="product",required = true) String product,
@RequestHeader(name="token",required = true) String token,
@RequestBody String param);
/**
*
* 远程删除仓库
*
* @param appKey
* @param product
* @param token
* @param riskSourceId 网络传输不支持long这边传string那边long接
* @return CommonResponse
* @throws <br>
* @author 张展弋
* @date 2020-9-8 17:43:11
*/
@RequestMapping(value = "/equip/warehouse/deleteAutoSysSyn", method = RequestMethod.POST,consumes = "application/json")
public CommonResponse delWarehouse(
@RequestHeader(name="appKey",required = true) String appKey,
@RequestHeader(name="product",required = true) String product,
@RequestHeader(name="token",required = true) String token,
@RequestBody String riskSourceId);
}
...@@ -8,6 +8,16 @@ public class RetrieveParams { ...@@ -8,6 +8,16 @@ public class RetrieveParams {
private Integer pageSize; private Integer pageSize;
private String dataLevel; private String dataLevel;
private String protectObjName; private String protectObjName;
private String riskSourceId;
public String getRiskSourceId() {
return riskSourceId;
}
public void setRiskSourceId(String riskSourceId) {
this.riskSourceId = riskSourceId;
}
public String getType() { public String getType() {
return type; return type;
} }
......
...@@ -22,7 +22,7 @@ public class BizMessageServiceImpl implements IBizMessageService { ...@@ -22,7 +22,7 @@ public class BizMessageServiceImpl implements IBizMessageService {
public Page queryForPage(String time, String type, String title, String orgCode, CommonPageable pageable) public Page queryForPage(String time, String type, String title, String orgCode, CommonPageable pageable)
{ {
Long total = bizMessageMapper.queryCountForPage(time, type, title, orgCode); Long total = bizMessageMapper.queryCountForPage(time, type, title, orgCode);
List<NodeMessageView> content = bizMessageMapper.queryForPage(time, type, title, orgCode,pageable.getOffset(),pageable.getPageSize()); List<NodeMessageView> content = bizMessageMapper.queryForPage(time, type, title, orgCode,pageable.getOffset(),pageable.getPageSize());
......
...@@ -21,12 +21,16 @@ import org.springframework.util.CollectionUtils; ...@@ -21,12 +21,16 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.rule.RuleTrigger; import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.ContingencyAction; import com.yeejoin.amos.fas.business.action.ContingencyAction;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.SetpEnum; import com.yeejoin.amos.fas.business.action.model.SetpEnum;
import com.yeejoin.amos.fas.business.action.mq.StationEnum;
import com.yeejoin.amos.fas.business.action.result.BubbleTipResult; import com.yeejoin.amos.fas.business.action.result.BubbleTipResult;
import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult; import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult;
import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher;
import com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper; import com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper;
import com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper; import com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao; import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
...@@ -76,6 +80,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -76,6 +80,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
@Autowired @Autowired
private RuleTrigger ruleTrigger; private RuleTrigger ruleTrigger;
@Value("${spring.application.name}")
private String serviceName;
/* public ContingencyInstanceImpl(IContingencyPlanInstanceRepository repository) { /* public ContingencyInstanceImpl(IContingencyPlanInstanceRepository repository) {
super(repository); super(repository);
...@@ -83,6 +90,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -83,6 +90,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
}*/ }*/
@Autowired @Autowired
ContingencyAction contingencyAction; ContingencyAction contingencyAction;
@Autowired
private ContingencyLogPublisher contingencyLogPublisher;
/** /**
* 创建预案执行记录 * 创建预案执行记录
* *
...@@ -193,27 +203,30 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -193,27 +203,30 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName())); ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
publisherPlanLog(stepCode, buttonCode, batchNo);
// 刷新记录区
// SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss");
// List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
// SafteyPlanResult result1 = new SafteyPlanResult();
// Map<String, Object> tempmap2 = new HashMap<>();
// ArrayList records = new ArrayList<>();
// if (ObjectUtils.isEmpty(list)) {
// list.forEach(action -> {
// HashMap map = new HashMap();
// map.put("time", sdf.format(action.getCreateDate()));
// map.put("stepName", action.getContent());
// });
// }
// tempmap2.put("content", records);
// result1.add(tempmap2);
// contingencyAction.sendcmd("recordarea", contingencyRo, result1);
} else { } else {
throw new Exception("数据异常,请联系管理员."); throw new Exception("数据异常,请联系管理员.");
} }
} }
private void publisherPlanLog(String stepCode, String buttonCode, String batchNo) {
ContingencyEvent event = new ContingencyEvent(this);
JSONObject json = new JSONObject();
JSONObject msgContext = new JSONObject();
JSONObject content = new JSONObject();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
msgContext.put("type", "clickEvent");
msgContext.put("content", content);
json.put("msgType", "message");
json.put("msgContext", msgContext);
event.setMsgBody(json.toJSONString());
String topic = String.format("/%s/%s/%s", serviceName, StationEnum.YINAN.getCode(),"plan");
event.setTopic(topic);
event.setMsgType("clickEvent");
event.setContingency(batchNo);
contingencyLogPublisher.publish(event);
}
public void setButtonExecuted(String batchNo, String contingencyPlanId, String code, String buttonState) throws Exception { public void setButtonExecuted(String batchNo, String contingencyPlanId, String code, String buttonState) throws Exception {
...@@ -237,7 +250,7 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -237,7 +250,7 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
} }
throw new Exception("请勿重复操作."); throw new Exception("请勿重复操作.");
} }
if ("CONFIRM".equals(buttonState)) { if ("CONFIRM".equals(buttonState)) {
if (code.equals(operate.getCode())) { if (code.equals(operate.getCode())) {
......
package com.yeejoin.amos.fas.business.service.impl; package com.yeejoin.amos.fas.business.service.impl;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.cache.enumeration.CacheType;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -48,41 +8,14 @@ import com.google.common.collect.Lists; ...@@ -48,41 +8,14 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.yeejoin.amos.component.rule.RuleTrigger; import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.model.CheckInputItemRo; import com.yeejoin.amos.fas.business.action.model.*;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.DeviceRo;
import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import com.yeejoin.amos.fas.business.action.model.ProtalDataRo;
import com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo;
import com.yeejoin.amos.fas.business.action.model.SetpEnum;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.bo.BindRegionBo; import com.yeejoin.amos.fas.business.bo.*;
import com.yeejoin.amos.fas.business.bo.JpushMsgBo;
import com.yeejoin.amos.fas.business.bo.JpushMsgContentBo;
import com.yeejoin.amos.fas.business.bo.MsgParamBo;
import com.yeejoin.amos.fas.business.bo.RpnCalculationBo;
import com.yeejoin.amos.fas.business.constants.FasConstant; import com.yeejoin.amos.fas.business.constants.FasConstant;
import com.yeejoin.amos.fas.business.dao.mapper.FireEquipMapper; import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper;
import com.yeejoin.amos.fas.business.dao.mapper.FmeaEquipmentPointMapper;
import com.yeejoin.amos.fas.business.dao.mapper.FmeaMapper;
import com.yeejoin.amos.fas.business.dao.mapper.FmeaPointInputitemMapper;
import com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper;
import com.yeejoin.amos.fas.business.dao.mapper.RiskSourceMapper;
import com.yeejoin.amos.fas.business.dao.mongo.EquipCommunicationDao; import com.yeejoin.amos.fas.business.dao.mongo.EquipCommunicationDao;
import com.yeejoin.amos.fas.business.dao.repository.IAlarmDao; import com.yeejoin.amos.fas.business.dao.repository.*;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao; import com.yeejoin.amos.fas.business.feign.IEquipManageFeign;
import com.yeejoin.amos.fas.business.dao.repository.IDictDao;
import com.yeejoin.amos.fas.business.dao.repository.IEvaluationModelDao;
import com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentDao;
import com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentPointDao;
import com.yeejoin.amos.fas.business.dao.repository.IPreplanPictureDao;
import com.yeejoin.amos.fas.business.dao.repository.IRiskFactorDao;
import com.yeejoin.amos.fas.business.dao.repository.IRiskLevelDao;
import com.yeejoin.amos.fas.business.dao.repository.IRiskSourceDao;
import com.yeejoin.amos.fas.business.dao.repository.IRpnChangeLogDao;
import com.yeejoin.amos.fas.business.feign.RemoteRuleServer;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService; import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.feign.RemoteWebSocketServer; import com.yeejoin.amos.fas.business.feign.RemoteWebSocketServer;
import com.yeejoin.amos.fas.business.jpush.AppMessagePushService; import com.yeejoin.amos.fas.business.jpush.AppMessagePushService;
...@@ -94,12 +27,9 @@ import com.yeejoin.amos.fas.business.param.FmeaBindParam; ...@@ -94,12 +27,9 @@ import com.yeejoin.amos.fas.business.param.FmeaBindParam;
import com.yeejoin.amos.fas.business.service.intfc.IDataRefreshService; import com.yeejoin.amos.fas.business.service.intfc.IDataRefreshService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService; import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService; import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.business.service.intfc.IView3dService;
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus; import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.util.CacheFactory; import com.yeejoin.amos.fas.business.util.*;
import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.util.DateUtils;
import com.yeejoin.amos.fas.business.util.JexlUtil;
import com.yeejoin.amos.fas.business.util.RpnUtils;
import com.yeejoin.amos.fas.business.vo.EquipCommunicationData; import com.yeejoin.amos.fas.business.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.business.vo.Toke; import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.client.invoke.RsDataQueue; import com.yeejoin.amos.fas.client.invoke.RsDataQueue;
...@@ -109,25 +39,42 @@ import com.yeejoin.amos.fas.common.enums.View3dRefreshAreaEum; ...@@ -109,25 +39,42 @@ import com.yeejoin.amos.fas.common.enums.View3dRefreshAreaEum;
import com.yeejoin.amos.fas.core.common.request.CommonPageable; import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.response.RegionTreeResponse; import com.yeejoin.amos.fas.core.common.response.RegionTreeResponse;
import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse; import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.StringUtil; import com.yeejoin.amos.fas.core.util.StringUtil;
import com.yeejoin.amos.fas.dao.entity.Alarm; import com.yeejoin.amos.fas.dao.entity.*;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.Dict;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.EvaluationModel;
import com.yeejoin.amos.fas.dao.entity.FireEquipment;
import com.yeejoin.amos.fas.dao.entity.FireEquipmentData;
import com.yeejoin.amos.fas.dao.entity.FireEquipmentPoint;
import com.yeejoin.amos.fas.dao.entity.Fmea;
import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint;
import com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem;
import com.yeejoin.amos.fas.dao.entity.PreplanPicture;
import com.yeejoin.amos.fas.dao.entity.RiskFactor;
import com.yeejoin.amos.fas.dao.entity.RiskLevel;
import com.yeejoin.amos.fas.dao.entity.RiskSource;
import com.yeejoin.amos.fas.dao.entity.RpnChangeLog;
import com.yeejoin.amos.fas.exception.YeeException; import com.yeejoin.amos.fas.exception.YeeException;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.cache.enumeration.CacheType;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
@Service("riskSourceService") @Service("riskSourceService")
public class RiskSourceServiceImpl implements IRiskSourceService { public class RiskSourceServiceImpl implements IRiskSourceService {
...@@ -183,8 +130,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -183,8 +130,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private FireEquipPointMapper fireEquipPointMapper; private FireEquipPointMapper fireEquipPointMapper;
@Autowired @Autowired
private IRiskLevelDao iRiskLevelDao; private IView3dService view3dService;
@Autowired
private IRiskLevelDao iRiskLevelDao;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
...@@ -202,9 +151,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -202,9 +151,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
IFireEquipmentDataDao iFireEquipmentDataDao; IFireEquipmentDataDao iFireEquipmentDataDao;
@Autowired @Autowired
private RemoteRuleServer remoteRuleServer;
@Autowired
private RemoteWebSocketServer remoteWebSocketServer; private RemoteWebSocketServer remoteWebSocketServer;
@Autowired @Autowired
...@@ -215,6 +161,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -215,6 +161,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired @Autowired
private IDictDao dictDao; private IDictDao dictDao;
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
...@@ -232,6 +179,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -232,6 +179,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired @Autowired
private IRiskFactorDao iRiskFactorDao; private IRiskFactorDao iRiskFactorDao;
@Autowired
private IEquipManageFeign equipManageFeign;
@Autowired
protected HttpServletRequest request;
public static String cacheKeyForCanBeRunning() { public static String cacheKeyForCanBeRunning() {
...@@ -270,19 +223,95 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -270,19 +223,95 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return riskSource; return riskSource;
} }
@Value("${equipManage.fegin.isSyn:false}")
private boolean isSyn;
@Override
public boolean isSynEquipManage() {
return isSyn;
}
@Override
public String synToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree) {
// 必须使用树形结构,一条一条的树杈到叶子遍历同步,否则底层节点会因为找不到父节点而同步失败
return doSynToEquipManage(appKey, product, token, success, riskSourcesTree);
}
private String doSynToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree) {
if(riskSourcesTree == null) {
return null;
}
String res = null;
for(RiskSourceTreeResponse rst : riskSourcesTree) {
res = saveToEquipManage(appKey, product, token, success, rst.getId(), rst.getCode(), rst.getName(), rst.getParentId());
if(res != null) {
return res;
}
res = doSynToEquipManage(appKey, product, token, success, rst.getChildren());
if(res != null) {
return res;
}
}
return null;
}
/**
*
* 风险模型新增及维护时远程同步
*
* @param id
* @param code
* @param name
* @param parentId
* @return CommonResponse
* @throws <br>
* @author 张展弋
* @date 2020-9-8 15:39:20
*/
public String saveToEquipManage(String appKey,String product,String token,String success,long id, String code, String name, Long parentId) {
if(!isSynEquipManage()) {
return null;
}
JSONObject js = new JSONObject();
js.put("sourceId", id);
js.put("name", name);
js.put("sourceCode", code);
// 这里的parentId和那边系统的不是一回事,这里只是借用传输
js.put("id", parentId);
CommonResponse cr = null;
try {
// 父节点id为0表示根节点,对应那边的仓库
cr = equipManageFeign.saveWarehouse(appKey, product, token, js.toString());
} catch (Exception e) {
e.printStackTrace();
}
if (cr == null) {
return "远程调用同步失败,请检查远程系统后重试!";
}
if (!success.equals(cr.getResult())) {
return "远程同步失败,请检查远程系统后重试!附加消息:" + cr.getMessage();
}
return null;
}
@Override @Override
public void deleteRiskSource(Long[] riskSourceId) throws Exception { public void deleteRiskSource(String appKey,String product,String token,String success,Long[] riskSourceId) throws Exception {
Set<Long> parentIds = new LinkedHashSet<>(); Set<Long> parentIds = new LinkedHashSet<>();
String synMsg = null;
for (Long rId : riskSourceId) { for (Long rId : riskSourceId) {
int count = iRiskSourceDao.countByParentId(rId); int count = iRiskSourceDao.countByParentId(rId);
Optional<RiskSource> rs = iRiskSourceDao.findById(rId); Optional<RiskSource> rs = iRiskSourceDao.findById(rId);
rs.ifPresent(riskSource -> parentIds.add(riskSource.getParentId())); rs.ifPresent(riskSource -> parentIds.add(riskSource.getParentId()));
if (parentIds.contains(0l)) { if (parentIds.contains(0L)) {
throw new YeeException("公司节点不能删除"); throw new YeeException("公司节点不能删除");
} }
if (count > 0) { if (count > 0) {
throw new YeeException("该数据有关联子项,请先删除子项数据"); throw new YeeException("该数据有关联子项,请先删除子项数据");
} }
synMsg = deleteToEquipManage(appKey, product, token, success, rId);
if(synMsg !=null) {
throw new YeeException("远程删除失败,附加消息:" + synMsg);
}
iRiskSourceDao.deleteById(rId); iRiskSourceDao.deleteById(rId);
} }
//1.重新计算rpn //1.重新计算rpn
...@@ -292,7 +321,44 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -292,7 +321,44 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
RsDataQueue rs = RsDataQueue.getInstance(); RsDataQueue rs = RsDataQueue.getInstance();
existIds.forEach(rs::addRiskSourcePointDeleteMessage); existIds.forEach(rs::addRiskSourcePointDeleteMessage);
} }
public void deleteById(Long id) {
iRiskSourceDao.deleteById(id);
}
/**
*
* 风险模型删除时远程同步
*
* @param appKey
* @param product
* @param token
* @param failed
* @param rId
* @return String
* @throws <br>
* @author 张展弋
* @date 2020-9-8 17:54:12
*/
private String deleteToEquipManage(String appKey,String product,String token,String success,Long rId) {
if(!isSynEquipManage()) {
return null;
}
CommonResponse cr = null;
try {
// 父节点id为0表示根节点,对应那边的仓库
cr = equipManageFeign.delWarehouse(appKey, product, token, rId.toString());
} catch (Exception e) {
e.printStackTrace();
}
if (cr == null) {
return "远程调用同步失败,请检查远程系统后重试!";
}
if (!success.equals(cr.getResult())) {
return "远程同步失败,请检查远程系统后重试!附加消息:" + cr.getMessage();
}
return null;
}
@Override @Override
public Page<HashMap<String, Object>> queryRiskSourceByPage(CommonPageInfoParam param) { public Page<HashMap<String, Object>> queryRiskSourceByPage(CommonPageInfoParam param) {
long total = riskSourceMapper.countPageData(param); long total = riskSourceMapper.countPageData(param);
...@@ -679,7 +745,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -679,7 +745,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
@Async @Async
public void processProtalData(String toke, String product, String appKey, ProtalDataRo protalData) { public void processProtalData(String toke, String product, String appKey, ProtalDataRo protalData, String orgCode) {
//巡检消息规则推送 //巡检消息规则推送
protalRuleMessagePush(protalData, toke, product, appKey); protalRuleMessagePush(protalData, toke, product, appKey);
if (!CollectionUtils.isEmpty(protalData.getPointInputitems())) { if (!CollectionUtils.isEmpty(protalData.getPointInputitems())) {
...@@ -715,6 +781,27 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -715,6 +781,27 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
rsDataQueue.addPatrolMessage(fmeaId, protalData.getCheckUser(), protalData.getName(), protalData.getNodeState())); rsDataQueue.addPatrolMessage(fmeaId, protalData.getCheckUser(), protalData.getName(), protalData.getNodeState()));
} }
iDataRefreshService.refreshViewData(DataRefreshTypeEum.check.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.check.getCode());
/**
* 推送巡检数据
* 影响区域:今日安全,消防安全=>巡检异常,一周安全趋势
*/
// 今日安全
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(new Date());
String topicOne = String.format("/%s/%s/%s/%s", serviceName, "yinan","data/refresh","todaySafetyIndex");
webMqttComponent.publish(topicOne, JSON.toJSONString(view3dService.getSafetyIndexInfoByDate(orgCode, dateString)));
// 巡检异常
String topicTwo = String.format("/%s/%s/%s/%s", serviceName, "yinan","data/refresh","fireSafety");
webMqttComponent.publish(topicTwo, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("check", orgCode)));
// 一周安全趋势
String topicThree = String.format("/%s/%s/%s/%s", serviceName, "yinan","data/refresh","weekSafetyIndex");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getSafetyIndexWeek(orgCode)));
// 今日巡检
String topicFour = String.format("/%s/%s/%s/%s", serviceName, "yinan","data/refresh","todayCheckStatus");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getStatisticsCheck(orgCode)));
} }
/** /**
...@@ -868,7 +955,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -868,7 +955,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* @param deviceData * @param deviceData
* @param equipment * @param equipment
* @param fireEquipment * @param fireEquipment
* @param fireEquipmentPointType * @param toke
*/ */
@Async @Async
void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment, Toke toke) { void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment, Toke toke) {
...@@ -929,6 +1016,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -929,6 +1016,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSourceMap.put("equipments", map); riskSourceMap.put("equipments", map);
remoteWebSocketServer.sendMessage("equipmentMode", JSON.toJSONString(riskSourceMap)); remoteWebSocketServer.sendMessage("equipmentMode", JSON.toJSONString(riskSourceMap));
// 推送设备状态信息
Alarm alarm = iAlarmDao.findByStatusTrueAndFireEquipmentPointCode(param.getPointCode());
String topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/monitorData");
webMqttComponent.publish(topic, JSON.toJSONString(view3dService.getEquipStatusList(alarm.getOrgCode())));
} catch (Exception e) { } catch (Exception e) {
log.error("推送前端数据失败-->"+JSON.toJSONString(param)); log.error("推送前端数据失败-->"+JSON.toJSONString(param));
} }
...@@ -970,6 +1062,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -970,6 +1062,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} else { } else {
//通知刷新3d页面告警数据 //通知刷新3d页面告警数据
iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode());
/**
* 推送告警数据
* 影响区域:消防安全=>火灾告警
*/
String topic = String.format("/%s/%s/%s/%s", serviceName, "yinan","data/refresh","fireSafety");
webMqttComponent.publish(topic, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("fire", fireEquipmentPoint.getOrgCode())));
} }
} }
} else { } else {
...@@ -994,9 +1093,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -994,9 +1093,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
content.put("orgCode", fireEquipment.getOrgCode()); content.put("orgCode", fireEquipment.getOrgCode());
content.put("status", deviceData.getSoe()); content.put("status", deviceData.getSoe());
iDataRefreshService.sendRefreshDataWithArea(View3dRefreshAreaEum.monitor_data.getCode(), content); iDataRefreshService.sendRefreshDataWithArea(View3dRefreshAreaEum.monitor_data.getCode(), content);
/**
* 推送设备状态
* 影响区域:设备状态
*/
String topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/monitorData");
webMqttComponent.publish(topic, JSON.toJSONString(view3dService.getEquipStatusList(fireEquipment.getOrgCode())));
} }
} }
// String topic = String.format("/%s/%s/%s", serviceName, "yinan","telesignaling"); // String topic = String.format("/%s/%s/%s", serviceName, "yinan","telesignaling");S
// webMqttComponent.publish(topic, JSON.toJSONString(deviceData)); // webMqttComponent.publish(topic, JSON.toJSONString(deviceData));
List<AlarmParam> list = new ArrayList<>(); List<AlarmParam> list = new ArrayList<>();
...@@ -1096,7 +1202,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1096,7 +1202,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired @Autowired
private WebMqttComponent webMqttComponent; private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}") @Value("${autoSys.push.type}")
private String pushType; private String pushType;
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String serviceName; private String serviceName;
...@@ -1291,7 +1397,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1291,7 +1397,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
//1.3更新fmea //1.3更新fmea
fmeaMapper.updateRpn(fmea); fmeaMapper.updateRpn(fmea);
//2.计算上级风险值(风险点及父节点) //2.计算上级风险值(风险点及父节点)
this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), nofityType, jpushMsgBo); this.notifyRiskSource(newLevel.getOrgCode(), fmeaId, fmea.getRiskSourceId(), nofityType, jpushMsgBo);
String topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
} }
} }
...@@ -1395,8 +1503,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1395,8 +1503,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
//1.3.更新fmea的rpn、风险等级及newOid //1.3.更新fmea的rpn、风险等级及newOid
fmeaMapper.updateRpn(fmea); fmeaMapper.updateRpn(fmea);
String topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
//2.计算风险点rpn、rpni、riskLevelId //2.计算风险点rpn、rpni、riskLevelId
this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), notifyType, jpushMsgBo); this.notifyRiskSource(newLevel.getOrgCode(), fmeaId, fmea.getRiskSourceId(), notifyType, jpushMsgBo);
} }
} }
} }
...@@ -1429,7 +1539,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1429,7 +1539,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* fmea的更新导致rpn、rpni的值改变 * fmea的更新导致rpn、rpni的值改变
*/ */
@Override @Override
public void notifyRiskSource(Long fmeaId, Long riskSourceId, String notifyType, JpushMsgBo jpushMsgBo) { public void notifyRiskSource(String orgCode, Long fmeaId, Long riskSourceId, String notifyType, JpushMsgBo jpushMsgBo) {
Optional<RiskSource> riskSource1 = iRiskSourceDao.findById(riskSourceId); Optional<RiskSource> riskSource1 = iRiskSourceDao.findById(riskSourceId);
RiskSource riskSource = null; RiskSource riskSource = null;
if (riskSource1.isPresent()) { if (riskSource1.isPresent()) {
...@@ -1497,20 +1607,98 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1497,20 +1607,98 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
} }
} }
try {
String topic = String.format("/%s/%s/%s", serviceName, "shaoxing","data/refresh/situationMap");
webMqttComponent.publish(topic, JSON.toJSONString(queryRiskAreaRpn()));
topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/riskDegreeHistogram");
webMqttComponent.publish(topic, JSON.toJSONString(queryRPNReport()));
topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/riskDegreePie");
webMqttComponent.publish(topic, JSON.toJSONString(queryForRiseUp()));
topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
// 今日安全
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(new Date());
if(StringUtils.isEmpty(orgCode)){
orgCode = riskSource.getOrgCode();
}
String topicOne = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/todaySafetyIndex");
webMqttComponent.publish(topicOne, JSON.toJSONString(view3dService.getSafetyIndexInfoByDate(orgCode, dateString)));
// 消防安全
String topicTow = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/fireSafety");
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("risk", orgCode)));
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("check", orgCode)));
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("fire", orgCode)));
// 一周安全趋势
String topicThree = String.format("/%s/%s/%s/%s", serviceName, "yinan","data/refresh","weekSafetyIndex");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getSafetyIndexWeek(orgCode)));
} catch (Exception e) {
log.error("数据获取失败", e);
}
} }
@Override @Override
public void notifyFmeaFromDelete(Long riskSourceId, String from) { public void notifyFmeaFromDelete(Long riskSourceId, String from) {
//1.计算风险点风险值信息 //1.计算风险点风险值信息
this.notifyRiskSource(0L, riskSourceId, from, null); this.notifyRiskSource(null, 0L, riskSourceId, from, null);
} }
@Override @Override
public void notifyRiskSourceDelete(Long parentId) { public void notifyRiskSourceDelete(Long parentId) {
Optional<RiskSource> riskSource1 = iRiskSourceDao.findById(parentId);
RiskSource riskSource = null;
if (riskSource1.isPresent()) {
riskSource = riskSource1.get();
} else {
return;
}
//1.风险点删除触发更新父节点rpn、rpni、风险等级 //1.风险点删除触发更新父节点rpn、rpni、风险等级
this.updateParentRpn(parentId); this.updateParentRpn(parentId);
//2.通知全景监控屏幕数据刷新 //2.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
try{
String topic = String.format("/%s/%s/%s", serviceName, "shaoxing","data/refresh/situationMap");
webMqttComponent.publish(topic, JSON.toJSONString(queryRiskAreaRpn()));
topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/riskDegreeHistogram");
webMqttComponent.publish(topic, JSON.toJSONString(queryRPNReport()));
topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/riskDegreePie");
webMqttComponent.publish(topic, JSON.toJSONString(queryForRiseUp()));
topic = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
// 今日安全
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(new Date());
String orgCode = riskSource.getOrgCode();
if(StringUtils.isEmpty(orgCode)){
orgCode = riskSource.getOrgCode();
}
String topicOne = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/todaySafetyIndex");
webMqttComponent.publish(topicOne, JSON.toJSONString(view3dService.getSafetyIndexInfoByDate(orgCode, dateString)));
// 消防安全
String topicTow = String.format("/%s/%s/%s", serviceName, "yinan","data/refresh/fireSafety");
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("risk", orgCode)));
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("check", orgCode)));
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("fire", orgCode)));
// 一周安全趋势
String topicThree = String.format("/%s/%s/%s/%s", serviceName, "yinan","data/refresh","weekSafetyIndex");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getSafetyIndexWeek(orgCode)));
}catch (Exception e) {
log.error("数据获取失败", e);
}
} }
private void updateParentRpn(long parentId) { private void updateParentRpn(long parentId) {
...@@ -1660,6 +1848,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1660,6 +1848,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
public void batchSaveRegionUe4(List<BindRegionBo> regionBoList) { public void batchSaveRegionUe4(List<BindRegionBo> regionBoList) {
riskSourceMapper.batchSaveRegionUe4(regionBoList); riskSourceMapper.batchSaveRegionUe4(regionBoList);
try {
String topic = String.format("/%s/%s/%s", serviceName, "shaoxing","data/refresh/situationMap");
webMqttComponent.publish(topic, JSON.toJSONString(queryRiskAreaRpn()));
topic = String.format("/%s/%s/%s", serviceName, "shaoxing","data/refresh/riskDegreeHistogram");
webMqttComponent.publish(topic, JSON.toJSONString(queryRPNReport()));
topic = String.format("/%s/%s/%s", serviceName, "shaoxing","data/refresh/riskDegreePie");
webMqttComponent.publish(topic, JSON.toJSONString(queryForRiseUp()));
topic = String.format("/%s/%s/%s", serviceName, "shaoxing","data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
} catch (Exception e) {
log.error("数据获取失败", e);
}
} }
private EvaluationModel getEvaluationModel(Long fmeaId) { private EvaluationModel getEvaluationModel(Long fmeaId) {
...@@ -1673,6 +1873,5 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1673,6 +1873,5 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
return null; return null;
} }
} }
package com.yeejoin.amos.fas.business.service.impl; package com.yeejoin.amos.fas.business.service.impl;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Resource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.SpringContextHelper; import org.typroject.tyboot.core.foundation.context.SpringContextHelper;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.fas.business.action.CustomerAction; import com.yeejoin.amos.fas.business.action.CustomerAction;
import com.yeejoin.amos.fas.business.action.model.BasicsRo; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult;
import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage;
import com.yeejoin.amos.fas.business.dao.mapper.RuleRuningSnapshotMapper; import com.yeejoin.amos.fas.business.dao.mapper.RuleRuningSnapshotMapper;
import com.yeejoin.amos.fas.business.dao.repository.IRuleRuningSnapshotDao;
import com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService; import com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService;
import com.yeejoin.amos.fas.business.service.model.RuleRuningSnapshot; import com.yeejoin.amos.fas.business.service.model.RuleRuningSnapshot;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
/** /**
* *
...@@ -39,15 +52,26 @@ public class RuleRunigSnapshotServiceImpl ...@@ -39,15 +52,26 @@ public class RuleRunigSnapshotServiceImpl
{ {
//IRuleRuningSnapshotRepository repository; //IRuleRuningSnapshotRepository repository;
@Autowired
private RuleRuningSnapshotMapper ruleRuningSnapshotMapper; private RuleRuningSnapshotMapper ruleRuningSnapshotMapper;
@Resource
IRuleRuningSnapshotDao ruleRuningSnapshotDao;
private static String replayBatchNo = null; private static String replayBatchNo = null;
static ObjectMapper objectMapper; static ObjectMapper objectMapper;
private final Logger logger = LoggerFactory.getLogger(RuleRunigSnapshotServiceImpl.class); private final Logger logger = LoggerFactory.getLogger(RuleRunigSnapshotServiceImpl.class);
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private WebMqttComponent webMqttComponent;
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
static { static {
objectMapper = new ObjectMapper(); objectMapper = new ObjectMapper();
} }
...@@ -67,20 +91,20 @@ public class RuleRunigSnapshotServiceImpl ...@@ -67,20 +91,20 @@ public class RuleRunigSnapshotServiceImpl
* @param paramsAndTypes * @param paramsAndTypes
* @param matchedObj * @param matchedObj
*/ */
public void process(Object bean,String methodName,String paramsAndTypes,Object matchedObj) public void process(Object bean,String methodName,String paramsAndTypes,String batchNo)
{ {
if(bean instanceof CustomerAction) if(bean instanceof CustomerAction)
{ {
Set set = (Set) matchedObj; // Set set = (Set) matchedObj;
BasicsRo fireEquimentDataRo = (BasicsRo) set.iterator().next(); // BasicsRo fireEquimentDataRo = (BasicsRo) set.iterator().next();
RuleRuningSnapshot ruleRuningSnapshot = new RuleRuningSnapshot(); RuleRuningSnapshot ruleRuningSnapshot = new RuleRuningSnapshot();
ruleRuningSnapshot.setId(UUID.randomUUID().toString()); ruleRuningSnapshot.setId(UUID.randomUUID().toString());
ruleRuningSnapshot.setMethodClass(bean.getClass().getName()); ruleRuningSnapshot.setMethodClass(bean.getClass().getName());
ruleRuningSnapshot.setMethodName(methodName); ruleRuningSnapshot.setMethodName(methodName);
ruleRuningSnapshot.setMethodParam(paramsAndTypes); ruleRuningSnapshot.setMethodParam(paramsAndTypes);
ruleRuningSnapshot.setBatchNo(fireEquimentDataRo.getBatchNo()); ruleRuningSnapshot.setBatchNo(batchNo);
//ruleRuningSnapshot.setPackageId(fireEquimentDataRo.getPackageId()); //ruleRuningSnapshot.setPackageId(fireEquimentDataRo.getPackageId());
//ruleRuningSnapshot.setEquipmentId(String.valueOf(fireEquimentDataRo.getId())); //ruleRuningSnapshot.setEquipmentId(String.valueOf(fireEquimentDataRo.getId()));
...@@ -88,16 +112,112 @@ public class RuleRunigSnapshotServiceImpl ...@@ -88,16 +112,112 @@ public class RuleRunigSnapshotServiceImpl
ruleRuningSnapshot.setCreateTime(now); ruleRuningSnapshot.setCreateTime(now);
ruleRuningSnapshot.setCreateMillisecond(String.valueOf(now.getTime())); ruleRuningSnapshot.setCreateMillisecond(String.valueOf(now.getTime()));
ruleRuningSnapshot.setPreviousInterval(0L); ruleRuningSnapshot.setPreviousInterval(0L);
RuleRuningSnapshot oldEntity = ruleRuningSnapshotMapper.querForObject(fireEquimentDataRo.getBatchNo()); RuleRuningSnapshot oldEntity = ruleRuningSnapshotMapper.querForObject(batchNo);
if(oldEntity != null) if(oldEntity != null)
ruleRuningSnapshot.setPreviousInterval(now.getTime() - Long.parseLong(oldEntity.getCreateMillisecond())); ruleRuningSnapshot.setPreviousInterval(now.getTime() - Long.parseLong(oldEntity.getCreateMillisecond()));
//repository.save(ruleRuningSnapshot); //repository.save(ruleRuningSnapshot);
ruleRuningSnapshotMapper.save(ruleRuningSnapshot); ruleRuningSnapshotDao.save(ruleRuningSnapshot);
} }
} }
@Transactional
public void reacordPlan(String topic, String msgType, String msgBody, Object contingency)
{
String batchNo = null;
if (contingency instanceof ContingencyRo) {
batchNo = ((ContingencyRo) contingency).getBatchNo();
} else if (contingency instanceof String) {
batchNo = contingency.toString();
} else {
batchNo = (String) redisTemplate.opsForValue().get(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
}
RuleRuningSnapshot ruleRuningSnapshot = new RuleRuningSnapshot();
ruleRuningSnapshot.setId(UUID.randomUUID().toString());
ruleRuningSnapshot.setMethodClass("com.yeejoin.amos.fas.business.action.ContingencyAction");
ruleRuningSnapshot.setPackageId(topic);
ruleRuningSnapshot.setMethodName(msgType);
ruleRuningSnapshot.setMethodParam(msgBody);
ruleRuningSnapshot.setBatchNo(batchNo);
Date now = new Date();
ruleRuningSnapshot.setCreateTime(now);
ruleRuningSnapshot.setCreateMillisecond(String.valueOf(now.getTime()));
ruleRuningSnapshot.setPreviousInterval(0L);
RuleRuningSnapshot oldEntity = ruleRuningSnapshotMapper.querForObject(batchNo);
if(oldEntity != null)
ruleRuningSnapshot.setPreviousInterval(now.getTime() - Long.parseLong(oldEntity.getCreateMillisecond()));
ruleRuningSnapshotDao.save(ruleRuningSnapshot);
}
@Async @Async
public void replayPlan(String batchNo, String randomNumber) throws Exception
{
try
{
List<RuleRuningSnapshot> oldEntityList=ruleRuningSnapshotMapper.querForObjectList(batchNo);
if(!CollectionUtils.isEmpty(oldEntityList))
{
logger.info("开始回放:batchNo="+batchNo);
logger.info("获取到动作记录个数:"+oldEntityList.size());
redisTemplate.opsForValue().set("replay:" + batchNo +":" + randomNumber, true);
int count = 0;
for(RuleRuningSnapshot snapshot : oldEntityList)
{
if(batchNo == null)
return ;
Object play = redisTemplate.opsForValue().get("replay:" + batchNo +":" + randomNumber);
if (ObjectUtils.isEmpty(play)) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
tempmap1.put("content", "stopPlan");
result.add(tempmap1);
Constructor<?> constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
ToipResponse toipResponse = action.buildResponse("message", batchNo, result.toJson());
webMqttComponent.publish(String.format("%s/%s/%s", snapshot.getPackageId(), "replay", randomNumber), toipResponse.toJsonStr());
return;
}
//延迟
logger.info("开始执行第"+(++count)+"个动作.");
logger.info("方法名:"+snapshot.getMethodClass()+"."+snapshot.getMethodName());
logger.info("需要延迟"+snapshot.getPreviousInterval()+"毫秒.......");
Thread.sleep(snapshot.getPreviousInterval());
try
{
webMqttComponent.publish(String.format("%s/%s/%s", snapshot.getPackageId(), "replay", randomNumber) , snapshot.getMethodParam());
logger.info("第"+(count)+"个动作执行成功.");
}catch (Exception e)
{
logger.info("第"+(count)+"个动作执行失败.");
e.printStackTrace();
logger.error(e.getMessage(),e);
}
}
}
}catch (Exception e)
{
logger.info("回放失败.");
logger.error(e.getMessage(),e);
} finally {
redisTemplate.delete("replay:" + batchNo +":" + randomNumber);
}
}
@Override
public void exitReplayPlan(String batchNo, String randomNumber) {
redisTemplate.delete("replay:" + batchNo +":" + randomNumber);
}
@Async
public void replay(String batchNo) throws Exception public void replay(String batchNo) throws Exception
{ {
...@@ -194,4 +314,6 @@ public class RuleRunigSnapshotServiceImpl ...@@ -194,4 +314,6 @@ public class RuleRunigSnapshotServiceImpl
public static void setReplayBatchNoToNull() { public static void setReplayBatchNoToNull() {
RuleRunigSnapshotServiceImpl.replayBatchNo = null; RuleRunigSnapshotServiceImpl.replayBatchNo = null;
} }
} }
\ No newline at end of file
...@@ -492,12 +492,12 @@ public class View3dServiceImpl implements IView3dService { ...@@ -492,12 +492,12 @@ public class View3dServiceImpl implements IView3dService {
} }
@Override @Override
public CommonResponse getStatisticsDuty(String appKey,String product,String orgCode) { public CommonResponse getStatisticsDuty(String appKey,String product,String token, String orgCode) {
Date curDate = new Date(); Date curDate = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("dutyDate", curDate); param.put("dutyDate", curDate);
return dutyModeServer.dutyListByDay(appKey,product,orgCode,param.toJSONString()); return dutyModeServer.dutyListByDay(appKey,product,token,orgCode,param.toJSONString());
} }
@Override @Override
...@@ -570,10 +570,11 @@ public class View3dServiceImpl implements IView3dService { ...@@ -570,10 +570,11 @@ public class View3dServiceImpl implements IView3dService {
} }
@Override @Override
public CommonResponse retrieveAll(String type, String inputText, int current, int pageSize,String orgCode,String dataLevel,String protectObjName,String token,String appKey,String product) { public CommonResponse retrieveAll(String type, String riskSourceId, String inputText, int current, int pageSize,String orgCode,String dataLevel,String protectObjName,String token,String appKey,String product) {
CommonPageable pageable = new CommonPageable( current, pageSize); CommonPageable pageable = new CommonPageable( current, pageSize);
Long count = view3dMapper.retrieveAllCount(type,inputText,orgCode,dataLevel,protectObjName); Long riskSource = StringUtils.isEmpty(riskSourceId) ? null : Long.parseLong(riskSourceId);
List<HashMap<String, Object>> retrieveAll = view3dMapper.retrieveAll(type, inputText,pageable.getOffset(),pageable.getPageSize(),orgCode,dataLevel,protectObjName); Long count = view3dMapper.retrieveAllCount(type,riskSource,inputText,orgCode,dataLevel,protectObjName);
List<HashMap<String, Object>> retrieveAll = view3dMapper.retrieveAll(type, riskSource,inputText,pageable.getOffset(),pageable.getPageSize(),orgCode,dataLevel,protectObjName);
Set<Object> userIds = new HashSet<>(); Set<Object> userIds = new HashSet<>();
retrieveAll.forEach(action->{ retrieveAll.forEach(action->{
if(!ObjectUtils.isEmpty(action.get("person"))){ if(!ObjectUtils.isEmpty(action.get("person"))){
......
package com.yeejoin.amos.fas.business.service.intfc; package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo; import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import com.yeejoin.amos.fas.business.action.model.ProtalDataRo; import com.yeejoin.amos.fas.business.action.model.ProtalDataRo;
import com.yeejoin.amos.fas.business.bo.BindRegionBo; import com.yeejoin.amos.fas.business.bo.BindRegionBo;
...@@ -19,7 +20,6 @@ import org.springframework.data.domain.Page; ...@@ -19,7 +20,6 @@ import org.springframework.data.domain.Page;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
public interface IRiskSourceService { public interface IRiskSourceService {
...@@ -27,11 +27,55 @@ public interface IRiskSourceService { ...@@ -27,11 +27,55 @@ public interface IRiskSourceService {
* 新增及维护风险点 * 新增及维护风险点
*/ */
RiskSource editRiskSource(HashMap<String, Object> map) throws Exception; RiskSource editRiskSource(HashMap<String, Object> map) throws Exception;
/**
* 风险模型新增及维护时远程同步
*
* @param appKey
* @param product
* @param token
* @param success contoler中的系统通用failed标识和这里返回前台的不一样。
* @param id
* @param code
* @param name
* @param parentId
* @return CommonResponse
* @throws <br>
* @author 张展弋
* @date 2020-9-8 17:39:32
*/
String saveToEquipManage(String appKey, String product, String token, String success, long id,
String code, String name, Long parentId);
/**
* 将本地 风险模型推送到远程同步
*
* @param appKey
* @param product
* @param token
* @param success
* @param riskSourcesTree
* @return String
* @throws <br>
* @author 张展弋
* @date 2020-9-9 15:40:18
*/
String synToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree);
/** /**
*
* 是否同步到对站系统
*
* @return boolean
* @throws <br>
* @author 张展弋
* @date 2020-9-8 15:45:34
*/
boolean isSynEquipManage();
/**
* 删除风险点 * 删除风险点
*/ */
void deleteRiskSource(Long[] riskSourceId) throws Exception; void deleteRiskSource(String appKey,String product,String token,String failed,Long[] riskSourceId) throws Exception;
/** /**
* 根据参数分页查询风险点信息 * 根据参数分页查询风险点信息
...@@ -76,7 +120,7 @@ public interface IRiskSourceService { ...@@ -76,7 +120,7 @@ public interface IRiskSourceService {
boolean processTaskData(ProtalDataRo taskData) throws Exception; boolean processTaskData(ProtalDataRo taskData) throws Exception;
void processProtalData(String toke,String product,String appKey,ProtalDataRo protalData) throws Exception; void processProtalData(String toke,String product,String appKey,ProtalDataRo protalData, String orgCode) throws Exception;
RiskSourceTreeResponse queryRiskSourceDetailById(Long id); RiskSourceTreeResponse queryRiskSourceDetailById(Long id);
...@@ -134,9 +178,20 @@ public interface IRiskSourceService { ...@@ -134,9 +178,20 @@ public interface IRiskSourceService {
*/ */
void batchSaveRegionUe4(List<BindRegionBo> regionBoList); void batchSaveRegionUe4(List<BindRegionBo> regionBoList);
void notifyRiskSource(Long fmeaId, Long riskSourceId, String notifyType, JpushMsgBo jpushMsgBo); void notifyRiskSource(String orgCode, Long fmeaId, Long riskSourceId, String notifyType, JpushMsgBo jpushMsgBo);
void notifyFmeaFromDelete(Long handId, String from); void notifyFmeaFromDelete(Long handId, String from);
void notifyRiskSourceDelete(Long handId); void notifyRiskSourceDelete(Long handId);
/**
*
* 不做任何不能删校验,直接删除,慎用
*
* @param id void
* @throws <br>
* @author 张展弋
* @date 2020-9-9 11:53:36
*/
void deleteById(Long id);
} }
...@@ -14,5 +14,9 @@ public interface IRuleRunningSnapshotService ...@@ -14,5 +14,9 @@ public interface IRuleRunningSnapshotService
void replay(String batchNo) throws Exception; void replay(String batchNo) throws Exception;
public void reacordPlan(String topic, String msgType, String msgBody, Object contingency);
public void replayPlan(String batchNo, String randomNumber) throws Exception;
void exitReplayPlan(String batchNo, String randomNumber);
} }
...@@ -104,7 +104,7 @@ public interface IView3dService { ...@@ -104,7 +104,7 @@ public interface IView3dService {
* 今日值班统计 * 今日值班统计
* @return * @return
*/ */
CommonResponse getStatisticsDuty(String appKey, String product, String orgCode); CommonResponse getStatisticsDuty(String appKey, String product, String token, String orgCode);
/** /**
* 设备状态消息最新5条 * 设备状态消息最新5条
...@@ -148,6 +148,7 @@ public interface IView3dService { ...@@ -148,6 +148,7 @@ public interface IView3dService {
/** /**
* 检索 * 检索
* @param type类型 * @param type类型
* @param riskRourceId
* @param inputText关键字 * @param inputText关键字
* @param dataLevel风险等级 * @param dataLevel风险等级
* @param protectObjName设备名称 * @param protectObjName设备名称
...@@ -156,7 +157,7 @@ public interface IView3dService { ...@@ -156,7 +157,7 @@ public interface IView3dService {
* @param orgCode * @param orgCode
* @return * @return
*/ */
CommonResponse retrieveAll(String type, String inputText, int current, int pageSize,String orgCode,String dataLevel,String protectObjName,String token,String appKey,String product); CommonResponse retrieveAll(String type, String riskRourceId, String inputText, int current, int pageSize,String orgCode,String dataLevel,String protectObjName,String token,String appKey,String product);
/** /**
* 等级查询 * 等级查询
......
package com.yeejoin.amos.fas.config; package com.yeejoin.amos.fas.config;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -20,8 +23,9 @@ public class ExceptionHandler { ...@@ -20,8 +23,9 @@ public class ExceptionHandler {
@org.springframework.web.bind.annotation.ExceptionHandler(PermissionException.class) @org.springframework.web.bind.annotation.ExceptionHandler(PermissionException.class)
@ResponseBody @ResponseBody
public CommonResponse handlePermissionException(HttpServletRequest request, PermissionException ex) { public CommonResponse handlePermissionException(HttpServletRequest request, HttpServletResponse resp, PermissionException ex) {
return CommonResponseUtil.failure(ex.getMessage()); resp.setStatus(HttpStatus.UNAUTHORIZED.value());
return CommonResponseUtil.failure(ex.getMessage());
} }
@org.springframework.web.bind.annotation.ExceptionHandler(YeeException.class) @org.springframework.web.bind.annotation.ExceptionHandler(YeeException.class)
......
...@@ -3,6 +3,12 @@ package com.yeejoin.amos.fas.config; ...@@ -3,6 +3,12 @@ package com.yeejoin.amos.fas.config;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.vo.DepartmentBo;
import com.yeejoin.amos.fas.business.vo.RoleBo;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
...@@ -29,6 +35,11 @@ import com.yeejoin.amos.feign.privilege.Privilege; ...@@ -29,6 +35,11 @@ import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Aspect @Aspect
@Component @Component
@ResponseBody @ResponseBody
...@@ -37,6 +48,9 @@ public class PermissionAspect { ...@@ -37,6 +48,9 @@ public class PermissionAspect {
@Autowired @Autowired
private RedisTemplate<String, String> redisTemplate; private RedisTemplate<String, String> redisTemplate;
@Autowired
private RemoteSecurityService remoteSecurityService;
// 前置通知,在方法执行之前 // 前置通知,在方法执行之前
@Before(value = "@annotation(Permission)") @Before(value = "@annotation(Permission)")
...@@ -46,16 +60,111 @@ public class PermissionAspect { ...@@ -46,16 +60,111 @@ public class PermissionAspect {
logger.info("======开始权限校验======"); logger.info("======开始权限校验======");
// 用户token // 用户token
String token = (String) request.getHeader("token"); String token = (String) request.getHeader("token");
token = ObjectUtils.isEmpty(token) ? (String) request.getHeader("X-Access-Token") : token; token = ObjectUtils.isEmpty(token) ? (String) request.getHeader("X-Access-Token") : token;
String product = (String) request.getHeader("product"); String product = (String) request.getHeader("product");
String appKey = (String) request.getHeader("appKey"); String appKey = (String) request.getHeader("appKey");
logger.info("用户token:" + token); logger.info("用户token:" + token);
RequestContext.setToken(token); RequestContext.setToken(token);
RequestContext.setProduct(product); RequestContext.setProduct(product);
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
if (!TokenOperation.refresh(token)) { if (!TokenOperation.refresh(token)) {
throw new PermissionException("登录信息失效,请重新登录"); throw new PermissionException("登录信息失效,请重新登录");
} }
if (joinPoint.getSignature().getName().equals("saveCurCompany")) {
return;
}
FeignClientResult feignClientResult;
AgencyUserModel userModel=null;
try {
feignClientResult = Privilege.agencyUserClient.getme();
userModel = (AgencyUserModel) feignClientResult.getResult();
} catch (InnerInvokException e) {
e.printStackTrace();
}
String userId = null;
ReginParams regionParam = new ReginParams();
if(userModel != null){
userId = userModel.getUserId();
Map<Long, List<RoleModel>> orgRoles = userModel.getOrgRoles();
List<RoleModel> roleModels = null;
if(!ObjectUtils.isEmpty(orgRoles)) {
for (Map.Entry<Long, List<RoleModel>> entry : orgRoles.entrySet()) {
roleModels = entry.getValue();
break;
}
}
ReginParams reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userModel.getUserId(), token)), ReginParams.class);
if(reginParams == null && userModel.getCompanys().size() > 0){
CompanyModel companyModel = userModel.getCompanys().get(0);
List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(token, product, appKey, companyModel.getSequenceNbr().toString());
if(deptList.size() > 0){
CompanyBo companyBo = convertCompanyModelToBo(companyModel);
DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0));
regionParam.setCompany(companyBo);
regionParam.setDepartment(departmentBo);
}
if(!ObjectUtils.isEmpty(roleModels)){
regionParam.setRole(convertRoleModelToBo(roleModels.get(0)));
}
redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(regionParam));
}
}
}
private DepartmentBo convertDepartmentModelToBo(DepartmentModel departmentModel){
DepartmentBo departmentBo = new DepartmentBo();
if(departmentModel != null) {
departmentBo.setCompanySeq(departmentModel.getCompanySeq().toString());
departmentBo.setDepartmentDesc(departmentModel.getDepartmentDesc());
departmentBo.setDepartmentName(departmentModel.getDepartmentName());
departmentBo.setLevel(departmentModel.getLevel());
departmentBo.setOrgCode(departmentModel.getOrgCode());
departmentBo.setParentId(departmentModel.getParentId().toString());
departmentBo.setDeptOrgCode(departmentModel.getDeptOrgCode().toString());
departmentBo.setSequenceNbr(departmentModel.getSequenceNbr().toString());
}
return departmentBo;
}
/**
* Model 转 Bo
*/
private CompanyBo convertCompanyModelToBo(CompanyModel companyModel){
CompanyBo companyBo = new CompanyBo();
if(companyModel != null) {
companyBo.setAddress(companyModel.getAddress());
companyBo.setCompanyName(companyModel.getCompanyName());
companyBo.setCompanyOrgCode(Long.parseLong(companyModel.getCompanyOrgCode().toString()));
companyBo.setEmail(companyModel.getEmail());
companyBo.setLandlinePhone(companyModel.getLandlinePhone());
companyBo.setLongitude(companyModel.getLongitude());
companyBo.setLatitude(companyModel.getLatitude());
companyBo.setLevel(companyModel.getLevel());
companyBo.setOrgCode(companyModel.getOrgCode());
companyBo.setSequenceNbr(companyModel.getSequenceNbr().toString());
companyBo.setParentId(companyModel.getParentId().toString());
}
return companyBo;
}
private RoleBo convertRoleModelToBo(RoleModel roleModel) {
RoleBo roleBo = new RoleBo();
if(roleModel != null){
roleBo.setRoleName(roleModel.getRoleName());
roleBo.setRoleType(roleModel.getRoleType());
roleBo.setSequenceNbr(roleModel.getSequenceNbr().toString());
}
return roleBo;
}
//redi缓存选择的用户信息
private String buildKey(String userId, String token) {
return "region_" + userId + "_" + token;
} }
} }
...@@ -15,6 +15,6 @@ public class PermissionException extends RuntimeException{ ...@@ -15,6 +15,6 @@ public class PermissionException extends RuntimeException{
} }
public HttpStatus getStatus() { public HttpStatus getStatus() {
return HttpStatus.FORBIDDEN; // 403 return HttpStatus.UNAUTHORIZED; // 401
} }
} }
security.password=a1234560 security.password=a1234560
security.loginId=shg security.loginId=fas_autosys
security.productWeb=CONVERTER_STATION_WEB security.productWeb=CONVERTER_STATION_WEB
security.appKeyWeb=CONVERTER_STATION security.appKeyWeb=CONVERTER_STATION
#environment #environment
#spring.profiles.active = dev #spring.profiles.active = dev
eureka.client.serviceUrl.defaultZone=http://172.16.3.75:10001/eureka/ eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/
eureka.client.register-with-eureka = true eureka.client.register-with-eureka = true
eureka.client.fetch-registry = true eureka.client.fetch-registry = true
eureka.client.healthcheck.enabled = true eureka.client.healthcheck.enabled = true
eureka.client.fetchRegistry = true eureka.client.fetchRegistry = true
eureka.instance.prefer-ip-address=true eureka.instance.prefer-ip-address=true
#DB properties: #DB properties:
spring.datasource.url=jdbc:mysql://172.16.11.33:3306/v2.0_zmd_yeejoin_safety_business?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8 spring.datasource.url=jdbc:mysql://172.16.11.33:3306/safety-business-2.0-36?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=admin_1234 spring.datasource.password=admin_1234
spring.datasource.driver-class-name = com.mysql.jdbc.Driver spring.datasource.driver-class-name = com.mysql.jdbc.Driver
...@@ -63,11 +63,8 @@ rule.definition.load=true ...@@ -63,11 +63,8 @@ rule.definition.load=true
rule.definition.model-package=com.yeejoin.amos.fas.business.action.model rule.definition.model-package=com.yeejoin.amos.fas.business.action.model
rule.definition.default-agency=STATE_GRID rule.definition.default-agency=STATE_GRID
amos.feign.gennerator.use-gateway=true amos.feign.gennerator.use-gateway=true
autoSys.push.type=mqtt autoSys.push.type=mqtt
amos.feign.gennerator.use-gateway=true
#����� #�����
file.downLoad.url=http://172.16.10.175:8888/ file.downLoad.url=http://172.16.10.175:8888/
...@@ -46,6 +46,10 @@ spring.servlet.multipart.max-request-size=20MB ...@@ -46,6 +46,10 @@ spring.servlet.multipart.max-request-size=20MB
#feginName #feginName
visual.fegin.name=maas-visual visual.fegin.name=maas-visual
dutyMode.fegin.name=AMOSDUTYMODE dutyMode.fegin.name=AMOSDUTYMODE
#队站装备管理名称,主要用于风险区域同步至仓库货位
equipManage.fegin.name=AMOS-EQUIPMANAGE-ZZY
#是否开启将风险区域同步至仓库货位true开启,false关闭。默认关闭。
equipManage.fegin.isSyn=false
spring.http.multipart.maxFileSize = 10480000 spring.http.multipart.maxFileSize = 10480000
spring.http.multipart.MaxRequestSize = 50480000 spring.http.multipart.MaxRequestSize = 50480000
......
...@@ -5,49 +5,57 @@ ...@@ -5,49 +5,57 @@
<select id="queryForPage" resultType="map"> <select id="queryForPage" resultType="map">
SELECT SELECT * FROM(
DATE_FORMAT(create_date,'%Y-%m-%d %H:%i:%s') create_time, SELECT
DATE_FORMAT(create_date,'%Y-%m-%d %H:%i:%s') create_time,
t.* t.*
FROM FROM
contingency_original_data t contingency_original_data t
WHERE WHERE
1 = 1 1 = 1
<if test="equipmentId!=null"> <if test="equipmentId!=null">
AND t.equipment_Id = #{equipmentId} AND t.equipment_Id = #{equipmentId}
</if> </if>
<if test="createTime!=null"> <if test="createTime!=null">
AND TO_DAYS(t.create_date) = TO_DAYS(#{createTime}) AND TO_DAYS(t.create_date) = TO_DAYS(#{createTime})
</if> </if>
) m
WHERE
1 = 1
<if test="contingencyName!=null and contingencyName!=''"> <if test="contingencyName!=null and contingencyName!=''">
AND t.fire_Equipment_Name like concat('%',#{contingencyName},'%') OR m.fire_Equipment_Name like concat('%',#{contingencyName},'%')
OR t.equipment_Name like concat('%',#{contingencyName},'%') OR m.equipment_Name like concat('%',#{contingencyName},'%')
</if> </if>
order by t.create_date desc order by m.create_date desc
LIMIT #{start},#{length} ; LIMIT #{start},#{length} ;
</select> </select>
<select id="queryCountForPage" resultType="long"> <select id="queryCountForPage" resultType="long">
SELECT SELECT count(1) FROM (
count(1) SELECT
FROM *
contingency_original_data t FROM
WHERE contingency_original_data t
1 = 1 WHERE
1 = 1
<if test="equipmentId!=null"> <if test="equipmentId!=null">
AND t.equipment_Id = #{equipmentId} AND t.equipment_Id = #{equipmentId}
</if> </if>
<if test="createTime!=null"> <if test="createTime!=null">
AND TO_DAYS(t.create_date) = TO_DAYS(#{createTime}) AND TO_DAYS(t.create_date) = TO_DAYS(#{createTime})
</if> </if>
) m
WHERE
1=1
<if test="contingencyName!=null and contingencyName!=''"> <if test="contingencyName!=null and contingencyName!=''">
AND t.fire_Equipment_Name like concat('%',#{contingencyName},'%') OR m.fire_Equipment_Name like concat('%',#{contingencyName},'%')
OR t.equipment_Name like concat('%',#{contingencyName},'%') OR m.equipment_Name like concat('%',#{contingencyName},'%')
</if> </if>
</select> </select>
......
...@@ -1178,7 +1178,7 @@ ...@@ -1178,7 +1178,7 @@
<select id="retrieveAllCount" resultType="long"> <select id="retrieveAllCount" resultType="long">
select count(1) select count(1)
from ( from (
select r.name,r.code,'riskSource' as typeCode,r.org_code as orgCode select r.name,r.code,'riskSource' as typeCode,r.org_code as orgCode, r.id as riskSourceId
from f_risk_source r from f_risk_source r
left join f_risk_level rl ON rl.id = r.risk_level_id left join f_risk_level rl ON rl.id = r.risk_level_id
where r.is_region = 'FALSE' where r.is_region = 'FALSE'
...@@ -1186,14 +1186,14 @@ ...@@ -1186,14 +1186,14 @@
AND rl.level = #{dataLevel} AND rl.level = #{dataLevel}
</if> </if>
UNION all UNION all
select p.name,p.point_no as code,'patrol' as typeCode,p.org_code as orgCode select p.name,p.point_no as code,'patrol' as typeCode,p.org_code as orgCode, p.risk_source_id as riskSourceId
from p_point p from p_point p
WHERE is_delete = FALSE WHERE is_delete = FALSE
UNION all UNION all
select name,code,'impEquipment' as typeCode,org_code as orgCode select name,code,'impEquipment' as typeCode,org_code as orgCode, e.risk_source_id as riskSourceId
from f_equipment e from f_equipment e
UNION all UNION all
select m.name,m.code,'monitorEquipment' as typeCode,m.org_code as orgCode select m.name,m.code,'monitorEquipment' as typeCode,m.org_code as orgCode, m.risk_source_id as riskSourceId
from f_fire_equipment m from f_fire_equipment m
left join f_equipment_fire_equipment fe on fe.fire_equipment_id = m.id left join f_equipment_fire_equipment fe on fe.fire_equipment_id = m.id
left join f_equipment f on f.id = fe.equipment_id left join f_equipment f on f.id = fe.equipment_id
...@@ -1202,29 +1202,29 @@ ...@@ -1202,29 +1202,29 @@
AND f.name = #{protectObjName} AND f.name = #{protectObjName}
</if> </if>
UNION all UNION all
select name,code,'video' as typeCode,org_code as orgCode select name,code,'video' as typeCode,org_code as orgCode, risk_source_id as riskSourceId
from f_fire_equipment where equip_classify = 2 from f_fire_equipment where equip_classify = 2
UNION all UNION all
select name,code,'fireEquipment' as typeCode,org_code as orgCode select name,code,'fireEquipment' as typeCode,org_code as orgCode, risk_source_id as riskSourceId
from f_water_resource where type = 1 from f_water_resource where type = 1
UNION all UNION all
select name,code,'fireEquipment' as typeCode,org_code as orgCode select name,code,'fireEquipment' as typeCode,org_code as orgCode, risk_source_id as riskSourceId
from f_water_resource where type = 2 from f_water_resource where type = 2
UNION all UNION all
select name,car_num as code,'fireEquipment' as typeCode,org_code as orgCode select name,car_num as code,'fireEquipment' as typeCode,org_code as orgCode, risk_source_id as riskSourceId
from f_fire_car from f_fire_car
UNION all UNION all
select name,code,'fireEquipment' as typeCode,org_code as orgCode select name,code,'fireEquipment' as typeCode,org_code as orgCode, risk_source_id as riskSourceId
from f_fire_equipment where equip_classify = 3 from f_fire_equipment where equip_classify = 3
UNION all UNION all
select name,code,'fireEquipment' as typeCode,org_code as orgCode select name,code,'fireEquipment' as typeCode,org_code as orgCode, risk_source_id as riskSourceId
from f_fire_station where type = 2 from f_fire_station where type = 2
UNION all UNION all
select name,code,'fireEquipment' as typeCode,org_code as orgCode select name,code,'fireEquipment' as typeCode,org_code as orgCode, risk_source_id as riskSourceId
from f_fire_station where type = 1 from f_fire_station where type = 1
) as tmp ) as tmp
where 1=1 where 1=1
<if test="inputText!=null" > <if test="inputText!=null and inputText != ''" >
AND ( AND (
tmp.code LIKE '%${inputText}%' tmp.code LIKE '%${inputText}%'
OR tmp.name LIKE '%${inputText}%' OR tmp.name LIKE '%${inputText}%'
...@@ -1233,6 +1233,9 @@ ...@@ -1233,6 +1233,9 @@
<if test="type!=null and type!=''"> <if test="type!=null and type!=''">
AND tmp.typeCode = #{type} AND tmp.typeCode = #{type}
</if> </if>
<if test="riskSourceId != null">
AND tmp.riskSourceId = #{riskSourceId}
</if>
<if test="orgCode!=null"> <if test="orgCode!=null">
AND (tmp.orgCode = #{orgCode} OR tmp.orgCode like CONCAT(#{orgCode},'-%') ) AND (tmp.orgCode = #{orgCode} OR tmp.orgCode like CONCAT(#{orgCode},'-%') )
</if> </if>
...@@ -1267,7 +1270,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1267,7 +1270,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
r.rpn as title, r.rpn as title,
CONCAT('riskSource-',r.id) as `key` CONCAT('riskSource-',r.id) as `key`,
r.id as riskSourceId
from f_risk_source r from f_risk_source r
left join f_risk_level rl ON rl.id = r.risk_level_id left join f_risk_level rl ON rl.id = r.risk_level_id
where r.is_region = 'FALSE' where r.is_region = 'FALSE'
...@@ -1307,7 +1311,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1307,7 +1311,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
when p.status = '2' then '不合格' when p.status = '2' then '不合格'
when p.status = '3' then '漏检' when p.status = '3' then '漏检'
end as title, end as title,
concat('patrol-',p.id) as `key` concat('patrol-',p.id) as `key`,
p.risk_source_id as riskSourceId
from p_point p from p_point p
WHERE is_delete = FALSE WHERE is_delete = FALSE
UNION all UNION all
...@@ -1338,7 +1343,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1338,7 +1343,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
name as title, name as title,
concat('impEquipment-',e.id) as `key` concat('impEquipment-',e.id) as `key`,
e.risk_source_id as riskSourceId
from f_equipment e from f_equipment e
UNION all UNION all
select concat('monitorEquipment-',m.id) as id,m.id as originId,m.name,m.code,m.ue4_location as ue4Location,m.ue4_rotation as ue4Rotation ,'monitorEquipment' as type,m.org_code as orgCode, select concat('monitorEquipment-',m.id) as id,m.id as originId,m.name,m.code,m.ue4_location as ue4Location,m.ue4_rotation as ue4Rotation ,'monitorEquipment' as type,m.org_code as orgCode,
...@@ -1368,7 +1374,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1368,7 +1374,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
m.name as title, m.name as title,
concat('monitorEquipment-',m.id) as `key` concat('monitorEquipment-',m.id) as `key`,
m.risk_source_id as riskSourceId
from f_fire_equipment m from f_fire_equipment m
left join f_equipment_fire_equipment fe on fe.fire_equipment_id = m.id left join f_equipment_fire_equipment fe on fe.fire_equipment_id = m.id
left join f_equipment f on f.id = fe.equipment_id left join f_equipment f on f.id = fe.equipment_id
...@@ -1405,7 +1412,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1405,7 +1412,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
m.name as title, m.name as title,
concat('video-',m.id) as `key` concat('video-',m.id) as `key`,
m.risk_source_id as riskSourceId
from f_fire_equipment m from f_fire_equipment m
left join f_equipment_fire_equipment fe on fe.fire_equipment_id = m.id left join f_equipment_fire_equipment fe on fe.fire_equipment_id = m.id
left join f_equipment f on f.id = fe.equipment_id left join f_equipment f on f.id = fe.equipment_id
...@@ -1439,7 +1447,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1439,7 +1447,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
name as title, name as title,
concat('hydrant-',id) as `key` concat('hydrant-',id) as `key`,
risk_source_id as riskSourceId
from f_water_resource where type = 1 from f_water_resource where type = 1
UNION all UNION all
select concat('pool-',id) as id,id as originId,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation,'pool' as type,org_code as orgCode, select concat('pool-',id) as id,id as originId,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation,'pool' as type,org_code as orgCode,
...@@ -1469,7 +1478,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1469,7 +1478,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
name as title, name as title,
concat('pool-',id) as `key` concat('pool-',id) as `key`,
risk_source_id as riskSourceId
from f_water_resource where type = 2 from f_water_resource where type = 2
UNION all UNION all
select concat('fireCar-',id) as id,id as originId,name,car_num as code,ue4_location as ue4Location,ue4_rotation as ue4Rotation, 'fireCar' as type,org_code as orgCode, select concat('fireCar-',id) as id,id as originId,name,car_num as code,ue4_location as ue4Location,ue4_rotation as ue4Rotation, 'fireCar' as type,org_code as orgCode,
...@@ -1499,7 +1509,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1499,7 +1509,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
name as title, name as title,
concat('fireCar-',id) as `key` concat('fireCar-',id) as `key`,
risk_source_id as riskSourceId
from f_fire_car from f_fire_car
UNION all UNION all
select concat('fireEquipment-',id) as id,id as originId,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation,'fireEquipment' as type,org_code as orgCode, select concat('fireEquipment-',id) as id,id as originId,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation,'fireEquipment' as type,org_code as orgCode,
...@@ -1529,7 +1540,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1529,7 +1540,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
name as title, name as title,
concat('fireEquipment-',id) as `key` concat('fireEquipment-',id) as `key`,
risk_source_id as riskSourceId
from f_fire_equipment where equip_classify = 3 from f_fire_equipment where equip_classify = 3
UNION all UNION all
select concat('fireChamber-',id) as id,id as originId,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation , 'fireChamber' as type,org_code as orgCode, select concat('fireChamber-',id) as id,id as originId,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation , 'fireChamber' as type,org_code as orgCode,
...@@ -1559,7 +1571,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1559,7 +1571,8 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
name as title, name as title,
concat('fireChamber-',id) as `key` concat('fireChamber-',id) as `key`,
risk_source_id as riskSourceId
from f_fire_station where type = 2 from f_fire_station where type = 2
UNION all UNION all
select concat('fireFoamRoom-',id) as id,id as originId,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'fireFoamRoom' as type,org_code as orgCode, select concat('fireFoamRoom-',id) as id,id as originId,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'fireFoamRoom' as type,org_code as orgCode,
...@@ -1589,11 +1602,12 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1589,11 +1602,12 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
'' as routeName, '' as routeName,
'' as person, '' as person,
name as title, name as title,
concat('fireFoamRoom-',id) as `key` concat('fireFoamRoom-',id) as `key`,
risk_source_id as riskSourceId
from f_fire_station where type = 1 from f_fire_station where type = 1
) as tmp ) as tmp
<where> <where>
<if test="inputText!=null" > <if test="inputText!=null and inputText != ''" >
AND ( AND (
tmp.code LIKE '%${inputText}%' tmp.code LIKE '%${inputText}%'
OR tmp.name LIKE '%${inputText}%' OR tmp.name LIKE '%${inputText}%'
...@@ -1602,6 +1616,9 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue ...@@ -1602,6 +1616,9 @@ from (select concat('riskSource',r.id) as id,r.id as originId,r.name,r.code,r.ue
<if test="type!=null and type!=''"> <if test="type!=null and type!=''">
AND tmp.typeCode = #{type} AND tmp.typeCode = #{type}
</if> </if>
<if test="riskSourceId != null">
AND tmp.riskSourceId = #{riskSourceId}
</if>
<if test="orgCode!=null"> <if test="orgCode!=null">
AND (tmp.orgCode = #{orgCode} OR tmp.orgCode like CONCAT(#{orgCode},'-%') ) AND (tmp.orgCode = #{orgCode} OR tmp.orgCode like CONCAT(#{orgCode},'-%') )
</if> </if>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<groupId>com.yeejoin</groupId> <groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId> <artifactId>amos-component-rule</artifactId>
<version>1.2.0-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
......
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