Commit 95526117 authored by suhuiguang's avatar suhuiguang

1.区域建筑关系建立

parent 52af9353
......@@ -10,6 +10,7 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
......@@ -38,7 +39,8 @@ public class BasicEntity /*extends Resource*/ implements Serializable{
private Date createDate = new Date();
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GeneratedValue(strategy=GenerationType.AUTO,generator = "myid")
@GenericGenerator(name = "myid", strategy = "com.yeejoin.amos.fas.config.ManulInsertGenerator")
@Column(name = "ID",nullable=false,unique=true)
public long getId() {
return id;
......
......@@ -79,6 +79,19 @@ public class RiskSource extends BasicEntity {
private String routePath;
/**
* 同步源id
*/
private Long sourceId;
public Long getSourceId() {
return sourceId;
}
public void setSourceId(Long sourceId) {
this.sourceId = sourceId;
}
/**
* 闪烁频率
*/
@Column(name = "flicker_frequency")
......
package com.yeejoin.amos.fas.business.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import com.yeejoin.amos.fas.business.action.model.ProtalDataRo;
......@@ -36,10 +14,22 @@ import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.RiskSource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/risksource")
......@@ -47,8 +37,6 @@ import io.swagger.annotations.ApiParam;
public class RiskSourceController extends BaseController {
private final Logger log = LoggerFactory.getLogger(RiskSourceController.class);
private final static String IS_RISK_AREA = "TRUE";
@Autowired
IRiskFactorService iRiskFactorService;
......@@ -734,4 +722,20 @@ public class RiskSourceController extends BaseController {
public CommonResponse queryFmeaByPointId(@PathVariable Long pointId) {
return CommonResponseUtil.success(riskSourceService.queryFmeaByPointId(pointId));
}
@Permission
@ApiOperation(value = "同步风险区域",notes = "创建或者更新,对站调用")
@PostMapping("/syn/region")
public CommonResponse synRegion(@RequestBody List<RiskSource> list){
ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams);
return CommonResponseUtil.success(riskSourceService.synRegion(getUserId(),compCode,list));
}
@Permission
@ApiOperation(value = "删除建筑与风险区域关系",notes = "对站调用")
@PutMapping("/remove/bind")
public CommonResponse removeBind(@RequestParam Long instanceId){
return CommonResponseUtil.success(riskSourceService.removeBind(instanceId));
}
}
......@@ -35,10 +35,11 @@ public interface IRiskSourceDao extends BaseDao<RiskSource, Long> {
@Query(value="select *from f_risk_source where is_region = 'TRUE' and parent_id > 0", nativeQuery = true)
List<RiskSource> queryRiskAreaRpn();
Optional<RiskSource> findByOrgCodeAndParentId(String orgCode, Long parentId);
List<RiskSource> findByParentIdAndIsRegion(long id, String string);
Optional<RiskSource> findByCode(String riskSourceCode);
List<RiskSource> findBySourceId(Long instanceId);
}
package com.yeejoin.amos.fas.business.service.impl;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.cache.enumeration.CacheType;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -49,39 +8,12 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.model.CheckInputItemRo;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.DeviceRo;
import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import com.yeejoin.amos.fas.business.action.model.ProtalDataRo;
import com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo;
import com.yeejoin.amos.fas.business.action.model.SetpEnum;
import com.yeejoin.amos.fas.business.action.model.*;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.bo.BindRegionBo;
import com.yeejoin.amos.fas.business.bo.JpushMsgBo;
import com.yeejoin.amos.fas.business.bo.JpushMsgContentBo;
import com.yeejoin.amos.fas.business.bo.MsgParamBo;
import com.yeejoin.amos.fas.business.bo.RpnCalculationBo;
import com.yeejoin.amos.fas.business.bo.*;
import com.yeejoin.amos.fas.business.constants.FasConstant;
import com.yeejoin.amos.fas.business.dao.mapper.FireEquipMapper;
import com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper;
import com.yeejoin.amos.fas.business.dao.mapper.FmeaEquipmentPointMapper;
import com.yeejoin.amos.fas.business.dao.mapper.FmeaMapper;
import com.yeejoin.amos.fas.business.dao.mapper.FmeaPointInputitemMapper;
import com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper;
import com.yeejoin.amos.fas.business.dao.mapper.RiskSourceMapper;
import com.yeejoin.amos.fas.business.dao.repository.IAlarmDao;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IDictDao;
import com.yeejoin.amos.fas.business.dao.repository.IEvaluationModelDao;
import com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentDao;
import com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentPointDao;
import com.yeejoin.amos.fas.business.dao.repository.IPreplanPictureDao;
import com.yeejoin.amos.fas.business.dao.repository.IRiskFactorDao;
import com.yeejoin.amos.fas.business.dao.repository.IRiskLevelDao;
import com.yeejoin.amos.fas.business.dao.repository.IRiskSourceDao;
import com.yeejoin.amos.fas.business.dao.repository.IRpnChangeLogDao;
import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.*;
import com.yeejoin.amos.fas.business.feign.IEquipManageFeign;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.feign.RemoteWebSocketServer;
......@@ -91,17 +23,9 @@ import com.yeejoin.amos.fas.business.jpush.PushMsgParam;
import com.yeejoin.amos.fas.business.param.AlarmParam;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
import com.yeejoin.amos.fas.business.param.FmeaBindParam;
import com.yeejoin.amos.fas.business.service.intfc.IDataRefreshService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.business.service.intfc.IView3dService;
import com.yeejoin.amos.fas.business.service.intfc.*;
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.util.CacheFactory;
import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.util.DateUtils;
import com.yeejoin.amos.fas.business.util.JexlUtil;
import com.yeejoin.amos.fas.business.util.RpnUtils;
import com.yeejoin.amos.fas.business.util.*;
import com.yeejoin.amos.fas.business.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import com.yeejoin.amos.fas.business.vo.Toke;
......@@ -109,30 +33,45 @@ import com.yeejoin.amos.fas.business.vo.TopicEntityVo;
import com.yeejoin.amos.fas.client.invoke.RsDataQueue;
import com.yeejoin.amos.fas.common.enums.CheckStatusEnum;
import com.yeejoin.amos.fas.common.enums.DataRefreshTypeEum;
import com.yeejoin.amos.fas.common.enums.RiskSourceRegionEum;
import com.yeejoin.amos.fas.common.enums.View3dRefreshAreaEum;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.response.RegionTreeResponse;
import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.StringUtil;
import com.yeejoin.amos.fas.dao.entity.Alarm;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.Dict;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.EvaluationModel;
import com.yeejoin.amos.fas.dao.entity.FireEquipment;
import com.yeejoin.amos.fas.dao.entity.FireEquipmentData;
import com.yeejoin.amos.fas.dao.entity.FireEquipmentPoint;
import com.yeejoin.amos.fas.dao.entity.Fmea;
import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint;
import com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem;
import com.yeejoin.amos.fas.dao.entity.PreplanPicture;
import com.yeejoin.amos.fas.dao.entity.RiskFactor;
import com.yeejoin.amos.fas.dao.entity.RiskLevel;
import com.yeejoin.amos.fas.dao.entity.RiskSource;
import com.yeejoin.amos.fas.dao.entity.RpnChangeLog;
import com.yeejoin.amos.fas.dao.entity.*;
import com.yeejoin.amos.fas.exception.YeeException;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.cache.enumeration.CacheType;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
@Service("riskSourceService")
......@@ -318,7 +257,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
// }
/**
*
* 风险模型新增及维护时远程同步
*
* @return CommonResponse
......@@ -351,9 +289,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
// }
// return null;
// }
@Override
public void deleteRiskSource(String appKey,String product,String token,String success,Long[] riskSourceId) throws Exception {
public void deleteRiskSource(String appKey, String product, String token, String success, Long[] riskSourceId) throws Exception {
Set<Long> parentIds = new LinkedHashSet<>();
String synMsg = null;
for (Long rId : riskSourceId) {
......@@ -385,8 +322,46 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public void deleteById(Long id) {
iRiskSourceDao.deleteById(id);
}
@Override
public List<RiskSource> synRegion(String userId, String compCode, List<RiskSource> list) {
List<RiskSource> entrys = new ArrayList<>();
list.forEach(r->{
r.setOrgCode(compCode);
r.setIsRegion(RiskSourceRegionEum.TRUE.getCode());
//TODO 注意:id使用了调用接口方的id,这样代码修改量较小
Optional<RiskSource> op = iRiskSourceDao.findById(r.getId());
if(op.isPresent()){
//有就更新,业务只能调整上级
RiskSource riskSource = op.get();
riskSource.setParentId(r.getParentId());
entrys.add(riskSource);
} else {
//无则插入
//TODO 注意:id使用了调用接口方的id,这样代码修改量较小
r.setCreateDate(new Date());
r.setIsIndoor(Boolean.FALSE);
r.setSourceId(r.getId());
r.setCreateBy(userId);
entrys.add(r);
}
});
return iRiskSourceDao.saveAll(entrys);
}
@Override
public Boolean removeBind(Long instanceId) {
List<RiskSource> exists = iRiskSourceDao.findBySourceId(instanceId);
if(!CollectionUtils.isEmpty(exists)){
exists.forEach(e->{
e.setSourceId(null);
});
exists = iRiskSourceDao.saveAll(exists);
}
return !CollectionUtils.isEmpty(exists);
}
/**
*
* 风险模型删除时远程同步
*
* @return String
......@@ -413,7 +388,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
// }
// return null;
// }
@Override
public Page<HashMap<String, Object>> queryRiskSourceByPage(CommonPageInfoParam param) {
long total = riskSourceMapper.countPageData(param);
......@@ -600,9 +574,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
public void alermContingency(String batchNo, FireEquipment fireEquipment, Equipment equipment) throws Exception {
Object oldContingencyRo = redisTemplate.opsForValue().get("contingencyRo");
ContingencyRo contingencyRo = new ContingencyRo();
......@@ -665,7 +636,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
log.debug("开始调用规则");
Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
log.debug("规则调用返回==",result);
log.debug("规则调用返回==", result);
ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData();
BeanUtils.copyProperties(contingencyRo, contingencyOriginalData);
......@@ -801,25 +772,23 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
// 今日安全
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(new Date());
String topicOne = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","todaySafetyIndex");
String topicOne = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "todaySafetyIndex");
webMqttComponent.publish(topicOne, JSON.toJSONString(view3dService.getSafetyIndexInfoByDate(orgCode, dateString)));
// 巡检异常
String topicTwo = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","fireSafety");
String topicTwo = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "fireSafety");
webMqttComponent.publish(topicTwo, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("check", orgCode)));
// 一周安全趋势
String topicThree = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","weekSafetyIndex");
String topicThree = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "weekSafetyIndex");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getSafetyIndexWeek(orgCode)));
// 今日巡检
String topicFour = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","todayCheckStatus");
String topicFour = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "todayCheckStatus");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getStatisticsCheck(orgCode)));
}
/**
* 巡检消息规则推送
*
......@@ -838,13 +807,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
log.info("巡检消息发送规则" + JSONObject.toJSONString(protalData));
ruleTrigger.publish(protalData, "风险管控/patrol", null);
} catch (Exception e) {
log.error(e.getMessage(),e);
log.error(e.getMessage(), e);
}
}
@Override
public RiskSourceTreeResponse queryRiskSourceDetailById(Long id) {
RiskSourceTreeResponse det = riskSourceMapper.findRiskSourceDetatil(id);
......@@ -929,7 +896,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
//处理设备和巡检数据
deviceData.setNodeState(deviceData.getState());
FireEquipmentPoint fireEquipmentPoint = iFireEquipmentPointDao.findOneByCode(deviceData.getPointCode());
if(!ObjectUtils.isEmpty(fireEquipmentPoint)){
if (!ObjectUtils.isEmpty(fireEquipmentPoint)) {
fireEquipmentPoint.setValue(deviceData.getState());
updateFirePointValue(fireEquipmentPoint.getId(), deviceData.getState());//不需要
......@@ -953,7 +920,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
//保存实时数据
// 根据监测点设备信息获取保护的重点装备
equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId());
deviceData.setMonitor(equipment != null?equipment.getName():"");
deviceData.setMonitor(equipment != null ? equipment.getName() : "");
deviceData.setId(String.valueOf(fireEquipment.getId()));
deviceData.setCode(fireEquipment.getCode());
saveFireEquipmentData(fireEquipmentPoint, fireEquipment, deviceData, fireEquipmentPointType, toke);
......@@ -965,7 +932,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Boolean have = impAndFireEquipMapper.existsAlarmPointByEqpPointIdAndEquipId(fireEquipmentPoint.getId(), equipment.getId());//判断重点设备关联该指标项,需要修改为新查询
if (!ObjectUtils.isEmpty(have) && have) {
//动态预案执行
dynamicPlan(deviceData, equipment, fireEquipment,toke);
dynamicPlan(deviceData, equipment, fireEquipment, toke);
}
}
}
......@@ -1011,8 +978,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
@Override
@javax.transaction.Transactional
public String processFireEqumtData(AlarmParam deviceData) throws Exception {
......@@ -1026,7 +991,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
String data = JSON.toJSONString(topicEntity);
System.out.println(data);
iEquipmentHandlerService.handlerMqttMessage("",data );
iEquipmentHandlerService.handlerMqttMessage("", data);
// 格式化发送数据
// sendRiskSourceData(deviceData);
//
......@@ -1036,6 +1001,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* webSocket向前台推送消防设备数据
*
* @param param
*/
@Async
......@@ -1051,10 +1017,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
// 推送设备状态信息
Alarm alarm = iAlarmDao.findByStatusTrueAndFireEquipmentPointCode(param.getPointCode());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/monitorData");
String topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/monitorData");
webMqttComponent.publish(topic, JSON.toJSONString(view3dService.getEquipStatusList(alarm.getOrgCode())));
} catch (Exception e) {
log.error("推送前端数据失败-->"+JSON.toJSONString(param));
log.error("推送前端数据失败-->" + JSON.toJSONString(param));
}
}
......@@ -1095,7 +1061,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* 设备消息规则推送
*
*/
@Async
void fireEquipRuleMessagePush(AlarmParam deviceData, Toke toke) {
......@@ -1110,7 +1075,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
log.info("设备消息规则推送" + JSONObject.toJSONString(deviceData));
ruleTrigger.publish(fireEquimentDataRo, "风险管控/fireEquiment", null);
} catch (Exception e) {
log.error(e.getMessage(),e);
log.error(e.getMessage(), e);
}
}
......@@ -1155,7 +1120,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 推送告警数据
* 影响区域:消防安全=>火灾告警
*/
String topic = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","fireSafety");
String topic = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "fireSafety");
webMqttComponent.publish(topic, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("fire", fireEquipmentPoint.getOrgCode())));
}
......@@ -1187,7 +1152,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 推送设备状态
* 影响区域:设备状态
*/
String topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/monitorData");
String topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/monitorData");
webMqttComponent.publish(topic, JSON.toJSONString(view3dService.getEquipStatusList(fireEquipment.getOrgCode())));
}
}
......@@ -1301,7 +1266,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
try {
redisTemplate.opsForHash().put("Analogue", data.getPointCode(), data);
// remoteWebSocketServer.sendMessage("plan", JSON.toJSONString(data));
String topic = String.format("/%s/%s/%s", serviceName, stationName,"analogue");
String topic = String.format("/%s/%s/%s", serviceName, stationName, "analogue");
webMqttComponent.publish(topic, JSON.toJSONString(data));
} catch (Exception e) {
e.printStackTrace();
......@@ -1487,7 +1452,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaMapper.updateRpn(fmea);
//2.计算上级风险值(风险点及父节点)
this.notifyRiskSource(newLevel.getOrgCode(), fmeaId, fmea.getRiskSourceId(), nofityType, jpushMsgBo);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/incidenceSeverityMatrix");
String topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
}
}
......@@ -1592,7 +1557,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
//1.3.更新fmea的rpn、风险等级及newOid
fmeaMapper.updateRpn(fmea);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/incidenceSeverityMatrix");
String topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
//2.计算风险点rpn、rpni、riskLevelId
this.notifyRiskSource(newLevel.getOrgCode(), fmeaId, fmea.getRiskSourceId(), notifyType, jpushMsgBo);
......@@ -1697,32 +1662,32 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
try {
String topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/situationMap");
String topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/situationMap");
webMqttComponent.publish(topic, JSON.toJSONString(queryRiskSourceSecondLevel(orgCode)));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/riskDegreeHistogram");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/riskDegreeHistogram");
webMqttComponent.publish(topic, JSON.toJSONString(queryRPNReport()));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/riskDegreePie");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/riskDegreePie");
webMqttComponent.publish(topic, JSON.toJSONString(queryForRiseUp()));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/incidenceSeverityMatrix");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
// 今日安全
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(new Date());
if(StringUtils.isEmpty(orgCode)){
if (StringUtils.isEmpty(orgCode)) {
orgCode = riskSource.getOrgCode();
}
String topicOne = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/todaySafetyIndex");
String topicOne = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/todaySafetyIndex");
webMqttComponent.publish(topicOne, JSON.toJSONString(view3dService.getSafetyIndexInfoByDate(orgCode, dateString)));
// 消防安全
String topicTow = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/fireSafety");
String topicTow = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/fireSafety");
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("risk", orgCode)));
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("check", orgCode)));
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("fire", orgCode)));
// 一周安全趋势
String topicThree = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","weekSafetyIndex");
String topicThree = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "weekSafetyIndex");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getSafetyIndexWeek(orgCode)));
} catch (Exception e) {
......@@ -1754,37 +1719,37 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
try{
String topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/situationMap");
try {
String topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/situationMap");
webMqttComponent.publish(topic, JSON.toJSONString(queryRiskSourceSecondLevel(riskSource.getOrgCode())));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/riskDegreeHistogram");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/riskDegreeHistogram");
webMqttComponent.publish(topic, JSON.toJSONString(queryRPNReport()));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/riskDegreePie");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/riskDegreePie");
webMqttComponent.publish(topic, JSON.toJSONString(queryForRiseUp()));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/incidenceSeverityMatrix");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
// 今日安全
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(new Date());
String orgCode = riskSource.getOrgCode();
if(StringUtils.isEmpty(orgCode)){
if (StringUtils.isEmpty(orgCode)) {
orgCode = riskSource.getOrgCode();
}
String topicOne = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/todaySafetyIndex");
String topicOne = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/todaySafetyIndex");
webMqttComponent.publish(topicOne, JSON.toJSONString(view3dService.getSafetyIndexInfoByDate(orgCode, dateString)));
// 消防安全
String topicTow = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/fireSafety");
String topicTow = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/fireSafety");
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("risk", orgCode)));
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("check", orgCode)));
webMqttComponent.publish(topicTow, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("fire", orgCode)));
// 一周安全趋势
String topicThree = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","weekSafetyIndex");
String topicThree = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "weekSafetyIndex");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getSafetyIndexWeek(orgCode)));
}catch (Exception e) {
} catch (Exception e) {
log.error("数据获取失败", e);
}
......@@ -1861,7 +1826,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
JpushMsgContentBo jpushMsgContentBo = jpushMsgBo.getMsg();
Set<String> target = jpushMsgBo.getTarget();
target.remove(null);
if(jpushMsgContentBo.getSend()){
if (jpushMsgContentBo.getSend()) {
PushMsgParam pushMsgParam = new PushMsgParam();
pushMsgParam.setRecivers(Lists.newArrayList(target));
pushMsgParam.setContent(jpushMsgContentBo.genMessage());
......@@ -1890,7 +1855,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSourceRuleRo.setTitle(msgContentBo.getSubject());
riskSourceRuleRo.setRg(String.valueOf(rpnr.subtract(rpni).toBigInteger()));
try {
log.info("规则告警发送数据为"+JSONObject.toJSONString(riskSourceRuleRo));
log.info("规则告警发送数据为" + JSONObject.toJSONString(riskSourceRuleRo));
ruleTrigger.publish(riskSourceRuleRo, "风险管控/riskSource", null);// 没有配决策流,processIds传null即可
} catch (Exception e) {
log.error("调用规则异常", e);
......@@ -1939,16 +1904,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
@Override
public void batchSaveRegionUe4(List<BindRegionBo> regionBoList,String orgCode) {
public void batchSaveRegionUe4(List<BindRegionBo> regionBoList, String orgCode) {
riskSourceMapper.batchSaveRegionUe4(regionBoList);
try {
String topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/situationMap");
String topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/situationMap");
webMqttComponent.publish(topic, JSON.toJSONString(queryRiskSourceSecondLevel(orgCode)));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/riskDegreeHistogram");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/riskDegreeHistogram");
webMqttComponent.publish(topic, JSON.toJSONString(queryRPNReport()));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/riskDegreePie");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/riskDegreePie");
webMqttComponent.publish(topic, JSON.toJSONString(queryForRiseUp()));
topic = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/incidenceSeverityMatrix");
topic = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/incidenceSeverityMatrix");
webMqttComponent.publish(topic, JSON.toJSONString(queryForMatrix()));
} catch (Exception e) {
log.error("数据获取失败", e);
......
......@@ -194,4 +194,20 @@ public interface IRiskSourceService {
* @date 2020-9-9 11:53:36
*/
void deleteById(Long id);
/**
* 同步创建/更新区域
* @param code userId
* @param compCode 公司编号
* @param list 同步数据支持多个
* @return List<RiskSource>
*/
List<RiskSource> synRegion(String code, String compCode, List<RiskSource> list);
/**
* 解除绑定关系
* @param instanceId 解除者id
* @return Boolean
*/
Boolean removeBind(Long instanceId);
}
package com.yeejoin.amos.fas.config;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentityGenerator;
import java.io.Serializable;
/**
* 自定义的主键生成策略,如果填写了主键id,如果数据库中没有这条记录,则新增指定id的记录;否则更新记录
*
* 如果不填写主键id,则利用数据库本身的自增策略指定id
*/
public class ManulInsertGenerator extends IdentityGenerator {
@Override
public Serializable generate(SharedSessionContractImplementor s, Object obj) throws HibernateException {
Serializable id = s.getEntityPersister(null, obj).getClassMetadata().getIdentifier(obj, s);
if (id != null && Long.parseLong(id.toString()) > 0) {
return id;
} else {
return super.generate(s, obj);
}
}
}
......@@ -587,4 +587,15 @@
ALTER TABLE `f_station_info` ADD COLUMN `fire_captain_user_id` varchar(20) NULL COMMENT '驻站消防队队长';
</sql>
</changeSet>
<changeSet author="shg" id="1609226808866-1">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_risk_source" columnName="source_id"/>
</not>
</preConditions>
<comment>f_risk_source add column source_id</comment>
<sql>
alter table `f_risk_source` add column `source_id` bigint(20) DEFAULT NULL AFTER `status`;
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -183,7 +183,7 @@
left join wl_equipment_index as ein on ind.equipment_index_id = ein.id
left join wl_stock_detail as sto on sto.qr_code = spe.qr_code
left join wl_warehouse_structure as str on sto.warehouse_structure_id = str.source_id
left join f_risk_source as sce on str.source_id = sce.id
left join f_risk_source as sce on str.source_id = sce.source_id
) d
WHERE
1 = 1
......@@ -298,8 +298,9 @@
LEFT JOIN wl_equipment we ON we.id = wed.equipment_id
LEFT JOIN wl_unit u ON u.id = we.unit_id
LEFT JOIN wl_warehouse_structure ws ON ws.source_id = wsd.warehouse_structure_id
left join f_risk_source as sce on sce.source_id = ws.source_id
WHERE
ws.source_id = #{riskSourceId}
sce.id = #{riskSourceId}
GROUP BY
wsd.equipment_detail_id,
wed.`name`
......
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