Commit c747033e authored by 吴江's avatar 吴江

修复冲突代码

parent 35d85995
...@@ -4,7 +4,6 @@ package com.yeejoin.amos.fas.business.service.impl; ...@@ -4,7 +4,6 @@ package com.yeejoin.amos.fas.business.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
...@@ -128,15 +127,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -128,15 +127,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private final Logger log = LoggerFactory.getLogger(RiskSourceServiceImpl.class); 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 @Autowired
private IRiskSourceDao iRiskSourceDao; private IRiskSourceDao iRiskSourceDao;
...@@ -144,6 +143,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -144,6 +143,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired @Autowired
private AppMessagePushService appMessagePushService; private AppMessagePushService appMessagePushService;
@Autowired @Autowired
private IRiskLevelDao riskLevelDao; private IRiskLevelDao riskLevelDao;
...@@ -174,6 +174,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -174,6 +174,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired @Autowired
private IRiskLevelDao iRiskLevelDao; private IRiskLevelDao iRiskLevelDao;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
...@@ -244,7 +245,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -244,7 +245,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (oldRiskSource1.isPresent()) { if (oldRiskSource1.isPresent()) {
oldRiskSource = oldRiskSource1.get(); oldRiskSource = oldRiskSource1.get();
} }
if (id == 0) {// 新增 if (id == 0) {//新增
riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL); riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL);
riskSource.setCreateDate(new Date()); riskSource.setCreateDate(new Date());
} else {// 更新 } else {// 更新
...@@ -267,14 +268,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -267,14 +268,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
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)){
throw new YeeException("公司节点不能删除");
}
if (count > 0) { if (count > 0) {
throw new YeeException("该数据有关联子项,请先删除子项数据"); throw new YeeException("该数据有关联子项,请先删除子项数据");
} }
iRiskSourceDao.deleteById(rId); iRiskSourceDao.deleteById(rId);
} }
// 1.重新计算rpn //1.重新计算rpn
List<Long> existIds = parentIds.stream().filter(e -> iRiskSourceDao.findById(e).isPresent()) List<Long> existIds = parentIds.stream().filter(e ->
.collect(Collectors.toList()); iRiskSourceDao.findById(e).isPresent()
).collect(Collectors.toList());
RsDataQueue rs = RsDataQueue.getInstance(); RsDataQueue rs = RsDataQueue.getInstance();
existIds.forEach(rs::addRiskSourcePointDeleteMessage); existIds.forEach(rs::addRiskSourcePointDeleteMessage);
} }
...@@ -286,6 +291,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -286,6 +291,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return new PageImpl<>(content, param, total); return new PageImpl<>(content, param, total);
} }
@Override @Override
public List<Map> queryForRegion() { public List<Map> queryForRegion() {
List<Map> result = riskSourceMapper.queryForRegion(); List<Map> result = riskSourceMapper.queryForRegion();
...@@ -298,6 +304,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -298,6 +304,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return result; return result;
} }
@Override @Override
public Map queryFor3DStatistics() { public Map queryFor3DStatistics() {
Map<String, List> result = riskSourceMapper.statistics3dCount(); Map<String, List> result = riskSourceMapper.statistics3dCount();
...@@ -307,11 +314,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -307,11 +314,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return result; return result;
} }
@Override @Override
public List<Map> queryRPNReport() { public List<Map> queryRPNReport() {
return riskSourceMapper.queryRPNReport(); return riskSourceMapper.queryRPNReport();
} }
@Override @Override
public Map queryForRiseUp() throws Exception { public Map queryForRiseUp() throws Exception {
Map<String, Map> result = new HashMap<>(); Map<String, Map> result = new HashMap<>();
...@@ -324,17 +333,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -324,17 +333,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 当月的升上率 //当月的升上率
startTime = format.format(timeArrayMonth[0]); startTime = format.format(timeArrayMonth[0]);
endTime = format.format(timeArrayMonth[1]); endTime = format.format(timeArrayMonth[1]);
Map resultMonth = this.riskSourceMapper.queryForRiseUp(startTime, endTime); Map resultMonth = this.riskSourceMapper.queryForRiseUp(startTime, endTime);
// 当季度的升上率 //当季度的升上率
startTime = format.format(timeArraySeason[0]); startTime = format.format(timeArraySeason[0]);
endTime = format.format(timeArraySeason[1]); endTime = format.format(timeArraySeason[1]);
Map resultSeason = this.riskSourceMapper.queryForRiseUp(startTime, endTime); Map resultSeason = this.riskSourceMapper.queryForRiseUp(startTime, endTime);
// 当年的升上率
//当年的升上率
startTime = format.format(timeArrayYear[0]); startTime = format.format(timeArrayYear[0]);
endTime = format.format(timeArrayYear[1]); endTime = format.format(timeArrayYear[1]);
Map resultYear = this.riskSourceMapper.queryForRiseUp(startTime, endTime); Map resultYear = this.riskSourceMapper.queryForRiseUp(startTime, endTime);
...@@ -353,6 +363,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -353,6 +363,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private static Date[] getDateInfo(Date date, String datetype) throws Exception { private static Date[] getDateInfo(Date date, String datetype) throws Exception {
Date[] returnDate = new Date[2]; Date[] returnDate = new Date[2];
Date start = null; Date start = null;
Date end = null; Date end = null;
if (DATETYPE_YYYYMMDD.equals(datetype)) { if (DATETYPE_YYYYMMDD.equals(datetype)) {
...@@ -385,16 +396,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -385,16 +396,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override @Override
public List<RiskSourceTreeResponse> findRiskSourceTrees() { public List<RiskSourceTreeResponse> findRiskSourceTrees(String compCode) {
return riskSourceMapper.getRiskSources(); return riskSourceMapper.getRiskSources(compCode);
} }
@Override @Override
public List<FmeaEquipmentPoint> bindFireEquiment(FmeaBindParam fmeaBindParam) { public List<FmeaEquipmentPoint> bindFireEquiment(FmeaBindParam fmeaBindParam) {
Long fmeaId = fmeaBindParam.getFmeaId(); Long fmeaId = fmeaBindParam.getFmeaId();
Long importantEquipId = fmeaBindParam.getImportantEquipmentId(); Long importantEquipId = fmeaBindParam.getImportantEquipmentId();
List<Long> equipmentPointIds = fmeaEquipmentPointMapper List<Long> equipmentPointIds = fmeaEquipmentPointMapper.listEquipmentPointIdsByEquipmentId(fmeaBindParam.getEquipmentId());
.listEquipmentPointIdsByEquipmentId(fmeaBindParam.getEquipmentId());
if (!CollectionUtils.isEmpty(equipmentPointIds)) { if (!CollectionUtils.isEmpty(equipmentPointIds)) {
fmeaEquipmentPointMapper.deleteByFmeaIdAndEquipmentPointIds(fmeaId, importantEquipId, equipmentPointIds); fmeaEquipmentPointMapper.deleteByFmeaIdAndEquipmentPointIds(fmeaId, importantEquipId, equipmentPointIds);
} }
...@@ -410,7 +420,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -410,7 +420,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (!CollectionUtils.isEmpty(returnList) && equipment != null) { if (!CollectionUtils.isEmpty(returnList) && equipment != null) {
fmeaEquipmentPointMapper.saveBatch(returnList); fmeaEquipmentPointMapper.saveBatch(returnList);
RsDataQueue rsDataQueue = RsDataQueue.getInstance(); RsDataQueue rsDataQueue = RsDataQueue.getInstance();
rsDataQueue.addEquipmentMessage(fmeaId, equipment.getName()); rsDataQueue.addEquipmentMessage(fmeaId,equipment.getName());
} }
return returnList; return returnList;
} }
...@@ -418,8 +428,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -418,8 +428,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
public List<FmeaPointInputitem> bindPointInputitem(FmeaBindParam fmeaBindParam) { public List<FmeaPointInputitem> bindPointInputitem(FmeaBindParam fmeaBindParam) {
Long fmeaId = fmeaBindParam.getFmeaId(); Long fmeaId = fmeaBindParam.getFmeaId();
List<Long> pointInputitemIds = fmeaPointInputitemMapper List<Long> pointInputitemIds = fmeaPointInputitemMapper.listPointInputitemIdsByPointId(fmeaBindParam.getPointId());
.listPointInputitemIdsByPointId(fmeaBindParam.getPointId());
if (!CollectionUtils.isEmpty(pointInputitemIds)) { if (!CollectionUtils.isEmpty(pointInputitemIds)) {
fmeaPointInputitemMapper.deleteByFmeaIdAndPointInputitemIds(fmeaId, pointInputitemIds); fmeaPointInputitemMapper.deleteByFmeaIdAndPointInputitemIds(fmeaId, pointInputitemIds);
} }
...@@ -444,16 +453,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -444,16 +453,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
public Page<Map> queryEquimentRelation(CommonPageable commonPageable, String equipmentId, String fname) { public Page<Map> queryEquimentRelation(CommonPageable commonPageable, String equipmentId, String fname) {
Long total = fireEquipMapper.queryEquimentRelationCount(equipmentId, fname); Long total = fireEquipMapper.queryEquimentRelationCount(equipmentId, fname);
List<Map> list = fireEquipMapper.queryEquimentRelation(commonPageable.getOffset(), commonPageable.getPageSize(), List<Map> list = fireEquipMapper.queryEquimentRelation(commonPageable.getOffset(), commonPageable.getPageSize(), equipmentId, fname);
equipmentId, fname);
return new PageImpl<>(list, commonPageable, total); return new PageImpl<>(list, commonPageable, total);
} }
@Override @Override
public List<Map<String, Object>> listEquipmentPointById(Long fmeaId, Long importantEquipId, Long equipmentId, public List<Map<String, Object>> listEquipmentPointById(Long fmeaId, Long importantEquipId, Long equipmentId, String equipmentPointName) {
String equipmentPointName) { List<Map<String, Object>> list = fmeaEquipmentPointMapper.listEquipmentPoint(fmeaId, importantEquipId, equipmentId, equipmentPointName);
List<Map<String, Object>> list = fmeaEquipmentPointMapper.listEquipmentPoint(fmeaId, importantEquipId,
equipmentId, equipmentPointName);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return Lists.newArrayList(); return Lists.newArrayList();
} }
...@@ -464,7 +470,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -464,7 +470,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
@Async @Async
public String processFireEqumtData(FireEquimentDataRo deviceData) throws Exception { public String processFireEqumtData(FireEquimentDataRo deviceData) throws Exception {
// 处理设备和巡检数据 //处理设备和巡检数据
deviceData.setNodeState(deviceData.getValue()); deviceData.setNodeState(deviceData.getValue());
String batchNo = UUID.randomUUID().toString(); String batchNo = UUID.randomUUID().toString();
deviceData.setBatchNo(batchNo); deviceData.setBatchNo(batchNo);
...@@ -482,15 +488,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -482,15 +488,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
deviceData.setMonitor(equipment.getName()); deviceData.setMonitor(equipment.getName());
deviceData.setEquimentId(String.valueOf(equipment.getId())); deviceData.setEquimentId(String.valueOf(equipment.getId()));
// Object result = remoteRuleServer.fireRule(deviceData, //Object result = remoteRuleServer.fireRule(deviceData, "风险管控/fireEquiment");
// "风险管控/fireEquiment"); //处理返回结果
// 处理返回结果
List<RiskSource> riskSources = this.riskSourceMapper.queryByFireEqument(deviceData.getFireEquimentId()); List<RiskSource> riskSources = this.riskSourceMapper.queryByFireEqument(deviceData.getFireEquimentId());
// asymbleWithParent(batchNo, riskSources, //asymbleWithParent(batchNo, riskSources, FireEquimentDataRo.class.getSimpleName(), deviceData.getFireEquimentId(), deviceData.getNodeState(), null, null);
// FireEquimentDataRo.class.getSimpleName(),
// deviceData.getFireEquimentId(), deviceData.getNodeState(),
// null, null);
try { try {
alermContingency(deviceData.getBatchNo(), fireEquipment, equipment); alermContingency(deviceData.getBatchNo(), fireEquipment, equipment);
...@@ -500,9 +502,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -500,9 +502,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
} }
return "SUCCESS"; return "SUCCESS";
} }
public void alermContingency(String batchNo, FireEquipment fireEquipment, Equipment equipment) throws Exception { public void alermContingency(String batchNo, FireEquipment fireEquipment, Equipment equipment) throws Exception {
ContingencyRo contingencyRo = new ContingencyRo(); ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo); contingencyRo.setBatchNo(batchNo);
...@@ -511,11 +515,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -511,11 +515,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo.setFireEquipmentId(String.valueOf(fireEquipment.getId())); contingencyRo.setFireEquipmentId(String.valueOf(fireEquipment.getId()));
contingencyRo.setFireEquipmentName(fireEquipment.getName()); contingencyRo.setFireEquipmentName(fireEquipment.getName());
contingencyRo.setStep("0"); contingencyRo.setStep("0");
// contingencyRo.setNodeState(deviceData.getNodeState()); //contingencyRo.setNodeState(deviceData.getNodeState());
contingencyRo.setConfirm("NONE"); contingencyRo.setConfirm("NONE");
contingencyRo.setFireTruckRoute(equipment.getFireTruckRoute()); contingencyRo.setFireTruckRoute(equipment.getFireTruckRoute());
contingencyRo.setRunstep(false); contingencyRo.setRunstep(false);
contingencyRo.setEquipmentPosition3d(equipment.getPosition3d()); contingencyRo.setEquipmentPosition3d(equipment.getPosition3d());
Map cameraInfo = impAndFireEquipMapper.queryForCamera(String.valueOf(equipment.getId())); Map cameraInfo = impAndFireEquipMapper.queryForCamera(String.valueOf(equipment.getId()));
if (cameraInfo != null) { if (cameraInfo != null) {
...@@ -544,15 +549,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -544,15 +549,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
} }
// Object result = remoteRuleServer.fireRuleFlow(contingencyRo, //Object result = remoteRuleServer.fireRuleFlow(contingencyRo, equipment.getReservePlan(), equipment.getName());
// equipment.getReservePlan(), equipment.getName());
equipment.setName("极Ⅰ高端YY换流变A相"); equipment.setName("极Ⅰ高端YY换流变A相");
ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName())); ruleTrigger.publish(contingencyRo, equipment.getReservePlan(),ArrayUtils.toArray( equipment.getName()));
ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData(); ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData();
BeanUtils.copyProperties(contingencyRo, contingencyOriginalData); BeanUtils.copyProperties(contingencyRo, contingencyOriginalData);
iContingencyOriginalDataDao.save(contingencyOriginalData); iContingencyOriginalDataDao.save(contingencyOriginalData);
} }
private Integer findRegionMaxLevel(Long regionRiskSourceId) { private Integer findRegionMaxLevel(Long regionRiskSourceId) {
Integer maxLevel = 0; Integer maxLevel = 0;
List<RiskSource> anomalyRiskSource = findAnomalyRiskSource(regionRiskSourceId); List<RiskSource> anomalyRiskSource = findAnomalyRiskSource(regionRiskSourceId);
...@@ -570,6 +575,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -570,6 +575,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
private List<RiskSource> findAnomalyRiskSource(Long riskSourceId) { private List<RiskSource> findAnomalyRiskSource(Long riskSourceId) {
List<RiskSource> returnList = new ArrayList<>(); List<RiskSource> returnList = new ArrayList<>();
List<RiskSource> childs = iRiskSourceDao.findByParentId(riskSourceId); List<RiskSource> childs = iRiskSourceDao.findByParentId(riskSourceId);
...@@ -585,18 +591,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -585,18 +591,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override @Override
public Page<Map<String, Object>> listFmeaPointInputitem(String toke, String product, String appKey, Long fmeaId, public Page<Map<String, Object>> listFmeaPointInputitem(String toke,String product,String appKey,Long fmeaId, Integer pageNumber, Integer pageSize) {
Integer pageNumber, Integer pageSize) {
List<Map<String, Object>> content = Lists.newArrayList(); List<Map<String, Object>> content = Lists.newArrayList();
CommonPageable pageable = new CommonPageable(pageNumber, pageSize);
long total = fmeaPointInputitemMapper.countByFmeaId(fmeaId); long total = fmeaPointInputitemMapper.countByFmeaId(fmeaId);
if (total == 0L) { if (total == 0L) {
return new PageImpl<>(content, null, total); return new PageImpl<>(content, pageable, total);
} }
content = fmeaPointInputitemMapper.listByFmeaId(fmeaId, pageNumber, pageSize); content = fmeaPointInputitemMapper.listByFmeaId(fmeaId, pageNumber, pageSize);
if (!CollectionUtils.isEmpty(content)) { if(!CollectionUtils.isEmpty(content)){
Set<String> userIds = new HashSet<>(); Set<String> userIds = new HashSet<>();
Set<String> deptIds = 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 userId = String.valueOf(map.get("userId"));
String deptId = String.valueOf(map.get("deptId")); String deptId = String.valueOf(map.get("deptId"));
userIds.add(userId); userIds.add(userId);
...@@ -605,41 +612,40 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -605,41 +612,40 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
userIds.remove(null); userIds.remove(null);
deptIds.remove(null); deptIds.remove(null);
List<AgencyUserModel> users = new ArrayList<>(); List<AgencyUserModel> users = new ArrayList<>();
if (!CollectionUtils.isEmpty(userIds)) { if(!CollectionUtils.isEmpty(userIds)){
users = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds)); users = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
} }
Map<String, String> userMap = users.stream() Map<String, String> userMap = users.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName));
.collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName));
List<DepartmentModel> depts = new ArrayList<>(); List<DepartmentModel> depts = new ArrayList<>();
if (!CollectionUtils.isEmpty(deptIds)) { if(!CollectionUtils.isEmpty(deptIds)){
depts = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, depts = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(deptIds));
Joiner.on(",").join(deptIds));
} }
Map<Long, String> deptMap = depts.stream() Map<Long, String > deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
.collect(Collectors.toMap(DepartmentModel::getSequenceNbr, DepartmentModel::getDepartmentName));
content.forEach(e -> { content.forEach(e -> {
e.put("userName", userMap.get(e.get("userId"))); e.put("userName",userMap.get(e.get("userId")));
e.put("deptName", deptMap.get(e.get("deptId"))); e.put("deptName",deptMap.get(e.get("deptId")));
e.put("tel", userMap.get(String.valueOf(e.get("deptId") + "tel"))); e.put("tel",userMap.get(String.valueOf(e.get("deptId")+"tel")));
}); });
} }
return new PageImpl<>(content, null, total); return new PageImpl<>(content, pageable, total);
} }
@Override @Override
public Page<Map<String, Object>> listFeamEquipmentPoint(Long fmeaId, Integer pageNumber, Integer pageSize) { public Page<Map<String, Object>> listFeamEquipmentPoint(Long fmeaId, Integer pageNumber, Integer pageSize) {
long total = fmeaEquipmentPointMapper.countByFmeaId(fmeaId); long total = fmeaEquipmentPointMapper.countByFmeaId(fmeaId);
List<Map<String, Object>> content = fmeaEquipmentPointMapper.listByFmeaId(fmeaId, pageNumber, pageSize); List<Map<String, Object>> content = fmeaEquipmentPointMapper.listByFmeaId(fmeaId, pageNumber, pageSize);
return new PageImpl<>(content, null, total); return new PageImpl<>(content, new CommonPageable(pageNumber, pageSize), total);
} }
@Override @Override
public boolean processTaskData(ProtalDataRo taskData) throws Exception { public boolean processTaskData(ProtalDataRo taskData) throws Exception {
taskData.setBatchNo(UUID.randomUUID().toString()); taskData.setBatchNo(UUID.randomUUID().toString());
// Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol"); //Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
return true; return true;
} }
@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) {
...@@ -651,8 +657,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -651,8 +657,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
inputIds.add(checkInputItemRo.getPointInputitemId()); inputIds.add(checkInputItemRo.getPointInputitemId());
map.put(checkInputItemRo.getPointInputitemId(), checkInputItemRo); map.put(checkInputItemRo.getPointInputitemId(), checkInputItemRo);
} }
List<FmeaPointInputitem> fmeaPointInputitems = fmeaPointInputitemMapper List<FmeaPointInputitem> fmeaPointInputitems = fmeaPointInputitemMapper.listByPointIdAndInputItemIds(pointId, inputIds);
.listByPointIdAndInputItemIds(pointId, inputIds);
Set<Long> fmeaIds = Sets.newHashSet(); Set<Long> fmeaIds = Sets.newHashSet();
List<Long> failIds = Lists.newArrayList(); List<Long> failIds = Lists.newArrayList();
List<Long> successIds = Lists.newArrayList(); List<Long> successIds = Lists.newArrayList();
...@@ -673,8 +678,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -673,8 +678,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaPointInputitemMapper.updateStateByIds(0, successIds); fmeaPointInputitemMapper.updateStateByIds(0, successIds);
} }
RsDataQueue rsDataQueue = RsDataQueue.getInstance(); RsDataQueue rsDataQueue = RsDataQueue.getInstance();
fmeaIds.forEach(fmeaId -> rsDataQueue.addPatrolMessage(fmeaId, protalData.getCheckUser(), fmeaIds.forEach(fmeaId ->
protalData.getName(), protalData.getNodeState())); rsDataQueue.addPatrolMessage(fmeaId,protalData.getCheckUser(),protalData.getName(),protalData.getNodeState()));
} }
iDataRefreshService.refreshViewData(DataRefreshTypeEum.check.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.check.getCode());
} }
...@@ -685,6 +690,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -685,6 +690,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return det; return det;
} }
@Override @Override
public Map earlyWarning(Long riskSourceId) { public Map earlyWarning(Long riskSourceId) {
Map returnMap = new HashMap(); Map returnMap = new HashMap();
...@@ -699,6 +705,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -699,6 +705,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return returnMap; return returnMap;
} }
@Override @Override
public List<HashMap<String, Object>> queryRiskAreaRpn() { public List<HashMap<String, Object>> queryRiskAreaRpn() {
return riskSourceMapper.queryRiskAreaRpn(); return riskSourceMapper.queryRiskAreaRpn();
...@@ -748,9 +755,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -748,9 +755,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
private void processFireData(AlarmParam deviceData) throws Exception { private void processFireData(AlarmParam deviceData) throws Exception {
deviceData.setPointCode("2"); //处理设备和巡检数据
// 处理设备和巡检数据
deviceData.setNodeState(deviceData.getState()); deviceData.setNodeState(deviceData.getState());
FireEquipmentPoint fireEquipmentPoint = iFireEquipmentPointDao.findOneByCode(deviceData.getPointCode()); FireEquipmentPoint fireEquipmentPoint = iFireEquipmentPointDao.findOneByCode(deviceData.getPointCode());
fireEquipmentPoint.setValue(deviceData.getState()); fireEquipmentPoint.setValue(deviceData.getState());
...@@ -760,8 +767,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -760,8 +767,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Dict dict = dictDao.getOne(fireEquipmentPoint.getAlarmType()); Dict dict = dictDao.getOne(fireEquipmentPoint.getAlarmType());
fireEquipmentPointType = dict.getDictValue(); fireEquipmentPointType = dict.getDictValue();
} }
Optional<FireEquipment> fireEquipment1 = this.iFireEquipmentDao Optional<FireEquipment> fireEquipment1 = this.iFireEquipmentDao.findById(fireEquipmentPoint.getFireEquipmentId());
.findById(fireEquipmentPoint.getFireEquipmentId());
FireEquipment fireEquipment = null; FireEquipment fireEquipment = null;
if (fireEquipment1.isPresent()) { if (fireEquipment1.isPresent()) {
fireEquipment = fireEquipment1.get(); fireEquipment = fireEquipment1.get();
...@@ -769,11 +775,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -769,11 +775,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Equipment equipment = null; Equipment equipment = null;
if (fireEquipment != null) { if (fireEquipment != null) {
deviceData.setCode(fireEquipment.getCode()); deviceData.setCode(fireEquipment.getCode());
// 保存实时数据 //保存实时数据
saveFireEquipmentData(fireEquipmentPoint, fireEquipment, deviceData, fireEquipmentPointType); saveFireEquipmentData(fireEquipmentPoint, fireEquipment, deviceData, fireEquipmentPointType);
equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId()); equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId());
if (equipment != null) { if (equipment != null) {
// 动态预案执行 //动态预案执行
dynamicPlan(deviceData, equipment, fireEquipment, fireEquipmentPointType); dynamicPlan(deviceData, equipment, fireEquipment, fireEquipmentPointType);
} }
} }
...@@ -781,15 +787,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -781,15 +787,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/** /**
* 预案执行 * 预案执行
*
* @param deviceData * @param deviceData
* @param equipment * @param equipment
* @param fireEquipment * @param fireEquipment
* @param fireEquipmentPointType * @param fireEquipmentPointType
*/ */
@Async @Async
private void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment, private void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment, String fireEquipmentPointType){
String fireEquipmentPointType) {
String batchNo = null; String batchNo = null;
Object batch = null; Object batch = null;
Dict dict = null; Dict dict = null;
...@@ -834,8 +838,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -834,8 +838,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} else { } else {
String alarmType = (String) redisTemplate.opsForHash().get("currentContingency", "alarmType"); String alarmType = (String) redisTemplate.opsForHash().get("currentContingency", "alarmType");
if (!ObjectUtils.isEmpty(alarmType) && dict.getDictValue().equals(alarmType)) { if (!ObjectUtils.isEmpty(alarmType) && dict.getDictValue().equals(alarmType)) {
ContingencyDeviceStatus contingencyDeviceStatus = (ContingencyDeviceStatus) redisTemplate.opsForHash() ContingencyDeviceStatus contingencyDeviceStatus = (ContingencyDeviceStatus) redisTemplate.opsForHash().get("currentContingency", "contingencyPlan");
.get("currentContingency", "contingencyPlan");
contingencyDeviceStatus.setNeedStatus("true"); contingencyDeviceStatus.setNeedStatus("true");
autoProcessContingency(contingencyDeviceStatus, alarmType); autoProcessContingency(contingencyDeviceStatus, alarmType);
} }
...@@ -849,22 +852,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -849,22 +852,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return "SUCCESS"; return "SUCCESS";
} }
private void saveFireEquipmentData(FireEquipmentPoint fireEquipmentPoint, FireEquipment fireEquipment,
AlarmParam deviceData, String fireEquipmentPointType) { private void saveFireEquipmentData(FireEquipmentPoint fireEquipmentPoint, FireEquipment fireEquipment, AlarmParam deviceData, String fireEquipmentPointType) {
if ("alarm_type_fire".equals(fireEquipmentPointType) || "alarm_type_trouble".equals(fireEquipmentPointType)) { if("alarm_type_fire".equals(fireEquipmentPointType) || "alarm_type_trouble".equals(fireEquipmentPointType)){
Alarm alarm = iAlarmDao.findByStatusTrueAndFireEquipmentPointCode(deviceData.getPointCode()); Alarm alarm = iAlarmDao.findByStatusTrueAndFireEquipmentPointCode(deviceData.getPointCode());
if (alarm != null) { if(alarm != null){
alarm.setFireEquipmentPointValue(deviceData.getState()); alarm.setFireEquipmentPointValue(deviceData.getState());
if ("false".equals(deviceData.getState())) { if("false".equals(deviceData.getState())){
alarm.setRecoveryDate(new Date()); alarm.setRecoveryDate(new Date());
alarm.setStatus(false); alarm.setStatus(false);
} else { }else{
alarm.setFrequency((alarm.getFrequency() + 1)); alarm.setFrequency((alarm.getFrequency()+1));
alarm.setUpdateDate(new Date()); alarm.setUpdateDate(new Date());
} }
iAlarmDao.save(alarm); iAlarmDao.save(alarm);
} else { }else{
if ("true".equals(deviceData.getState())) { if("true".equals(deviceData.getState())){
alarm = new Alarm(); alarm = new Alarm();
alarm.setFireEquipmentCode(fireEquipment.getCode()); alarm.setFireEquipmentCode(fireEquipment.getCode());
alarm.setFireEquipmentId(fireEquipment.getId()); alarm.setFireEquipmentId(fireEquipment.getId());
...@@ -878,20 +881,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -878,20 +881,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
iAlarmDao.save(alarm); iAlarmDao.save(alarm);
} }
} }
if (alarm != null) { if(alarm != null){
if ("alarm_type_trouble".equals(fireEquipmentPointType)) { if ("alarm_type_trouble".equals(fireEquipmentPointType)) {
// 通知刷新3d页面相关故障数据 //通知刷新3d页面相关故障数据
if (alarm.getFrequency() == 1 || alarm.getStatus() == false) { if(alarm.getFrequency()==1 || alarm.getStatus() == false){
notifyAlarm(fireEquipmentPoint, deviceData); notifyAlarm(fireEquipmentPoint, deviceData);
iDataRefreshService.refreshViewData(DataRefreshTypeEum.trouble.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.trouble.getCode());
} }
} else { }else{
// 通知刷新3d页面告警数据 //通知刷新3d页面告警数据
iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode());
} }
} }
} else { }else{
if ("SWITCH".equals(fireEquipmentPoint.getType())) { // 保存遥信信号数据到mysql中 if("SWITCH".equals(fireEquipmentPoint.getType())){ //保存遥信信号数据到mysql中
FireEquipmentData fireEquipmentData = new FireEquipmentData(); FireEquipmentData fireEquipmentData = new FireEquipmentData();
fireEquipmentData.setEqPointCode(deviceData.getPointCode()); fireEquipmentData.setEqPointCode(deviceData.getPointCode());
fireEquipmentData.seteValue(deviceData.getState()); fireEquipmentData.seteValue(deviceData.getState());
...@@ -915,10 +918,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -915,10 +918,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
List<AlarmParam> list = new ArrayList<>(); List<AlarmParam> list = new ArrayList<>();
list.add(deviceData); list.add(deviceData);
// 保存所有数据(遥测,遥信)到mongo //保存所有数据(遥测,遥信)到mongo
saveData(list, "soe"); saveData(list, "soe");
} }
@Override @Override
public void saveData(List<AlarmParam> deviceDatas, String type) { public void saveData(List<AlarmParam> deviceDatas, String type) {
List<EquipCommunicationData> list = deviceDatas.stream().map(param -> { List<EquipCommunicationData> list = deviceDatas.stream().map(param -> {
...@@ -956,8 +961,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -956,8 +961,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (!param.getState().equals(fireEquipmentPoint.getValue())) { if (!param.getState().equals(fireEquipmentPoint.getValue())) {
fireEquipmentPoint.setValue(param.getState()); fireEquipmentPoint.setValue(param.getState());
updateFirePointValue(fireEquipmentPoint.getId(), param.getState()); updateFirePointValue(fireEquipmentPoint.getId(), param.getState());
Equipment equipment = impAndFireEquipMapper Equipment equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.valueOf(data.getFireEquipmentId()));
.queryImpEqumtByFireEquipmt(Long.valueOf(data.getFireEquipmentId()));
if (!ObjectUtils.isEmpty(equipment)) { if (!ObjectUtils.isEmpty(equipment)) {
if (dict != null && dict.getDictValue().equals("alarm_type_trouble")) { if (dict != null && dict.getDictValue().equals("alarm_type_trouble")) {
notifyAlarm(fireEquipmentPoint, param); notifyAlarm(fireEquipmentPoint, param);
...@@ -978,8 +982,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -978,8 +982,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 设备告警触发fema的sod值 * 设备告警触发fema的sod值
*/ */
private void notifyAlarm(FireEquipmentPoint fireEquipmentPoint, AlarmParam param) { private void notifyAlarm(FireEquipmentPoint fireEquipmentPoint, AlarmParam param) {
List<FmeaEquipmentPoint> fmeaEquipmentPoints = fmeaEquipmentPointMapper List<FmeaEquipmentPoint> fmeaEquipmentPoints = fmeaEquipmentPointMapper.listByEquipmentPointId(fireEquipmentPoint.getId());
.listByEquipmentPointId(fireEquipmentPoint.getId());
Set<Long> fmeaIds = Sets.newHashSet(); Set<Long> fmeaIds = Sets.newHashSet();
List<Long> ids = Lists.newArrayList(); List<Long> ids = Lists.newArrayList();
fmeaEquipmentPoints.forEach(fmeaEquipmentPoint -> { fmeaEquipmentPoints.forEach(fmeaEquipmentPoint -> {
...@@ -997,7 +1000,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -997,7 +1000,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaEquipmentPointMapper.updateStateByIds(state, ids); fmeaEquipmentPointMapper.updateStateByIds(state, ids);
} }
RsDataQueue rsDataQueue = RsDataQueue.getInstance(); RsDataQueue rsDataQueue = RsDataQueue.getInstance();
fmeaIds.forEach(fmeaId -> rsDataQueue.addEquipmentMessage(fmeaId, param.getMonitor())); fmeaIds.forEach(fmeaId -> rsDataQueue.addEquipmentMessage(fmeaId,param.getMonitor()));
} }
} }
...@@ -1012,9 +1015,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1012,9 +1015,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override @Override
public List<HashMap<String, Object>> queryRiskSourceSecondLevel() { public List<HashMap<String, Object>> queryRiskSourceSecondLevel(String compCode) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return riskSourceMapper.queryRiskSourceSecondLevel(); return riskSourceMapper.queryRiskSourceSecondLevel(compCode);
} }
@Override @Override
...@@ -1038,8 +1041,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1038,8 +1041,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
switch (contingencyDeviceStatus.getActionName()) { switch (contingencyDeviceStatus.getActionName()) {
case "确认灾情": case "确认灾情":
// redisTemplate.opsForHash().put("currentContingency", // redisTemplate.opsForHash().put("currentContingency", "equipmentId", contingencyDeviceStatus.getEquipmentId());
// "equipmentId", contingencyDeviceStatus.getEquipmentId());
redisTemplate.opsForValue().set("equipmentId", contingencyDeviceStatus.getEquipmentId()); redisTemplate.opsForValue().set("equipmentId", contingencyDeviceStatus.getEquipmentId());
break; break;
case "断开上级电源": case "断开上级电源":
...@@ -1075,18 +1077,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1075,18 +1077,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (ObjectUtils.isEmpty(contingencyDeviceStatus)) { if (ObjectUtils.isEmpty(contingencyDeviceStatus)) {
return; return;
} }
int pointCount = fireEquipPointMapper int pointCount = fireEquipPointMapper.queryCountByEuipmentIdAndAlarmType(contingencyDeviceStatus.getEquipmentId(), alarmType);
.queryCountByEuipmentIdAndAlarmType(contingencyDeviceStatus.getEquipmentId(), alarmType); int count = fireEquipPointMapper.queryStopCountByEuipmentIdAndAlarmType(contingencyDeviceStatus.getEquipmentId(), alarmType, contingencyDeviceStatus.getNeedStatus());
int count = fireEquipPointMapper.queryStopCountByEuipmentIdAndAlarmType(
contingencyDeviceStatus.getEquipmentId(), alarmType, contingencyDeviceStatus.getNeedStatus());
if (pointCount > 0 && pointCount == count) { if (pointCount > 0 && pointCount == count) {
try { try {
String batchNo = (String) redisTemplate.opsForHash().get("currentContingency", "batchNo"); String batchNo = (String) redisTemplate.opsForHash().get("currentContingency", "batchNo");
iContingencyInstance.setButtonExecuted(batchNo, contingencyDeviceStatus.getContingencyPlanId(), iContingencyInstance.setButtonExecuted(batchNo, contingencyDeviceStatus.getContingencyPlanId(), contingencyDeviceStatus.getButtonCode(), contingencyDeviceStatus.getConfirm());
contingencyDeviceStatus.getButtonCode(), contingencyDeviceStatus.getConfirm()); iContingencyInstance.fire(batchNo, contingencyDeviceStatus.getStepCode(), contingencyDeviceStatus.getContingencyPlanId(), contingencyDeviceStatus.getButtonCode(), contingencyDeviceStatus.getConfirm(), contingencyDeviceStatus.getStepState());
iContingencyInstance.fire(batchNo, contingencyDeviceStatus.getStepCode(),
contingencyDeviceStatus.getContingencyPlanId(), contingencyDeviceStatus.getButtonCode(),
contingencyDeviceStatus.getConfirm(), contingencyDeviceStatus.getStepState());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1103,9 +1100,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1103,9 +1100,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (!ObjectUtils.isEmpty(map.get("area"))) { if (!ObjectUtils.isEmpty(map.get("area"))) {
area = Double.valueOf(map.get("area").toString()); area = Double.valueOf(map.get("area").toString());
} }
String maxlevel = map.get("max_level") != null ? map.get("max_level").toString() : "0.0"; 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 level = map.get("value") !=null&& StringUtil.isNumeric(map.get("value").toString())?String.format("%.2f", (Double.valueOf(map.get("value").toString()))):maxlevel;
? String.format("%.2f", (Double.valueOf(map.get("value").toString()))) : maxlevel;
String volume = String.format("%.2f", Double.valueOf(level) * area); String volume = String.format("%.2f", Double.valueOf(level) * area);
if (hashOperations.size("Analogue") > 0) { if (hashOperations.size("Analogue") > 0) {
...@@ -1115,8 +1111,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1115,8 +1111,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
continue; continue;
} }
EquipCommunicationData data = (EquipCommunicationData) hashOperations.get("Analogue", map.get("CODE")); EquipCommunicationData data = (EquipCommunicationData) hashOperations.get("Analogue", map.get("CODE"));
map.put("level", StringUtil.isNumeric(data.getState()) ? data.getState() : level); 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("volume", String.format("%.2f", (Double.valueOf(map.get("level").toString())* area)));
} else { } else {
map.put("level", level); map.put("level", level);
map.put("volume", volume); map.put("volume", volume);
...@@ -1134,12 +1130,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1134,12 +1130,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public Integer getChildTypeByPid(Long riskSourceId) { public Integer getChildTypeByPid(Long riskSourceId) {
Long regionCount = riskSourceMapper.countByParentIdAndIsRegion(riskSourceId, "TRUE"); Long regionCount = riskSourceMapper.countByParentIdAndIsRegion(riskSourceId, "TRUE");
if (!regionCount.equals(0L)) { if (!regionCount.equals(0L)) {
// 子节点有风险区域 //子节点有风险区域
return 1; return 1;
} }
Long pointCount = riskSourceMapper.countByParentIdAndIsRegion(riskSourceId, "FALSE"); Long pointCount = riskSourceMapper.countByParentIdAndIsRegion(riskSourceId, "FALSE");
if (!pointCount.equals(0L)) { if (!pointCount.equals(0L)) {
// 子节点有风险点 //子节点有风险点
return 2; return 2;
} }
return 3; return 3;
...@@ -1149,8 +1145,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1149,8 +1145,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 修改、添加导致rpn、rpni改变 * 修改、添加导致rpn、rpni改变
*/ */
@Override @Override
public void notifyFmeaFromUpdate(String toke, String product, String appKey, Long fmeaId, String nofityType, public void notifyFmeaFromUpdate(String toke, String product, String appKey, Long fmeaId, String nofityType,String userName) {
String userName) {
Fmea fmea = fmeaMapper.getById(fmeaId); Fmea fmea = fmeaMapper.getById(fmeaId);
if (fmea == null) { if (fmea == null) {
return; return;
...@@ -1160,12 +1155,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1160,12 +1155,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal oidValue = new BigDecimal(fmea.getOidValue()); BigDecimal oidValue = new BigDecimal(fmea.getOidValue());
BigDecimal sidValue = new BigDecimal(fmea.getSidValue()); BigDecimal sidValue = new BigDecimal(fmea.getSidValue());
BigDecimal didValue = new BigDecimal(fmea.getDidValue()); 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 rpni = oidValue.multiply(sidValue).multiply(didValue).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal rpn; BigDecimal rpn;
// 1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo //1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo
if (fmea.getNewEvaluationOid() == null) { if (fmea.getNewEvaluationOid() == null) {
fmea.setNewEvaluationOid(fmea.getEvaluationOid()); fmea.setNewEvaluationOid(fmea.getEvaluationOid());
rpn = rpni; rpn = rpni;
...@@ -1191,19 +1186,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1191,19 +1186,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
msgParamBo.setNotifyType(nofityType); msgParamBo.setNotifyType(nofityType);
jpushMsgBo = this.getJushMessageInfo(msgParamBo); jpushMsgBo = this.getJushMessageInfo(msgParamBo);
} }
// 1.3更新fmea //1.3更新fmea
fmeaMapper.updateRpn(fmea); fmeaMapper.updateRpn(fmea);
// 2.计算上级风险值(风险点及父节点) //2.计算上级风险值(风险点及父节点)
this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), nofityType, jpushMsgBo); this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), nofityType, jpushMsgBo);
} }
} }
private JpushMsgBo getJushMessageInfo(MsgParamBo msgParam) { private JpushMsgBo getJushMessageInfo(MsgParamBo msgParam){
JpushMsgBo msgBo = new JpushMsgBo(); JpushMsgBo msgBo = new JpushMsgBo();
Optional<RiskFactor> optional = iRiskFactorDao.findById(msgParam.getFmea().getRiskFactorsId()); Optional<RiskFactor> optional = iRiskFactorDao.findById(msgParam.getFmea().getRiskFactorsId());
if (optional.isPresent()) { if(optional.isPresent()){
JpushMsgContentBo jpushMsgContentBo = new JpushMsgContentBo(optional.get().getName(), JpushMsgContentBo jpushMsgContentBo = new JpushMsgContentBo(optional.get().getName(),msgParam.getNotifyType());
msgParam.getNotifyType());
jpushMsgContentBo.setExecute(msgParam.getUserName()); jpushMsgContentBo.setExecute(msgParam.getUserName());
jpushMsgContentBo.setLevelIsChange(msgParam.getLevelIsChange()); jpushMsgContentBo.setLevelIsChange(msgParam.getLevelIsChange());
jpushMsgContentBo.setLevel(msgParam.getLevel()); jpushMsgContentBo.setLevel(msgParam.getLevel());
...@@ -1219,8 +1213,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1219,8 +1213,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Set<String> targets = new LinkedHashSet<>(); Set<String> targets = new LinkedHashSet<>();
Set<String> userIds = this.getUsersByLevel(msgParam.getManagerLevel(), msgParam.getFmea()); Set<String> userIds = this.getUsersByLevel(msgParam.getManagerLevel(), msgParam.getFmea());
userIds.forEach(userId -> { userIds.forEach(userId -> {
AgencyUserModel user = remoteSecurityService.getUserById(msgParam.getToke(), msgParam.getProduct(), AgencyUserModel user = remoteSecurityService.getUserById(msgParam.getToke(), msgParam.getProduct(), msgParam.getAppKey(), userId);
msgParam.getAppKey(), userId);
if (user != null) { if (user != null) {
String target = user.getMobile(); String target = user.getMobile();
targets.add(target); targets.add(target);
...@@ -1254,8 +1247,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1254,8 +1247,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 告警或者不合格项导致fmea的rpn、new_evaluation_oid改变 * 告警或者不合格项导致fmea的rpn、new_evaluation_oid改变
*/ */
@Override @Override
public void notifyFmeaFromAbnormal(String toke, String product, String appKey, Long fmeaId, String notifyType, public void notifyFmeaFromAbnormal(
String userName, String relationName) { String toke, String product, String appKey,
Long fmeaId, String notifyType,String userName, String relationName) {
Fmea fmea = fmeaMapper.getById(fmeaId); Fmea fmea = fmeaMapper.getById(fmeaId);
if (fmea == null) { if (fmea == null) {
return; return;
...@@ -1263,18 +1257,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1263,18 +1257,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (fmea.getEvaluationOid() != null && fmea.getEvaluationSid() != null && fmea.getEvaluationDid() != null) { if (fmea.getEvaluationOid() != null && fmea.getEvaluationSid() != null && fmea.getEvaluationDid() != null) {
List<FmeaEquipmentPoint> equipmentPoints = fmeaEquipmentPointMapper.listFmeaByFmeaId(fmeaId); List<FmeaEquipmentPoint> equipmentPoints = fmeaEquipmentPointMapper.listFmeaByFmeaId(fmeaId);
List<FmeaPointInputitem> pointInputitems = fmeaPointInputitemMapper.listFmeaByFmeaId(fmeaId); List<FmeaPointInputitem> pointInputitems = fmeaPointInputitemMapper.listFmeaByFmeaId(fmeaId);
// 1.准备更新数据 //1.准备更新数据
Double maxRate = RpnUtils.getMaxRate(equipmentPoints, pointInputitems); Double maxRate = RpnUtils.getMaxRate(equipmentPoints, pointInputitems);
if (maxRate != null) { if (maxRate != null) {
// 1.1根据设备和巡检数据获取高的故障率 //1.1根据设备和巡检数据获取高的故障率
List<EvaluationModel> oModels = iEvaluationModelDao.findAllByType("O"); List<EvaluationModel> oModels = iEvaluationModelDao.findAllByType("O");
EvaluationModel oEvaluationModel = getBetweenModel(maxRate, oModels); EvaluationModel oEvaluationModel = getBetweenModel(maxRate, oModels);
if (oEvaluationModel != null) { if (oEvaluationModel != null) {
BigDecimal newOidValue = new BigDecimal(oEvaluationModel.getCoefficient()); BigDecimal newOidValue = new BigDecimal(oEvaluationModel.getCoefficient());
BigDecimal sidValue = new BigDecimal(fmea.getSidValue()); BigDecimal sidValue = new BigDecimal(fmea.getSidValue());
BigDecimal didValue = new BigDecimal(fmea.getDidValue()); BigDecimal didValue = new BigDecimal(fmea.getDidValue());
BigDecimal rpn = newOidValue.multiply(sidValue).multiply(didValue).setScale(2, BigDecimal rpn = newOidValue.multiply(sidValue).multiply(didValue).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal.ROUND_HALF_UP);
List<RiskLevel> levels = riskLevelDao.findAll(); List<RiskLevel> levels = riskLevelDao.findAll();
RiskLevel newLevel = RpnUtils.getBetweenLevel(rpn, levels); RiskLevel newLevel = RpnUtils.getBetweenLevel(rpn, levels);
fmea.setRpn(rpn); fmea.setRpn(rpn);
...@@ -1282,7 +1275,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1282,7 +1275,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
JpushMsgBo jpushMsgBo = new JpushMsgBo(); JpushMsgBo jpushMsgBo = new JpushMsgBo();
MsgParamBo msgParamBo = new MsgParamBo(); MsgParamBo msgParamBo = new MsgParamBo();
if (newLevel != null) { if (newLevel != null) {
// 1.2根据风险等级对应的责任等级获取责任人 //1.2根据风险等级对应的责任等级获取责任人
fmea.setRiskLevelId(newLevel.getId()); fmea.setRiskLevelId(newLevel.getId());
msgParamBo.setAppKey(appKey); msgParamBo.setAppKey(appKey);
msgParamBo.setToke(toke); msgParamBo.setToke(toke);
...@@ -1295,16 +1288,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1295,16 +1288,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
msgParamBo.setRelationName(relationName); msgParamBo.setRelationName(relationName);
jpushMsgBo = this.getJushMessageInfo(msgParamBo); jpushMsgBo = this.getJushMessageInfo(msgParamBo);
} }
// 1.3.更新fmea的rpn、风险等级及newOid //1.3.更新fmea的rpn、风险等级及newOid
fmeaMapper.updateRpn(fmea); fmeaMapper.updateRpn(fmea);
// 2.计算风险点rpn、rpni、riskLevelId //2.计算风险点rpn、rpni、riskLevelId
this.notifyRiskSource(fmeaId, fmea.getRiskSourceId(), notifyType, jpushMsgBo); 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 rpnChangeLog = new RpnChangeLog();
rpnChangeLog.setRiskSourceId(riskSourceId); rpnChangeLog.setRiskSourceId(riskSourceId);
rpnChangeLog.setRpn(rpn); rpnChangeLog.setRpn(rpn);
...@@ -1340,22 +1333,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1340,22 +1333,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return; return;
} }
List<Fmea> fmeas = fmeaMapper.listByRiskSourceId(riskSourceId); List<Fmea> fmeas = fmeaMapper.listByRiskSourceId(riskSourceId);
if (CollectionUtils.isEmpty(fmeas)) {// fema全部删除 if (CollectionUtils.isEmpty(fmeas)) {//fema全部删除
BigDecimal resetValue = new BigDecimal("0"); BigDecimal resetValue = new BigDecimal("0");
riskSource.setRpn(null); riskSource.setRpn(null);
riskSource.setRpni(null); riskSource.setRpni(null);
riskSource.setRiskLevelId(null); riskSource.setRiskLevelId(null);
riskSource.setFlickerFrequency(0); riskSource.setFlickerFrequency(0);
// 1.更新fmea对应风险点rpn、rpni、level //1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper.updateRpn(riskSource); riskSourceMapper.updateRpn(riskSource);
// 2.记录风险点rpn变化流水 //2.记录风险点rpn变化流水
this.saveRpnLog(riskSource.getId(), fmeaId, resetValue, resetValue, notifyType); this.saveRpnLog(riskSource.getId(), fmeaId, resetValue, resetValue, notifyType);
// 3.更新父节点rpn、rpni、风险等级 //3.更新父节点rpn、rpni、风险等级
this.updateParentRpn(riskSource.getParentId()); this.updateParentRpn(riskSource.getParentId());
// 4.通知全景监控屏幕数据刷新 //4.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
} else {// fmea评价、巡检、告警 } else {//fmea评价、巡检、告警
RpnCalculationBo rpnValueBo = RpnUtils.calRpnAndRpni(fmeas); RpnCalculationBo rpnValueBo = RpnUtils.calRpnAndRpni(fmeas);
if (rpnValueBo.isEmpty()) { if (rpnValueBo.isEmpty()) {
return; return;
...@@ -1369,20 +1362,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1369,20 +1362,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setRpn(rpn); riskSource.setRpn(rpn);
riskSource.setRpni(rpni); riskSource.setRpni(rpni);
riskSource.setRiskLevelId(newRiskLevel.getId()); riskSource.setRiskLevelId(newRiskLevel.getId());
String changeType = RpnUtils.calChangeTypeByLevel(oldRiskLevel.getLevel(), newRiskLevel.getLevel()); String changeType = RpnUtils.calChangeTypeByLevel(oldRiskLevel.getLevel(),newRiskLevel.getLevel());
riskSource.setFlickerFrequency(RpnUtils.calRiskPointFrequency(rpn, rpni, changeType)); riskSource.setFlickerFrequency(RpnUtils.calRiskPointFrequency(rpn,rpni,changeType));
// 1.更新fmea对应风险点rpn、rpni、level //1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper.updateRpn(riskSource); riskSourceMapper.updateRpn(riskSource);
// 2.记录风险点rpn变化流水 //2.记录风险点rpn变化流水
this.saveRpnLog(riskSource.getId(), fmeaId, rpn, rpni, notifyType); this.saveRpnLog(riskSource.getId(), fmeaId, rpn, rpni, notifyType);
// 3.更新父节点rpn、rpni、风险等级 //3.更新父节点rpn、rpni、风险等级
this.updateParentRpn(riskSource.getParentId()); this.updateParentRpn(riskSource.getParentId());
// 4.极光推送给手机客户端 //4.极光推送给手机客户端
jpushRiskSourceMessage(jpushMsgBo); jpushRiskSourceMessage(jpushMsgBo);
// 5.规则告警(消息)TODO //5.规则告警(消息)TODO
notifyRule(riskSourceId, rpn, rpni, notifyType, changeType); notifyRule(riskSourceId, rpn, rpni, notifyType,changeType);
// 6.通知全景监控屏幕数据刷新 //6.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
} }
} }
...@@ -1390,15 +1383,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1390,15 +1383,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@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(0L, riskSourceId, from, null);
} }
@Override @Override
public void notifyRiskSourceDelete(Long parentId) { public void notifyRiskSourceDelete(Long parentId) {
// 1.风险点删除触发更新父节点rpn、rpni、风险等级 //1.风险点删除触发更新父节点rpn、rpni、风险等级
this.updateParentRpn(parentId); this.updateParentRpn(parentId);
// 2.通知全景监控屏幕数据刷新 //2.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode()); iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
} }
...@@ -1412,9 +1405,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1412,9 +1405,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
List<RiskSource> riskSourceList = new ArrayList<>(); List<RiskSource> riskSourceList = new ArrayList<>();
List<Long> ids = new ArrayList<>(); List<Long> ids = new ArrayList<>();
riskSourceList = iRiskSourceDao.findByParentId(riskSource.getId()); riskSourceList = iRiskSourceDao.findByParentId(riskSource.getId());
// 递归获取区域(含子区域)所有点 //递归获取区域(含子区域)所有点
this.getAllRiskPoint(ids, riskSourceList); this.getAllRiskPoint(ids, riskSourceList);
if (CollectionUtils.isEmpty(ids)) {// 没有风险点,则赋初始值null if (CollectionUtils.isEmpty(ids)) {//没有风险点,则赋初始值null
riskSource.setRpn(null); riskSource.setRpn(null);
riskSource.setRpni(null); riskSource.setRpni(null);
riskSource.setRiskLevelId(null); riskSource.setRiskLevelId(null);
...@@ -1442,13 +1435,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1442,13 +1435,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/** /**
* 获得子节点:巡检点 * 获得子节点:巡检点
* *
* @param ids * @param ids 返回
* 返回 * @param riskSourceList 风险点区域列表
* @param riskSourceList
* 风险点区域列表
*/ */
private void getAllRiskPoint(List<Long> ids, List<RiskSource> riskSourceList) { private void getAllRiskPoint(List<Long> ids, List<RiskSource> riskSourceList) {
// TODO 递归 //TODO 递归
for (RiskSource riskSource : riskSourceList) { for (RiskSource riskSource : riskSourceList) {
if (riskSource.getIsRegion().equalsIgnoreCase("TRUE")) { if (riskSource.getIsRegion().equalsIgnoreCase("TRUE")) {
List<RiskSource> list = iRiskSourceDao.findByParentId(riskSource.getId()); List<RiskSource> list = iRiskSourceDao.findByParentId(riskSource.getId());
...@@ -1470,7 +1461,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1470,7 +1461,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
JpushMsgContentBo jpushMsgContentBo = jpushMsgBo.getMsg(); JpushMsgContentBo jpushMsgContentBo = jpushMsgBo.getMsg();
Set<String> target = jpushMsgBo.getTarget(); Set<String> target = jpushMsgBo.getTarget();
if (jpushMsgContentBo.getSend()) { if(jpushMsgContentBo.getSend()){
PushMsgParam pushMsgParam = new PushMsgParam(); PushMsgParam pushMsgParam = new PushMsgParam();
pushMsgParam.setRecivers(Lists.newArrayList(target)); pushMsgParam.setRecivers(Lists.newArrayList(target));
pushMsgParam.setContent(jpushMsgContentBo.genMessage()); pushMsgParam.setContent(jpushMsgContentBo.genMessage());
...@@ -1483,7 +1474,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1483,7 +1474,12 @@ 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 riskSourceRuleRo = new RiskSourceRuleRo();
riskSourceRuleRo.setId(id); riskSourceRuleRo.setId(id);
riskSourceRuleRo.setRpnr(rpnr); riskSourceRuleRo.setRpnr(rpnr);
...@@ -1503,7 +1499,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1503,7 +1499,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return getRiskRegionTree(regionList); return getRiskRegionTree(regionList);
} }
// 区域列表转树 //区域列表转树
private static List<RegionTreeResponse> getRiskRegionTree(List<RegionTreeResponse> list) { private static List<RegionTreeResponse> getRiskRegionTree(List<RegionTreeResponse> list) {
HashMap<Long, RegionTreeResponse> hashMap = new HashMap<>(); HashMap<Long, RegionTreeResponse> hashMap = new HashMap<>();
list.forEach(e -> hashMap.put(e.getId(), e)); list.forEach(e -> hashMap.put(e.getId(), e));
......
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