Commit 071c4c65 authored by 吴江's avatar 吴江

规则修改适配

parent bea1dac1
package com.yeejoin.amos.fas.dao.entity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
/**
*
* <pre>
* 消息实体
* </pre>
*
* @author HK
* @version $Id: Message.java, v 0.1 2018年1月18日 下午7:48:58 HK Exp $
*/
@Entity
@Table(name = "toip_sys_message")
public class Message extends BusinessEntity
{
/**
* <pre>
*
* </pre>
*/
private static final long serialVersionUID = 292329658525267887L;
/**
* id
*/
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "id", nullable = false, length = 36)
protected String id;
/**
* 时间
*/
private Date time;
/**
* 标题
*/
private String title;
/**
* 内容
*/
private String content;
/**
* 类型
*/
private String type;
/**
* 发送者
*/
private String sender;
/**
* 接收者
*/
private String receiver;
/**
* 已读者
*/
private String reader;
/**
* 业务id
*/
private String bizId;
/**
* 业务员实体名,例如com.yeejoin.amos.toip.bizrulebridge.entity.Fire
*/
private String bizclassName;
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public Date getTime()
{
return time;
}
public void setTime(Date time)
{
this.time = time;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getContent()
{
return content;
}
public void setContent(String content)
{
this.content = content;
}
public String getType()
{
return type;
}
public void setType(String type)
{
this.type = type;
}
public String getSender()
{
return sender;
}
public void setSender(String sender)
{
this.sender = sender;
}
public String getReceiver()
{
return receiver;
}
public void setReceiver(String receiver)
{
this.receiver = receiver;
}
public String getReader()
{
return reader;
}
public void setReader(String reader)
{
this.reader = reader;
}
public String getBizId()
{
return bizId;
}
public void setBizId(String bizId)
{
this.bizId = bizId;
}
public String getBizclassName()
{
return bizclassName;
}
public void setBizclassName(String bizclassName)
{
this.bizclassName = bizclassName;
}
}
package com.yeejoin.amos.fas.business.action;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Component;
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.message.ActionResultMessage;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
/**
*
* <pre>
* 气泡提示动作
* </pre>
*
* @author amos
* @version $Id: BubbleTipAction.java, v 0.1 2019年5月16日 上午10:42:32 amos Exp $
*/
@Component
public class BubbleTipAction implements CustomerAction
{
private static String PACKAGEURL = "com.yeejoin.amos.rule.map.action.result.message.";
//@ExposeAction("气泡提示")
public void sendBubbleTip(Object bizobj, Boolean showInfo, Object title, String type)
{
BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj);
result.add(tempmap1);
//是否显示气泡
Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("showInfo", showInfo);
result.add(tempmap2);
//显示title提示
Map<String, Object> tempmap3 = new HashMap<>();
tempmap3.put("title", title);
result.add(tempmap3);
//节点类型
Map<String, Object> tempmap4 = new HashMap<>();
tempmap4.put("type", type);
result.add(tempmap4);
Constructor<?> constructor;
try
{
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
ActionResultMessage<?> action = (ActionResultMessage<?>) constructor.newInstance(result);
String firstStr = "fromws";
String secondStr = "map";
String thirdStr = "bubble";
Object obj = action.execute(firstStr, secondStr, thirdStr);
result.setToipResponse((ToipResponse) obj);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
package com.yeejoin.amos.fas.business.action;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Component;
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.message.ActionResultMessage;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
/**
*
* <pre>
* 风险态势图动作
* </pre>
*
* @author amos
* @version $Id: RiskSituationAction.java, v 0.1 2019年5月16日 下午5:26:27 amos Exp $
*/
@Component
public class RiskSituationAction implements CustomerAction
{
private static String PACKAGEURL = "com.yeejoin.amos.rule.map.action.result.message.";
//@ExposeAction("气泡提示")
public void sendBubbleTip(Object bizobj, Boolean showInfo, String title)
{
BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj);
result.add(tempmap1);
//是否显示气泡
Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("showInfo", showInfo);
result.add(tempmap2);
//显示title提示
Map<String, Object> tempmap3 = new HashMap<>();
tempmap3.put("title", title);
result.add(tempmap3);
Constructor<?> constructor;
try
{
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
ActionResultMessage<?> action = (ActionResultMessage<?>) constructor.newInstance(result);
String firstStr = "fromws";
String secondStr = "riskSituation";
String thirdStr = "bubble";
Object obj = action.execute(firstStr, secondStr, thirdStr);
result.setToipResponse((ToipResponse) obj);
}
catch (Exception e)
{
e.printStackTrace();
}
}
//@ExposeAction("区域颜色改变")
public void regionChange(Object bizobj, String colour)
{
BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj);
result.add(tempmap1);
//更改颜色
Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("colour", colour);
result.add(tempmap2);
Constructor<?> constructor;
try
{
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
ActionResultMessage<?> action = (ActionResultMessage<?>) constructor.newInstance(result);
String firstStr = "fromws";
String secondStr = "riskSituation";
String thirdStr = "colour";
Object obj = action.execute(firstStr, secondStr, thirdStr);
result.setToipResponse((ToipResponse) obj);
}
catch (Exception e)
{
e.printStackTrace();
}
}
//@ExposeAction(value = "区域闪烁",snapshot = false)
public void regionFlicker(Object bizobj, Integer frequency)
{
BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj);
result.add(tempmap1);
//更改颜色
Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("frequency", frequency);
result.add(tempmap2);
Constructor<?> constructor;
try
{
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
ActionResultMessage<?> action = (ActionResultMessage<?>) constructor.newInstance(result);
String firstStr = "fromws";
String secondStr = "riskSituation";
String thirdStr = "flicker";
Object obj = action.execute(firstStr, secondStr, thirdStr);
result.setToipResponse((ToipResponse) obj);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
package com.yeejoin.amos.fas.business.action;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
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.TipResult;
import com.yeejoin.amos.fas.business.action.result.message.ActionResultMessage;
import com.yeejoin.amos.fas.business.action.util.DataItemUtil;
import com.yeejoin.amos.fas.business.service.model.BasicsRo;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.dao.entity.BusinessEntity;
import com.yeejoin.amos.fas.dao.entity.Message;
/**
*
* <pre>
* 消息提示动作
* </pre>
*
* @author amos
* @version $Id: SimpleTipAction.java, v 0.1 2019年4月24日 下午2:47:37 amos Exp $
*/
@Component
public class SimpleTipAction implements CustomerAction
{
private static String PACKAGEURL = "com.yeejoin.amos.rule.map.action.result.message.";
// @Autowired
// private IMessageService messageService;
//@ExposeAction("消息提示")
// public void sendMessageTip(Object bizobj, String title, String content,String type)
// {
//
// try
// {
//
// ELEvaluationContext.setVariable("bizobj",bizobj);
// TipResult result = new TipResult();
// result.add(bizobj);
// Map<String, Object> tempmap1 = new HashMap<>();
// tempmap1.put("title", title);
// result.add(tempmap1);
// Map<String, Object> tempmap2 = new HashMap<>();
// content =DataItemUtil.getNative(content);
// tempmap2.put("content", content);
// result.add(tempmap2);
//
//
// Constructor<?> constructor;
//
// constructor = Class.forName(
// PACKAGEURL + result.getClass().getSimpleName() + "Message")
// .getConstructor(ActionResult.class);
// ActionResultMessage<?> action = (ActionResultMessage<?>) constructor.newInstance(result);
// String firstStr = "fromws";
// String secondStr = "global";
// String thirdStr = "msg";
// result.setBizObj((BusinessEntity)bizobj);
// Object obj = action.execute(firstStr, secondStr, thirdStr);
// result.setToipResponse((ToipResponse) obj);
// saveMessageAction(result,type);
// }
// catch (Exception e)
// {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// @SuppressWarnings("unchecked")
// private void saveMessageAction(AbstractActionResult abstractActionResult,String type)
// {
// Message message = new Message();
// List<Map<String, Object>> list = (List<Map<String, Object>>) abstractActionResult.getData();
// for(Map<String, Object> map : list) {
// for(String str: map.keySet()) {
// if(str.equals("content")) {
// message.setContent(map.get("content").toString());
// }else
// if (str.equals("title"))
// {
// message.setTitle(map.get("title").toString());
// }
// }
// BasicsRo basicsRo = (BasicsRo)abstractActionResult.getToipResponse().getBizObj();
// message.setTime(basicsRo.getDateTime());
// message.setBizId(basicsRo.getId());
// message.setBizclassName(abstractActionResult.getToipResponse().getBizObj().getClass().toString());
// message.setType(type);
// messageService.save(message);
// }
// }
}
package com.yeejoin.amos.fas.business.action.el;
import java.util.Map;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
public class ELEvaluationContext
{
private static EvaluationContext instance = new StandardEvaluationContext();
private static ExpressionParser parser = new SpelExpressionParser();
public static EvaluationContext getInstance()
{
return instance;
}
public static void setVariable(String name, Object value)
{
instance.setVariable(name, value);
}
public static void setVariable(Map<String, Object> vars)
{
for (Map.Entry<String, Object> entry : vars.entrySet())
{
instance.setVariable(entry.getKey(), entry.getValue());
}
}
public static Object getValue(String Expression){
return parser.parseExpression(Expression).getValue(instance);
}
}
package com.yeejoin.amos.fas.business.action.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
public class DataItemUtil
{
public static boolean getEnable(JSONObject jsonObject)
{
try
{
return jsonObject.getBooleanValue("enable");
}
catch (Exception e)
{
return false;
}
}
public static String getDisplayName(JSONObject jsonObject)
{
try
{
return jsonObject.get("displayname").toString();
}
catch (Exception e)
{
return null;
}
}
public static String getValue(JSONObject jsonObject)
{
try
{
return jsonObject.get("value").toString();
}
catch (Exception e)
{
return null;
}
}
public static String getName(JSONObject jsonObject)
{
try
{
return jsonObject.get("name").toString();
}
catch (Exception e)
{
return null;
}
}
public static 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;
}
}
......@@ -249,6 +249,8 @@ public class BaseController {
if (reginParams.getCompany() != null) {
return reginParams.getCompany().getOrgCode();
}
return null;
}
......
......@@ -144,7 +144,7 @@ public interface View3dMapper extends BaseMapper{
*/
List<View3dNodeVo> initViewErrorNode(String type,Long riskSourceId, String orgCode);
List<Node3DVoResponse> findViewDataByType(String type,Long riskSourceId,String orgCode);
List<Node3DVoResponse> findViewDataByType(@Param("type")String type,@Param("riskSourceId")Long riskSourceId,@Param("orgCode")String orgCode);
Long retrieveAllCount(String type, String inputText,String orgCode,String dataLevel,String protectObjName);
......
......@@ -15,6 +15,7 @@ import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import org.apache.commons.lang3.ArrayUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -176,7 +177,8 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
Equipment equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId()));
//Object result = remoteRuleServer.fireRuleFlow(contingencyRo, equipment.getReservePlan(),equipment.getName());
ruleTrigger.publish(contingencyRo, equipment.getReservePlan());
equipment.setName("极Ⅰ高端YY换流变A相");
ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
BubbleTipResult result1 = new BubbleTipResult();
Map<String, Object> tempmap2 = new HashMap<>();
......
......@@ -243,6 +243,10 @@ public class EquipmentServiceImpl implements IEquipmentService {
}
long total = this.impAndFireEquipMapper.queryBindFirEqumtPageCount(String.valueOf(equipmentId));
List<FireEquipment> list = this.impAndFireEquipMapper.queryBindFirEqumtPage(start, length, String.valueOf(equipmentId));
if(commonPageable==null)
{
commonPageable = new CommonPageable();
}
Page result = new PageImpl(list, commonPageable, total);
return result;
}
......
......@@ -4,6 +4,7 @@ package com.yeejoin.amos.fas.business.service.impl;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
......@@ -22,6 +23,7 @@ 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;
......@@ -126,15 +128,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private final Logger log = LoggerFactory.getLogger(RiskSourceServiceImpl.class);
private static final String DATETYPE_YYYYMMDD = "yyyyMMdd"; //
private static final String DATETYPE_YYYYMMDD = "yyyyMMdd"; //
private static final String DATETYPE_YYYYWW = "yyyyWW";//
private static final String DATETYPE_YYYYWW = "yyyyWW";//
private static final String DATETYPE_YYYYS = "yyyyS";//季节
private static final String DATETYPE_YYYYS = "yyyyS";// 季节
private static final String DATETYPE_YYYYMM = "yyyyMM";//
private static final String DATETYPE_YYYYMM = "yyyyMM";//
private static final String DATETYPE_YYYY = "yyyy";//
private static final String DATETYPE_YYYY = "yyyy";//
@Autowired
private IRiskSourceDao iRiskSourceDao;
......@@ -142,7 +144,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired
private AppMessagePushService appMessagePushService;
@Autowired
private IRiskLevelDao riskLevelDao;
......@@ -173,7 +174,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired
private IRiskLevelDao iRiskLevelDao;
@Autowired
private RemoteSecurityService remoteSecurityService;
......@@ -244,7 +244,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (oldRiskSource1.isPresent()) {
oldRiskSource = oldRiskSource1.get();
}
if (id == 0) {//新增
if (id == 0) {// 新增
riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL);
riskSource.setCreateDate(new Date());
} else {// 更新
......@@ -272,10 +272,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
iRiskSourceDao.deleteById(rId);
}
//1.重新计算rpn
List<Long> existIds = parentIds.stream().filter(e ->
iRiskSourceDao.findById(e).isPresent()
).collect(Collectors.toList());
// 1.重新计算rpn
List<Long> existIds = parentIds.stream().filter(e -> iRiskSourceDao.findById(e).isPresent())
.collect(Collectors.toList());
RsDataQueue rs = RsDataQueue.getInstance();
existIds.forEach(rs::addRiskSourcePointDeleteMessage);
}
......@@ -287,7 +286,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return new PageImpl<>(content, param, total);
}
@Override
public List<Map> queryForRegion() {
List<Map> result = riskSourceMapper.queryForRegion();
......@@ -300,7 +298,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return result;
}
@Override
public Map queryFor3DStatistics() {
Map<String, List> result = riskSourceMapper.statistics3dCount();
......@@ -310,13 +307,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return result;
}
@Override
public List<Map> queryRPNReport() {
return riskSourceMapper.queryRPNReport();
}
@Override
public Map queryForRiseUp() throws Exception {
Map<String, Map> result = new HashMap<>();
......@@ -329,18 +324,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//当月的升上率
// 当月的升上率
startTime = format.format(timeArrayMonth[0]);
endTime = format.format(timeArrayMonth[1]);
Map resultMonth = this.riskSourceMapper.queryForRiseUp(startTime, endTime);
//当季度的升上率
// 当季度的升上率
startTime = format.format(timeArraySeason[0]);
endTime = format.format(timeArraySeason[1]);
Map resultSeason = this.riskSourceMapper.queryForRiseUp(startTime, endTime);
//当年的升上率
// 当年的升上率
startTime = format.format(timeArrayYear[0]);
endTime = format.format(timeArrayYear[1]);
Map resultYear = this.riskSourceMapper.queryForRiseUp(startTime, endTime);
......@@ -359,7 +353,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private static Date[] getDateInfo(Date date, String datetype) throws Exception {
Date[] returnDate = new Date[2];
Date start = null;
Date end = null;
if (DATETYPE_YYYYMMDD.equals(datetype)) {
......@@ -400,7 +393,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public List<FmeaEquipmentPoint> bindFireEquiment(FmeaBindParam fmeaBindParam) {
Long fmeaId = fmeaBindParam.getFmeaId();
Long importantEquipId = fmeaBindParam.getImportantEquipmentId();
List<Long> equipmentPointIds = fmeaEquipmentPointMapper.listEquipmentPointIdsByEquipmentId(fmeaBindParam.getEquipmentId());
List<Long> equipmentPointIds = fmeaEquipmentPointMapper
.listEquipmentPointIdsByEquipmentId(fmeaBindParam.getEquipmentId());
if (!CollectionUtils.isEmpty(equipmentPointIds)) {
fmeaEquipmentPointMapper.deleteByFmeaIdAndEquipmentPointIds(fmeaId, importantEquipId, equipmentPointIds);
}
......@@ -416,7 +410,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (!CollectionUtils.isEmpty(returnList) && equipment != null) {
fmeaEquipmentPointMapper.saveBatch(returnList);
RsDataQueue rsDataQueue = RsDataQueue.getInstance();
rsDataQueue.addEquipmentMessage(fmeaId,equipment.getName());
rsDataQueue.addEquipmentMessage(fmeaId, equipment.getName());
}
return returnList;
}
......@@ -424,7 +418,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public List<FmeaPointInputitem> bindPointInputitem(FmeaBindParam fmeaBindParam) {
Long fmeaId = fmeaBindParam.getFmeaId();
List<Long> pointInputitemIds = fmeaPointInputitemMapper.listPointInputitemIdsByPointId(fmeaBindParam.getPointId());
List<Long> pointInputitemIds = fmeaPointInputitemMapper
.listPointInputitemIdsByPointId(fmeaBindParam.getPointId());
if (!CollectionUtils.isEmpty(pointInputitemIds)) {
fmeaPointInputitemMapper.deleteByFmeaIdAndPointInputitemIds(fmeaId, pointInputitemIds);
}
......@@ -449,13 +444,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public Page<Map> queryEquimentRelation(CommonPageable commonPageable, String equipmentId, String fname) {
Long total = fireEquipMapper.queryEquimentRelationCount(equipmentId, fname);
List<Map> list = fireEquipMapper.queryEquimentRelation(commonPageable.getOffset(), commonPageable.getPageSize(), equipmentId, fname);
List<Map> list = fireEquipMapper.queryEquimentRelation(commonPageable.getOffset(), commonPageable.getPageSize(),
equipmentId, fname);
return new PageImpl<>(list, commonPageable, total);
}
@Override
public List<Map<String, Object>> listEquipmentPointById(Long fmeaId, Long importantEquipId, Long equipmentId, String equipmentPointName) {
List<Map<String, Object>> list = fmeaEquipmentPointMapper.listEquipmentPoint(fmeaId, importantEquipId, equipmentId, equipmentPointName);
public List<Map<String, Object>> listEquipmentPointById(Long fmeaId, Long importantEquipId, Long equipmentId,
String equipmentPointName) {
List<Map<String, Object>> list = fmeaEquipmentPointMapper.listEquipmentPoint(fmeaId, importantEquipId,
equipmentId, equipmentPointName);
if (CollectionUtils.isEmpty(list)) {
return Lists.newArrayList();
}
......@@ -466,7 +464,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
@Async
public String processFireEqumtData(FireEquimentDataRo deviceData) throws Exception {
//处理设备和巡检数据
// 处理设备和巡检数据
deviceData.setNodeState(deviceData.getValue());
String batchNo = UUID.randomUUID().toString();
deviceData.setBatchNo(batchNo);
......@@ -484,11 +482,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
deviceData.setMonitor(equipment.getName());
deviceData.setEquimentId(String.valueOf(equipment.getId()));
//Object result = remoteRuleServer.fireRule(deviceData, "风险管控/fireEquiment");
//处理返回结果
// Object result = remoteRuleServer.fireRule(deviceData,
// "风险管控/fireEquiment");
// 处理返回结果
List<RiskSource> riskSources = this.riskSourceMapper.queryByFireEqument(deviceData.getFireEquimentId());
//asymbleWithParent(batchNo, riskSources, FireEquimentDataRo.class.getSimpleName(), deviceData.getFireEquimentId(), deviceData.getNodeState(), null, null);
// asymbleWithParent(batchNo, riskSources,
// FireEquimentDataRo.class.getSimpleName(),
// deviceData.getFireEquimentId(), deviceData.getNodeState(),
// null, null);
try {
alermContingency(deviceData.getBatchNo(), fireEquipment, equipment);
......@@ -498,11 +500,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
return "SUCCESS";
}
public void alermContingency(String batchNo, FireEquipment fireEquipment, Equipment equipment) throws Exception {
ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo);
......@@ -511,12 +511,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo.setFireEquipmentId(String.valueOf(fireEquipment.getId()));
contingencyRo.setFireEquipmentName(fireEquipment.getName());
contingencyRo.setStep("0");
//contingencyRo.setNodeState(deviceData.getNodeState());
// contingencyRo.setNodeState(deviceData.getNodeState());
contingencyRo.setConfirm("NONE");
contingencyRo.setFireTruckRoute(equipment.getFireTruckRoute());
contingencyRo.setRunstep(false);
contingencyRo.setEquipmentPosition3d(equipment.getPosition3d());
Map cameraInfo = impAndFireEquipMapper.queryForCamera(String.valueOf(equipment.getId()));
if (cameraInfo != null) {
......@@ -545,14 +544,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
//Object result = remoteRuleServer.fireRuleFlow(contingencyRo, equipment.getReservePlan(), equipment.getName());
ruleTrigger.publish(contingencyRo, equipment.getReservePlan());
// Object result = remoteRuleServer.fireRuleFlow(contingencyRo,
// equipment.getReservePlan(), equipment.getName());
equipment.setName("极Ⅰ高端YY换流变A相");
ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData();
BeanUtils.copyProperties(contingencyRo, contingencyOriginalData);
iContingencyOriginalDataDao.save(contingencyOriginalData);
}
private Integer findRegionMaxLevel(Long regionRiskSourceId) {
Integer maxLevel = 0;
List<RiskSource> anomalyRiskSource = findAnomalyRiskSource(regionRiskSourceId);
......@@ -570,7 +570,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
private List<RiskSource> findAnomalyRiskSource(Long riskSourceId) {
List<RiskSource> returnList = new ArrayList<>();
List<RiskSource> childs = iRiskSourceDao.findByParentId(riskSourceId);
......@@ -586,18 +585,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
@Override
public Page<Map<String, Object>> listFmeaPointInputitem(String toke,String product,String appKey,Long fmeaId, Integer pageNumber, Integer pageSize) {
public Page<Map<String, Object>> listFmeaPointInputitem(String toke, String product, String appKey, Long fmeaId,
Integer pageNumber, Integer pageSize) {
List<Map<String, Object>> content = Lists.newArrayList();
long total = fmeaPointInputitemMapper.countByFmeaId(fmeaId);
if (total == 0L) {
return new PageImpl<>(content, null, total);
}
content = fmeaPointInputitemMapper.listByFmeaId(fmeaId, pageNumber, pageSize);
if(!CollectionUtils.isEmpty(content)){
if (!CollectionUtils.isEmpty(content)) {
Set<String> userIds = new HashSet<>();
Set<String> deptIds = new HashSet<>();
for(Map<String, Object> map : content)
{
for (Map<String, Object> map : content) {
String userId = String.valueOf(map.get("userId"));
String deptId = String.valueOf(map.get("deptId"));
userIds.add(userId);
......@@ -606,19 +605,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
userIds.remove(null);
deptIds.remove(null);
List<AgencyUserModel> users = new ArrayList<>();
if(!CollectionUtils.isEmpty(userIds)){
if (!CollectionUtils.isEmpty(userIds)) {
users = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
}
Map<String, String> userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
Map<String, String> userMap = users.stream()
.collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName));
List<DepartmentModel> depts = new ArrayList<>();
if(!CollectionUtils.isEmpty(deptIds)){
depts = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(deptIds));
if (!CollectionUtils.isEmpty(deptIds)) {
depts = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey,
Joiner.on(",").join(deptIds));
}
Map<Long, String > deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
Map<Long, String> deptMap = depts.stream()
.collect(Collectors.toMap(DepartmentModel::getSequenceNbr, DepartmentModel::getDepartmentName));
content.forEach(e -> {
e.put("userName",userMap.get(e.get("userId")));
e.put("deptName",deptMap.get(e.get("deptId")));
e.put("tel",userMap.get(String.valueOf(e.get("deptId")+"tel")));
e.put("userName", userMap.get(e.get("userId")));
e.put("deptName", deptMap.get(e.get("deptId")));
e.put("tel", userMap.get(String.valueOf(e.get("deptId") + "tel")));
});
}
return new PageImpl<>(content, null, total);
......@@ -631,15 +633,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return new PageImpl<>(content, null, total);
}
@Override
public boolean processTaskData(ProtalDataRo taskData) throws Exception {
taskData.setBatchNo(UUID.randomUUID().toString());
//Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
// Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
return true;
}
@Override
@Async
public void processProtalData(String toke, String product, String appKey, ProtalDataRo protalData) {
......@@ -651,7 +651,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
inputIds.add(checkInputItemRo.getPointInputitemId());
map.put(checkInputItemRo.getPointInputitemId(), checkInputItemRo);
}
List<FmeaPointInputitem> fmeaPointInputitems = fmeaPointInputitemMapper.listByPointIdAndInputItemIds(pointId, inputIds);
List<FmeaPointInputitem> fmeaPointInputitems = fmeaPointInputitemMapper
.listByPointIdAndInputItemIds(pointId, inputIds);
Set<Long> fmeaIds = Sets.newHashSet();
List<Long> failIds = Lists.newArrayList();
List<Long> successIds = Lists.newArrayList();
......@@ -672,8 +673,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaPointInputitemMapper.updateStateByIds(0, successIds);
}
RsDataQueue rsDataQueue = RsDataQueue.getInstance();
fmeaIds.forEach(fmeaId ->
rsDataQueue.addPatrolMessage(fmeaId,protalData.getCheckUser(),protalData.getName(),protalData.getNodeState()));
fmeaIds.forEach(fmeaId -> rsDataQueue.addPatrolMessage(fmeaId, protalData.getCheckUser(),
protalData.getName(), protalData.getNodeState()));
}
iDataRefreshService.refreshViewData(DataRefreshTypeEum.check.getCode());
}
......@@ -684,7 +685,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return det;
}
@Override
public Map earlyWarning(Long riskSourceId) {
Map returnMap = new HashMap();
......@@ -699,7 +699,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return returnMap;
}
@Override
public List<HashMap<String, Object>> queryRiskAreaRpn() {
return riskSourceMapper.queryRiskAreaRpn();
......@@ -749,9 +748,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
private void processFireData(AlarmParam deviceData) throws Exception {
//处理设备和巡检数据
deviceData.setPointCode("2");
// 处理设备和巡检数据
deviceData.setNodeState(deviceData.getState());
FireEquipmentPoint fireEquipmentPoint = iFireEquipmentPointDao.findOneByCode(deviceData.getPointCode());
fireEquipmentPoint.setValue(deviceData.getState());
......@@ -761,7 +760,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Dict dict = dictDao.getOne(fireEquipmentPoint.getAlarmType());
fireEquipmentPointType = dict.getDictValue();
}
Optional<FireEquipment> fireEquipment1 = this.iFireEquipmentDao.findById(fireEquipmentPoint.getFireEquipmentId());
Optional<FireEquipment> fireEquipment1 = this.iFireEquipmentDao
.findById(fireEquipmentPoint.getFireEquipmentId());
FireEquipment fireEquipment = null;
if (fireEquipment1.isPresent()) {
fireEquipment = fireEquipment1.get();
......@@ -769,11 +769,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Equipment equipment = null;
if (fireEquipment != null) {
deviceData.setCode(fireEquipment.getCode());
//保存实时数据
// 保存实时数据
saveFireEquipmentData(fireEquipmentPoint, fireEquipment, deviceData, fireEquipmentPointType);
equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId());
if (equipment != null) {
//动态预案执行
// 动态预案执行
dynamicPlan(deviceData, equipment, fireEquipment, fireEquipmentPointType);
}
}
......@@ -781,13 +781,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* 预案执行
*
* @param deviceData
* @param equipment
* @param fireEquipment
* @param fireEquipmentPointType
*/
@Async
private void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment, String fireEquipmentPointType){
private void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment,
String fireEquipmentPointType) {
String batchNo = null;
Object batch = null;
Dict dict = null;
......@@ -832,7 +834,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} else {
String alarmType = (String) redisTemplate.opsForHash().get("currentContingency", "alarmType");
if (!ObjectUtils.isEmpty(alarmType) && dict.getDictValue().equals(alarmType)) {
ContingencyDeviceStatus contingencyDeviceStatus = (ContingencyDeviceStatus) redisTemplate.opsForHash().get("currentContingency", "contingencyPlan");
ContingencyDeviceStatus contingencyDeviceStatus = (ContingencyDeviceStatus) redisTemplate.opsForHash()
.get("currentContingency", "contingencyPlan");
contingencyDeviceStatus.setNeedStatus("true");
autoProcessContingency(contingencyDeviceStatus, alarmType);
}
......@@ -846,22 +849,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return "SUCCESS";
}
private void saveFireEquipmentData(FireEquipmentPoint fireEquipmentPoint, FireEquipment fireEquipment, AlarmParam deviceData, String fireEquipmentPointType) {
if("alarm_type_fire".equals(fireEquipmentPointType) || "alarm_type_trouble".equals(fireEquipmentPointType)){
private void saveFireEquipmentData(FireEquipmentPoint fireEquipmentPoint, FireEquipment fireEquipment,
AlarmParam deviceData, String fireEquipmentPointType) {
if ("alarm_type_fire".equals(fireEquipmentPointType) || "alarm_type_trouble".equals(fireEquipmentPointType)) {
Alarm alarm = iAlarmDao.findByStatusTrueAndFireEquipmentPointCode(deviceData.getPointCode());
if(alarm != null){
if (alarm != null) {
alarm.setFireEquipmentPointValue(deviceData.getState());
if("false".equals(deviceData.getState())){
if ("false".equals(deviceData.getState())) {
alarm.setRecoveryDate(new Date());
alarm.setStatus(false);
}else{
alarm.setFrequency((alarm.getFrequency()+1));
} else {
alarm.setFrequency((alarm.getFrequency() + 1));
alarm.setUpdateDate(new Date());
}
iAlarmDao.save(alarm);
}else{
if("true".equals(deviceData.getState())){
} else {
if ("true".equals(deviceData.getState())) {
alarm = new Alarm();
alarm.setFireEquipmentCode(fireEquipment.getCode());
alarm.setFireEquipmentId(fireEquipment.getId());
......@@ -875,20 +878,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
iAlarmDao.save(alarm);
}
}
if(alarm != null){
if (alarm != null) {
if ("alarm_type_trouble".equals(fireEquipmentPointType)) {
//通知刷新3d页面相关故障数据
if(alarm.getFrequency()==1 || alarm.getStatus() == false){
// 通知刷新3d页面相关故障数据
if (alarm.getFrequency() == 1 || alarm.getStatus() == false) {
notifyAlarm(fireEquipmentPoint, deviceData);
iDataRefreshService.refreshViewData(DataRefreshTypeEum.trouble.getCode());
}
}else{
//通知刷新3d页面告警数据
} else {
// 通知刷新3d页面告警数据
iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode());
}
}
}else{
if("SWITCH".equals(fireEquipmentPoint.getType())){ //保存遥信信号数据到mysql中
} else {
if ("SWITCH".equals(fireEquipmentPoint.getType())) { // 保存遥信信号数据到mysql中
FireEquipmentData fireEquipmentData = new FireEquipmentData();
fireEquipmentData.setEqPointCode(deviceData.getPointCode());
fireEquipmentData.seteValue(deviceData.getState());
......@@ -912,12 +915,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
List<AlarmParam> list = new ArrayList<>();
list.add(deviceData);
//保存所有数据(遥测,遥信)到mongo
// 保存所有数据(遥测,遥信)到mongo
saveData(list, "soe");
}
@Override
public void saveData(List<AlarmParam> deviceDatas, String type) {
List<EquipCommunicationData> list = deviceDatas.stream().map(param -> {
......@@ -955,7 +956,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (!param.getState().equals(fireEquipmentPoint.getValue())) {
fireEquipmentPoint.setValue(param.getState());
updateFirePointValue(fireEquipmentPoint.getId(), param.getState());
Equipment equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.valueOf(data.getFireEquipmentId()));
Equipment equipment = impAndFireEquipMapper
.queryImpEqumtByFireEquipmt(Long.valueOf(data.getFireEquipmentId()));
if (!ObjectUtils.isEmpty(equipment)) {
if (dict != null && dict.getDictValue().equals("alarm_type_trouble")) {
notifyAlarm(fireEquipmentPoint, param);
......@@ -976,7 +978,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 设备告警触发fema的sod值
*/
private void notifyAlarm(FireEquipmentPoint fireEquipmentPoint, AlarmParam param) {
List<FmeaEquipmentPoint> fmeaEquipmentPoints = fmeaEquipmentPointMapper.listByEquipmentPointId(fireEquipmentPoint.getId());
List<FmeaEquipmentPoint> fmeaEquipmentPoints = fmeaEquipmentPointMapper
.listByEquipmentPointId(fireEquipmentPoint.getId());
Set<Long> fmeaIds = Sets.newHashSet();
List<Long> ids = Lists.newArrayList();
fmeaEquipmentPoints.forEach(fmeaEquipmentPoint -> {
......@@ -994,7 +997,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaEquipmentPointMapper.updateStateByIds(state, ids);
}
RsDataQueue rsDataQueue = RsDataQueue.getInstance();
fmeaIds.forEach(fmeaId -> rsDataQueue.addEquipmentMessage(fmeaId,param.getMonitor()));
fmeaIds.forEach(fmeaId -> rsDataQueue.addEquipmentMessage(fmeaId, param.getMonitor()));
}
}
......@@ -1035,7 +1038,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
switch (contingencyDeviceStatus.getActionName()) {
case "确认灾情":
// redisTemplate.opsForHash().put("currentContingency", "equipmentId", contingencyDeviceStatus.getEquipmentId());
// redisTemplate.opsForHash().put("currentContingency",
// "equipmentId", contingencyDeviceStatus.getEquipmentId());
redisTemplate.opsForValue().set("equipmentId", contingencyDeviceStatus.getEquipmentId());
break;
case "断开上级电源":
......@@ -1071,13 +1075,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (ObjectUtils.isEmpty(contingencyDeviceStatus)) {
return;
}
int pointCount = fireEquipPointMapper.queryCountByEuipmentIdAndAlarmType(contingencyDeviceStatus.getEquipmentId(), alarmType);
int count = fireEquipPointMapper.queryStopCountByEuipmentIdAndAlarmType(contingencyDeviceStatus.getEquipmentId(), alarmType, contingencyDeviceStatus.getNeedStatus());
int pointCount = fireEquipPointMapper
.queryCountByEuipmentIdAndAlarmType(contingencyDeviceStatus.getEquipmentId(), alarmType);
int count = fireEquipPointMapper.queryStopCountByEuipmentIdAndAlarmType(
contingencyDeviceStatus.getEquipmentId(), alarmType, contingencyDeviceStatus.getNeedStatus());
if (pointCount > 0 && pointCount == count) {
try {
String batchNo = (String) redisTemplate.opsForHash().get("currentContingency", "batchNo");
iContingencyInstance.setButtonExecuted(batchNo, contingencyDeviceStatus.getContingencyPlanId(), contingencyDeviceStatus.getButtonCode(), contingencyDeviceStatus.getConfirm());
iContingencyInstance.fire(batchNo, contingencyDeviceStatus.getStepCode(), contingencyDeviceStatus.getContingencyPlanId(), contingencyDeviceStatus.getButtonCode(), contingencyDeviceStatus.getConfirm(), contingencyDeviceStatus.getStepState());
iContingencyInstance.setButtonExecuted(batchNo, contingencyDeviceStatus.getContingencyPlanId(),
contingencyDeviceStatus.getButtonCode(), contingencyDeviceStatus.getConfirm());
iContingencyInstance.fire(batchNo, contingencyDeviceStatus.getStepCode(),
contingencyDeviceStatus.getContingencyPlanId(), contingencyDeviceStatus.getButtonCode(),
contingencyDeviceStatus.getConfirm(), contingencyDeviceStatus.getStepState());
} catch (Exception e) {
e.printStackTrace();
}
......@@ -1094,8 +1103,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (!ObjectUtils.isEmpty(map.get("area"))) {
area = Double.valueOf(map.get("area").toString());
}
String maxlevel = map.get("max_level") !=null?map.get("max_level").toString():"0.0";
String level = map.get("value") !=null&& StringUtil.isNumeric(map.get("value").toString())?String.format("%.2f", (Double.valueOf(map.get("value").toString()))):maxlevel;
String maxlevel = map.get("max_level") != null ? map.get("max_level").toString() : "0.0";
String level = map.get("value") != null && StringUtil.isNumeric(map.get("value").toString())
? String.format("%.2f", (Double.valueOf(map.get("value").toString()))) : maxlevel;
String volume = String.format("%.2f", Double.valueOf(level) * area);
if (hashOperations.size("Analogue") > 0) {
......@@ -1105,8 +1115,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
continue;
}
EquipCommunicationData data = (EquipCommunicationData) hashOperations.get("Analogue", map.get("CODE"));
map.put("level", StringUtil.isNumeric(data.getState())?data.getState():level);
map.put("volume", String.format("%.2f", (Double.valueOf(map.get("level").toString())* area)));
map.put("level", StringUtil.isNumeric(data.getState()) ? data.getState() : level);
map.put("volume", String.format("%.2f", (Double.valueOf(map.get("level").toString()) * area)));
} else {
map.put("level", level);
map.put("volume", volume);
......@@ -1124,12 +1134,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public Integer getChildTypeByPid(Long riskSourceId) {
Long regionCount = riskSourceMapper.countByParentIdAndIsRegion(riskSourceId, "TRUE");
if (!regionCount.equals(0L)) {
//子节点有风险区域
// 子节点有风险区域
return 1;
}
Long pointCount = riskSourceMapper.countByParentIdAndIsRegion(riskSourceId, "FALSE");
if (!pointCount.equals(0L)) {
//子节点有风险点
// 子节点有风险点
return 2;
}
return 3;
......@@ -1139,7 +1149,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 修改、添加导致rpn、rpni改变
*/
@Override
public void notifyFmeaFromUpdate(String toke, String product, String appKey, Long fmeaId, String nofityType,String userName) {
public void notifyFmeaFromUpdate(String toke, String product, String appKey, Long fmeaId, String nofityType,
String userName) {
Fmea fmea = fmeaMapper.getById(fmeaId);
if (fmea == null) {
return;
......@@ -1149,12 +1160,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal oidValue = new BigDecimal(fmea.getOidValue());
BigDecimal sidValue = new BigDecimal(fmea.getSidValue());
BigDecimal didValue = new BigDecimal(fmea.getDidValue());
//1.1计算rpni
// 1.1计算rpni
BigDecimal rpni = oidValue.multiply(sidValue).multiply(didValue).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal rpn;
//1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo
// 1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo
if (fmea.getNewEvaluationOid() == null) {
fmea.setNewEvaluationOid(fmea.getEvaluationOid());
rpn = rpni;
......@@ -1180,18 +1191,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
msgParamBo.setNotifyType(nofityType);
jpushMsgBo = this.getJushMessageInfo(msgParamBo);
}
//1.3更新fmea
// 1.3更新fmea
fmeaMapper.updateRpn(fmea);
//2.计算上级风险值(风险点及父节点)
// 2.计算上级风险值(风险点及父节点)
this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), nofityType, jpushMsgBo);
}
}
private JpushMsgBo getJushMessageInfo(MsgParamBo msgParam){
private JpushMsgBo getJushMessageInfo(MsgParamBo msgParam) {
JpushMsgBo msgBo = new JpushMsgBo();
Optional<RiskFactor> optional = iRiskFactorDao.findById(msgParam.getFmea().getRiskFactorsId());
if(optional.isPresent()){
JpushMsgContentBo jpushMsgContentBo = new JpushMsgContentBo(optional.get().getName(),msgParam.getNotifyType());
if (optional.isPresent()) {
JpushMsgContentBo jpushMsgContentBo = new JpushMsgContentBo(optional.get().getName(),
msgParam.getNotifyType());
jpushMsgContentBo.setExecute(msgParam.getUserName());
jpushMsgContentBo.setLevelIsChange(msgParam.getLevelIsChange());
jpushMsgContentBo.setLevel(msgParam.getLevel());
......@@ -1207,7 +1219,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Set<String> targets = new LinkedHashSet<>();
Set<String> userIds = this.getUsersByLevel(msgParam.getManagerLevel(), msgParam.getFmea());
userIds.forEach(userId -> {
AgencyUserModel user = remoteSecurityService.getUserById(msgParam.getToke(), msgParam.getProduct(), msgParam.getAppKey(), userId);
AgencyUserModel user = remoteSecurityService.getUserById(msgParam.getToke(), msgParam.getProduct(),
msgParam.getAppKey(), userId);
if (user != null) {
String target = user.getMobile();
targets.add(target);
......@@ -1241,9 +1254,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 告警或者不合格项导致fmea的rpn、new_evaluation_oid改变
*/
@Override
public void notifyFmeaFromAbnormal(
String toke, String product, String appKey,
Long fmeaId, String notifyType,String userName, String relationName) {
public void notifyFmeaFromAbnormal(String toke, String product, String appKey, Long fmeaId, String notifyType,
String userName, String relationName) {
Fmea fmea = fmeaMapper.getById(fmeaId);
if (fmea == null) {
return;
......@@ -1251,17 +1263,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (fmea.getEvaluationOid() != null && fmea.getEvaluationSid() != null && fmea.getEvaluationDid() != null) {
List<FmeaEquipmentPoint> equipmentPoints = fmeaEquipmentPointMapper.listFmeaByFmeaId(fmeaId);
List<FmeaPointInputitem> pointInputitems = fmeaPointInputitemMapper.listFmeaByFmeaId(fmeaId);
//1.准备更新数据
// 1.准备更新数据
Double maxRate = RpnUtils.getMaxRate(equipmentPoints, pointInputitems);
if (maxRate != null) {
//1.1根据设备和巡检数据获取高的故障率
// 1.1根据设备和巡检数据获取高的故障率
List<EvaluationModel> oModels = iEvaluationModelDao.findAllByType("O");
EvaluationModel oEvaluationModel = getBetweenModel(maxRate, oModels);
if (oEvaluationModel != null) {
BigDecimal newOidValue = new BigDecimal(oEvaluationModel.getCoefficient());
BigDecimal sidValue = new BigDecimal(fmea.getSidValue());
BigDecimal didValue = new BigDecimal(fmea.getDidValue());
BigDecimal rpn = newOidValue.multiply(sidValue).multiply(didValue).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal rpn = newOidValue.multiply(sidValue).multiply(didValue).setScale(2,
BigDecimal.ROUND_HALF_UP);
List<RiskLevel> levels = riskLevelDao.findAll();
RiskLevel newLevel = RpnUtils.getBetweenLevel(rpn, levels);
fmea.setRpn(rpn);
......@@ -1269,7 +1282,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
JpushMsgBo jpushMsgBo = new JpushMsgBo();
MsgParamBo msgParamBo = new MsgParamBo();
if (newLevel != null) {
//1.2根据风险等级对应的责任等级获取责任人
// 1.2根据风险等级对应的责任等级获取责任人
fmea.setRiskLevelId(newLevel.getId());
msgParamBo.setAppKey(appKey);
msgParamBo.setToke(toke);
......@@ -1282,16 +1295,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
msgParamBo.setRelationName(relationName);
jpushMsgBo = this.getJushMessageInfo(msgParamBo);
}
//1.3.更新fmea的rpn、风险等级及newOid
// 1.3.更新fmea的rpn、风险等级及newOid
fmeaMapper.updateRpn(fmea);
//2.计算风险点rpn、rpni、riskLevelId
// 2.计算风险点rpn、rpni、riskLevelId
this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), notifyType, jpushMsgBo);
}
}
}
}
private void saveRpnLog(Long riskSourceId, Long fmeaId, BigDecimal rpn, BigDecimal rpni,String notifyType) {
private void saveRpnLog(Long riskSourceId, Long fmeaId, BigDecimal rpn, BigDecimal rpni, String notifyType) {
RpnChangeLog rpnChangeLog = new RpnChangeLog();
rpnChangeLog.setRiskSourceId(riskSourceId);
rpnChangeLog.setRpn(rpn);
......@@ -1327,22 +1340,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return;
}
List<Fmea> fmeas = fmeaMapper.listByRiskSourceId(riskSourceId);
if (CollectionUtils.isEmpty(fmeas)) {//fema全部删除
if (CollectionUtils.isEmpty(fmeas)) {// fema全部删除
BigDecimal resetValue = new BigDecimal("0");
riskSource.setRpn(null);
riskSource.setRpni(null);
riskSource.setRiskLevelId(null);
riskSource.setFlickerFrequency(0);
//1.更新fmea对应风险点rpn、rpni、level
// 1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper.updateRpn(riskSource);
//2.记录风险点rpn变化流水
// 2.记录风险点rpn变化流水
this.saveRpnLog(riskSource.getId(), fmeaId, resetValue, resetValue, notifyType);
//3.更新父节点rpn、rpni、风险等级
// 3.更新父节点rpn、rpni、风险等级
this.updateParentRpn(riskSource.getParentId());
//4.通知全景监控屏幕数据刷新
// 4.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
} else {//fmea评价、巡检、告警
} else {// fmea评价、巡检、告警
RpnCalculationBo rpnValueBo = RpnUtils.calRpnAndRpni(fmeas);
if (rpnValueBo.isEmpty()) {
return;
......@@ -1356,20 +1369,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setRpn(rpn);
riskSource.setRpni(rpni);
riskSource.setRiskLevelId(newRiskLevel.getId());
String changeType = RpnUtils.calChangeTypeByLevel(oldRiskLevel.getLevel(),newRiskLevel.getLevel());
riskSource.setFlickerFrequency(RpnUtils.calRiskPointFrequency(rpn,rpni,changeType));
//1.更新fmea对应风险点rpn、rpni、level
String changeType = RpnUtils.calChangeTypeByLevel(oldRiskLevel.getLevel(), newRiskLevel.getLevel());
riskSource.setFlickerFrequency(RpnUtils.calRiskPointFrequency(rpn, rpni, changeType));
// 1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper.updateRpn(riskSource);
//2.记录风险点rpn变化流水
// 2.记录风险点rpn变化流水
this.saveRpnLog(riskSource.getId(), fmeaId, rpn, rpni, notifyType);
//3.更新父节点rpn、rpni、风险等级
// 3.更新父节点rpn、rpni、风险等级
this.updateParentRpn(riskSource.getParentId());
//4.极光推送给手机客户端
// 4.极光推送给手机客户端
jpushRiskSourceMessage(jpushMsgBo);
//5.规则告警(消息)TODO
notifyRule(riskSourceId, rpn, rpni, notifyType,changeType);
//6.通知全景监控屏幕数据刷新
// 5.规则告警(消息)TODO
notifyRule(riskSourceId, rpn, rpni, notifyType, changeType);
// 6.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
}
}
......@@ -1377,15 +1390,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public void notifyFmeaFromDelete(Long riskSourceId, String from) {
//1.计算风险点风险值信息
// 1.计算风险点风险值信息
this.notifyRiskSource(0L, riskSourceId, from, null);
}
@Override
public void notifyRiskSourceDelete(Long parentId) {
//1.风险点删除触发更新父节点rpn、rpni、风险等级
// 1.风险点删除触发更新父节点rpn、rpni、风险等级
this.updateParentRpn(parentId);
//2.通知全景监控屏幕数据刷新
// 2.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
}
......@@ -1399,9 +1412,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
List<RiskSource> riskSourceList = new ArrayList<>();
List<Long> ids = new ArrayList<>();
riskSourceList = iRiskSourceDao.findByParentId(riskSource.getId());
//递归获取区域(含子区域)所有点
// 递归获取区域(含子区域)所有点
this.getAllRiskPoint(ids, riskSourceList);
if (CollectionUtils.isEmpty(ids)) {//没有风险点,则赋初始值null
if (CollectionUtils.isEmpty(ids)) {// 没有风险点,则赋初始值null
riskSource.setRpn(null);
riskSource.setRpni(null);
riskSource.setRiskLevelId(null);
......@@ -1429,11 +1442,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* 获得子节点:巡检点
*
* @param ids 返回
* @param riskSourceList 风险点区域列表
* @param ids
* 返回
* @param riskSourceList
* 风险点区域列表
*/
private void getAllRiskPoint(List<Long> ids, List<RiskSource> riskSourceList) {
//TODO 递归
// TODO 递归
for (RiskSource riskSource : riskSourceList) {
if (riskSource.getIsRegion().equalsIgnoreCase("TRUE")) {
List<RiskSource> list = iRiskSourceDao.findByParentId(riskSource.getId());
......@@ -1455,7 +1470,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
JpushMsgContentBo jpushMsgContentBo = jpushMsgBo.getMsg();
Set<String> target = jpushMsgBo.getTarget();
if(jpushMsgContentBo.getSend()){
if (jpushMsgContentBo.getSend()) {
PushMsgParam pushMsgParam = new PushMsgParam();
pushMsgParam.setRecivers(Lists.newArrayList(target));
pushMsgParam.setContent(jpushMsgContentBo.genMessage());
......@@ -1468,12 +1483,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* 规则告警
*/
private void notifyRule(
Long id,
BigDecimal rpnr,
BigDecimal rpni,
String notifyType,
String changeType) {
private void notifyRule(Long id, BigDecimal rpnr, BigDecimal rpni, String notifyType, String changeType) {
RiskSourceRuleRo riskSourceRuleRo = new RiskSourceRuleRo();
riskSourceRuleRo.setId(id);
riskSourceRuleRo.setRpnr(rpnr);
......@@ -1493,7 +1503,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return getRiskRegionTree(regionList);
}
//区域列表转树
// 区域列表转树
private static List<RegionTreeResponse> getRiskRegionTree(List<RegionTreeResponse> list) {
HashMap<Long, RegionTreeResponse> hashMap = new HashMap<>();
list.forEach(e -> hashMap.put(e.getId(), e));
......
package com.yeejoin.amos.fas.business.service.model;
public class ContingencyRo extends BasicsRo {
import java.io.Serializable;
public class ContingencyRo implements Serializable {
private String batchNo;
public String getBatchNo() {
return batchNo;
}
public void setBatchNo(String batchNo) {
this.batchNo = batchNo;
}
/**
*
......
......@@ -8,9 +8,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
......@@ -18,6 +18,7 @@ import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
......@@ -27,6 +28,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.yeejoin.amos.fas.client.invoke.RsDataQueue;
import com.yeejoin.amos.fas.context.IotContext;
import com.yeejoin.amos.filter.CrossDomainFilter;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
......@@ -91,4 +93,25 @@ public class YeeAmosFireAutoSysStart implements ApplicationContextAware
IotContext.getInstance().setApplicationContext(applicationContext);
RsDataQueue.getInstance().start();
}
/**
*
* <pre>
* 跨域处理的FilterBean
* </pre>
*
* @return
*/
@Bean
public FilterRegistrationBean crossFilterRegistrationBean()
{
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
CrossDomainFilter crossDomainFilter = new CrossDomainFilter();
registrationBean.setFilter(crossDomainFilter);
// List<String> urlPatterns = new ArrayList<String>();
// urlPatterns.add("/*");
// registrationBean.setUrlPatterns(urlPatterns);
registrationBean.setOrder(0);//值小的Filter先执行
return registrationBean;
}
}
\ No newline at end of file
......@@ -5,12 +5,12 @@ security.appKeyWeb=CONVERTER_STATION
#environment
#spring.profiles.active = dev
eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/
eureka.client.serviceUrl.defaultZone=http://172.16.3.75:10001/eureka/
eureka.client.register-with-eureka = true
eureka.client.fetch-registry = true
eureka.client.healthcheck.enabled = true
eureka.client.fetchRegistry = true
eureka.instance.prefer-ip-address=true
#DB properties:
spring.datasource.url=jdbc:mysql://172.16.11.33:3306/safety-business-2.0?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.username=root
......@@ -53,5 +53,10 @@ emqx.broker=tcp://172.16.10.85:1883
emqx.user-name=super
emqx.password=a123456
Push.fegin.name=PPMESSAGEPUSHSERVICE15
dutyMode.fegin.name=AMOS-DUTY
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
rule.definition.model-package=com.yeejoin.amos.fas.business.service.model
\ No newline at end of file
......@@ -10,6 +10,7 @@ eureka.client.register-with-eureka = true
eureka.client.fetch-registry = true
eureka.client.healthcheck.enabled = true
eureka.client.fetchRegistry = true
eureka.instance.prefer-ip-address=true
#DB properties:
spring.datasource.url=jdbc:mysql://amos-mysql:3306/yeejoin_safety_business?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
......@@ -55,3 +56,7 @@ emqx.password=a123456
Push.fegin.name=AMOS-PUSH
dutyMode.fegin.name=AMOS-DUTY
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
rule.definition.model-package=com.yeejoin.amos.fas.business.service.model
\ No newline at end of file
......@@ -10,6 +10,7 @@ eureka.client.register-with-eureka = true
eureka.client.fetch-registry = true
eureka.client.healthcheck.enabled = true
eureka.client.fetchRegistry = true
eureka.instance.prefer-ip-address=true
#DB properties:
spring.datasource.url=jdbc:mysql://47.103.14.66:3306/91-safety-business?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
......@@ -55,3 +56,7 @@ emqx.password=a123456
Push.fegin.name=PPMESSAGEPUSHSERVICE15
dutyMode.fegin.name=AMOS-DUTY
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
rule.definition.model-package=com.yeejoin.amos.fas.business.service.model
\ No newline at end of file
spring.application.name = AMOS-AUTOSYS
spring.application.name = AMOS-AUTOSYS-WJ
server.port = 8083
......
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