Commit 4769ee42 authored by 单奇雲's avatar 单奇雲

Merge branch 'dev_upgrade' of http://172.16.10.76/station/YeeAmosFireAutoSysRoot into dev_upgrade

parents 1bc40a6f 9d0130e1
......@@ -46,4 +46,9 @@ public class FasConstant {
public static final String RISK_SOURCE_STATUS_ANOMALY = "ANOMALY";//风险点状态-正常
public static final String PLAN_SOURCE_TYPE = "plan_source_type";//预案资源类型
public static final String ALL_POINT = "all";
public static String appKey = "";
public static String product = "";
public static String token = "";
public static String staticOrgCode = "";
}
......@@ -174,6 +174,4 @@ public class CommonController extends BaseController {
List<AgencyUserModel> users = commonService.getAllUser(getToken(),getProduct(),getAppKey(), compCode);
return CommonResponseUtil.success(users);
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -27,6 +28,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import static com.yeejoin.amos.fas.business.constants.FasConstant.*;
@RestController
@RequestMapping("/api/view3d")
@Api(tags="全景监控api")
......@@ -151,6 +154,10 @@ public class View3dController extends BaseController {
public CommonResponse getStatisticsDuty(){
ReginParams reginParams =getSelectedOrgInfo();
String orgCode = this.getOrgCode(reginParams);
appKey = getAppKey();
product = getProduct();
staticOrgCode = orgCode;
token = getToken();
return view3dService.getStatisticsDuty(getAppKey(),getProduct(),orgCode);
}
......@@ -249,4 +256,10 @@ public class View3dController extends BaseController {
public CommonResponse listPointsByRegion(@PathVariable Long regionId, @RequestParam(required = false, defaultValue = "all") String type){
return CommonResponseUtil.success(view3dService.listPointsByRegionId(regionId,type));
}
@ApiOperation(value = "预案人员测试方法",notes = "预案人员测试方法")
@GetMapping(value = "dutyListByDate")
public Map<String, String> getDutyListByDate(){
return view3dService.getDutyListByDate();
}
}
......@@ -10,4 +10,8 @@ public class DutyModeServerFallback implements IDutyModeServer{
return CommonResponseUtil.failure("fegin调用失败!!!");
}
@Override
public CommonResponse dutyListByDate(String appKey, String product, String token, String orgCode, String param) {
return CommonResponseUtil.failure("fegin调用失败!!!");
}
}
......@@ -2,10 +2,7 @@ package com.yeejoin.amos.fas.business.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.*;
import com.yeejoin.amos.fas.core.util.CommonResponse;
......@@ -19,4 +16,11 @@ public interface IDutyModeServer {
@RequestHeader(name="orgCode",required = true) String orgCode,
@RequestBody String param);
@RequestMapping(value = "/duty/dutyListByDate", method = RequestMethod.POST,consumes = "application/json")
public CommonResponse dutyListByDate(
@RequestHeader(name="appKey",required = true) String appKey,
@RequestHeader(name="product",required = true) String product,
@RequestHeader(name="token",required = true) String token,
@RequestHeader(name="orgCode",required = true) String orgCode,
@RequestBody String param);
}
......@@ -56,8 +56,6 @@ public class RemoteSecurityService {
return userModel;
}
//部门id获取部门信息
public DepartmentModel getDepartmentByDeptId(String toke,String product,String appKey,String deparmentId) {
if (deparmentId == null || deparmentId.equals("")) {
......
......@@ -19,6 +19,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.base.Joiner;
......@@ -104,9 +105,11 @@ public class FireCarServiceImpl implements IFireCarService {
if(!CollectionUtils.isEmpty(deptIds)){
List<DepartmentModel> depts =remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(deptIds));
Map<Long, String> deptMap = depts.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr,DepartmentModel::getDepartmentName));
content.forEach(e -> {
e.put("departmentName",deptMap.get(Long.valueOf(e.get("dept_id").toString())));
});
if (!ObjectUtils.isEmpty(deptMap)){
content.forEach(e -> {
e.put("departmentName",deptMap.get(Long.valueOf(e.get("dept_id").toString())));
});
}
}
}
Page<HashMap<String, Object>> result = new PageImpl<HashMap<String, Object>>(content, param, total);
......
......@@ -31,6 +31,7 @@ import com.yeejoin.amos.fas.business.util.JexlUtil;
import com.yeejoin.amos.fas.business.util.RpnUtils;
import com.yeejoin.amos.fas.business.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.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.View3dRefreshAreaEum;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
......@@ -361,6 +362,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Equipment equipment = equipmentService.queryOne(importantEquipId);
if (!CollectionUtils.isEmpty(returnList) && equipment != null) {
fmeaEquipmentPointMapper.saveBatch(returnList);
}
if(equipment != null){
RsDataQueue rsDataQueue = RsDataQueue.getInstance();
rsDataQueue.addEquipmentMessage(fmeaId,equipment.getName());
}
......@@ -383,9 +386,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
if (!CollectionUtils.isEmpty(returnList)) {
fmeaPointInputitemMapper.saveBatch(returnList);
RsDataQueue rsDataQueue = RsDataQueue.getInstance();
rsDataQueue.addPatrolMessage(fmeaId);
}
RsDataQueue rsDataQueue = RsDataQueue.getInstance();
rsDataQueue.addPatrolMessage(fmeaId);
return returnList;
}
......@@ -554,12 +557,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
for(int i=0;i<content.size();i++){
if(content.get(i).get("userId") !=null && userMap.containsKey(content.get(i).get("userId"))){
if(StringUtil.isNotEmpty(content.get(i).get("userId")) && userMap.containsKey(content.get(i).get("userId"))){
AgencyUserModel user = userMap.get(content.get(i).get("userId"));
content.get(i).put("userName", user.getRealName());
content.get(i).put("tel", user.getMobile());
}
if(content.get(i).get("deptId") !=null && deptMap.containsKey(Long.valueOf(content.get(i).get("deptId").toString()))){
if(StringUtil.isNotEmpty(content.get(i).get("deptId")) && deptMap.containsKey(Long.valueOf(content.get(i).get("deptId").toString()))){
content.get(i).put("deptName", deptMap.get(Long.valueOf(content.get(i).get("deptId").toString())));
}
}
......@@ -628,7 +631,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* @param protalData
*/
@Async
private void protalRuleMessagePush(ProtalDataRo protalData){
void protalRuleMessagePush(ProtalDataRo protalData){
String bacthNo = UUID.randomUUID().toString();
protalData.setBatchNo(bacthNo);
protalData.setOriginalNodeState(protalData.getNodeState());
......@@ -1116,18 +1119,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal sidValue = new BigDecimal(fmea.getSidValue());
BigDecimal didValue = new BigDecimal(fmea.getDidValue());
//1.1计算rpni
BigDecimal rpni = oidValue.multiply(sidValue).multiply(didValue).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal rpn;
//1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo
//1.2未评价过,计算绑定的巡检点项 设备点位故障率
if (fmea.getNewEvaluationOid() == null) {
fmea.setNewEvaluationOid(fmea.getEvaluationOid());
rpn = rpni;
EvaluationModel evaluationModel = this.getEvaluationModel(fmeaId);
if(evaluationModel != null){//已经绑定点位或者巡检点项且匹配到风险模型,则更新为计算后的结果
BigDecimal newOidValue = new BigDecimal(evaluationModel.getCoefficient());
rpn = newOidValue.multiply(sidValue).multiply(didValue).setScale(2, BigDecimal.ROUND_HALF_UP);
fmea.setNewEvaluationOid(evaluationModel.getId());
}else {//未绑定点位或者巡检点项或者匹配不到风险模型,则更新为rpn与rpni一致
fmea.setNewEvaluationOid(fmea.getEvaluationOid());
rpn = rpni;
}
} else {
BigDecimal newOidValue = new BigDecimal(fmea.getNewOidValue());
rpn = newOidValue.multiply(sidValue).multiply(didValue).setScale(2, BigDecimal.ROUND_HALF_UP);
}
List<RiskLevel> levels = riskLevelDao.findAll();
RiskLevel newLevel = RpnUtils.getBetweenLevel(rpn, levels);
......@@ -1344,11 +1351,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
//3.更新父节点rpn、rpni、风险等级
this.updateParentRpn(riskSource.getParentId());
//4.极光推送给手机客户端
if(notifyType=="recovery"||notifyType=="fmeaUpdate"||(notifyType=="alarm"&&rpnDiffer>0)||(notifyType=="patrol"&&rpnDiffer>0&&checkStatus.equals("不合格")))
jpushRiskSourceMessage(jpushMsgBo);
//5.规则告警(消息)TODO
if(notifyType=="recovery"||notifyType=="fmeaUpdate"||(notifyType=="alarm"&&rpnDiffer>0)||(notifyType=="patrol"&&rpnDiffer>0&&checkStatus.equals("不合格")))
if("recovery".equals(notifyType) || "fmeaUpdate".equals(notifyType) || ("alarm".equals(notifyType)&&rpnDiffer>0)||("patrol".equals(notifyType) && rpnDiffer>0 && CheckStatusEnum.UNQUALIFIED.getName().equals(checkStatus))){
jpushRiskSourceMessage(jpushMsgBo);
}
//5.规则告警(消息)
if("recovery".equals(notifyType) || "fmeaUpdate".equals(notifyType) || ("alarm".equals(notifyType)&&rpnDiffer>0) ||(notifyType=="patrol" && rpnDiffer>0 && CheckStatusEnum.UNQUALIFIED.getName().equals(checkStatus))){
notifyRule(riskSourceId, rpn, rpni, notifyType,changeType, jpushMsgBo.getMsg());
}
//6.通知全景监控屏幕数据刷新
iDataRefreshService.refreshViewData(DataRefreshTypeEum.rpn.getCode());
}
......@@ -1516,4 +1525,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public void batchSaveRegionUe4(List<BindRegionBo> regionBoList) {
riskSourceMapper.batchSaveRegionUe4(regionBoList);
}
private EvaluationModel getEvaluationModel(Long fmeaId){
List<FmeaEquipmentPoint> equipmentPoints = fmeaEquipmentPointMapper.listFmeaByFmeaId(fmeaId);
List<FmeaPointInputitem> pointInputitems = fmeaPointInputitemMapper.listFmeaByFmeaId(fmeaId);
Double maxRate = RpnUtils.getMaxRate(equipmentPoints, pointInputitems);
if(maxRate != null){
List<EvaluationModel> oModels = iEvaluationModelDao.findAllByType("O");
EvaluationModel oEvaluationModel = getBetweenModel(maxRate, oModels);
return oEvaluationModel;
}
return null;
}
}
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yeejoin.amos.fas.business.action.ContingencyAction;
import com.yeejoin.amos.fas.business.bo.BindPointBo;
import com.yeejoin.amos.fas.business.bo.CheckErrorBo;
import com.yeejoin.amos.fas.business.bo.RiskPointRpnChangeBo;
......@@ -47,6 +48,8 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static com.yeejoin.amos.fas.business.constants.FasConstant.token;
/**
* @author DELL
*/
......@@ -616,6 +619,13 @@ public class View3dServiceImpl implements IView3dService {
return pointList;
}
@Override
public Map<String, String> getDutyListByDate() {
ContingencyAction contingencyAction = new ContingencyAction();
Map<String, String> f1 = contingencyAction.getStrengthMap("F1");
return f1;
}
private List<Map<String,Object>> getPointsByRegionIds(List<Long> ids){
return view3dMapper.getAllPointInRegions(ids);
}
......
......@@ -173,4 +173,6 @@ public interface IView3dService {
* @return list
*/
List<Map<String, Object>> listPointsByRegionId(Long regionId, String type);
Map<String, String> getDutyListByDate();
}
package com.yeejoin.amos.fas.business.util;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.client.RestTemplate;
import static com.yeejoin.amos.fas.business.constants.FasConstant.*;
@Component
public class HttpUtil {
private ObjectMapper objectMapper = new ObjectMapper();
private static String dutyUrl;
@Value("${DutyMode.dutyUrl}")
public void setDutyUrl(String dutyUrl) {
HttpUtil.dutyUrl = dutyUrl;
}
public static String doGet(String url) {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(2000);
RestTemplate restTemplate = new RestTemplate(requestFactory);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_HTML);
httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> httpEntity = new HttpEntity(httpHeaders);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
return jsonObject.toString();
}
public static String PostJson(String url, String json) {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(2000);
RestTemplate restTemplate = new RestTemplate(requestFactory);
HttpHeaders headers = new HttpHeaders();
HttpMethod method = HttpMethod.POST;
// 以表单的方式提交
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.add("X-From-Service", "true");
//将请求头部和参数合成一个请求
HttpEntity<String> requestEntity = new HttpEntity<>(json, headers);
//执行HTTP请求,将返回的结构使用ResultVO类格式化
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
return jsonObject.toString();
}
public static String doPostJson(String url, String json) {
if (ObjectUtils.isEmpty(url)){
url = dutyUrl;
}
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(2000);
RestTemplate restTemplate = new RestTemplate(requestFactory);
HttpHeaders headers = new HttpHeaders();
HttpMethod method = HttpMethod.POST;
// 以表单的方式提交
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.set("appKey", appKey);
headers.set("product", product);
headers.set("token", token);
headers.set("orgCode", staticOrgCode);
headers.set("X-Access-Token", token);
//将请求头部和参数合成一个请求
HttpEntity<String> requestEntity = new HttpEntity<>(json, headers);
//执行HTTP请求,将返回的结构使用ResultVO类格式化
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
return jsonObject.toString();
}
public static String appendPostJson(String suffix,String json) {
String url = dutyUrl + suffix;
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(2000);
RestTemplate restTemplate = new RestTemplate(requestFactory);
HttpHeaders headers = new HttpHeaders();
HttpMethod method = HttpMethod.POST;
// 以表单的方式提交
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.set("appKey", appKey);
headers.set("product", product);
headers.set("token", token);
headers.set("orgCode", staticOrgCode);
headers.set("X-Access-Token", token);
//将请求头部和参数合成一个请求
HttpEntity<String> requestEntity = new HttpEntity<>(json, headers);
//执行HTTP请求,将返回的结构使用ResultVO类格式化
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
return jsonObject.toString();
}
}
......@@ -58,6 +58,7 @@ emqx.password=a123456
Push.fegin.name=APPMESSAGEPUSHSERVICE-36
dutyMode.fegin.name=AMOSDUTYMODE
DutyMode.dutyUrl=http://172.16.11.36:10005/
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
......
......@@ -59,6 +59,7 @@ emqx.password=a123456
Push.fegin.name=AMOS-PUSH
dutyMode.fegin.name=AMOS-DUTY
DutyMode.dutyUrl=http://172.16.11.36:10005/
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
......
......@@ -59,6 +59,7 @@ emqx.password=a123456
Push.fegin.name=PPMESSAGEPUSHSERVICE15
dutyMode.fegin.name=AMOS-DUTY
DutyMode.dutyUrl=http://172.16.11.36:10005/
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
......
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