Commit 66bc74c0 authored by maoying's avatar maoying

修改系统账号登陆信息存储

parent 028f276b
......@@ -26,6 +26,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -54,8 +55,8 @@ import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.util.CacheFactory;
import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.util.HttpUtil;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
@Component
......@@ -82,10 +83,6 @@ public class ContingencyAction implements CustomerAction {
private FireStengthService fireStrengthService;
@Autowired
private ContingencyLogPublisher contingencyLogPublisher;
// private RestTemplate restTemplate = new RestTemplate();
// @Value("${bussunis.domain}")
// private String bussunisDomain ;
@Autowired
private IRiskSourceService riskSourceService;
......@@ -103,6 +100,12 @@ public class ContingencyAction implements CustomerAction {
public static ConcurrentHashMap<String, Map<String, Object>> pointCache = new ConcurrentHashMap<>();
private static CacheMap cacheMap = CacheFactory.newChacheMap();
private static final String TOKE = "TOKE";
@Autowired
private RemoteSecurityService remoteSecurityService;
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
/* private static Map<String, String> positionMap = new HashMap<String, String>() {{
put("S1", "S1");
......@@ -127,9 +130,10 @@ public class ContingencyAction implements CustomerAction {
* A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6
*/
public Map<String, String> getStrengthMap(String batchNo) {
Map<String, String> returnMap = stringStringMap.get(batchNo);
public Map<String, String> getStrengthMap(ContingencyRo contingencyRo) {
String batchNo = contingencyRo.getBatchNo();
String orgCode = contingencyRo.getEquipmentOrgCode();
Map<String, String> returnMap = stringStringMap.get(contingencyRo.getBatchNo());
if (CollectionUtils.isEmpty(returnMap)) {
stringStringMap = new HashMap<>();
returnMap = new HashMap<>();
......@@ -137,11 +141,16 @@ public class ContingencyAction implements CustomerAction {
Date curDate = new Date();
JSONObject param = new JSONObject();
param.put("dutyDate", curDate);
//CommonResponse commonResponse = dutyModeServer.dutyListByDate(appKey, product, token, staticOrgCode, param.toJSONString());
Toke toke = remoteSecurityService.getServerToken();
CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString());
// String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString());
// JSONObject jsonObject = JSONObject.parseObject(result);
// JSONArray dataList = JSONObject.parseObject(commonResponse.getDataList().toString());
String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString());
JSONObject jsonObject = JSONObject.parseObject(result);
JSONArray dataList = (JSONArray) jsonObject.get("dataList");
String JSONStr = JSON.toJSONString(commonResponse.getDataList());
JSONArray dataList = JSONObject.parseArray(JSONStr);
log.info(String.format("请求值班系统返回dataList:%s", dataList));
if (!ObjectUtils.isEmpty(dataList)) {
......@@ -242,37 +251,6 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("steparea", contingencyRo, result);
}
// public static void main(String[] args) {
// SetpEnum[] stepArr = SetpEnum.values();
// Map<String, Object> tempmap1 = new HashMap<>();
// ArrayList list = new ArrayList();
// HashMap preStep = new HashMap();
// StepComparator comparator = new StepComparator();
// Arrays.sort(stepArr, comparator);
// boolean flage = false;
// SetpEnum pstep = null;
// for (SetpEnum step : stepArr) {
// if (Long.valueOf(step.getValue()) == Long.valueOf("3")) {
// if (!ObjectUtils.isEmpty(pstep)) {
// preStep.put("stepCode", pstep.getValue());
// preStep.put("stepName", pstep.getTitle());
// }
// flage = true;
// }
// if (flage) {
// HashMap map = new HashMap();
// map.put("stepCode", step.getValue());
// map.put("stepName", step.getTitle());
// list.add(map);
// }
// pstep = step;
// }
//
// tempmap1.put("step", list);
// tempmap1.put("preStep", preStep);
// log.info("巡检消息发送规则" + JSONObject.toJSONString(tempmap1));
// }
/**
* @param stepCode 当前步骤编号
* @param paramObj 预案对象
......@@ -366,15 +344,10 @@ public class ContingencyAction implements CustomerAction {
private String instedParams(String content, ContingencyRo contingencyRo) {
Map<String, String> strengthMap = this.getStrengthMap(contingencyRo.getBatchNo());
Map<String, String> strengthMap = this.getStrengthMap(contingencyRo);
for (String key : strengthMap.keySet())
content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key));
/* for (String key : positionMap.keySet())
c ontent = content.replaceAll("\\$\\{" + key + "}", positionMap.get(key));
*/
Field[] fields = contingencyRo.getClass().getDeclaredFields();
Method getMethod = null;
try {
......@@ -388,8 +361,6 @@ public class ContingencyAction implements CustomerAction {
}
content = getNative(content);
// content = content.replaceAll("\\$\\{", "");
// content = content.replaceAll("}", "");
} catch (Exception e) {
e.printStackTrace();
}
......@@ -450,16 +421,13 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("optionarea", paramObj, result);
// sendButton(contingencyRo.getBatchNo(), contingencyPlanId, contingencyRo.getEquipmentId(), actionName, buttonJson);
}
private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) {
// String url = bussunisDomain+ "/api/risksource/contingency/setup";
ObjectMapper objectMapper = new ObjectMapper();
//Map<String,Object> map = new HashMap<>();
/**
* batchNo
......@@ -473,14 +441,6 @@ public class ContingencyAction implements CustomerAction {
try {
Map button = objectMapper.readValue(buttonJson, Map.class);
Map operateInstance = (Map) ((List) button.get("operate")).get(0);
// map.put("batchNo",batchNo);
// map.put("actionName",actionName);
// map.put("equipmentId",equipmentId);
// map.put("stepCode",button.get("stepCode"));
// map.put("buttonCode",operateInstance.get("code"));
// map.put("confirm","CONFIRM");
// map.put("stepState",operateInstance.get("stepState"));
// map.put("contingencyPlanId",contingencyPlanId);
ContingencyDeviceStatus contingencyDeviceStatus = new ContingencyDeviceStatus();
contingencyDeviceStatus.setActionName(actionName);
contingencyDeviceStatus.setButtonCode(String.valueOf(operateInstance.get("code")));
......@@ -490,8 +450,6 @@ public class ContingencyAction implements CustomerAction {
contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode")));
contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState")));
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
//HttpEntity<Map> entity = new HttpEntity<>(map);
// restTemplate.exchange(url, HttpMethod.POST,entity,Map.class);
} catch (IOException e) {
e.printStackTrace();
......@@ -682,10 +640,6 @@ public class ContingencyAction implements CustomerAction {
redisTemplate.delete("contingencyRo");
}
private static CacheMap cacheMap = CacheFactory.newChacheMap();
private static final String TOKE = "TOKE";
@Autowired
private RemoteSecurityService remoteSecurityService;
@RuleMethod(methodLabel = "自动执行步骤", project = "青海换流站消防预案")
public void autoExecute(
......@@ -696,12 +650,14 @@ public class ContingencyAction implements CustomerAction {
@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "");
Toke toke = cacheMap.getValue(TOKE);
if (toke == null) {
toke = remoteSecurityService.come();
Long times = (long) (20 * 24 * 60 * 60);
cacheMap.setex(TOKE, toke, times);
}
Toke toke = remoteSecurityService.getServerToken();
// Toke toke = cacheMap.getValue(TOKE);
// if (toke == null) {
// toke = remoteSecurityService.come();
// Long times = (long) (20 * 24 * 60 * 60);
// cacheMap.setex(TOKE, toke, times);
// }
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
try {
......
......@@ -17,7 +17,7 @@ public class ContingencyRo implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1863437780244849215L;
private static final long serialVersionUID = -8687517896814257800L;
@Label("消防设备名称")
private String fireEquipmentName;//消防设备名称
@Label("消防设备id")
......@@ -35,6 +35,10 @@ public class ContingencyRo implements Serializable {
//负责人名称,手机号
@Label("重点设备id")
private String equipmentId;//重点设备id
@Label("重点设备组织编码")
private String equipmentOrgCode="10";//重点设备组织编码
@Label("重点设备名称")
private String equipmentName;
@Label("重点设备坐标")
......
......@@ -278,10 +278,4 @@ public class View3dController extends BaseController {
return CommonResponseUtil.success(view3dService.listPointsByRegionId(regionId,type));
}
@Permission
@ApiOperation(value = "预案人员测试方法",notes = "预案人员测试方法")
@GetMapping(value = "dutyListByDate")
public Map<String, String> getDutyListByDate(){
return view3dService.getDutyListByDate();
}
}
package com.yeejoin.amos.fas.business.feign;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.yeejoin.amos.fas.business.jpush.PushMsgParam;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
@Service("pushFeignServer")
public class PushFeignServer {
private final RestTemplate restTemplate;
public PushFeignServer() {
this.restTemplate = new RestTemplate();
}
@Value("${Push.fegin.name}")
private String RPushFeginName;
private static String sendMessage = "/api/user/sendMessage";
public String geturls(String url){
return "http://"+RPushFeginName+url;
}
public HttpHeaders getHeader(String toke,String product,String appKey){
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Content-Type", "application/json");
headers.set("token", toke);
headers.set("product",product);
headers.set("appKey", appKey);
return headers;
}
public CommonResponse sendMessage( String toke,String product,String appKey, List<PushMsgParam> pushMsgParam){
try {
HttpEntity httpEntity = new HttpEntity<>(pushMsgParam, getHeader( toke, product, appKey));
CommonResponse commonResponse1 = restTemplate.postForObject(geturls(sendMessage),httpEntity, CommonResponse.class);
return commonResponse1;
} catch (Exception e) {
e.printStackTrace();
return CommonResponseUtil.failure("发送失败");
}
}
}
//package com.yeejoin.amos.fas.business.feign;
//
//import java.util.List;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Service;
//import org.springframework.web.client.RestTemplate;
//
//import com.yeejoin.amos.fas.business.jpush.PushMsgParam;
//import com.yeejoin.amos.fas.core.util.CommonResponse;
//import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
//@Service("pushFeignServer")
//public class PushFeignServer {
// private final RestTemplate restTemplate;
//
// public PushFeignServer() {
// this.restTemplate = new RestTemplate();
// }
//
// @Value("${Push.fegin.name}")
// private String RPushFeginName;
// private static String sendMessage = "/api/user/sendMessage";
//
// public String geturls(String url){
// return "http://"+RPushFeginName+url;
// }
// public HttpHeaders getHeader(String toke,String product,String appKey){
// HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.APPLICATION_JSON);
// headers.set("Content-Type", "application/json");
// headers.set("token", toke);
// headers.set("product",product);
// headers.set("appKey", appKey);
// return headers;
// }
//
// public CommonResponse sendMessage( String toke,String product,String appKey, List<PushMsgParam> pushMsgParam){
// try {
// HttpEntity httpEntity = new HttpEntity<>(pushMsgParam, getHeader( toke, product, appKey));
// CommonResponse commonResponse1 = restTemplate.postForObject(geturls(sendMessage),httpEntity, CommonResponse.class);
// return commonResponse1;
// } catch (Exception e) {
// e.printStackTrace();
// return CommonResponseUtil.failure("发送失败");
//
// }
// }
//}
package com.yeejoin.amos.fas.business.feign;
import com.yeejoin.amos.fas.business.action.model.BasicsRo;
import com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo;
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
//import com.yeejoin.amos.op.core.util.ApplicationConfig;
//import com.yeejoin.amos.op.core.util.Constants;
import com.yeejoin.amos.fas.business.util.Constants;
import com.yeejoin.amos.fas.business.util.JSONUtil;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
/**
* <pre>
* 规则模型系统远程调用
* </pre>
*
* @author amos
* @version $Id: RemoteRuleServer.java, v 0.1 2019年5月7日 下午5:52:21 amos Exp $
*/
@Service("remoteRuleServer")
public class RemoteRuleServer {
/* @Autowired
private ApplicationConfig applicationConfig;*/
@Value("${params.remoteRuleUrl}")
private String remoteRuleUrl;
private final RestTemplate restTemplate;
private final Logger log = LoggerFactory.getLogger(RemoteRuleServer.class);
private ObjectMapper objectMapper = new ObjectMapper();
public RemoteRuleServer() {
this.restTemplate = new RestTemplate();
}
/**
* 触发风险点规则
*/
public Object fireRule(RiskSourceRuleRo riskSourceRuleRo, String packageId) throws Exception {
Map<String, String> map = new HashMap<>();
String data = JSONUtil.toJson(riskSourceRuleRo);
log.info(data);
map.put("resFact", data);
map.put("packageId", packageId);
map.put("className", riskSourceRuleRo.getClass().getName());
/*String url = applicationConfig.getParamValueStr("params.remoteRuleUrl");*/
String url =remoteRuleUrl;
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<Map<String, String>> formEntity = new HttpEntity<>(map, headers);
ResponseEntity responseEntity = restTemplate.exchange(url + "urule/rule/fireRule",
HttpMethod.POST, formEntity, String.class);
responseEntity.getBody();
Map commonResponse = objectMapper.readValue(responseEntity.getBody().toString(), Map.class);
if (commonResponse != null && commonResponse.get("result").equals(Constants.RESULT_SUCCESS)) {
log.info("调用规则服务成功,请求参数:" + formEntity.toString());
return commonResponse.get("dataList");
}
return null;
}
/**
* <pre>
* 触发规则流
* </pre>
*
* @param resFact 触发规则对象
* @param packageId 规范规则包
* @param processId 规则流id
* @return
*/
public Object fireRuleFlow(BasicsRo resFact, String packageId, String processId) throws Exception {
String data = JSONUtil.toJson(resFact);
log.info("调用规则请求====================>" + data);
Map<String, String> map = new HashMap<String, String>();
map.put("resFact", data);
map.put("packageId", packageId);
map.put("processId", processId);
map.put("className", resFact.getClass().getName());
//String url = applicationConfig.getParamValueStr("params.remoteRuleUrl");
String url =remoteRuleUrl;
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType
.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<Map<String, String>> formEntity = new HttpEntity<Map<String, String>>(map, headers);
ResponseEntity responseEntity = restTemplate.exchange(url + "urule/rule/fireRuleFlow",
HttpMethod.POST, formEntity, String.class);
Map commonResponse = objectMapper.readValue(responseEntity.getBody().toString(), Map.class);
if (commonResponse != null && commonResponse.get("result").equals(Constants.RESULT_SUCCESS)) {
return commonResponse.get("dataList");
}
return null;
}
public Object autoProcessContingency(ContingencyDeviceStatus contingencyDeviceStatus) throws Exception {
Map<String, String> map = new HashMap<String, String>();
// String url = applicationConfig.getParamValueStr("params.remoteRuleUrl");
String url =remoteRuleUrl;
// String url = "http://172.16.10.70:8080/";
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType
.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<Map<String, String>> formEntity = new HttpEntity<Map<String, String>>(map, headers);
String urlParams = "batchNo=%s&stepCode=%s&buttonCode=%s&confirm=%s&contingencyPlanId=%s&stepState=%s";
String.format(urlParams,
contingencyDeviceStatus.getButtonCode(),
contingencyDeviceStatus.getStepCode(),
contingencyDeviceStatus.getConfirm(),
contingencyDeviceStatus.getContingencyPlanId(),
contingencyDeviceStatus.getStepState());
ResponseEntity responseEntity = restTemplate.exchange(url + "/api/timeline/fire?" + urlParams,
HttpMethod.PUT, formEntity, String.class);
Map commonResponse = objectMapper.readValue(responseEntity.getBody().toString(), Map.class);
if (commonResponse != null && commonResponse.get("result").equals(Constants.RESULT_SUCCESS)) {
return commonResponse.get("dataList");
}
return null;
}
}
\ No newline at end of file
//package com.yeejoin.amos.fas.business.feign;
//
//import com.yeejoin.amos.fas.business.action.model.BasicsRo;
//import com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo;
//import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
////import com.yeejoin.amos.op.core.util.ApplicationConfig;
////import com.yeejoin.amos.op.core.util.Constants;
//import com.yeejoin.amos.fas.business.util.Constants;
//import com.yeejoin.amos.fas.business.util.JSONUtil;
//
//import org.codehaus.jackson.map.ObjectMapper;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.HttpMethod;
//import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity;
//import org.springframework.stereotype.Service;
//import org.springframework.web.client.RestTemplate;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * <pre>
// * 规则模型系统远程调用
// * </pre>
// *
// * @author amos
// * @version $Id: RemoteRuleServer.java, v 0.1 2019年5月7日 下午5:52:21 amos Exp $
// */
//@Service("remoteRuleServer")
//public class RemoteRuleServer {
//
// /* @Autowired
// private ApplicationConfig applicationConfig;*/
// @Value("${params.remoteRuleUrl}")
// private String remoteRuleUrl;
//
// private final RestTemplate restTemplate;
//
// private final Logger log = LoggerFactory.getLogger(RemoteRuleServer.class);
//
// private ObjectMapper objectMapper = new ObjectMapper();
//
// public RemoteRuleServer() {
// this.restTemplate = new RestTemplate();
// }
//
// /**
// * 触发风险点规则
// */
// public Object fireRule(RiskSourceRuleRo riskSourceRuleRo, String packageId) throws Exception {
// Map<String, String> map = new HashMap<>();
// String data = JSONUtil.toJson(riskSourceRuleRo);
// log.info(data);
// map.put("resFact", data);
// map.put("packageId", packageId);
// map.put("className", riskSourceRuleRo.getClass().getName());
// /*String url = applicationConfig.getParamValueStr("params.remoteRuleUrl");*/
// String url =remoteRuleUrl;
// HttpHeaders headers = new HttpHeaders();
// MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
// headers.setContentType(type);
// headers.add("Accept", MediaType.APPLICATION_JSON.toString());
// HttpEntity<Map<String, String>> formEntity = new HttpEntity<>(map, headers);
// ResponseEntity responseEntity = restTemplate.exchange(url + "urule/rule/fireRule",
// HttpMethod.POST, formEntity, String.class);
//
// responseEntity.getBody();
// Map commonResponse = objectMapper.readValue(responseEntity.getBody().toString(), Map.class);
// if (commonResponse != null && commonResponse.get("result").equals(Constants.RESULT_SUCCESS)) {
// log.info("调用规则服务成功,请求参数:" + formEntity.toString());
// return commonResponse.get("dataList");
// }
// return null;
// }
//
// /**
// * <pre>
// * 触发规则流
// * </pre>
// *
// * @param resFact 触发规则对象
// * @param packageId 规范规则包
// * @param processId 规则流id
// * @return
// */
// public Object fireRuleFlow(BasicsRo resFact, String packageId, String processId) throws Exception {
// String data = JSONUtil.toJson(resFact);
// log.info("调用规则请求====================>" + data);
// Map<String, String> map = new HashMap<String, String>();
// map.put("resFact", data);
// map.put("packageId", packageId);
// map.put("processId", processId);
// map.put("className", resFact.getClass().getName());
// //String url = applicationConfig.getParamValueStr("params.remoteRuleUrl");
// String url =remoteRuleUrl;
// HttpHeaders headers = new HttpHeaders();
// MediaType type = MediaType
// .parseMediaType("application/json; charset=UTF-8");
// headers.setContentType(type);
// headers.add("Accept", MediaType.APPLICATION_JSON.toString());
// HttpEntity<Map<String, String>> formEntity = new HttpEntity<Map<String, String>>(map, headers);
// ResponseEntity responseEntity = restTemplate.exchange(url + "urule/rule/fireRuleFlow",
// HttpMethod.POST, formEntity, String.class);
//
//
// Map commonResponse = objectMapper.readValue(responseEntity.getBody().toString(), Map.class);
// if (commonResponse != null && commonResponse.get("result").equals(Constants.RESULT_SUCCESS)) {
// return commonResponse.get("dataList");
// }
// return null;
// }
//
//
// public Object autoProcessContingency(ContingencyDeviceStatus contingencyDeviceStatus) throws Exception {
// Map<String, String> map = new HashMap<String, String>();
//
// // String url = applicationConfig.getParamValueStr("params.remoteRuleUrl");
// String url =remoteRuleUrl;
// // String url = "http://172.16.10.70:8080/";
// HttpHeaders headers = new HttpHeaders();
// MediaType type = MediaType
// .parseMediaType("application/json; charset=UTF-8");
// headers.setContentType(type);
// headers.add("Accept", MediaType.APPLICATION_JSON.toString());
// HttpEntity<Map<String, String>> formEntity = new HttpEntity<Map<String, String>>(map, headers);
// String urlParams = "batchNo=%s&stepCode=%s&buttonCode=%s&confirm=%s&contingencyPlanId=%s&stepState=%s";
// String.format(urlParams,
// contingencyDeviceStatus.getButtonCode(),
// contingencyDeviceStatus.getStepCode(),
// contingencyDeviceStatus.getConfirm(),
// contingencyDeviceStatus.getContingencyPlanId(),
// contingencyDeviceStatus.getStepState());
// ResponseEntity responseEntity = restTemplate.exchange(url + "/api/timeline/fire?" + urlParams,
// HttpMethod.PUT, formEntity, String.class);
//
//
// Map commonResponse = objectMapper.readValue(responseEntity.getBody().toString(), Map.class);
// if (commonResponse != null && commonResponse.get("result").equals(Constants.RESULT_SUCCESS)) {
// return commonResponse.get("dataList");
// }
// return null;
// }
//}
\ No newline at end of file
......@@ -6,16 +6,25 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Joiner;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.config.TokenOperation;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.fas.business.util.CacheFactory;
import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.exception.PermissionException;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.*;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.ArrayList;
......@@ -23,6 +32,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service("remoteSecurityService")
......@@ -37,10 +47,11 @@ public class RemoteSecurityService {
private String appKeyWeb;
@Autowired
private RedisTemplate<String, String> redisTemplate;
//根据公司名称获取公司人
public List<CompanyModel> listCompanyTree(String toke,String product,String appKey,String companyName) {
// CommonResponse commonResponse = iAmosSecurityServer.listCompanyTree();
//return handleArray(commonResponse, CompanyBo.class);
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
......@@ -61,9 +72,6 @@ public class RemoteSecurityService {
if (deparmentId == null || deparmentId.equals("")) {
return null;
}
// CommonResponse commonResponse = iAmosSecurityServer.getDepartmentByDeptId(deparmentId);
// return handleObj(commonResponse, DepartmentBo.class);
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
......@@ -97,8 +105,6 @@ public class RemoteSecurityService {
}
return departmentModel;
//CommonResponse commonResponse = iAmosSecurityServer.listDepartmentsByCompanyId(companyId);
//return handleArray(commonResponse, DepartmentBo.class);
}
// * 根据公司id查询机构用户
public List<AgencyUserModel> listUserByCompanyId(String toke,String product,String appKey,String companyId) {
......@@ -144,26 +150,45 @@ public class RemoteSecurityService {
return agencyUserModel;
}
public Toke come() {
public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel=new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(password);
Map map=null;
FeignClientResult feignClientResult;
Toke oked=new Toke();
Toke toke = null;
try {
RequestContext.setProduct(productWeb);
feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
map = (Map) feignClientResult.getResult();
if(map!=null){
oked.setToke(map.get("token").toString());
oked.setProduct(productWeb);
oked.setAppKey(appKeyWeb);
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if(ObjectUtils.isEmpty(toke)){
toke = getLogin(dPasswordAuthModel);
}else{
if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
}
} catch (InnerInvokException e) {
e.printStackTrace();
}
return oked;
return toke;
}
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel){
Toke toke = new Toke();
RequestContext.setProduct(productWeb);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult();
if(map!=null){
toke.setToke(map.get("token").toString());
toke.setProduct(productWeb);
toke.setAppKey(appKeyWeb);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke),28,TimeUnit.DAYS);
}
return toke;
}
//redi缓存系统用户token信息
private String buildKey(String username) {
return "system_" + username;
}
/**
......
package com.yeejoin.amos.fas.business.jpush;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import cn.jpush.api.push.model.PushPayload;
@Service
public class AppMessagePushService {
protected static final Logger log = LoggerFactory.getLogger(AppMessagePushService.class);
/*
@Value("${params.isPush}")
private String isPush;
private static final String APP_KEY = "1b3f7b961200f4b236811dfe";
private static final String MASTER_SECRET = "8b650e645fb3a43c96be02b2";
private static JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
*/
@Autowired
private com.yeejoin.amos.fas.business.feign.PushFeign PushFeign;
// public void sendMessage(List<PushMsgParam> responses) {
// try {
// if (responses != null && "true".equals(isPush)) {
// for (PushMsgParam response : responses) {
// PushPayload payload = buildPushPayload(response);
// jpushClient.sendPush(payload);
// }
// }
// } catch (Exception e) {
// log.error("极光推送异常", e);
// }
// }
private PushPayload buildPushPayload(PushMsgParam response) {
CommonResponse commonResponse = PushFeign.buildPushPayload(response);
return (PushPayload)commonResponse.getDataList();
// if (JPushTypeEnum.ALL.getCode().equals(response.getType())) {
// return PushPayload.newBuilder()
// .setPlatform(Platform.android())
// .setAudience(Audience.all())
// .setNotification(Notification.android(response.getContent(), response.getSubject(), response.getExtras()))
// .build();
// } else if (JPushTypeEnum.TAG.getCode().equals(response.getType())) {
// return PushPayload.newBuilder()
// .setPlatform(Platform.android())
// .setAudience(Audience.tag(response.getRecivers()))
// .setNotification(Notification.android(response.getContent(), response.getSubject(), response.getExtras()))
// .build();
// } else {
// return PushPayload.newBuilder()
// .setPlatform(Platform.android())
// .setAudience(Audience.alias(response.getRecivers()))
// .setNotification(Notification.android(response.getContent(), response.getSubject(), response.getExtras()))
// .build();
// }
}
public void sendMessage(PushMsgParam response) {
......
......@@ -31,7 +31,6 @@ import com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper;
import com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository;
import com.yeejoin.amos.fas.business.feign.RemoteRuleServer;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import com.yeejoin.amos.fas.business.service.model.Operate;
import com.yeejoin.amos.fas.business.service.model.OperateGroup;
......@@ -51,9 +50,6 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
IContingencyOriginalDataDao iContingencyOriginalDataDao;
@Autowired
private RemoteRuleServer remoteRuleServer;
@Autowired
private RestTemplate restTemplate;
@Autowired
......
......@@ -53,6 +53,7 @@ public class DataRefreshServiceImpl implements IDataRefreshService {
remoteWebSocketServer.sendMessage("3dViewMessage", JSON.toJSONString(param));
} catch (Exception e) {
log.error("通知前端数据刷新失败-->"+JSON.toJSONString(param));
log.error("通知前端数据刷新失败-->"+e.getMessage());
}
}
}
package com.yeejoin.amos.fas.business.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import com.google.common.base.Joiner;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.fas.business.action.model.RiskSourceRo;
import com.yeejoin.amos.fas.business.dao.mapper.FmeaEquipmentPointMapper;
import com.yeejoin.amos.fas.business.dao.mapper.FmeaMapper;
......@@ -11,7 +26,6 @@ import com.yeejoin.amos.fas.business.dao.repository.IFmeaDao;
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.feign.RemoteRuleServer;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
import com.yeejoin.amos.fas.business.service.intfc.IFmeaService;
......@@ -20,20 +34,8 @@ import com.yeejoin.amos.fas.dao.entity.Fmea;
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.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.bouncycastle.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Service("fmeaService")
public class FmeaServiceImpl implements IFmeaService {
......@@ -120,26 +122,6 @@ public class FmeaServiceImpl implements IFmeaService {
}
// public void updateRpniInfo(Long riskSourceId) {
//
//
// new Thread(() ->
// {
// String batchNo = UUID.randomUUID().toString();
//
// List<RiskSource> riskSources = new ArrayList<>();
//
// RiskSource riskSource = this.iRiskSourceDao.findById(riskSourceId);
// riskSources.add(riskSource);
// try {
// asymbleWithParent(batchNo, riskSources, RiskFactor.class.getSimpleName());
// } catch (Exception e) {
// e.printStackTrace();
// }
// }).start();
//
// }
@Override
public int queryControlObjCount(String[] ids) {
int count1 = iFmeaDao.countAssociatedEquipPointByIds(ids);
......@@ -150,48 +132,6 @@ public class FmeaServiceImpl implements IFmeaService {
return 0;//没有关联对象
}
// private boolean asymbleWithParent(String bacthNo, List<RiskSource> riskSourceList, String from) throws Exception {
// if (!CollectionUtils.isEmpty(riskSourceList)) {
// for (RiskSource riskSource : riskSourceList) {
// //当前规则
// RiskSourceRo riskSourceRo = this.transfer(bacthNo, riskSource, from, new BigDecimal(0));
//
// Object result = remoteRuleServer.fireRule(riskSourceRo, "风险管控/riskFactor");
// BigDecimal RPNi = updateRpn(result, riskSource, null);
// //处理返回结果
//
// //反查 父级风险点,取得处于第二级的父级风险点
// findParent(bacthNo, riskSource, RPNi);
// }
// }
// return true;
// }
// /**
// * 查询父节点风险点
// *
// * @param riskSource
// * @param RPNi
// * @return
// */
// private BigDecimal findParent(String bacthNo, RiskSource riskSource,
// BigDecimal RPNi) throws Exception {
// if (riskSource != null && riskSource.getId() != 0 && RPNi.doubleValue() != 0) {
// RiskSource parent = this.iRiskSourceDao.findOne(riskSource.getParentId());
// if (null != parent) {
// RiskSourceRo parentRiskResource = this.transfer(bacthNo, parent, "child", RPNi);
// Object result = remoteRuleServer.fireRule(parentRiskResource, "风险管控/riskFactorParent");
// updateRpn(result, parent, RPNi);
//
// if (parent.getParentId() != 0)
// this.findParent(bacthNo, parent, RPNi);
// }
// }
//
// return RPNi;
// }
private RiskSourceRo transfer(String bacthNo, RiskSource riskSource, String from, BigDecimal rpni) {
RiskSourceRo riskSourceRo = new RiskSourceRo();
......
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;
......@@ -8,13 +49,40 @@ 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.*;
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.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.bo.*;
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.constants.FasConstant;
import com.yeejoin.amos.fas.business.dao.mapper.*;
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.mongo.EquipCommunicationDao;
import com.yeejoin.amos.fas.business.dao.repository.*;
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.feign.IEquipManageFeign;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.feign.RemoteWebSocketServer;
......@@ -29,7 +97,11 @@ 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.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.util.*;
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.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.client.invoke.RsDataQueue;
......@@ -41,39 +113,24 @@ 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.*;
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.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")
......@@ -556,19 +613,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo.setEquipmentName(equipment.getName());
contingencyRo.setFireEquipmentId(String.valueOf(fireEquipment.getId()));
contingencyRo.setFireEquipmentName(fireEquipment.getName());
// if (ObjectUtils.isEmpty(oldContingencyRo)) {
// contingencyRo.setStep(SetpEnum.STEP0.getValue());
// } else {
// contingencyRo.setStep(((ContingencyRo)oldContingencyRo).getStep());
// }
contingencyRo.setStep(SetpEnum.STEP0.getValue());
contingencyRo.setConfirm("NONE");
contingencyRo.setFireTruckRoute(equipment.getFireTruckRoute());
contingencyRo.setRunstep(false);
contingencyRo.setEquipmentPosition3d(equipment.getPosition3d());
contingencyRo.setEquipmentCode(equipment.getCode());
contingencyRo.setEquipmentOrgCode(equipment.getOrgCode());
Map cameraInfo = impAndFireEquipMapper.queryForCamera(String.valueOf(equipment.getId()));
......@@ -702,7 +753,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public boolean processTaskData(ProtalDataRo taskData) throws Exception {
taskData.setBatchNo(UUID.randomUUID().toString());
//Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
return true;
}
......@@ -856,14 +906,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
log.warn("alarmParam is empty!");
} else {
try {
Toke toke = cacheMap.getValue(TOKE);
if (toke == null) {
toke = remoteSecurityService.come();
Long times = (long) (20 * 24 * 60 * 60);
cacheMap.setex(TOKE, toke, times);
}
log.error("rule token ", toke.toString());
processDeivceData(deviceData,toke);
// Toke toke = cacheMap.getValue(TOKE);
// if (toke == null) {
// toke = remoteSecurityService.come();
// Long times = (long) (20 * 24 * 60 * 60);
// cacheMap.setex(TOKE, toke, times);
// }
// log.error("rule token ", toke.toString());
processDeivceData(deviceData);
} catch (Exception e) {
log.error("parse alarmParam happened error", e);
// 失败处理
......@@ -875,10 +926,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
private void processDeivceData(AlarmParam deviceData, Toke toke) {
private void processDeivceData(AlarmParam deviceData) {
//处理设备和巡检数据
deviceData.setNodeState(deviceData.getState());
FireEquipmentPoint fireEquipmentPoint = iFireEquipmentPointDao.findOneByCode(deviceData.getPointCode());
if(!ObjectUtils.isEmpty(fireEquipmentPoint)){
fireEquipmentPoint.setValue(deviceData.getState());
updateFirePointValue(fireEquipmentPoint.getId(), deviceData.getState());
......@@ -897,7 +950,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Equipment equipment = null;
if (fireEquipment != null) {
Toke toke = remoteSecurityService.getServerToken();
//保存实时数据
// 根据监测点设备信息获取保护的重点装备
equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId());
......@@ -915,10 +968,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
//动态预案执行
dynamicPlan(deviceData, equipment, fireEquipment,toke);
}
}
}
}
/**
* 预案执行
*
......@@ -1017,9 +1071,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
deviceData.setMonitor(equipment.getName());
deviceData.setEquimentId(String.valueOf(equipment.getId()));
//Object result = remoteRuleServer.fireRule(deviceData, "风险管控/fireEquiment");
//处理返回结果
List<RiskSource> riskSources = this.riskSourceMapper.queryByFireEqument(deviceData.getFireEquimentId());
//asymbleWithParent(batchNo, riskSources, FireEquimentDataRo.class.getSimpleName(), deviceData.getFireEquimentId(), deviceData.getNodeState(), null, null);
......
......@@ -661,12 +661,6 @@ 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);
......
......@@ -174,5 +174,4 @@ public interface IView3dService {
*/
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();
}
}
//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();
// }
//}
......@@ -103,13 +103,14 @@ public class RsDataQueue {
FmeaMessage fmeaMessage = blockingQueue.take();
if (riskSourceService != null) {
//获取缓存
CacheMap cacheMap = CacheFactory.newChacheMap();
Toke toke = cacheMap.getValue(TOKE);
if (toke == null) {
toke = remoteSecurityService.come();
Long times = (long) (20 * 24 * 60 * 60);
cacheMap.setex(TOKE, toke, times);
}
Toke toke = remoteSecurityService.getServerToken();
// CacheMap cacheMap = CacheFactory.newChacheMap();
// Toke toke = cacheMap.getValue(TOKE);
// if (toke == null) {
// toke = remoteSecurityService.come();
// Long times = (long) (20 * 24 * 60 * 60);
// cacheMap.setex(TOKE, toke, times);
// }
String from = fmeaMessage.getNorifyFrom();
Long handId = fmeaMessage.getHandId();
String userName = fmeaMessage.getUserName();
......
......@@ -28,7 +28,7 @@ spring.data.mongodb.uri = mongodb://172.16.11.33:27017/iecmonitor
#rule
#params.remoteRuleUrl=http://172.16.3.3:8080/
params.remoteRuleUrl=http://magintursh.xicp.net:18080/
params.remoteWebsocketUrl=http://172.16.10.72:10600/
params.remoteWebsocketUrl=http://172.16.11.36:10600/
spring.redis.database=0
spring.redis.host=172.16.10.85
......@@ -56,14 +56,15 @@ emqx.password=a123456
Push.fegin.name=APPMESSAGEPUSHSERVICE-36
dutyMode.fegin.name=AMOSDUTYMODE
DutyMode.dutyUrl=http://172.16.10.72:10005/
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
rule.definition.model-package=com.yeejoin.amos.fas.business.action.model
rule.definition.default-agency=STATE_GRID
#Fegin service config
amos.feign.gennerator.use-gateway=true
autoSys.push.type=mqtt
#�����
......
......@@ -55,8 +55,7 @@ emqx.user-name=super
emqx.password=a123456
Push.fegin.name=AMOS-PUSH
dutyMode.fegin.name=AMOS-DUTY
DutyMode.dutyUrl=http://172.16.11.36:10005/
dutyMode.fegin.name=AMOSDUTYMODE
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
......
......@@ -55,8 +55,7 @@ emqx.user-name=super
emqx.password=a123456
Push.fegin.name=PPMESSAGEPUSHSERVICE15
dutyMode.fegin.name=AMOS-DUTY
DutyMode.dutyUrl=http://172.16.11.36:10005/
dutyMode.fegin.name=AMOSDUTYMODE
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true
......
spring.application.name = AMOS-AUTOSYS
spring.application.name = Amos-autosys
server.port = 8083
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment