Commit bc9bdd42 authored by suhuiguang's avatar suhuiguang

1.异常区域查询-全景监控

parent f71058be
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.bo.BindPointBo;
import com.yeejoin.amos.fas.business.bo.BindRegionBo;
import com.yeejoin.amos.fas.business.service.intfc.IView3dService;
import com.yeejoin.amos.fas.business.vo.ExceptionRegionVo;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.ApiOperation;
......@@ -121,4 +122,15 @@ public class View3dController extends BaseController {
return CommonResponseUtil.success(view3dService.getSystemOnlineDate(orgCode));
}
@ApiOperation(value = "异常区域信息查询",notes = "异常区域信息查询")
@GetMapping(value = "region/exception/list")
public CommonResponse getExceptionRegion(){
ReginParams reginParams =getSelectedOrgInfo();
String orgCode = this.getOrgCode(reginParams);
//TODO:测试数据待删除
orgCode = "1*2";
List<ExceptionRegionVo> exceptionRegionVoList = view3dService.getExceptionRegion(orgCode);
return CommonResponseUtil.success(exceptionRegionVoList);
}
}
......@@ -24,6 +24,7 @@ import com.yeejoin.amos.fas.business.dao.mapper.PatrolMapper;
import com.yeejoin.amos.fas.business.dao.repository.*;
import com.yeejoin.amos.fas.business.service.intfc.IView3dService;
import com.yeejoin.amos.fas.business.vo.ErrorContentVo;
import com.yeejoin.amos.fas.business.vo.ExceptionRegionVo;
import com.yeejoin.amos.fas.business.vo.SafetyIndexDetailVo;
import com.yeejoin.amos.fas.business.vo.TodaySafetyIndexVo;
import com.yeejoin.amos.fas.common.enums.CheckStatusEnum;
......@@ -240,7 +241,7 @@ public class View3dServiceImpl implements IView3dService {
if(optional.isPresent()){
//1.按照等级进行转换rpn为分数-机构
RiskSource riskSource = optional.get();
double safetyIndex = this.calSafetyIndex(riskSource);
double safetyIndex = this.changeRpnToSafetyIndex(riskSource.getRpn());
vo.setSafetyIndex(safetyIndex);
//2.统计风险上升异常数量(风险点)-日期+机构
Long upperNum = this.getRiskUpperNum(orgCode, date);
......@@ -321,8 +322,8 @@ public class View3dServiceImpl implements IView3dService {
return view3dMapper.countUpperRiskPoint(param);
}
private double calSafetyIndex(RiskSource riskSource) {
BigDecimal rpn = new BigDecimal(String.valueOf(riskSource.getRpn() == null ? "0" : riskSource.getRpn()));
private double changeRpnToSafetyIndex(BigDecimal rpn) {
BigDecimal rpnBig = rpn == null ? new BigDecimal("0") : rpn;
//计算规则:除10 减100 求绝对值,结果保留1位小数
return rpn.divide(new BigDecimal("10")).subtract(new BigDecimal("100")).abs().setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
}
......@@ -338,4 +339,41 @@ public class View3dServiceImpl implements IView3dService {
Date now = DateUtil.getNow();
return DateUtil.dayComparePrecise(beginDate,now);
}
@Override
public List<ExceptionRegionVo> getExceptionRegion(String orgCode) {
Optional<RiskSource> optional = iRiskSourceDao.findByOrgCodeAndParentId(orgCode,0L);
List<ExceptionRegionVo> exceptionList = new ArrayList<>();
if (optional.isPresent()) {
List<RiskSource> regionList = iRiskSourceDao.findByParentId(optional.get().getId());
exceptionList = regionList.stream().filter(riskSource -> {
//TODO:待毛颖确认,增加判断故障的规则(统计数据:故障或者rpn上升)
BigDecimal rpnBig = riskSource.getRpn() == null ? new BigDecimal("0") : riskSource.getRpn();
return rpnBig.subtract(riskSource.getRpni()).doubleValue() > 0;
}).map(riskSource -> {
ExceptionRegionVo regionVo = new ExceptionRegionVo();
regionVo.setId(riskSource.getId());
regionVo.setUe4Location(getInitJSONArray(riskSource.getUe4Location()));
regionVo.setUe4Rotation(getInitJSONArray(riskSource.getUe4Rotation()));
regionVo.setUe4Extent(getInitJSONArray(riskSource.getUe4Extent()));
regionVo.setSafetyIndex(changeRpnToSafetyIndex(riskSource.getRpn()));
regionVo.setBreakdown(isBreakDown(riskSource.getId()));
return regionVo;
}).collect(Collectors.toList());
}
return exceptionList;
}
private JSONArray getInitJSONArray(String str){
if(StringUtil.isNotEmpty(str)){
return JSON.parseArray(str);
} else {
return new JSONArray();
}
}
private Boolean isBreakDown(Long id){
//TODO:判断是否故障,待毛颖确认
return true;
}
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.service.intfc;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.bo.BindPointBo;
import com.yeejoin.amos.fas.business.vo.ExceptionRegionVo;
import com.yeejoin.amos.fas.business.vo.SafetyIndexDetailVo;
import com.yeejoin.amos.fas.business.vo.TodaySafetyIndexVo;
import com.yeejoin.amos.fas.core.common.response.RegionTreeResponse;
......@@ -78,4 +79,6 @@ public interface IView3dService {
* @return eg:10年3月2天
*/
Map<String, Object> getSystemOnlineDate(String orgCode);
List<ExceptionRegionVo> getExceptionRegion(String orgCode);
}
package com.yeejoin.amos.fas.business.vo;
import com.alibaba.fastjson.JSONArray;
/**
* @author suhg
*/
public class ExceptionRegionVo {
/**
* 风险点id
*/
private Long id;
/**
* 安全指数
*/
private Double safetyIndex;
/**
* 是否故障
*/
private boolean breakdown ;
/**
* ue4点坐标
*/
private JSONArray ue4Location;
/**
* ue4旋转
*/
private JSONArray ue4Rotation;
/**
* ue4缩放
*/
private JSONArray ue4Extent;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Double getSafetyIndex() {
return safetyIndex;
}
public void setSafetyIndex(Double safetyIndex) {
this.safetyIndex = safetyIndex;
}
public JSONArray getUe4Location() {
return ue4Location;
}
public void setUe4Location(JSONArray ue4Location) {
this.ue4Location = ue4Location;
}
public JSONArray getUe4Rotation() {
return ue4Rotation;
}
public void setUe4Rotation(JSONArray ue4Rotation) {
this.ue4Rotation = ue4Rotation;
}
public JSONArray getUe4Extent() {
return ue4Extent;
}
public void setUe4Extent(JSONArray ue4Extent) {
this.ue4Extent = ue4Extent;
}
public boolean isBreakdown() {
return breakdown;
}
public void setBreakdown(boolean breakdown) {
this.breakdown = breakdown;
}
}
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