Commit 6b621fd7 authored by suhuiguang's avatar suhuiguang

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

parents 1ff71201 0018fa6d
...@@ -7,6 +7,7 @@ public class SafetyExecuteBo { ...@@ -7,6 +7,7 @@ public class SafetyExecuteBo {
private String label; private String label;
private String pointId; private String pointId;
private String type; private String type;
private String status;//指标状态
private String changeDate; private String changeDate;
public Long getId() { public Long getId() {
return id; return id;
...@@ -44,4 +45,10 @@ public class SafetyExecuteBo { ...@@ -44,4 +45,10 @@ public class SafetyExecuteBo {
public void setChangeDate(String changeDate) { public void setChangeDate(String changeDate) {
this.changeDate = changeDate; this.changeDate = changeDate;
} }
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
} }
...@@ -12,6 +12,8 @@ import com.yeejoin.amos.fas.core.util.CommonResponseUtil; ...@@ -12,6 +12,8 @@ import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Authorization;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
......
...@@ -74,6 +74,14 @@ public interface View3dMapper extends BaseMapper{ ...@@ -74,6 +74,14 @@ public interface View3dMapper extends BaseMapper{
*/ */
List<CheckErrorBo> getAllErrorPatrolPoint(Map<String, Object> params); List<CheckErrorBo> getAllErrorPatrolPoint(Map<String, Object> params);
/**
* 今日安全指数故障告警详情
* @param params orgCode,date
* @return list
*/
List<CheckErrorBo> getAllFaultAlarm(Map<String, Object> params);
/** /**
* 今日巡检统计接口 * 今日巡检统计接口
* @param orgCode * @param orgCode
...@@ -96,6 +104,20 @@ public interface View3dMapper extends BaseMapper{ ...@@ -96,6 +104,20 @@ public interface View3dMapper extends BaseMapper{
List<SafetyExecuteBo> getCheckErrorTop5(String orgCode); List<SafetyExecuteBo> getCheckErrorTop5(String orgCode);
/** /**
* 火灾告警最新5条
* @param orgCode
* @return
*/
List<SafetyExecuteBo> getFireAlarmTop5(String orgCode);
/**
* 设备状态最新5条
* @param orgCode
* @return
*/
List<SafetyExecuteBo> getEquipStatusTop5(String orgCode);
/**
* 按照类型查询点 * 按照类型查询点
* @param params {orgCode,type} * @param params {orgCode,type}
* @return 列表 * @return 列表
......
...@@ -22,6 +22,7 @@ import java.util.stream.Collectors; ...@@ -22,6 +22,7 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -768,14 +769,25 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -768,14 +769,25 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Equipment equipment = null; Equipment equipment = null;
if (fireEquipment != null) { if (fireEquipment != null) {
deviceData.setCode(fireEquipment.getCode()); deviceData.setCode(fireEquipment.getCode());
equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId()); //保存实时数据
//报警数据存库
saveFireEquipmentData(fireEquipmentPoint, fireEquipment, deviceData, fireEquipmentPointType); saveFireEquipmentData(fireEquipmentPoint, fireEquipment, deviceData, fireEquipmentPointType);
List<AlarmParam> list = new ArrayList<>(); equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId());
list.add(deviceData);
//保存到mongo
saveData(list, "soe");
if (equipment != null) { if (equipment != null) {
//动态预案执行
dynamicPlan(deviceData, equipment, fireEquipment, fireEquipmentPointType);
}
}
}
/**
* 预案执行
* @param deviceData
* @param equipment
* @param fireEquipment
* @param fireEquipmentPointType
*/
@Async
private void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment, String fireEquipmentPointType){
String batchNo = null; String batchNo = null;
Object batch = null; Object batch = null;
Dict dict = null; Dict dict = null;
...@@ -806,7 +818,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -806,7 +818,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
Object canBeRunning = redisTemplate.opsForValue().get(cacheKeyForCanBeRunning()); Object canBeRunning = redisTemplate.opsForValue().get(cacheKeyForCanBeRunning());
if (canBeRunning == null) { if (canBeRunning == null) {
try { try {
alermContingency(batchNo, fireEquipment, equipment); alermContingency(batchNo, fireEquipment, equipment);
} catch (Exception e) { } catch (Exception e) {
...@@ -818,14 +829,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -818,14 +829,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
redisTemplate.opsForHash().put("currentContingency", "batchNo", batchNo); redisTemplate.opsForHash().put("currentContingency", "batchNo", batchNo);
redisTemplate.opsForHash().put("currentContingency", "contingencyPlan", null); redisTemplate.opsForHash().put("currentContingency", "contingencyPlan", null);
redisTemplate.opsForHash().put("currentContingency", "alarmType", null); redisTemplate.opsForHash().put("currentContingency", "alarmType", null);
//通知刷新3d页面告警数据
iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode());
} else { } else {
if ("alarm_type_trouble".equals(fireEquipmentPointType)) {
notifyAlarm(fireEquipmentPoint, deviceData);
//通知刷新3d页面相关故障数据
iDataRefreshService.refreshViewData(DataRefreshTypeEum.trouble.getCode());
}
String alarmType = (String) redisTemplate.opsForHash().get("currentContingency", "alarmType"); String alarmType = (String) redisTemplate.opsForHash().get("currentContingency", "alarmType");
if (!ObjectUtils.isEmpty(alarmType) && dict.getDictValue().equals(alarmType)) { if (!ObjectUtils.isEmpty(alarmType) && dict.getDictValue().equals(alarmType)) {
ContingencyDeviceStatus contingencyDeviceStatus = (ContingencyDeviceStatus) redisTemplate.opsForHash().get("currentContingency", "contingencyPlan"); ContingencyDeviceStatus contingencyDeviceStatus = (ContingencyDeviceStatus) redisTemplate.opsForHash().get("currentContingency", "contingencyPlan");
...@@ -834,8 +838,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -834,8 +838,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
} }
} }
}
}
@Override @Override
@javax.transaction.Transactional @javax.transaction.Transactional
...@@ -846,7 +848,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -846,7 +848,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private void saveFireEquipmentData(FireEquipmentPoint fireEquipmentPoint, FireEquipment fireEquipment, AlarmParam deviceData, String fireEquipmentPointType) { private void saveFireEquipmentData(FireEquipmentPoint fireEquipmentPoint, FireEquipment fireEquipment, AlarmParam deviceData, String fireEquipmentPointType) {
if("alarm_type_fire".equals(fireEquipmentPointType) || "alarm_type_trouble".equals(fireEquipmentPointType)){ if("alarm_type_fire".equals(fireEquipmentPointType) || "alarm_type_trouble".equals(fireEquipmentPointType)){
Alarm alarm = iAlarmDao.findByStatusTrueAndFireEquipmentPointCode(deviceData.getPointCode()); Alarm alarm = iAlarmDao.findByStatusTrueAndFireEquipmentPointCode(deviceData.getPointCode());
if(alarm != null){ if(alarm != null){
...@@ -858,7 +859,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -858,7 +859,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
alarm.setFrequency((alarm.getFrequency()+1)); alarm.setFrequency((alarm.getFrequency()+1));
alarm.setUpdateDate(new Date()); alarm.setUpdateDate(new Date());
} }
iAlarmDao.save(alarm);
}else{ }else{
if("true".equals(deviceData.getState())){
alarm = new Alarm(); alarm = new Alarm();
alarm.setFireEquipmentCode(fireEquipment.getCode()); alarm.setFireEquipmentCode(fireEquipment.getCode());
alarm.setFireEquipmentId(fireEquipment.getId()); alarm.setFireEquipmentId(fireEquipment.getId());
...@@ -869,9 +872,23 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -869,9 +872,23 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
alarm.setFireEquipmentPointValue(deviceData.getState()); alarm.setFireEquipmentPointValue(deviceData.getState());
alarm.setOrgCode(fireEquipment.getOrgCode()); alarm.setOrgCode(fireEquipment.getOrgCode());
alarm.setType(fireEquipmentPointType); alarm.setType(fireEquipmentPointType);
}
iAlarmDao.save(alarm); iAlarmDao.save(alarm);
}
}
if(alarm != null){
if ("alarm_type_trouble".equals(fireEquipmentPointType)) {
//通知刷新3d页面相关故障数据
if(alarm.getFrequency()==1 || alarm.getStatus() == false){
notifyAlarm(fireEquipmentPoint, deviceData);
iDataRefreshService.refreshViewData(DataRefreshTypeEum.trouble.getCode());
}
}else{ }else{
//通知刷新3d页面告警数据
iDataRefreshService.refreshViewData(DataRefreshTypeEum.alarm.getCode());
}
}
}else{
if("SWITCH".equals(fireEquipmentPoint.getType())){ //保存遥信信号数据到mysql中
FireEquipmentData fireEquipmentData = new FireEquipmentData(); FireEquipmentData fireEquipmentData = new FireEquipmentData();
fireEquipmentData.setEqPointCode(deviceData.getPointCode()); fireEquipmentData.setEqPointCode(deviceData.getPointCode());
fireEquipmentData.seteValue(deviceData.getState()); fireEquipmentData.seteValue(deviceData.getState());
...@@ -889,9 +906,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -889,9 +906,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
content.put("label", fireEquipmentData.getEqPointName()); content.put("label", fireEquipmentData.getEqPointName());
content.put("changeDate", fireEquipmentData.getCreateDate()); content.put("changeDate", fireEquipmentData.getCreateDate());
content.put("orgCode", fireEquipment.getOrgCode()); content.put("orgCode", fireEquipment.getOrgCode());
content.put("status", deviceData.getSoe());
iDataRefreshService.sendRefreshDataWithArea(DataRefreshTypeEum.monitor.getCode(), content); iDataRefreshService.sendRefreshDataWithArea(DataRefreshTypeEum.monitor.getCode(), content);
} }
} }
List<AlarmParam> list = new ArrayList<>();
list.add(deviceData);
//保存所有数据(遥测,遥信)到mongo
saveData(list, "soe");
}
@Override @Override
public void saveData(List<AlarmParam> deviceDatas, String type) { public void saveData(List<AlarmParam> deviceDatas, String type) {
...@@ -1072,7 +1097,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1072,7 +1097,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
continue; continue;
} }
EquipCommunicationData data = (EquipCommunicationData) hashOperations.get("Analogue", map.get("CODE")); EquipCommunicationData data = (EquipCommunicationData) hashOperations.get("Analogue", map.get("CODE"));
map.put("level", String.format("%.2f", Double.valueOf(data.getState()))); map.put("level", String.format("%.2f", StringUtils.isNumeric(data.getState())?Double.valueOf(data.getState()):0));
if (!ObjectUtils.isEmpty(map.get("level"))) { if (!ObjectUtils.isEmpty(map.get("level"))) {
double area = 0; double area = 0;
if (!ObjectUtils.isEmpty(map.get("area"))) { if (!ObjectUtils.isEmpty(map.get("area"))) {
......
...@@ -307,8 +307,7 @@ public class View3dServiceImpl implements IView3dService { ...@@ -307,8 +307,7 @@ public class View3dServiceImpl implements IView3dService {
Long checkExceptionNum = this.getCheckExceptionNum(orgCode,date); Long checkExceptionNum = this.getCheckExceptionNum(orgCode,date);
vo.setCheckExceptionNum(checkExceptionNum); vo.setCheckExceptionNum(checkExceptionNum);
//4.统计故障数量-日期+机构 //4.统计故障数量-日期+机构
//TODO:待毛颖确认调整完成后继续 vo.setFireExceptionNum(getFireExceptionNum(orgCode,date));
vo.setFireExceptionNum(0L);
} else { } else {
throw new YeeException("机构:"+orgCode+" 不存在"); throw new YeeException("机构:"+orgCode+" 不存在");
} }
...@@ -350,6 +349,15 @@ public class View3dServiceImpl implements IView3dService { ...@@ -350,6 +349,15 @@ public class View3dServiceImpl implements IView3dService {
}); });
} else if(StatisticsErrorTypeEum.equip.getCode().equals(type)){ } else if(StatisticsErrorTypeEum.equip.getCode().equals(type)){
//TODO:待毛颖确认调整完成后继续 //TODO:待毛颖确认调整完成后继续
List<CheckErrorBo> checkErrorBoList = view3dMapper.getAllFaultAlarm(params);
Map<String,List<CheckErrorBo>> map = checkErrorBoList.stream().collect(Collectors.groupingBy(CheckErrorBo::getStatus));
map.forEach((k,v)->{
SafetyIndexDetailVo safetyIndexDetailVo = new SafetyIndexDetailVo();
safetyIndexDetailVo.setTypeCode(k);
safetyIndexDetailVo.setTypeName(k);
safetyIndexDetailVo.setContent(getErrorContentVos(v));
resultList.add(safetyIndexDetailVo);
});
} }
return resultList; return resultList;
} }
...@@ -478,23 +486,24 @@ public class View3dServiceImpl implements IView3dService { ...@@ -478,23 +486,24 @@ public class View3dServiceImpl implements IView3dService {
case "check"://巡检异常 case "check"://巡检异常
return view3dMapper.getCheckErrorTop5(orgCode); return view3dMapper.getCheckErrorTop5(orgCode);
case "fire": case "fire":
return JSON.parseArray(" [\r\n" + return view3dMapper.getFireAlarmTop5(orgCode);
" {\r\n" + // return JSON.parseArray(" [\r\n" +
" \"id\": 35781,\r\n" + // " {\r\n" +
" \"code\": \"s001\",\r\n" + // " \"id\": 35781,\r\n" +
" \"label\": \"设备test\",\r\n" + // " \"code\": \"s001\",\r\n" +
" \"pointId\": \"1\",\r\n" + // " \"label\": \"设备test\",\r\n" +
" \"type\": \"check\",\r\n" + // " \"pointId\": \"1\",\r\n" +
" \"changeDate\": \"2020-04-23 14:31:31\"\r\n" + // " \"type\": \"check\",\r\n" +
" },\r\n" + // " \"changeDate\": \"2020-04-23 14:31:31\"\r\n" +
" {\r\n" + // " },\r\n" +
" \"id\": 35780,\r\n" + // " {\r\n" +
" \"code\": \"s002\",\r\n" + // " \"id\": 35780,\r\n" +
" \"label\": \"设备002\",\r\n" + // " \"code\": \"s002\",\r\n" +
" \"pointId\": \"23123\",\r\n" + // " \"label\": \"设备002\",\r\n" +
" \"type\": \"check\",\r\n" + // " \"pointId\": \"23123\",\r\n" +
" \"changeDate\": \"2020-04-23 14:31:27\"\r\n" + // " \"type\": \"check\",\r\n" +
" }]", SafetyExecuteBo.class); // " \"changeDate\": \"2020-04-23 14:31:27\"\r\n" +
// " }]", SafetyExecuteBo.class);
default: default:
throw new YeeException("不支持的类型 -->"+ type); throw new YeeException("不支持的类型 -->"+ type);
} }
...@@ -510,9 +519,10 @@ public class View3dServiceImpl implements IView3dService { ...@@ -510,9 +519,10 @@ public class View3dServiceImpl implements IView3dService {
} }
@Override @Override
public Object getEquipStatusList(String orgCode) { public List<SafetyExecuteBo> getEquipStatusList(String orgCode) {
return JSON.parseArray("[{\"id\":1,\"label\":\"设备1 label\",\"changeDate\":\"2020-04-26 10:00:00\"}" return view3dMapper.getEquipStatusTop5(orgCode);
+ ",{\"id\":2,\"label\":\"设备2 label\",\"changeDate\":\"2020-04-25 10:00:00\"}]"); // return JSON.parseArray("[{\"id\":1,\"label\":\"设备1 label\",\"changeDate\":\"2020-04-26 10:00:00\"}"
// + ",{\"id\":2,\"label\":\"设备2 label\",\"changeDate\":\"2020-04-25 10:00:00\"}]");
} }
@Override @Override
......
...@@ -112,7 +112,7 @@ public interface IView3dService { ...@@ -112,7 +112,7 @@ public interface IView3dService {
* @param orgCode * @param orgCode
* @return * @return
*/ */
Object getEquipStatusList(String orgCode); List<SafetyExecuteBo> getEquipStatusList(String orgCode);
/** /**
* 左侧菜单(异常点) * 左侧菜单(异常点)
......
...@@ -438,7 +438,15 @@ ...@@ -438,7 +438,15 @@
</select> </select>
<select id="countFireException" resultType="long"> <select id="countFireException" resultType="long">
SELECT
count(1)
FROM
f_alarm a
WHERE
`status` = TRUE
AND org_code = #{orgCode}
AND type = 'alarm_type_trouble'
AND date_format(a.update_date, '%Y-%m-%d') = #{date}
</select> </select>
<select id="getAllErrorRiskPoint" resultType="com.yeejoin.amos.fas.business.bo.RiskPointRpnChangeBo" > <select id="getAllErrorRiskPoint" resultType="com.yeejoin.amos.fas.business.bo.RiskPointRpnChangeBo" >
...@@ -473,6 +481,23 @@ ...@@ -473,6 +481,23 @@
and a.org_code = #{orgCode} and a.org_code = #{orgCode}
</select> </select>
<select id="getAllFaultAlarm" resultType="com.yeejoin.amos.fas.business.bo.CheckErrorBo">
SELECT
a.id,
a.fire_equipment_point_name as `name`,
fe.equip_type as status,
a.update_date as changeDate
FROM
f_alarm a
LEFT JOIN f_fire_equipment fe ON fe.id = a.fire_equipment_id
WHERE
`status` = TRUE
AND type = 'alarm_type_trouble'
AND a.org_code = #{orgCode}
AND date_format(a.update_date, '%Y-%m-%d') =#{date}
</select>
<select id="getStatisticsCheck" resultType="java.util.HashMap"> <select id="getStatisticsCheck" resultType="java.util.HashMap">
<![CDATA[ <![CDATA[
SELECT d.status as type, count(1) as value SELECT d.status as type, count(1) as value
...@@ -503,11 +528,42 @@ ...@@ -503,11 +528,42 @@
left join p_point I ON I.id = p.point_id left join p_point I ON I.id = p.point_id
where p.is_ok IN ('2', '3') where p.is_ok IN ('2', '3')
AND I.is_delete = 0 AND I.is_delete = 0
AND p.org_code = #{org_code} or p.org_code like CONCAT(#{orgCode},'-','%') AND p.org_code = #{orgCode} or p.org_code like CONCAT(#{orgCode},'-','%')
ORDER BY p.check_time desc ORDER BY p.check_time desc
limit 0,5 limit 0,5
</select> </select>
<select id="getFireAlarmTop5" resultType="com.yeejoin.amos.fas.business.bo.SafetyExecuteBo">
SELECT
a.fire_equipment_id id,
a.fire_equipment_code code,
a.fire_equipment_point_name as `label`,
a.update_date as changeDate,
"monitorEquipment" type
FROM
f_alarm a
WHERE
a.org_code = #{orgCode}
AND a.`status` = TRUE
AND a.type = 'alarm_type_fire'
ORDER BY a.update_date DESC
limit 0,5
</select>
<select id="getEquipStatusTop5" resultType="com.yeejoin.amos.fas.business.bo.SafetyExecuteBo">
SELECT
fed.id,
fed.eq_point_name label,
fed.e_value status,
fed.create_date changeDate
FROM
f_fire_equipment_data fed
WHERE
fed.org_code = #{orgCode}
ORDER BY fed.create_date DESC
limit 0,5
</select>
<select id="getPintsByType" resultType="hashmap"> <select id="getPintsByType" resultType="hashmap">
select CONCAT(type,'-',id) as `key`,sp.* from select CONCAT(type,'-',id) as `key`,sp.* from
(select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'riskSource' as type,org_code as orgCode, (select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'riskSource' as type,org_code as orgCode,
......
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