Commit 5360ac70 authored by 吴俊凯's avatar 吴俊凯

1.4.0.2版本修改代码提交

parent 27aead40
...@@ -15,9 +15,10 @@ public enum AlarmPointEnum { ...@@ -15,9 +15,10 @@ public enum AlarmPointEnum {
未确认已清除("未确认已清除", "未确认已清除"), 未确认已清除("未确认已清除", "未确认已清除"),
已确认未清除("已确认未清除", "已确认未清除"), 已确认未清除("已确认未清除", "已确认未清除"),
已确认已清除("已确认已清除", "已确认已清除"), 已确认已清除("已确认已清除", "已确认已清除"),
异常("异常", "异常"), 正常("正常", "正常"),
正常("正常", "正常"); 异常("异常", "异常"),
告警("告警", "告警"),;
/** /**
* 名称,描述 * 名称,描述
*/ */
......
...@@ -26,7 +26,7 @@ public enum DeviceUriEnum { ...@@ -26,7 +26,7 @@ public enum DeviceUriEnum {
this.desc = desc; this.desc = desc;
} }
public String getUri() { public String getUri() {
return uri; return uri;
} }
......
...@@ -16,12 +16,12 @@ import com.yeejoin.amos.spc.dao.entity.BasicEntity; ...@@ -16,12 +16,12 @@ import com.yeejoin.amos.spc.dao.entity.BasicEntity;
@Entity @Entity
@Table(name="p_alarm_point") @Table(name="p_alarm_point")
public class AlarmPoint { public class AlarmPoint {
/** /**
* *
*/ */
private static final long serialVersionUID = 5191299540189393188L; private static final long serialVersionUID = 5191299540189393188L;
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "id",nullable=false,unique=true) @Column(name = "id",nullable=false,unique=true)
...@@ -29,30 +29,30 @@ public class AlarmPoint { ...@@ -29,30 +29,30 @@ public class AlarmPoint {
@Column(name = "point_id") @Column(name = "point_id")
private Long pointId; private Long pointId;
@Column(name = "update_date") @Column(name = "update_date")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateDate; private Date updateDate;
@Column(name = "is_alarm") @Column(name = "is_alarm")
private Integer isAlarm = 1;//0 正常|1 告警 private Integer isAlarm = 1;//0 正常|1 告警
@Column(name = "point_type") @Column(name = "point_type")
private String pointType; private String pointType;
@Column(name = "content") @Column(name = "content")
private String content;//告警内容 private String content;//告警内容
@Column(name = "code") @Column(name = "code")
private String code;//code private String code;//code
@Column(name = "point_name") @Column(name = "point_name")
private String pointName; private String pointName;
@Column(name = "source_id") @Column(name = "source_id")
private String sourceId; private String sourceId;
@Column(name = "auth_org") @Column(name = "auth_org")
private String authOrg; private String authOrg;
...@@ -67,6 +67,16 @@ public class AlarmPoint { ...@@ -67,6 +67,16 @@ public class AlarmPoint {
@Column(name = "point_attrs") @Column(name = "point_attrs")
private String pointAttrs;//告警点信息 private String pointAttrs;//告警点信息
@Column(name = "cpbl_id")
private Long cpblId;//告警指标ID
public Long getTarget() {
return cpblId;
}
public void setTarget(Long target) {
this.cpblId = target;
}
public Date getUpdateDate() { public Date getUpdateDate() {
return updateDate; return updateDate;
......
...@@ -30,7 +30,7 @@ public class DeviceListener extends EmqxListener implements InitializingBean { ...@@ -30,7 +30,7 @@ public class DeviceListener extends EmqxListener implements InitializingBean {
private static final Logger logger = Logger.getLogger(DeviceListener.class); private static final Logger logger = Logger.getLogger(DeviceListener.class);
private static ObjectMapper mapper = new ObjectMapper(); private static ObjectMapper mapper = new ObjectMapper();
//临界温度 //临界温度
private static final double CRITICAL_TEMPERATURE = 35; private static final double CRITICAL_TEMPERATURE = 35;
...@@ -108,19 +108,19 @@ public class DeviceListener extends EmqxListener implements InitializingBean { ...@@ -108,19 +108,19 @@ public class DeviceListener extends EmqxListener implements InitializingBean {
System.out.println("----shudu equipmentsPointId : "+ equipmentsPointId); System.out.println("----shudu equipmentsPointId : "+ equipmentsPointId);
List<Long> riskFactorId = equipmentMapper.judgeEquipmentExists(equipmentsPointId); List<Long> riskFactorId = equipmentMapper.judgeEquipmentExists(equipmentsPointId);
Integer value = 0; Integer value = 0;
if (Double.valueOf(statusName) >= CRITICAL_TEMPERATURE) { // if (Double.valueOf(statusName) >= CRITICAL_TEMPERATURE) {
value = DevicePointEnum.getValue("异常"); // value = DevicePointEnum.getValue("异常");
equipmentMapper.updateEquipmentPointStatus(value, queryEquipmentPoint.getId()); // equipmentMapper.updateEquipmentPointStatus(value, queryEquipmentPoint.getId());
} else { // } else {
value = DevicePointEnum.getValue("正常"); // value = DevicePointEnum.getValue("正常");
equipmentMapper.updateEquipmentPointStatus(value, queryEquipmentPoint.getId()); // equipmentMapper.updateEquipmentPointStatus(value, queryEquipmentPoint.getId());
} // }
System.out.println("----shudu riskFactorId : "+ riskFactorId); System.out.println("----shudu riskFactorId : "+ riskFactorId);
for (int j = 0; j < riskFactorId.size(); j++) { for (int j = 0; j < riskFactorId.size(); j++) {
try { try {
riskModelRemoteClient.updateEquipmentAlarmData(riskFactorId.get(j),eqpName,value); riskModelRemoteClient.updateEquipmentAlarmData(riskFactorId.get(j),eqpName,value);
...@@ -130,8 +130,8 @@ public class DeviceListener extends EmqxListener implements InitializingBean { ...@@ -130,8 +130,8 @@ public class DeviceListener extends EmqxListener implements InitializingBean {
} }
} }
} }
if (remark.equals("temperatureAlarm") || remark.equals("humidityAlarm")) { if ("告警".equals(statusName)||"异常".equals(statusName)||"正常".equals(statusName)) {
System.out.println("----start chuli device temperatureAlarm : "+ remark); System.out.println("----start chuli device temperatureAlarm : "+ remark);
EquipmentQualityVo queryEquipmentPoint = equipmentMapper.queryEquipmentPoint(eqpId, remark); EquipmentQualityVo queryEquipmentPoint = equipmentMapper.queryEquipmentPoint(eqpId, remark);
System.out.println("----update device queryEquipmentPoint :"+ queryEquipmentPoint); System.out.println("----update device queryEquipmentPoint :"+ queryEquipmentPoint);
...@@ -156,6 +156,7 @@ public class DeviceListener extends EmqxListener implements InitializingBean { ...@@ -156,6 +156,7 @@ public class DeviceListener extends EmqxListener implements InitializingBean {
System.out.println("----update device state fail : "+ riskFactorId); System.out.println("----update device state fail : "+ riskFactorId);
} }
} }
} }
}); });
......
...@@ -129,7 +129,7 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea ...@@ -129,7 +129,7 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea
} }
//告警信息 //告警信息
String metricKey = ""; String metricKey = "";
//默认状态为正常 //默认状态为正常
int statusByName = 0; int statusByName = 0;
// jsonArray.forEach(e -> { // jsonArray.forEach(e -> {
for (Object e : jsonArray) { for (Object e : jsonArray) {
...@@ -204,7 +204,7 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea ...@@ -204,7 +204,7 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea
// }); // });
//增加报警 //增加报警
List<AlarmPoint> alarmPoint = alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.设备.getCode(), eqpId); List<AlarmPoint> alarmPoint = alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.设备.getCode(), eqpId);
if (alarmPoint != null && alarmPoint.size() > 0) { if (alarmPoint != null && alarmPoint.size() > 0) {
//存在报警,判断当前状态是不是合格,合格则删除上次的报警 //存在报警,判断当前状态是不是合格,合格则删除上次的报警
...@@ -241,10 +241,10 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea ...@@ -241,10 +241,10 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea
} }
} }
//增建告警记录表 //增建告警记录表
//告警记录 //告警记录
List<Alarm> curAlarmList = alarmService.findByQueryColumn(eqpId + metricKey); List<Alarm> curAlarmList = alarmService.findByQueryColumn(eqpId + metricKey);
if (curAlarmList != null && curAlarmList.size() > 0) { if (curAlarmList != null && curAlarmList.size() > 0) {
Alarm alarm = curAlarmList.get(0); Alarm alarm = curAlarmList.get(0);
alarm.setUpdateDate(DateTimeKit.now()); alarm.setUpdateDate(DateTimeKit.now());
if (!ObjectUtils.isEmpty(alarm.getHappenDate())) { if (!ObjectUtils.isEmpty(alarm.getHappenDate())) {
......
...@@ -14,6 +14,8 @@ public class AlarmConstant { ...@@ -14,6 +14,8 @@ public class AlarmConstant {
public static String ALARM_NORMAL_STATUS = "清除"; public static String ALARM_NORMAL_STATUS = "清除";
public static String ALARM_ABNORMAL_STATUS = "告警"; public static String ALARM_ABNORMAL_STATUS = "告警";
public static String ALARM_DEVICE = "警告告警"; public static String ALARM_DEVICE = "警告告警";
public static String ALARM_DEVICE_TYPE = "监测设备告警"; public static String ALARM_DEVICE_TYPE = "动环告警";
public static String ALARM_DEVICE_AlARAM = "监测异常"; public static String ALARM_DEVICE_AlARAM = "监测异常";
public static String ALARM_DEVICE_MAJOR = "重要告警";
} }
package com.yeejoin.amos.bank.controller; package com.yeejoin.amos.bank.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonArray;
import com.yeejoin.amos.bank.dao.entity.AlarmPoint; import com.yeejoin.amos.bank.dao.entity.AlarmPoint;
import com.yeejoin.amos.bank.dao.repository.ITopographyNodeDetailRepository;
import com.yeejoin.amos.bank.param.DepartmentBo; import com.yeejoin.amos.bank.param.DepartmentBo;
import com.yeejoin.amos.bank.service.IAlarmPointService; import com.yeejoin.amos.bank.service.IAlarmPointService;
import com.yeejoin.amos.bank.service.IAlarmService; import com.yeejoin.amos.bank.service.IAlarmService;
...@@ -19,12 +23,15 @@ import org.apache.log4j.Logger; ...@@ -19,12 +23,15 @@ import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
...@@ -47,7 +54,8 @@ public class AlarmPointController extends BaseController { ...@@ -47,7 +54,8 @@ public class AlarmPointController extends BaseController {
private IAlarmService iAlarmService; private IAlarmService iAlarmService;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
@Autowired
private ITopographyNodeDetailRepository iTopographyNodeDetailDao;
/** /**
* 获取告警数据 * 获取告警数据
* *
...@@ -87,24 +95,24 @@ public class AlarmPointController extends BaseController { ...@@ -87,24 +95,24 @@ public class AlarmPointController extends BaseController {
public CommonResponse bankInfoList() { public CommonResponse bankInfoList() {
return CommonResponseUtil.success(autoInspectionService.bankInfoList()); return CommonResponseUtil.success(autoInspectionService.bankInfoList());
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ApiOperation(value = "巡检点统计", notes = "首页统计") @ApiOperation(value = "巡检点统计", notes = "首页统计")
@PostMapping(value = "/mobile/getcountxd") @PostMapping(value = "/mobile/getcountxd")
public CommonResponse getcountxd(@RequestBody Map maps) { public CommonResponse getcountxd(@RequestBody Map maps) {
//String code=maps.get("code").toString(); //String code=maps.get("code").toString();
//获取当前登录人公司orgcode //获取当前登录人公司orgcode
ReginParams reginParams =getSelectedOrgInfo(); ReginParams reginParams =getSelectedOrgInfo();
String code=reginParams.getCompany().getOrgCode(); String code=reginParams.getCompany().getOrgCode();
// List<HashMap<String, Object>> listxd= iAlarmService.getcountxd(code); // List<HashMap<String, Object>> listxd= iAlarmService.getcountxd(code);
List<HashMap<String, Object>> listyc= iAlarmService.getcountyc( code); List<HashMap<String, Object>> listyc= iAlarmService.getcountyc( code);
// List<HashMap<String, Object>> list2= iAlarmService.getcountnum(code); // List<HashMap<String, Object>> list2= iAlarmService.getcountnum(code);
List<HashMap<String, Object>> lista =new ArrayList<>(); List<HashMap<String, Object>> lista =new ArrayList<>();
// for (int i = 0; i < listxd.size(); i++) { // for (int i = 0; i < listxd.size(); i++) {
// HashMap<String, Object> map =new HashMap<>(); // HashMap<String, Object> map =new HashMap<>();
// for (int j = 0; j < listyc.size(); j++) { // for (int j = 0; j < listyc.size(); j++) {
...@@ -115,94 +123,94 @@ public class AlarmPointController extends BaseController { ...@@ -115,94 +123,94 @@ public class AlarmPointController extends BaseController {
// z=listxd.get(i).get("num").toString(); // z=listxd.get(i).get("num").toString();
// } // }
// if(listyc.get(j).get("num")!=null){ // if(listyc.get(j).get("num")!=null){
// y=listyc.get(j).get("num").toString(); // y=listyc.get(j).get("num").toString();
// } // }
// //
// map.put("value", z+"/"+y); // map.put("value", z+"/"+y);
// map.put("name", listxd.get(i).get("name")); // map.put("name", listxd.get(i).get("name"));
// map.put("level",listxd.get(i).get("code")); // map.put("level",listxd.get(i).get("code"));
// //
// } // }
// //
// } // }
// lista.add(map); // lista.add(map);
// //
// } // }
int num=0; int num=0;
for (int i = 0; i < listyc.size(); i++) { for (int i = 0; i < listyc.size(); i++) {
HashMap<String, Object> map =new HashMap<>(); HashMap<String, Object> map =new HashMap<>();
String ynum="0"; String ynum="0";
if(listyc.get(i).get("num")!=null){ if(listyc.get(i).get("num")!=null){
num=num+Integer.valueOf(listyc.get(i).get("num").toString()); num=num+Integer.valueOf(listyc.get(i).get("num").toString());
ynum=listyc.get(i).get("num").toString(); ynum=listyc.get(i).get("num").toString();
} }
map.put("value",ynum); map.put("value",ynum);
map.put("name", listyc.get(i).get("name")); map.put("name", listyc.get(i).get("name"));
map.put("level",listyc.get(i).get("code")); map.put("level",listyc.get(i).get("code"));
lista.add(map); lista.add(map);
} }
Map<String, Object> map =new HashMap<>(); Map<String, Object> map =new HashMap<>();
map.put("total",num); map.put("total",num);
map.put("data", lista); map.put("data", lista);
return CommonResponseUtil.success(map); return CommonResponseUtil.success(map);
} }
//巡检点统计 //巡检点统计
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ApiOperation(value = "巡检点统计", notes = "首页统计") @ApiOperation(value = "巡检点统计", notes = "首页统计")
@GetMapping(value = "/mobile/getxuncount") @GetMapping(value = "/mobile/getxuncount")
public CommonResponse getxuncount() { public CommonResponse getxuncount() {
ReginParams reginParams =getSelectedOrgInfo(); ReginParams reginParams =getSelectedOrgInfo();
String code=reginParams.getCompany().getOrgCode(); String code=reginParams.getCompany().getOrgCode();
List<HashMap<String, Object>> listyc= iAlarmService.getxuncount( code); List<HashMap<String, Object>> listyc= iAlarmService.getxuncount( code);
xun xu= new xun(); xun xu= new xun();
int count=0; int count=0;
if(listyc!=null&&listyc.size()>0){ if(listyc!=null&&listyc.size()>0){
for (int i = 0; i < listyc.size(); i++) { for (int i = 0; i < listyc.size(); i++) {
switch(listyc.get(i).get("status")+""){ switch(listyc.get(i).get("status")+""){
case "0": case "0":
int nu= Integer.valueOf(listyc.get(i).get("num").toString()) ; int nu= Integer.valueOf(listyc.get(i).get("num").toString()) ;
count= count+nu; count= count+nu;
xu.setNotIncluded(nu); xu.setNotIncluded(nu);
break; break;
case "1": case "1":
int nu1= Integer.valueOf(listyc.get(i).get("num").toString()) ; int nu1= Integer.valueOf(listyc.get(i).get("num").toString()) ;
count= count+nu1; count= count+nu1;
xu.setNormal(nu1); xu.setNormal(nu1);
break; break;
case "2": case "2":
int nu2= Integer.valueOf(listyc.get(i).get("num").toString()) ; int nu2= Integer.valueOf(listyc.get(i).get("num").toString()) ;
count= count+nu2; count= count+nu2;
xu.setAbnormal(nu2); xu.setAbnormal(nu2);
break; break;
default: default:
int nu3= Integer.valueOf(listyc.get(i).get("num").toString()) ; int nu3= Integer.valueOf(listyc.get(i).get("num").toString()) ;
count= count+nu3; count= count+nu3;
xu.setMissedDetection(nu3); xu.setMissedDetection(nu3);
break; break;
} }
} }
xu.setCountnum(count); xu.setCountnum(count);
} }
return CommonResponseUtil.success(xu); return CommonResponseUtil.success(xu);
} }
class xun{ class xun{
int notIncluded;//未纳入巡检; int notIncluded;//未纳入巡检;
int normal;//正常; int normal;//正常;
int abnormal;//异常; int abnormal;//异常;
int missedDetection;//漏检; int missedDetection;//漏检;
int countnum;//总数; int countnum;//总数;
public int getNotIncluded() { public int getNotIncluded() {
return notIncluded; return notIncluded;
} }
...@@ -233,13 +241,13 @@ public class AlarmPointController extends BaseController { ...@@ -233,13 +241,13 @@ public class AlarmPointController extends BaseController {
public void setCountnum(int countnum) { public void setCountnum(int countnum) {
this.countnum = countnum; this.countnum = countnum;
} }
} }
@ApiOperation(value = "获取当前用户所属公司的所有部门", notes = "获取当前用户所属公司的所有部门") @ApiOperation(value = "获取当前用户所属公司的所有部门", notes = "获取当前用户所属公司的所有部门")
@RequestMapping(value = "/queryDept", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/queryDept", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryCurrentCompanyDept() { public CommonResponse queryCurrentCompanyDept() {
...@@ -247,16 +255,16 @@ public class AlarmPointController extends BaseController { ...@@ -247,16 +255,16 @@ public class AlarmPointController extends BaseController {
ReginParams reginParams =getSelectedOrgInfo(); ReginParams reginParams =getSelectedOrgInfo();
Long dep = reginParams.getCompany().getSequenceNbr(); Long dep = reginParams.getCompany().getSequenceNbr();
List<DepartmentModel> departmentModels = remoteSecurityService.listDepartmentsByCompanyId(dep); List<DepartmentModel> departmentModels = remoteSecurityService.listDepartmentsByCompanyId(dep);
List<DepartmentBo> departmentBos = ModelToBo(departmentModels); List<DepartmentBo> departmentBos = ModelToBo(departmentModels);
return CommonResponseUtil.success(departmentBos); return CommonResponseUtil.success(departmentBos);
} }
/** /**
* 类型转换 DepartmentModel => DepartmentBo * 类型转换 DepartmentModel => DepartmentBo
* @param departmentModels * @param departmentModels
...@@ -286,8 +294,8 @@ public class AlarmPointController extends BaseController { ...@@ -286,8 +294,8 @@ public class AlarmPointController extends BaseController {
); );
return departmentBos; return departmentBos;
} }
private List<DepartmentBo> ModelToBo2(List<LinkedHashMap> departmentModels){ private List<DepartmentBo> ModelToBo2(List<LinkedHashMap> departmentModels){
List<DepartmentBo> departmentBos = new ArrayList<>(); List<DepartmentBo> departmentBos = new ArrayList<>();
departmentModels.forEach( departmentModels.forEach(
...@@ -301,19 +309,114 @@ public class AlarmPointController extends BaseController { ...@@ -301,19 +309,114 @@ public class AlarmPointController extends BaseController {
departmentBo.setLevel(x.get("level")+""); departmentBo.setLevel(x.get("level")+"");
departmentBo.setOrgCode(x.get("orgCode")+""); departmentBo.setOrgCode(x.get("orgCode")+"");
departmentBo.setParentId(x.get("parentId")+""); departmentBo.setParentId(x.get("parentId")+"");
if (x.get("children")!=null) { if (x.get("children")!=null) {
List<LinkedHashMap> collect = (List<LinkedHashMap>) x.get("children"); List<LinkedHashMap> collect = (List<LinkedHashMap>) x.get("children");
departmentBos.addAll( ModelToBo2(collect)); departmentBos.addAll( ModelToBo2(collect));
} }
departmentBos.add(departmentBo); departmentBos.add(departmentBo);
} }
); );
return departmentBos; return departmentBos;
} }
/**
* 获取七天告警数据统计
*
* @return 告警数据
*/
@GetMapping(value = "/statistics", produces = "application/json;charset=UTF-8")
@ApiOperation(value = "七天告警数据统计", notes = "七天告警数据统计")
public CommonResponse getStatisticsAlarms() throws ParseException {
Map<String,Object> result = alarmPointService.getSevenDayscount();
return CommonResponseUtil.success(result);
}
/**
* 首页动环信息展示
*
* @return 告警数据
*/
@GetMapping(value = "/mobile/show", produces = "application/json;charset=UTF-8")
@ApiOperation(value = "首页动环信息展示", notes = "首页动环信息展示")
public CommonResponse getMobileShow() {
List<Map<String,Object>> detailList = iTopographyNodeDetailDao.HomePageDetail();
List<Map<String,String>> changeList = new ArrayList<>();
for (int i = 0; i <detailList.size() ; i++) {
Map<String,String > map = new HashMap<>();
if(StringUtils.isEmpty(detailList.get(i).get("nodeid"))){
break;
}
map.put("nodeid",detailList.get(i).get("nodeid").toString());
map.put("text",detailList.get(i).get("text").toString());
JSONArray array = JSONArray.parseArray(detailList.get(i).get("node_detail").toString());
if(StringUtils.isEmpty(array)){
break;
}
if("3-0025".equals(detailList.get(i).get("nodeid").toString())||"3-0026".equals(detailList.get(i).get("nodeid").toString())){
map.put("area","西安");
for (int j = 0; j <array.size() ; j++) {
JSONObject detail = JSONObject.parseObject(array.get(j).toString());
if(detail.get("name").toString().equals("烟感探测器报警")){
map.put("value",detail.get("value").toString());
}
if(detail.get("name").toString().equals("漏水监测报警")){
map.put("value",detail.get("value").toString());
}
}
}else if("3-0044".equals(detailList.get(i).get("nodeid").toString())||"3-0045".equals(detailList.get(i).get("nodeid").toString())){
map.put("area","咸阳");
for (int j = 0; j <array.size() ; j++) {
JSONObject detail = JSONObject.parseObject(array.get(j).toString());
if(detail.get("name").toString().equals("烟感探测器报警")){
map.put("value",detail.get("value").toString());
}
if(detail.get("name").toString().equals("漏水监测报警")){
map.put("value",detail.get("value").toString());
}
}
}else{
for (int j = 0; j <array.size() ; j++) {
JSONObject detail = JSONObject.parseObject(array.get(j).toString());
if(detail.get("name").toString().equals("温度")||detail.get("name").toString().equals("室内温度")){
map.put("value",detail.get("value").toString());
}
}
}
changeList.add(map);
}
Map<String,Object> result = new HashMap<>();
List<Map<String,String>> QSZXList = new ArrayList<>();
List<Map<String,String>> SBJXList = new ArrayList<>();
List<Map<String,String>> HBList = new ArrayList<>();
List<Map<String,String>> XFJCList = new ArrayList<>();
List<Map<String,String>> LSJCList = new ArrayList<>();
for (int i = 0; i <changeList.size() ; i++) {
if ("1#温湿度".equals(changeList.get(i).get("text")) || "2#温湿度".equals(changeList.get(i).get("text"))) {
QSZXList.add(changeList.get(i));
}
if ("3#温湿度".equals(changeList.get(i).get("text")) || "4#温湿度".equals(changeList.get(i).get("text"))) {
SBJXList.add(changeList.get(i));
}
if ("1温湿度".equals(changeList.get(i).get("text")) || "5温湿度".equals(changeList.get(i).get("text"))) {
HBList.add(changeList.get(i));
}
if ("3-0044".equals(changeList.get(i).get("nodeid")) || "3-0025".equals(changeList.get(i).get("nodeid"))) {
XFJCList.add(changeList.get(i));
}
if ("3-0026".equals(changeList.get(i).get("nodeid")) || "3-0045".equals(changeList.get(i).get("nodeid"))) {
LSJCList.add(changeList.get(i));
}
}
result.put("QSZX",QSZXList);
result.put("SBJ",SBJXList);
result.put("HB",HBList);
result.put("XFJC",XFJCList);
result.put("LSJC",LSJCList);
return CommonResponseUtil.success(result);
}
} }
package com.yeejoin.amos.bank.controller; package com.yeejoin.amos.bank.controller;
import java.util.Date; import java.util.Date;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.bank.dao.entity.AlarmPoint; import com.yeejoin.amos.bank.dao.entity.AlarmPoint;
import com.yeejoin.amos.bank.service.IAlarmPointService; import com.yeejoin.amos.bank.service.IAlarmPointService;
...@@ -23,17 +21,17 @@ import io.swagger.annotations.ApiParam; ...@@ -23,17 +21,17 @@ import io.swagger.annotations.ApiParam;
@RequestMapping(value = "/bank/dynamicRingData") @RequestMapping(value = "/bank/dynamicRingData")
@Api(value = "/bank/dynamicRingData", tags = {"动环数据API"}) @Api(value = "/bank/dynamicRingData", tags = {"动环数据API"})
public class DynamicRingDataController extends BaseController{ public class DynamicRingDataController extends BaseController{
@Autowired @Autowired
private IDynamicRingDataService dynamicRingDataService; private IDynamicRingDataService dynamicRingDataService;
@GetMapping(value = "/{id}", produces = "application/json;charset=UTF-8") @GetMapping(value = "/{id}", produces = "application/json;charset=UTF-8")
@ApiOperation(value = "动环数据", notes = "动环数据") @ApiOperation(value = "动环数据", notes = "动环数据")
public CommonResponse detail(@ApiParam(value = "动环数据id", required = false) @PathVariable(value = "id")Long id) { public CommonResponse detail(@ApiParam(value = "动环数据id", required = false) @PathVariable(value = "id")Long id) {
String token = getToken(); String token = getToken();
return CommonResponseUtil.success(dynamicRingDataService.queryDynamicRingDataById(id,token)); return CommonResponseUtil.success(dynamicRingDataService.queryDynamicRingDataById(id,token));
} }
@Autowired @Autowired
private IAlarmPointService alar; private IAlarmPointService alar;
@GetMapping(value = "/test", produces = "application/json;charset=UTF-8") @GetMapping(value = "/test", produces = "application/json;charset=UTF-8")
...@@ -47,4 +45,10 @@ public class DynamicRingDataController extends BaseController{ ...@@ -47,4 +45,10 @@ public class DynamicRingDataController extends BaseController{
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
@PutMapping (value = "/update", produces = "application/json;charset=UTF-8")
@ApiOperation(value = "动环修改坐标位置", notes = "动环修改坐标位置")
public CommonResponse updatePosition(@ApiParam(value = "动环修改坐标位置", required = true) @RequestBody Map<String,Object> param) {
String result = dynamicRingDataService.updatePosition(param);
return CommonResponseUtil.success(result);
}
} }
...@@ -19,4 +19,7 @@ public interface IAlarmPointRepository extends IBaseRepository<AlarmPoint, Strin ...@@ -19,4 +19,7 @@ public interface IAlarmPointRepository extends IBaseRepository<AlarmPoint, Strin
@Query(value="select * from p_alarm_point where point_type IN ('4','5') and point_id =?1 and content = ?2 ",nativeQuery=true ) @Query(value="select * from p_alarm_point where point_type IN ('4','5') and point_id =?1 and content = ?2 ",nativeQuery=true )
public List<AlarmPoint> selectPointTypeAndPointId(String pointId,String content); public List<AlarmPoint> selectPointTypeAndPointId(String pointId,String content);
@Query(value="select * from p_alarm_point where point_type =?1 and point_id =?2 and cpbl_id =?3 ",nativeQuery=true )
public List<AlarmPoint> selectPointTypeAndPointId(String type, Long pointId,Long cpblId);
} }
...@@ -17,9 +17,13 @@ public interface IAlarmRepository extends IBaseRepository<Alarm, String> { ...@@ -17,9 +17,13 @@ public interface IAlarmRepository extends IBaseRepository<Alarm, String> {
@Query(value="select * from spc_alarm where query_column =?1 AND current_state in ('未确认未清除','已确认未清除','异常','告警')",nativeQuery=true ) @Query(value="select * from spc_alarm where query_column =?1 AND current_state in ('未确认未清除','已确认未清除','异常','告警')",nativeQuery=true )
public List<Alarm> selectByQueryColumn(String type); public List<Alarm> selectByQueryColumn(String type);
@Query(value="select COUNT(*) value,sa.alarm_level name, sa.org_code orgCode from spc_alarm sa where sa.org_code like CONCAT('%', ?1, '%' ) and sa.current_state in ('未确认未清除','已确认未清除','异常','告警') GROUP BY sa.alarm_level",nativeQuery=true ) @Query(value="select COUNT(*) value,sa.alarm_level name, sa.org_code orgCode from spc_alarm sa where sa.org_code like CONCAT('%', ?1, '%' ) and sa.current_state in ('未确认未清除','已确认未清除','异常','告警') GROUP BY sa.alarm_level",nativeQuery=true )
public List<Map<String, Object>> countnum(String code); public List<Map<String, Object>> countnum(String code);
@Query(value="select * from spc_alarm where source_id =?1 AND current_state in ('未确认未清除','已确认未清除','异常','告警')",nativeQuery=true )
public List<Alarm> selectByQuerySourceId(String sourceId);
} }
package com.yeejoin.amos.bank.dao.repository; package com.yeejoin.amos.bank.dao.repository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.yeejoin.amos.bank.TopographyNodeDetail; import com.yeejoin.amos.bank.TopographyNodeDetail;
import com.yeejoin.amos.op.core.jpa.IBaseRepository; import com.yeejoin.amos.op.core.jpa.IBaseRepository;
import java.util.List;
import java.util.Map;
@Repository("iTopographyNodeDetailDao") @Repository("iTopographyNodeDetailDao")
public interface ITopographyNodeDetailRepository extends IBaseRepository<TopographyNodeDetail, String> { public interface ITopographyNodeDetailRepository extends IBaseRepository<TopographyNodeDetail, String> {
TopographyNodeDetail findByNodeid(String nodeid); TopographyNodeDetail findByNodeid(String nodeid);
@Query(value="SELECT\n" +
"\tb.nodeid,b.node_detail,a.state,a.text,a.treeid \n" +
"FROM\n" +
"( SELECT id ,state ,text,treeid FROM b_topography_node WHERE text IN ( '1#温湿度', '2#温湿度', '3#温湿度', '4#温湿度', '1温湿度', '5温湿度', '消防监测', '漏水监测' ) ) AS a\n" +
"\tLEFT JOIN b_topography_node_detail b ON a.id = b.nodeid",nativeQuery=true )
List<Map<String,Object>> HomePageDetail();
} }
package com.yeejoin.amos.bank.dao.repository; package com.yeejoin.amos.bank.dao.repository;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -10,12 +11,12 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -10,12 +11,12 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
@Repository("iTopographyNodeDao") @Repository("iTopographyNodeDao")
public interface ITopographyNodeRepository extends IBaseRepository<TopographyNode, String> { public interface ITopographyNodeRepository extends IBaseRepository<TopographyNode, String> {
@Query(value="select * from b_topography_node where org_code like concat(?1,'%') and treeid =?2 and type =?3",nativeQuery=true ) @Query(value="select * from b_topography_node where org_code like concat(?1,'%') and treeid =?2 and type =?3",nativeQuery=true )
List<TopographyNode> findByOrgCodeAndTreeidAndType(String orgcode,String treeid, int type); List<TopographyNode> findByOrgCodeAndTreeidAndType(String orgcode,String treeid, int type);
@Query(value="select * from b_topography_node where org_code like concat(?1,'%') and type =?2",nativeQuery=true ) @Query(value="select * from b_topography_node where org_code like concat(?1,'%') and type =?2",nativeQuery=true )
List<TopographyNode> findByOrgCodeAndType(String orgcode,int type); List<TopographyNode> findByOrgCodeAndType(String orgcode,int type);
TopographyNode findBySourceId(String sourceId); TopographyNode findBySourceId(String sourceId);
TopographyNode findBySourceIdAndTreeid(String fromSourceId, String treeId); TopographyNode findBySourceIdAndTreeid(String fromSourceId, String treeId);
...@@ -25,4 +26,7 @@ public interface ITopographyNodeRepository extends IBaseRepository<TopographyNod ...@@ -25,4 +26,7 @@ public interface ITopographyNodeRepository extends IBaseRepository<TopographyNod
TopographyNode findBySourceIdAndTreeidAndGroup(String toSourceId, String treeIdStr, String groupKey); TopographyNode findBySourceIdAndTreeidAndGroup(String toSourceId, String treeIdStr, String groupKey);
TopographyNode findBySourceIdAndType(String sourceId, int type); TopographyNode findBySourceIdAndType(String sourceId, int type);
@Query(value = "SELECT node.id,detail.node_detail FROM b_topography_node node LEFT JOIN b_topography_node_detail detail ON node.id = detail.nodeid WHERE node.source_id =?1", nativeQuery=true )
Map<String,Object> findNodeDetailBySourceId(String sourceId);
} }
...@@ -79,4 +79,14 @@ public class RemoteDeviceService { ...@@ -79,4 +79,14 @@ public class RemoteDeviceService {
} }
return null; return null;
} }
public String updatePosition(String jsonDate) {
try {
Object result = deviceRemoteClient.updatePosition(jsonDate);
return JSON.toJSONString(result);
} catch (InnerInvokException e) {
log.error("updatePosition fail " + e.getMessage());
}
return null;
}
} }
...@@ -41,7 +41,7 @@ public interface DeviceRemoteClient { ...@@ -41,7 +41,7 @@ public interface DeviceRemoteClient {
*/ */
@RequestMapping(value = "/xml/alarm", method = RequestMethod.GET) @RequestMapping(value = "/xml/alarm", method = RequestMethod.GET)
Object sendAlarm(@RequestParam(value = "xmlData", required = false) String xmlData) throws InnerInvokException; Object sendAlarm(@RequestParam(value = "xmlData", required = false) String xmlData) throws InnerInvokException;
/** /**
* 查询设备详情列表以及指标 * 查询设备详情列表以及指标
* @param equipmentId * @param equipmentId
...@@ -50,5 +50,9 @@ public interface DeviceRemoteClient { ...@@ -50,5 +50,9 @@ public interface DeviceRemoteClient {
*/ */
@RequestMapping(value = "/device/cpbl/attr", method = RequestMethod.GET) @RequestMapping(value = "/device/cpbl/attr", method = RequestMethod.GET)
CommonResponse listDeviceAndDeviceCpblAttr(@RequestParam(value = "equipmentId",required = false) Long equipmentId) throws InnerInvokException; CommonResponse listDeviceAndDeviceCpblAttr(@RequestParam(value = "equipmentId",required = false) Long equipmentId) throws InnerInvokException;
/**
* 修改动环设备坐标点(暂时不启用)
*/
@RequestMapping(value = "/xml/updatePosition", method = RequestMethod.POST)
Object updatePosition(@RequestParam(value = "xmlData", required = false) String xmlData) throws InnerInvokException;
} }
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.bank.remote.client; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.bank.remote.client;
import com.yeejoin.amos.component.feign.config.InnerInvokException; import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -12,12 +13,12 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -12,12 +13,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
* @Description: * @Description:
* @Date: 2020-02-18 14:52 * @Date: 2020-02-18 14:52
*/ */
@FeignClient(name = "YEEAMOSPATROL-237") @FeignClient(name = "${gateway.fegin.name}")
public interface PatrolRemoteClient { public interface PatrolRemoteClient {
/** /**
* 发送告警信息 * 发送告警信息
*/ */
@RequestMapping(value = "api/msgSubscribe/alarmNotification", method = RequestMethod.POST, consumes="application/json" ) @RequestMapping(value = "api/msgSubscribe/alarmNotification", method = RequestMethod.POST, consumes= MediaType.APPLICATION_JSON_UTF8_VALUE)
CommonResponse sendAlarmNotification(@RequestBody String input) throws InnerInvokException; CommonResponse sendAlarmNotification(@RequestBody String input) throws InnerInvokException;
} }
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.bank.remote.client; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.bank.remote.client;
import com.yeejoin.amos.component.feign.config.InnerInvokException; import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -12,13 +13,13 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -12,13 +13,13 @@ import org.springframework.web.bind.annotation.RequestParam;
* @author DELL * @author DELL
* *
*/ */
@FeignClient(name = "${Risk.fegin.name}") @FeignClient(name = "${gateway.fegin.name}")
public interface RiskModelRemoteClient { public interface RiskModelRemoteClient {
/** /**
* 修改rpn值 * 修改rpn值
*/ */
@RequestMapping(value = "api/risksource/update/fireqeuiment/sod", method = RequestMethod.GET, consumes = "application/json") @RequestMapping(value = "api/risksource/update/fireqeuiment/sod", method = RequestMethod.GET, consumes= MediaType.APPLICATION_JSON_UTF8_VALUE)
CommonResponse updateEquipmentAlarmData(@RequestParam(value = "riskFactorID") Long riskFactorID, CommonResponse updateEquipmentAlarmData(@RequestParam(value = "riskFactorID") Long riskFactorID,
@RequestParam("equipmentName") String equipmentName,@RequestParam("state") Integer state) @RequestParam("equipmentName") String equipmentName,@RequestParam("state") Integer state)
throws InnerInvokException; throws InnerInvokException;
...@@ -26,13 +27,13 @@ public interface RiskModelRemoteClient { ...@@ -26,13 +27,13 @@ public interface RiskModelRemoteClient {
/** /**
* 根据风险因素id查询巡检点和指标项目列表 * 根据风险因素id查询巡检点和指标项目列表
*/ */
@RequestMapping(value = "/api/risksource/getEquiments/points", method = RequestMethod.GET, consumes="application/json" ) @RequestMapping(value = "/api/risksource/getEquiments/points", method = RequestMethod.GET, consumes= MediaType.APPLICATION_JSON_UTF8_VALUE)
CommonResponse listPointInputitemByFactorId(@RequestParam(value = "factorId") Long factorId) throws InnerInvokException; CommonResponse listPointInputitemByFactorId(@RequestParam(value = "factorId") Long factorId) throws InnerInvokException;
/** /**
* 根据风险因素id查询设备和指标项列表 * 根据风险因素id查询设备和指标项列表
*/ */
@RequestMapping(value = "/api/risksource/getFactorBindPoints", method = RequestMethod.GET, consumes="application/json" ) @RequestMapping(value = "/api/risksource/getFactorBindPoints", method = RequestMethod.GET, consumes= MediaType.APPLICATION_JSON_UTF8_VALUE)
CommonResponse queryBoundByFactroId(@RequestParam(value = "factorId") Long factorId) throws InnerInvokException; CommonResponse queryBoundByFactroId(@RequestParam(value = "factorId") Long factorId) throws InnerInvokException;
} }
package com.yeejoin.amos.bank.service; package com.yeejoin.amos.bank.service;
import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map;
import com.yeejoin.amos.bank.dao.entity.AlarmPoint; import com.yeejoin.amos.bank.dao.entity.AlarmPoint;
import com.yeejoin.amos.op.core.jpa.IGenericManager; import com.yeejoin.amos.op.core.jpa.IGenericManager;
public interface IAlarmPointService extends IGenericManager<AlarmPoint, String> { public interface IAlarmPointService extends IGenericManager<AlarmPoint, String> {
public void saveItem(AlarmPoint alarmPoint); public void saveItem(AlarmPoint alarmPoint);
public void deleteItem(List<AlarmPoint> alarmPointList); public void deleteItem(List<AlarmPoint> alarmPointList);
public void deleteItems(List<AlarmPoint> alarmPointList); public void deleteItems(List<AlarmPoint> alarmPointList);
public List<AlarmPoint> selectPointTypeAndPointId(String type,Long pointId); public List<AlarmPoint> selectPointTypeAndPointId(String type,Long pointId);
public void alarmTigger(String xmlData,String token); public void alarmTigger(String xmlData,String token);
public List<AlarmPoint> queryAutoInspection(String pointId, String content); public List<AlarmPoint> queryAutoInspection(String pointId, String content);
public Map<String,Object> getSevenDayscount() throws ParseException;
public List<AlarmPoint> selectPointTypeAndPointId(String type,Long pointId,Long cpblId);
} }
...@@ -12,18 +12,20 @@ import com.yeejoin.amos.op.core.jpa.IGenericManager; ...@@ -12,18 +12,20 @@ import com.yeejoin.amos.op.core.jpa.IGenericManager;
import com.yeejoin.amos.spc.core.common.request.CommonPageable; import com.yeejoin.amos.spc.core.common.request.CommonPageable;
public interface IAlarmService extends IGenericManager<Alarm, String> { public interface IAlarmService extends IGenericManager<Alarm, String> {
public Page<Alarm> list(List<DaoCriteria> criterias,CommonPageable commonPageable); public Page<Alarm> list(List<DaoCriteria> criterias,CommonPageable commonPageable);
public void saveBatch(List<Alarm> alarms); public void saveBatch(List<Alarm> alarms);
public List<Alarm> findByQueryColumn(String queryColumn); public List<Alarm> findByQueryColumn(String queryColumn);
public List<Map<String, Object>> countnum(String code); public List<Map<String, Object>> countnum(String code);
List<HashMap<String, Object>> getcountxd(String code); List<HashMap<String, Object>> getcountxd(String code);
List<HashMap<String, Object>> getcountnum(String code); List<HashMap<String, Object>> getcountnum(String code);
List<HashMap<String, Object>> getcountyc( String code); List<HashMap<String, Object>> getcountyc( String code);
List<HashMap<String, Object>> getxuncount( String code); List<HashMap<String, Object>> getxuncount( String code);
public List<Alarm> selectByQuerySourceId(String sourceId);
} }
package com.yeejoin.amos.bank.service; package com.yeejoin.amos.bank.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.spc.core.common.response.Node3DVoResponse; import com.yeejoin.amos.spc.core.common.response.Node3DVoResponse;
...@@ -15,4 +16,5 @@ public interface IDynamicRingDataService { ...@@ -15,4 +16,5 @@ public interface IDynamicRingDataService {
ArrayList<Node3DVoResponse> query3dData(String token,String orgCode); ArrayList<Node3DVoResponse> query3dData(String token,String orgCode);
String updatePosition (Map<String,Object> param);
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
package com.yeejoin.amos.bank.service.impl; package com.yeejoin.amos.bank.service.impl;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.bank.common.enums.AbnormalStateEnum;
import com.yeejoin.amos.bank.dao.entity.AlarmPoint; import com.yeejoin.amos.bank.dao.entity.AlarmPoint;
import com.yeejoin.amos.bank.dao.repository.IAlarmPointRepository; import com.yeejoin.amos.bank.dao.repository.IAlarmPointRepository;
import com.yeejoin.amos.bank.remote.RemoteAlarmTiggerService; import com.yeejoin.amos.bank.remote.RemoteAlarmTiggerService;
...@@ -11,20 +12,20 @@ import com.yeejoin.amos.spc.business.dao.mapper.InputItemMapper; ...@@ -11,20 +12,20 @@ import com.yeejoin.amos.spc.business.dao.mapper.InputItemMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.text.ParseException;
import java.util.List; import java.text.SimpleDateFormat;
import java.util.Map; import java.util.*;
@Service @Service
public class AlarmServiceImpl extends GenericManagerImpl<AlarmPoint, String> implements IAlarmPointService { public class AlarmServiceImpl extends GenericManagerImpl<AlarmPoint, String> implements IAlarmPointService {
@Autowired @Autowired
private IAlarmPointRepository iAlarmPointDao; private IAlarmPointRepository iAlarmPointDao;
@Autowired @Autowired
private InputItemMapper inputMapper; private InputItemMapper inputMapper;
@Autowired @Autowired
private RemoteAlarmTiggerService alarmTiggerService; private RemoteAlarmTiggerService alarmTiggerService;
...@@ -59,11 +60,17 @@ public class AlarmServiceImpl extends GenericManagerImpl<AlarmPoint, String> im ...@@ -59,11 +60,17 @@ public class AlarmServiceImpl extends GenericManagerImpl<AlarmPoint, String> im
@Override @Override
public List<AlarmPoint> selectPointTypeAndPointId(String type, Long pointId) { public List<AlarmPoint> selectPointTypeAndPointId(String type, Long pointId) {
return iAlarmPointDao.selectPointTypeAndPointId( type, pointId); return iAlarmPointDao.selectPointTypeAndPointId( type, pointId);
} }
@Override
public List<AlarmPoint> selectPointTypeAndPointId(String type, Long pointId,Long cpblId) {
return iAlarmPointDao.selectPointTypeAndPointId( type,pointId,cpblId);
}
@Override @Override
public void alarmTigger(String xmlData,String token) { public void alarmTigger(String xmlData,String token) {
...@@ -78,4 +85,33 @@ public class AlarmServiceImpl extends GenericManagerImpl<AlarmPoint, String> im ...@@ -78,4 +85,33 @@ public class AlarmServiceImpl extends GenericManagerImpl<AlarmPoint, String> im
public List<AlarmPoint> queryAutoInspection(String pointId,String content) { public List<AlarmPoint> queryAutoInspection(String pointId,String content) {
return iAlarmPointDao.selectPointTypeAndPointId(pointId,content); return iAlarmPointDao.selectPointTypeAndPointId(pointId,content);
} }
@Override
public Map<String,Object> getSevenDayscount() throws ParseException {
Map<String,Object> result = new HashMap<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -6);
//紧急告警
List<Long> urgent = inputMapper.getSevenDayscount(AbnormalStateEnum.E.getName());
result.put("urgent",urgent);
//重要告警
List<Long> important = inputMapper.getSevenDayscount(AbnormalStateEnum.M.getName());
result.put("important",important);
//次要告警
List<Long> secondary = inputMapper.getSevenDayscount(AbnormalStateEnum.S.getName());
result.put("secondary",secondary);
//警告告警
List<Long> warning = inputMapper.getSevenDayscount(AbnormalStateEnum.W.getName());
result.put("warning",warning);
List<String> xAxis = new ArrayList<>();
for (int i = 0; i < 7; i++) {
xAxis.add(sdf.format(c.getTime()).substring(5,sdf.format(c.getTime()).length()));
c.add(Calendar.DATE, 1);
}
//时间轴
result.put("xAxis",xAxis);
return result;
}
} }
...@@ -74,7 +74,23 @@ public class DynamicRingDataServiceImpl implements IDynamicRingDataService { ...@@ -74,7 +74,23 @@ public class DynamicRingDataServiceImpl implements IDynamicRingDataService {
return list; return list;
} }
private void convertNode3DVoResponse(ArrayList<Node3DVoResponse> list, JSONObject json, String type,String orgCode) { @Override
public String updatePosition(Map<String, Object> param) {
String params1 = "{\"eqpTempAttr\":{\"name\":\"affiliatedSystem\",\"value\":\"动环系统\"},\"pageNumber\":0,\"pageSize\":1000000000,\"needAttr\":[\"position\",\"storey\",\"storey\"]}";
String resStr = deviceService.selectEquipments(params1);
//String resStr = deviceService.dynamicRingData(DeviceUriEnum.查询三维设备点, token, params1);
JSONObject updateObject =new JSONObject();
JSONArray resJson = JSONArray.parseArray(JSONObject.parseObject(resStr).get("content").toString());
for (int i = 0; i <resJson.size() ; i++) {
if(resJson.getJSONObject(i).get("id").equals(param.get("id"))){
resJson.getJSONObject(i).getJSONObject("equipmentAttrs").put("position",param.get("position3d"));
updateObject = resJson.getJSONObject(i);
}
}
return deviceService.updatePosition(updateObject.toJSONString());
}
private void convertNode3DVoResponse(ArrayList<Node3DVoResponse> list, JSONObject json, String type,String orgCode) {
List<JSONObject> dataArray = (List<JSONObject>) json.get("content"); List<JSONObject> dataArray = (List<JSONObject>) json.get("content");
dataArray.forEach(e -> { dataArray.forEach(e -> {
JSONArray authOrgs = e.getJSONArray("authOrg"); JSONArray authOrgs = e.getJSONArray("authOrg");
...@@ -132,6 +148,8 @@ public class DynamicRingDataServiceImpl implements IDynamicRingDataService { ...@@ -132,6 +148,8 @@ public class DynamicRingDataServiceImpl implements IDynamicRingDataService {
node3dVoResponse.setType("dynamicRingData"); node3dVoResponse.setType("dynamicRingData");
return node3dVoResponse; return node3dVoResponse;
} }
public static void main(String[] args) {
}
} }
...@@ -47,13 +47,13 @@ import fr.opensagres.xdocreport.template.velocity.internal.Foreach; ...@@ -47,13 +47,13 @@ import fr.opensagres.xdocreport.template.velocity.internal.Foreach;
*/ */
@Service @Service
public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, String> implements ITopographyService { public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, String> implements ITopographyService {
//平台字典管理中配置value为key值 //平台字典管理中配置value为key值
private static final String BNAK_ORG_KEY = "BANK_ORG"; private static final String BNAK_ORG_KEY = "BANK_ORG";
//平台字典管理中配置value为key值 //平台字典管理中配置value为key值
private static final String BNAK_XIAN_KEY = "xian"; private static final String BNAK_XIAN_KEY = "xian";
//平台字典管理中配置value为key值 //平台字典管理中配置value为key值
private static final String BNAK_KEJICHU_KEY = "科技处"; private static final String BNAK_KEJICHU_KEY = "科技处";
...@@ -74,7 +74,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -74,7 +74,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
@Autowired @Autowired
private RemoteWebSocketServer webSocketServer; private RemoteWebSocketServer webSocketServer;
@Autowired @Autowired
RemoteSecurityService remoteSecurityService; RemoteSecurityService remoteSecurityService;
...@@ -85,7 +85,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -85,7 +85,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
@Override @Override
public List<TopographyTreeDTO> getTree(String orgcode,int type) { public List<TopographyTreeDTO> getTree(String orgcode,int type) {
List<TopographyTreeDTO> list = iTopographyTreeDao.findByTypeAndOrgCode(type,orgcode).stream().map(t -> convert(t)).collect(Collectors.toList()); List<TopographyTreeDTO> list = iTopographyTreeDao.findByTypeAndOrgCode(type,orgcode).stream().map(t -> convert(t)).collect(Collectors.toList());
boolean judgeDeviceAuth = JudgeDeviceAuth(list,orgcode); boolean judgeDeviceAuth = JudgeDeviceAuth(list,orgcode);
if(false == judgeDeviceAuth) { if(false == judgeDeviceAuth) {
...@@ -159,7 +159,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -159,7 +159,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
} }
iTopographyNodeDao.saveAll(list); iTopographyNodeDao.saveAll(list);
} }
@Override @Override
public String getSelfOrgCode() { public String getSelfOrgCode() {
List<DictionarieValueModel> listDictionaryByDictCode = remoteSecurityService.listDictionaryByDictCode(BNAK_ORG_KEY); List<DictionarieValueModel> listDictionaryByDictCode = remoteSecurityService.listDictionaryByDictCode(BNAK_ORG_KEY);
...@@ -170,7 +170,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -170,7 +170,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
} }
}); });
return sb.toString(); return sb.toString();
} }
@Override @Override
...@@ -326,8 +326,9 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -326,8 +326,9 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
public Object getNodeDetail(String id) { public Object getNodeDetail(String id) {
TopographyNode node = iTopographyNodeDao.findById(id).get(); TopographyNode node = iTopographyNodeDao.findById(id).get();
TopographyNodeDetail detail = iTopographyNodeDetailDao.findByNodeid(id); TopographyNodeDetail detail = iTopographyNodeDetailDao.findByNodeid(id);
List<Map> list = new ArrayList<>();
if (detail != null) { if (detail != null) {
List<Map> list = JSON.parseArray(detail.getNodeDetail(), Map.class); list = JSON.parseArray(detail.getNodeDetail(), Map.class);
for (Map map : list) { for (Map map : list) {
if (map.get("name").equals("监测状态") || map.get("name").equals("健康状态")) { if (map.get("name").equals("监测状态") || map.get("name").equals("健康状态")) {
if (node.getState() == 0) { if (node.getState() == 0) {
...@@ -342,10 +343,12 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -342,10 +343,12 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
} }
return list; return list;
} else { } else {
return null; return list;
} }
} }
@Override @Override
public List<Map> getDeviceNodes(String orgcode) { public List<Map> getDeviceNodes(String orgcode) {
List<TopographyNode> nodes = iTopographyNodeDao.findByOrgCodeAndType(orgcode, 4); List<TopographyNode> nodes = iTopographyNodeDao.findByOrgCodeAndType(orgcode, 4);
...@@ -362,7 +365,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -362,7 +365,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
} }
return results; return results;
} }
@Override @Override
public List<TopographyLineDTO> getDeviceLinks(String orgcode) { public List<TopographyLineDTO> getDeviceLinks(String orgcode) {
...@@ -393,7 +396,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -393,7 +396,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
} }
} }
/** /**
* 判断该用户登选择公司有无查看该拓扑的权限 * 判断该用户登选择公司有无查看该拓扑的权限
* @param list * @param list
...@@ -401,15 +404,15 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -401,15 +404,15 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
* @return * @return
*/ */
private boolean JudgeDeviceAuth(List<TopographyTreeDTO> list, String orgCode) { private boolean JudgeDeviceAuth(List<TopographyTreeDTO> list, String orgCode) {
String userOrgCode = null; String userOrgCode = null;
if(orgCode.startsWith("%#")) { if(orgCode.startsWith("%#")) {
userOrgCode = truncateHeadString(orgCode,2); userOrgCode = truncateHeadString(orgCode,2);
}else { }else {
userOrgCode = orgCode; userOrgCode = orgCode;
} }
for (TopographyTreeDTO topographyTreeDTO : list) { for (TopographyTreeDTO topographyTreeDTO : list) {
if (!StringUtils.isEmpty(topographyTreeDTO.getOrgCode())) { if (!StringUtils.isEmpty(topographyTreeDTO.getOrgCode())) {
...@@ -430,7 +433,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -430,7 +433,7 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
} }
} }
} }
} else { } else {
String[] arr = topographyTreeDTO.getOrgCode().split("-"); String[] arr = topographyTreeDTO.getOrgCode().split("-");
...@@ -443,11 +446,11 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -443,11 +446,11 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
} }
} }
} }
return false; return false;
} }
/** /**
* 去除字符串前n个字符 * 去除字符串前n个字符
* @param origin 要操作的字符串 * @param origin 要操作的字符串
...@@ -465,5 +468,5 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St ...@@ -465,5 +468,5 @@ public class TopographyServiceImpl extends GenericManagerImpl<TopographyTree, St
} }
return String.copyValueOf(ret); return String.copyValueOf(ret);
} }
} }
...@@ -20,7 +20,7 @@ import com.yeejoin.amos.spc.core.util.query.BaseQuerySpecification; ...@@ -20,7 +20,7 @@ import com.yeejoin.amos.spc.core.util.query.BaseQuerySpecification;
@Service @Service
public class spcAlarmServiceImpl extends GenericManagerImpl<Alarm, String> implements IAlarmService { public class spcAlarmServiceImpl extends GenericManagerImpl<Alarm, String> implements IAlarmService {
@Autowired @Autowired
private IAlarmRepository iAlarmDao; private IAlarmRepository iAlarmDao;
@Autowired @Autowired
...@@ -33,7 +33,7 @@ public class spcAlarmServiceImpl extends GenericManagerImpl<Alarm, String> impl ...@@ -33,7 +33,7 @@ public class spcAlarmServiceImpl extends GenericManagerImpl<Alarm, String> impl
@Override @Override
public Page<Alarm> list(List<DaoCriteria> criterias, CommonPageable commonPageable) { public Page<Alarm> list(List<DaoCriteria> criterias, CommonPageable commonPageable) {
BaseQuerySpecification<Alarm> spec = new BaseQuerySpecification<>(criterias); BaseQuerySpecification<Alarm> spec = new BaseQuerySpecification<>(criterias);
Page<Alarm> page = iAlarmDao.findAll(spec, commonPageable); Page<Alarm> page = iAlarmDao.findAll(spec, commonPageable);
return page; return page;
} }
...@@ -46,7 +46,7 @@ public class spcAlarmServiceImpl extends GenericManagerImpl<Alarm, String> impl ...@@ -46,7 +46,7 @@ public class spcAlarmServiceImpl extends GenericManagerImpl<Alarm, String> impl
public List<Alarm> findByQueryColumn(String queryColumn) { public List<Alarm> findByQueryColumn(String queryColumn) {
return iAlarmDao.selectByQueryColumn(queryColumn); return iAlarmDao.selectByQueryColumn(queryColumn);
} }
public List<Map<String, Object>> countnum(String code) { public List<Map<String, Object>> countnum(String code) {
return iAlarmDao.countnum(code); return iAlarmDao.countnum(code);
} }
...@@ -74,4 +74,9 @@ public class spcAlarmServiceImpl extends GenericManagerImpl<Alarm, String> impl ...@@ -74,4 +74,9 @@ public class spcAlarmServiceImpl extends GenericManagerImpl<Alarm, String> impl
// TODO Auto-generated method stub // TODO Auto-generated method stub
return inputMapper.getxuncount(code); return inputMapper.getxuncount(code);
} }
@Override
public List<Alarm> selectByQuerySourceId(String sourceId) {
return iAlarmDao.selectByQuerySourceId(sourceId);
}
} }
...@@ -12,10 +12,19 @@ import java.util.List; ...@@ -12,10 +12,19 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.bank.TopographyNodeDetail;
import com.yeejoin.amos.bank.dao.mapper.AlarmMapper;
import com.yeejoin.amos.bank.dao.repository.ITopographyNodeDetailRepository;
import com.yeejoin.amos.bank.dao.repository.ITopographyNodeRepository;
import com.yeejoin.amos.bank.utils.DateTimeKit;
import com.yeejoin.amos.spc.core.util.StringUtil;
import io.micrometer.core.instrument.util.StringUtils;
import org.java_websocket.WebSocket; import org.java_websocket.WebSocket;
import org.java_websocket.client.WebSocketClient; import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake; import org.java_websocket.handshake.ServerHandshake;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.io.support.PropertiesLoaderUtils; import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
...@@ -36,6 +45,9 @@ import com.yeejoin.amos.bank.utils.HttpUtil; ...@@ -36,6 +45,9 @@ import com.yeejoin.amos.bank.utils.HttpUtil;
import com.yeejoin.amos.bank.utils.JsonUtil; import com.yeejoin.amos.bank.utils.JsonUtil;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.spc.exception.YeeException; import com.yeejoin.amos.spc.exception.YeeException;
import org.springframework.util.ObjectUtils;
import static com.yeejoin.amos.bank.constants.AlarmConstant.*;
/** /**
* 接收动环告警 * 接收动环告警
...@@ -45,27 +57,51 @@ import com.yeejoin.amos.spc.exception.YeeException; ...@@ -45,27 +57,51 @@ import com.yeejoin.amos.spc.exception.YeeException;
public class MonitorAlarmWebSocketClient extends WebSocketClient { public class MonitorAlarmWebSocketClient extends WebSocketClient {
private static final Logger log = Logger.getLogger(MonitorAlarmWebSocketClient.class); private static final Logger log = Logger.getLogger(MonitorAlarmWebSocketClient.class);
private static final String TAB = "\r\n";
private static ApplicationContext allpicationContext;
private ITopographyNodeRepository iTopographyNodeRepository;
private ITopographyNodeDetailRepository iTopographyNodeDetailDao;
private IAlarmPointService alarmPointService; private IAlarmPointService alarmPointService;
private IAlarmService alarmService; private IAlarmService alarmService;
private ITopographyService iTopographyService; private ITopographyService iTopographyService;
private AmosWsClient client; private AmosWsClient client;
private static final String TAB = "\r\n"; private AlarmMapper alarmMapper;
private IAlarmRepository iAlarmDao; private IAlarmRepository iAlarmDao;
private String address; private String address;
private static ApplicationContext allpicationContext;
private PatrolRemoteClient patrolRemoteClient; private PatrolRemoteClient patrolRemoteClient;
public MonitorAlarmWebSocketClient(String url) throws URISyntaxException {
super(new URI(url));
}
public static void setAllpicationContext(ApplicationContext context) { public static void setAllpicationContext(ApplicationContext context) {
allpicationContext = context; allpicationContext = context;
} }
public MonitorAlarmWebSocketClient(String url) throws URISyntaxException { private static String getAuthOrg(String authOrg) {
super(new URI(url)); if (!StringUtils.isEmpty(authOrg) && authOrg.startsWith("[") && authOrg.endsWith("]")) {
String str = authOrg.substring(1, authOrg.length() - 1).replace(" ", "").replace(",", "#");
return "#"+ str;
}
return null;
}
public static synchronized void synMonitorAlarmPoint() {
System.out.println("-------------------Monitoring of ring alarms start-------------------------");
try {
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
String monitorAlarmWebSocketClientUrl = (String) props.get("params.remoteWebsocketUrl") + "metricData?subData=monitorAlarm";
MonitorAlarmWebSocketClient client = new MonitorAlarmWebSocketClient(monitorAlarmWebSocketClientUrl);
client.connect();
while (!client.getReadyState().equals(WebSocket.READYSTATE.OPEN)) {
//System.out.println("connecting...Dynamic ring alarm----" + client.getReadyState());
}
System.out.println("build " + monitorAlarmWebSocketClientUrl + "connected...");
} catch (URISyntaxException | IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
} }
@Override @Override
...@@ -81,6 +117,9 @@ public class MonitorAlarmWebSocketClient extends WebSocketClient { ...@@ -81,6 +117,9 @@ public class MonitorAlarmWebSocketClient extends WebSocketClient {
alarmService = (IAlarmService) allpicationContext.getBean(IAlarmService.class); alarmService = (IAlarmService) allpicationContext.getBean(IAlarmService.class);
patrolRemoteClient= (PatrolRemoteClient) allpicationContext.getBean(PatrolRemoteClient.class); patrolRemoteClient= (PatrolRemoteClient) allpicationContext.getBean(PatrolRemoteClient.class);
iAlarmDao =(IAlarmRepository) allpicationContext.getBean(IAlarmRepository.class); iAlarmDao =(IAlarmRepository) allpicationContext.getBean(IAlarmRepository.class);
alarmMapper = (AlarmMapper) allpicationContext.getBean(AlarmMapper.class);
iTopographyNodeRepository = (ITopographyNodeRepository) allpicationContext.getBean(ITopographyNodeRepository.class);
iTopographyNodeDetailDao = (ITopographyNodeDetailRepository) allpicationContext.getBean(ITopographyNodeDetailRepository.class);
try { try {
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties"); Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
...@@ -98,118 +137,174 @@ public class MonitorAlarmWebSocketClient extends WebSocketClient { ...@@ -98,118 +137,174 @@ public class MonitorAlarmWebSocketClient extends WebSocketClient {
String formatJsonString = JsonUtil.formatJsonString(paramString); String formatJsonString = JsonUtil.formatJsonString(paramString);
JSONObject msgJson = JSONObject.parseObject(formatJsonString); JSONObject msgJson = JSONObject.parseObject(formatJsonString);
Long eqpId = msgJson.getLong("eqpId"); Long eqpId = msgJson.getLong("eqpId");
String cpblName = msgJson.getString("cpblName");
if (null != eqpId) { if (null != eqpId) {
String curStatus = msgJson.getString("currentState"); String curStatus = msgJson.getString("currentState");
Map<String,Object> nodeDetailMap = iTopographyNodeRepository.findNodeDetailBySourceId(msgJson.getString("sourceId"));
List<JSONObject> alarmAttributes = (List<JSONObject>) msgJson.get("capacityAttrList"); List<JSONObject> alarmAttributes = (List<JSONObject>) msgJson.get("capacityAttrList");
synchronized (this) { synchronized (this) {
//拼接json存入动环详情表
Boolean alarmFlagBoolean = false; Boolean alarmFlagBoolean = false;
for (JSONObject a : alarmAttributes) { for (JSONObject a : alarmAttributes) {
String atr = (String) a.get("name"); String atr = (String) a.get("name");
String res = (String) msgJson.get(atr); String res = (String) msgJson.get(atr);
if (res != null && AlarmPointEnum.异常.getName().equals(res)) { if (res != null &&(AlarmPointEnum.异常.getName().equals(res)||AlarmPointEnum.告警.getName().equals(res))) {
alarmFlagBoolean = true; alarmFlagBoolean = true;
log.info("Moving ring device[" + eqpId + "]" + atr + "abnormal"); log.info("Moving ring device[" + eqpId + "]" + atr + "abnormal");
break; break;
} }
} }
List<AlarmPoint> pointList = alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.动环.getCode(), eqpId); //组装动环信息JSON
if (!alarmFlagBoolean && pointList != null) { List<Map<String, String>> DHlist = new ArrayList<>();
alarmPointService.deleteItems(pointList);
log.info("Clear p_alarm_point Alarm data ...success"); for (JSONObject a : alarmAttributes) {
iTopographyService.sendAbnormal(msgJson.getString("sourceId"), 0); String atr = (String) a.get("name");
String res = (String) msgJson.get(atr);
Map<String, String> map = new HashMap();
if (!"labelType".equals(atr)) {
map.put("name", a.get("displayName").toString());
map.put("value", msgJson.get(atr).toString());
DHlist.add(map);
}
}
if (nodeDetailMap.get("node_detail") != null && !StringUtils.isBlank(nodeDetailMap.get("node_detail").toString())) {
JSONArray nodeDetailArray = JSONArray.parseArray(nodeDetailMap.get("node_detail").toString());
for (int i = 0; i < DHlist.size(); i++) {
int count = 0;
for (int j = 0; j < nodeDetailArray.size(); j++) {
if (DHlist.get(i).get("name").equals(JSONObject.parseObject(nodeDetailArray.get(j).toString()).get("name"))) {
nodeDetailArray.getJSONObject(j).put("value", DHlist.get(i).get("value"));
count++;
}
}
if (count == 0) {
JSONObject detailObject = new JSONObject();
detailObject.put("name", DHlist.get(i).get("name"));
detailObject.put("value", DHlist.get(i).get("value"));
nodeDetailArray.add(detailObject);
}
TopographyNodeDetail topographyNodeDetail = iTopographyNodeDetailDao.findByNodeid(nodeDetailMap.get("id").toString());
topographyNodeDetail.setNodeDetail(nodeDetailArray.toJSONString());
iTopographyNodeDetailDao.save(topographyNodeDetail);
}
} else { } else {
if (null == pointList || pointList.size() == 0) { JSONArray nodeDetailArray = new JSONArray();
String alramContent = msgJson.getString("describe"); for (int i = 0; i < DHlist.size(); i++) {
String eqpType = msgJson.getString("eqpType"); JSONObject jsonObject = new JSONObject();
String eqpName = msgJson.getString("eqpName"); jsonObject.put("name", DHlist.get(i).get("name").toString());
String equipmentAttrs = msgJson.getString("equipmentAttrs"); jsonObject.put("value", DHlist.get(i).get("value").toString());
String sourceId = msgJson.getString("sourceId"); nodeDetailArray.add(jsonObject);
String orgCode = msgJson.getString("orgCode");
AlarmPoint alarmPoint = new AlarmPoint();
alarmPoint.setCode(orgCode);
alarmPoint.setPointId(eqpId);
// alarmPoint.setPointType(eqpType);
alarmPoint.setPointType(AlarmPointTypeEnum.动环.getCode());
alarmPoint.setUpdateDate(new Date());
alarmPoint.setContent(alramContent);
alarmPoint.setPointAttrs(equipmentAttrs);
alarmPoint.setPointName(eqpName);
alarmPointService.saveItem(alarmPoint);
log.info("Save alarm data....success");
//推送消息巡检app
//String url = address + "api/msgSubscribe/alarmNotification";
try {
Map<String, Object> map = new HashMap<String, Object>();
map.put("code", msgJson.getString("orgCode"));
map.put("body", "告警源名称:" + eqpName + TAB + "告警信息" + alramContent);
String stringJson = JSONObject.toJSONString(map);
//HttpUtil.PostJson(url, stringJson);
CommonResponse result = patrolRemoteClient.sendAlarmNotification(stringJson);
log.info("手机推送告警信息...success");
} catch (Exception e) {
log.info("手机推送告警信息失败...fail" + e.getMessage());
}
} }
iTopographyService.sendAbnormal(msgJson.getString("sourceId"), 1); TopographyNodeDetail topographyNodeDetail = new TopographyNodeDetail();
topographyNodeDetail.setNodeDetail(JSON.toJSONString(nodeDetailArray));
topographyNodeDetail.setNodeid(nodeDetailMap.get("id").toString());
iTopographyNodeDetailDao.save(topographyNodeDetail);
} }
Sort sort = new Sort(Sort.Direction.DESC, "updateDate");
List<AlarmPoint> alarms = alarmPointService.findAll(sort);
WebsocketParam param = new WebsocketParam("alarmPoint", JSON.toJSONString(alarms));
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
String url = (String) props.get("params.remoteWebsocketUrl") + "/generic/sendMessage";
HttpUtil.PostJson(url, JSON.toJSONString(param));
log.info("send websocekt info:" + param);
//告警记录 //告警记录
ArrayList<Alarm> alarmList = new ArrayList<>(); String res = AlarmPointEnum.正常.getName();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String alarmTypeCombination="";
for (JSONObject atrJson : alarmAttributes) { for (JSONObject atrJson : alarmAttributes) {
String atrName = (String) atrJson.get("name"); String atrName = (String) atrJson.get("name");
String alarmType = (String) atrJson.get("displayName");
String res = (String) msgJson.get(atrName);
if ("labelType".equals(atrName)) { if ("labelType".equals(atrName)) {
continue; continue;
} }
String alarmType = (String) atrJson.get("displayName");
if(AlarmPointEnum.异常.getName().equals(msgJson.getString(atrName))||AlarmPointEnum.告警.getName().equals(msgJson.getString(atrName))){
alarmTypeCombination = alarmType + alarmTypeCombination;
res = AlarmPointEnum.异常.getName();
}
}
Long cpblId = msgJson.getLong("cpblId");
String sourceId = msgJson.getString("sourceId");
String orgCode = msgJson.getString("orgCode");
String authOrg = msgJson.getString("authOrg");
String eqpName = msgJson.getString("eqpName");
String alramContent = msgJson.getString("alramContent");
String authOrgTemp = JsonUtil.arraysToString(JsonUtil.toStringArray(authOrg));
if (!ObjectUtils.isEmpty(authOrgTemp)) {
orgCode = authOrgTemp;
}
//添加告警记录
if(!"运行参数".equals(cpblName)||!"常电监测".equals(cpblName)||!"常电监测".equals(cpblName)){
addRecordAlarm(alarmTypeCombination, res, sourceId, orgCode, authOrg, eqpName,cpblName,alramContent);
List<AlarmPoint> pointList = alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.动环.getCode(), eqpId,cpblId);
List<Alarm> curAlarmList = alarmService.selectByQuerySourceId(sourceId);
if (!alarmFlagBoolean && pointList.size() > 0) {
alarmPointService.deleteItems(pointList);
log.info("Clear p_alarm_point Alarm data ...success");
//设备所有的指标都不异常,才可以将state置为0
if(curAlarmList.size()==0){
iTopographyService.sendAbnormal(msgJson.getString("sourceId"), 0);
}
} else {
if (alarmFlagBoolean && pointList.size() == 0) {
// String alramContent = msgJson.getString("describe");
String eqpType = msgJson.getString("eqpType");
// String eqpName = msgJson.getString("eqpName");
String equipmentAttrs = msgJson.getString("equipmentAttrs");
// String sourceId = msgJson.getString("sourceId");
String authOrgs = getAuthOrg(msgJson.getString("authOrg"));
//String orgCode = msgJson.getString("orgCode");
AlarmPoint alarmPoint = new AlarmPoint();
alarmPoint.setCode(authOrgs);
alarmPoint.setSourceId(sourceId);
alarmPoint.setPointId(eqpId);
alarmPoint.setAuthOrg(authOrgs);
// alarmPoint.setPointType(eqpType);
alarmPoint.setPointType(AlarmPointTypeEnum.动环.getCode());
alarmPoint.setUpdateDate(new Date());
alarmPoint.setContent(eqpName+alarmTypeCombination);
alarmPoint.setPointAttrs(equipmentAttrs);
alarmPoint.setPointName(eqpName);
alarmPoint.setTarget(cpblId);
alarmPointService.saveItem(alarmPoint);
log.info("Save alarm data....success");
//告警记录 //推送消息巡检app
String queryColumn = msgJson.getString("sourceId") + "_" + alarmType; //String url = address + "api/msgSubscribe/alarmNotification";
//查出当前记录中的告警记录 try {
List<Alarm> curAlarmList = alarmService.findByQueryColumn(queryColumn); Map<String, Object> map = new HashMap<String, Object>();
if (curAlarmList != null && curAlarmList.size() > 0) { map.put("code", msgJson.getString("orgCode"));
map.put("body", "告警源名称:" + eqpName + TAB + "告警信息" + alramContent);
Alarm alarm = curAlarmList.get(0); String stringJson = JSONObject.toJSONString(map);
// if(alarm != null || AlarmPointEnum.异常.getName().equals(res)) { //HttpUtil.PostJson(url, stringJson);
alarm.setUpdateDate(df.format(new Date())); CommonResponse result = patrolRemoteClient.sendAlarmNotification(stringJson);
alarm.setCurrentState(res); log.info("手机推送告警信息...success");
alarmList.add(alarm); } catch (Exception e) {
// } log.info("手机推送告警信息失败...fail" + e.getMessage());
} else {//记录无告警则新增 }
Alarm alarm = new Alarm(); }else {
alarm.setSourceId(msgJson.getString("sourceId")); if(pointList.size()>0){
alarm.setAlarmSourceIp(msgJson.getString("sourceId")); AlarmPoint alarmPoint =pointList.get(0);
alarm.setAlarmSourceType(alarmType); alarmPoint.setContent(eqpName+alarmTypeCombination);
alarm.setUpdateDate(df.format(new Date())); alarmPointService.save(alarmPoint);
alarm.setOrgCode(msgJson.getString("orgCode")); }
alarm.setQueryColumn(queryColumn); }
alarm.setAlarmLevel("警告告警");
alarm.setCurrentState(res);
alarmList.add(alarm);
} }
if(alarmFlagBoolean){
iTopographyService.sendAbnormal(msgJson.getString("sourceId"), 1);
}
Sort sort = new Sort(Sort.Direction.DESC, "updateDate");
List<AlarmPoint> alarms = alarmPointService.findAll(sort);
WebsocketParam param = new WebsocketParam("alarmPoint", JSON.toJSONString(alarms));
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
String url = (String) props.get("params.remoteWebsocketUrl") + "/generic/sendMessage";
HttpUtil.PostJson(url, JSON.toJSONString(param));
log.info("send websocekt info:" + param);
} }
//alarmService.save(alarmList);
iAlarmDao.saveAll(alarmList);
log.info("Save alarm records ....success");
} }
}else { }else {
throw new YeeException("eqpId 不能为空!!!"); throw new YeeException("eqpId 不能为空!!!");
} }
} catch (Exception e) { } catch (Exception e) {
log.info("*********************error****************************"); log.info("*********************error****************************");
log.info(e.getMessage()); log.info(e.getMessage());
...@@ -227,21 +322,61 @@ public class MonitorAlarmWebSocketClient extends WebSocketClient { ...@@ -227,21 +322,61 @@ public class MonitorAlarmWebSocketClient extends WebSocketClient {
log.info("abnormal " + e); log.info("abnormal " + e);
} }
public static synchronized void synMonitorAlarmPoint() { /**
System.out.println("-------------------Monitoring of ring alarms start-------------------------"); * 添加告警记录
try { * @param alarmType 告警类型
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties"); * @param alarmStatus 状态,正常 异常
String monitorAlarmWebSocketClientUrl = (String) props.get("params.remoteWebsocketUrl") + "metricData?subData=monitorAlarm"; * @param sourceId
MonitorAlarmWebSocketClient client = new MonitorAlarmWebSocketClient(monitorAlarmWebSocketClientUrl); * @param orgCode
client.connect(); * @param authOrg
while (!client.getReadyState().equals(WebSocket.READYSTATE.OPEN)) { * @param eqpName 设备名称
* @param cpblName 报警类型
*/
private void addRecordAlarm(String alarmType, String alarmStatus,String sourceId,String orgCode,String authOrg,String eqpName,String cpblName,String alramContent) {
//告警记录
String queryColumn = sourceId + "_" + cpblName;
//查出当前记录中的告警记录
List<Alarm> curAlarmList = alarmService.findByQueryColumn(queryColumn);
if (curAlarmList != null && curAlarmList.size() > 0) {
Alarm alarm = curAlarmList.get(0);
alarm.setOrgCode(orgCode);
alarm.setUpdateDate(DateTimeKit.now());
if (!ObjectUtils.isEmpty(alarm.getHappenDate())) {
String subtract = DateTimeKit.getSubtract(alarm.getHappenDate());
alarm.setContinueDate(subtract);
}
//System.out.println("connecting...Dynamic ring alarm----" + client.getReadyState()); if (AlarmPointEnum.异常.getName().equals(alarmStatus)||AlarmPointEnum.告警.getName().equals(alarmStatus)) {
alarm.setCurrentState(ALARM_ABNORMAL_STATUS);
} else {
alarm.setClearDate(DateTimeKit.now());
alarm.setClearPerson(CLEAR_PERSON);
alarm.setCurrentState(ALARM_NORMAL_STATUS);
}
alarmMapper.updateAlarm(alarm);
} else {//记录无告警则新增
Alarm alarm = new Alarm();
alarm.setSourceId(sourceId);
alarm.setAlarmReason(cpblName);
alarm.setAlarmSourceName(eqpName);
alarm.setAlarmLevel(ALARM_DEVICE_MAJOR);
// alarm.setAlarmSourceIp(sourceId);
alarm.setAlarmSourceType(ALARM_DEVICE_TYPE);
alarm.setClearDate("");
alarm.setContinueDate("");
alarm.setEnsureDate("");
alarm.setEnsurePerson("");
alarm.setOrgCode(orgCode);
alarm.setHappenDate(DateTimeKit.now());
alarm.setQueryColumn( sourceId + "_" + cpblName);
List<Alarm> curAlarmRList = alarmService.findByQueryColumn(queryColumn);
if (AlarmPointEnum.异常.getName().equals(alarmStatus)||AlarmPointEnum.告警.getName().equals(alarmStatus)) {
alarm.setCurrentState(ALARM_ABNORMAL_STATUS);
iAlarmDao.save(alarm);
} else {
alarm.setCurrentState(ALARM_NORMAL_STATUS);
} }
System.out.println("build " + monitorAlarmWebSocketClientUrl + "connected...");
} catch (URISyntaxException | IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} }
log.info("Save shidu alarm records ....success");
} }
} }
package com.yeejoin.amos.bank.webSocket; package com.yeejoin.amos.bank.webSocket;
import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_ABNORMAL_STATUS; import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_ABNORMAL_STATUS;
import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_CAUSE;
import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_LEVEL;
import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_NORMAL_STATUS; import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_NORMAL_STATUS;
import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_TYPE;
import static com.yeejoin.amos.bank.constants.AlarmConstant.CLEAR_PERSON; import static com.yeejoin.amos.bank.constants.AlarmConstant.CLEAR_PERSON;
import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_DEVICE;
import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_DEVICE_TYPE; import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_DEVICE_TYPE;
import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_DEVICE_AlARAM; import static com.yeejoin.amos.bank.constants.AlarmConstant.ALARM_DEVICE_MAJOR;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -23,11 +18,13 @@ import java.util.List; ...@@ -23,11 +18,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import com.yeejoin.amos.bank.TopographyNodeDetail;
import com.yeejoin.amos.bank.dao.repository.ITopographyNodeDetailRepository;
import com.yeejoin.amos.bank.dao.repository.ITopographyNodeRepository;
import org.java_websocket.WebSocket; import org.java_websocket.WebSocket;
import org.java_websocket.client.WebSocketClient; import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake; import org.java_websocket.handshake.ServerHandshake;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.io.support.PropertiesLoaderUtils; import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
...@@ -63,29 +60,51 @@ import org.springframework.util.ObjectUtils; ...@@ -63,29 +60,51 @@ import org.springframework.util.ObjectUtils;
public class ShiduAlarmWebSocketClient extends WebSocketClient { public class ShiduAlarmWebSocketClient extends WebSocketClient {
private static final Logger log = Logger.getLogger(ShiduAlarmWebSocketClient.class); private static final Logger log = Logger.getLogger(ShiduAlarmWebSocketClient.class);
private static final String TAB = "\r\n";
private static ApplicationContext allpicationContext;
private ITopographyNodeRepository iTopographyNodeRepository;
private ITopographyNodeDetailRepository iTopographyNodeDetailDao;
private IAlarmPointService alarmPointService; private IAlarmPointService alarmPointService;
private IAlarmService alarmService; private IAlarmService alarmService;
private ITopographyService iTopographyService; private ITopographyService iTopographyService;
private AmosWsClient client; private AmosWsClient client;
private static final String TAB = "\r\n";
private IAlarmRepository iAlarmDao; private IAlarmRepository iAlarmDao;
private String address; private String address;
private static ApplicationContext allpicationContext;
private PatrolRemoteClient patrolRemoteClient; private PatrolRemoteClient patrolRemoteClient;
private AlarmMapper alarmMapper; private AlarmMapper alarmMapper;
public ShiduAlarmWebSocketClient(String url) throws URISyntaxException {
super(new URI(url));
}
public static void setAllpicationContext(ApplicationContext context) { public static void setAllpicationContext(ApplicationContext context) {
allpicationContext = context; allpicationContext = context;
} }
public ShiduAlarmWebSocketClient(String url) throws URISyntaxException { private static String getAuthOrg(String authOrg) {
super(new URI(url)); if (!StringUtils.isEmpty(authOrg) && authOrg.startsWith("[") && authOrg.endsWith("]")) {
String str = authOrg.substring(1, authOrg.length() - 1).replace(" ", "").replace(",", "#");
return "#"+ str;
}
return null;
}
public static synchronized void synMonitorAlarmPoint() {
System.out.println("-------------------shidu Monitoring of ring alarms start-------------------------");
try {
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
String monitorAlarmWebSocketClientUrl = (String) props.get("params.remoteWebsocketUrl") + "metricData?subData=shiduAlarm";
ShiduAlarmWebSocketClient client = new ShiduAlarmWebSocketClient(monitorAlarmWebSocketClientUrl);
client.connect();
while (!client.getReadyState().equals(WebSocket.READYSTATE.OPEN)) {
log.info("connecting... shidu Dynamic ring alarm----" + client.getReadyState());
}
System.out.println("build " + monitorAlarmWebSocketClientUrl + "connected...");
} catch (URISyntaxException | IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
} }
@Override @Override
...@@ -102,7 +121,8 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient { ...@@ -102,7 +121,8 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient {
patrolRemoteClient= (PatrolRemoteClient) allpicationContext.getBean(PatrolRemoteClient.class); patrolRemoteClient= (PatrolRemoteClient) allpicationContext.getBean(PatrolRemoteClient.class);
iAlarmDao =(IAlarmRepository) allpicationContext.getBean(IAlarmRepository.class); iAlarmDao =(IAlarmRepository) allpicationContext.getBean(IAlarmRepository.class);
alarmMapper = (AlarmMapper) allpicationContext.getBean(AlarmMapper.class); alarmMapper = (AlarmMapper) allpicationContext.getBean(AlarmMapper.class);
iTopographyNodeRepository = (ITopographyNodeRepository) allpicationContext.getBean(ITopographyNodeRepository.class);
iTopographyNodeDetailDao = (ITopographyNodeDetailRepository) allpicationContext.getBean(ITopographyNodeDetailRepository.class);
try { try {
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties"); Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
address = (String) props.get("params.patrol"); address = (String) props.get("params.patrol");
...@@ -120,128 +140,191 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient { ...@@ -120,128 +140,191 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient {
log.info("chuli shidu message after:" + formatJsonString); log.info("chuli shidu message after:" + formatJsonString);
JSONObject msgJson = JSONObject.parseObject(formatJsonString); JSONObject msgJson = JSONObject.parseObject(formatJsonString);
Long eqpId = msgJson.getLong("eqpId"); Long eqpId = msgJson.getLong("eqpId");
String cpblName = msgJson.getString("cpblName");
if (null != eqpId) { if (null != eqpId) {
Map<String,Object> nodeDetailMap = iTopographyNodeRepository.findNodeDetailBySourceId(msgJson.getString("sourceId"));
List<JSONObject> alarmAttributes = (List<JSONObject>) msgJson.get("capacityAttrList"); List<JSONObject> alarmAttributes = (List<JSONObject>) msgJson.get("capacityAttrList");
synchronized (this) {
synchronized (this) {
//拼接json存入动环详情表
Boolean alarmFlagBoolean = false; Boolean alarmFlagBoolean = false;
for (JSONObject a : alarmAttributes) { for (JSONObject a : alarmAttributes) {
String atr = (String) a.get("name"); String atr = (String) a.get("name");
String res = (String) msgJson.get(atr); String res = (String) msgJson.get(atr);
if (res != null && AlarmPointEnum.异常.getName().equals(res)) { if (res != null && (AlarmPointEnum.异常.getName().equals(res)||AlarmPointEnum.告警.getName().equals(res))) {
alarmFlagBoolean = true; alarmFlagBoolean = true;
log.info("Moving ring device[" + eqpId + "]" + atr + "abnormal"); log.info("Moving ring device[" + eqpId + "]" + atr + "abnormal");
break; break;
} }
} }
List<AlarmPoint> pointList = alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.动环.getCode(), eqpId);
if (!alarmFlagBoolean && pointList != null) {
alarmPointService.deleteItems(pointList);
log.info("Clear p_alarm_point Alarm data ...success");
iTopographyService.sendAbnormal(msgJson.getString("sourceId"), 0);
} else {
if (null == pointList || pointList.size() == 0) {
String alramContent = msgJson.getString("describe");
String eqpType = msgJson.getString("eqpType");
String eqpName = msgJson.getString("eqpName");
String equipmentAttrs = msgJson.getString("equipmentAttrs");
String sourceId = msgJson.getString("sourceId");
String authOrgs = getAuthOrg(msgJson.getString("authOrg"));
//String orgCode = msgJson.getString("orgCode");
AlarmPoint alarmPoint = new AlarmPoint();
alarmPoint.setCode(authOrgs);
alarmPoint.setSourceId(sourceId);
alarmPoint.setPointId(eqpId);
alarmPoint.setAuthOrg(authOrgs);
// alarmPoint.setPointType(eqpType);
alarmPoint.setPointType(AlarmPointTypeEnum.动环.getCode());
alarmPoint.setUpdateDate(new Date());
alarmPoint.setContent(alramContent);
alarmPoint.setPointAttrs(equipmentAttrs);
alarmPoint.setPointName(eqpName);
alarmPointService.saveItem(alarmPoint);
log.info("Save alarm data....success");
//推送消息巡检app //组装动环信息JSON
//String url = address + "api/msgSubscribe/alarmNotification"; List<Map<String, String>> DHlist = new ArrayList<>();
try { for (JSONObject a : alarmAttributes) {
Map<String, Object> map = new HashMap<String, Object>(); String atr = (String) a.get("name");
map.put("code", msgJson.getString("orgCode")); String res = (String) msgJson.get(atr);
map.put("body", "告警源名称:" + eqpName + TAB + "告警信息" + alramContent); Map<String, String> map = new HashMap();
String stringJson = JSONObject.toJSONString(map); if (!"labelType".equals(atr)) {
//HttpUtil.PostJson(url, stringJson); map.put("name", a.get("displayName").toString());
CommonResponse result = patrolRemoteClient.sendAlarmNotification(stringJson); map.put("value", msgJson.get(atr).toString());
log.info("手机推送告警信息...success"); DHlist.add(map);
} catch (Exception e) {
log.info("手机推送告警信息失败...fail" + e.getMessage());
}
} }
iTopographyService.sendAbnormal(msgJson.getString("sourceId"), 1);
} }
Sort sort = new Sort(Sort.Direction.DESC, "updateDate"); if (nodeDetailMap.get("node_detail") != null) {
List<AlarmPoint> alarms = alarmPointService.findAll(sort); JSONArray nodeDetailArray = JSONArray.parseArray(nodeDetailMap.get("node_detail").toString());
for (int i = 0; i < DHlist.size(); i++) {
WebsocketParam param = new WebsocketParam("alarmPoint", JSON.toJSONString(alarms)); int count = 0;
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties"); for (int j = 0; j < nodeDetailArray.size(); j++) {
String url = (String) props.get("params.remoteWebsocketUrl") + "/generic/sendMessage"; if (DHlist.get(i).get("name").equals(JSONObject.parseObject(nodeDetailArray.get(j).toString()).get("name"))) {
HttpUtil.PostJson(url, JSON.toJSONString(param)); nodeDetailArray.getJSONObject(j).put("value", DHlist.get(i).get("value"));
log.info("send websocekt info:" + param); count++;
}
}
if (count == 0) {
JSONObject detailObject = new JSONObject();
detailObject.put("name", DHlist.get(i).get("name"));
detailObject.put("value", DHlist.get(i).get("value"));
nodeDetailArray.add(detailObject);
}
TopographyNodeDetail topographyNodeDetail = iTopographyNodeDetailDao.findByNodeid(nodeDetailMap.get("id").toString());
topographyNodeDetail.setNodeDetail(nodeDetailArray.toJSONString());
iTopographyNodeDetailDao.save(topographyNodeDetail);
}
} else {
JSONArray nodeDetailArray = new JSONArray();
for (int i = 0; i < DHlist.size(); i++) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", DHlist.get(i).get("name").toString());
jsonObject.put("value", DHlist.get(i).get("value").toString());
nodeDetailArray.add(jsonObject);
}
TopographyNodeDetail topographyNodeDetail = new TopographyNodeDetail();
topographyNodeDetail.setNodeDetail(JSON.toJSONString(nodeDetailArray));
topographyNodeDetail.setNodeid(nodeDetailMap.get("id").toString());
iTopographyNodeDetailDao.save(topographyNodeDetail);
}
//告警记录 //告警记录
String res = AlarmPointEnum.正常.getName();
String alarmTypeCombination="";
for (JSONObject atrJson : alarmAttributes) { for (JSONObject atrJson : alarmAttributes) {
String atrName = (String) atrJson.get("name"); String atrName = (String) atrJson.get("name");
String alarmType = (String) atrJson.get("displayName");
String res = (String) msgJson.get(atrName);
if ("labelType".equals(atrName)) { if ("labelType".equals(atrName)) {
continue; continue;
} }
String alarmType = (String) atrJson.get("displayName");
if(AlarmPointEnum.异常.getName().equals(msgJson.getString(atrName))||AlarmPointEnum.告警.getName().equals(msgJson.getString(atrName))){
alarmTypeCombination = alarmType + alarmTypeCombination;
res = AlarmPointEnum.异常.getName();
}
}
Long cpblId = msgJson.getLong("cpblId");
String sourceId = msgJson.getString("sourceId");
String orgCode = msgJson.getString("orgCode");
String authOrg = msgJson.getString("authOrg");
String eqpName = msgJson.getString("eqpName");
String alramContent = msgJson.getString("alramContent");
String authOrgTemp = JsonUtil.arraysToString(JsonUtil.toStringArray(authOrg));
if (!ObjectUtils.isEmpty(authOrgTemp)) {
orgCode = authOrgTemp;
}
//添加告警记录
if(!"运行参数".equals(cpblName)||!"常电监测".equals(cpblName)||!"常电监测".equals(cpblName)){
addRecordAlarm(alarmTypeCombination, res, sourceId, orgCode, authOrg, eqpName,cpblName,alramContent);
List<AlarmPoint> pointList = alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.动环.getCode(), eqpId,cpblId);
List<Alarm> curAlarmList = alarmService.selectByQuerySourceId(sourceId);
if (!alarmFlagBoolean && pointList.size() > 0) {
alarmPointService.deleteItems(pointList);
log.info("Clear p_alarm_point Alarm data ...success");
//设备所有的指标都不异常,才可以将state置为0
if(curAlarmList.size()==0){
iTopographyService.sendAbnormal(msgJson.getString("sourceId"), 0);
}
} else {
if (alarmFlagBoolean && pointList.size() == 0) {
// String alramContent = msgJson.getString("describe");
String eqpType = msgJson.getString("eqpType");
// String eqpName = msgJson.getString("eqpName");
String equipmentAttrs = msgJson.getString("equipmentAttrs");
// String sourceId = msgJson.getString("sourceId");
String authOrgs = getAuthOrg(msgJson.getString("authOrg"));
//String orgCode = msgJson.getString("orgCode");
AlarmPoint alarmPoint = new AlarmPoint();
alarmPoint.setCode(authOrgs);
alarmPoint.setSourceId(sourceId);
alarmPoint.setPointId(eqpId);
alarmPoint.setAuthOrg(authOrgs);
// alarmPoint.setPointType(eqpType);
alarmPoint.setPointType(AlarmPointTypeEnum.动环.getCode());
alarmPoint.setUpdateDate(new Date());
alarmPoint.setContent(eqpName+alarmTypeCombination);
alarmPoint.setPointAttrs(equipmentAttrs);
alarmPoint.setPointName(eqpName);
alarmPoint.setTarget(cpblId);
alarmPointService.saveItem(alarmPoint);
log.info("Save alarm data....success");
String sourceId = msgJson.getString("sourceId"); //推送消息巡检app
String orgCode = msgJson.getString("orgCode"); //String url = address + "api/msgSubscribe/alarmNotification";
String authOrg = msgJson.getString("authOrg"); try {
String eqpName = msgJson.getString("eqpName"); Map<String, Object> map = new HashMap<String, Object>();
String cpblName = msgJson.getString("cpblName"); map.put("code", msgJson.getString("orgCode"));
String authOrgTemp = JsonUtil.arraysToString(JsonUtil.toStringArray(authOrg)); map.put("body", "告警源名称:" + eqpName + TAB + "告警信息" + alramContent);
if (!ObjectUtils.isEmpty(authOrgTemp)) { String stringJson = JSONObject.toJSONString(map);
orgCode = authOrgTemp; //HttpUtil.PostJson(url, stringJson);
CommonResponse result = patrolRemoteClient.sendAlarmNotification(stringJson);
log.info("手机推送告警信息...success");
} catch (Exception e) {
log.info("手机推送告警信息失败...fail" + e.getMessage());
}
}else {
if(pointList.size()>0){
AlarmPoint alarmPoint =pointList.get(0);
alarmPoint.setContent(eqpName+alarmTypeCombination);
alarmPointService.save(alarmPoint);
}
}
}
if(alarmFlagBoolean){
iTopographyService.sendAbnormal(msgJson.getString("sourceId"), 1);
} }
//添加告警记录 Sort sort = new Sort(Sort.Direction.DESC, "updateDate");
addRecordAlarm(alarmType, res, sourceId, orgCode, authOrg, eqpName,cpblName); List<AlarmPoint> alarms = alarmPointService.findAll(sort);
WebsocketParam param = new WebsocketParam("alarmPoint", JSON.toJSONString(alarms));
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
String url = (String) props.get("params.remoteWebsocketUrl") + "/generic/sendMessage";
HttpUtil.PostJson(url, JSON.toJSONString(param));
log.info("send websocekt info:" + param);
} }
} }
}else { }else {
throw new YeeException("eqpId 不能为空!!!"); throw new YeeException("eqpId 不能为空!!!");
} }
} catch (Exception e) { } catch (Exception e) {
log.info("*********************error****************************"); log.info("*********************error****************************");
log.info(e.getMessage()); log.info(e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
private static String getAuthOrg(String authOrg) {
if (!StringUtils.isEmpty(authOrg) && authOrg.startsWith("[") && authOrg.endsWith("]")) {
String str = authOrg.substring(1, authOrg.length() - 1).replace(" ", "").replace(",", "#");
return "#"+ str;
}
return null;
}
/** /**
* 添加告警记录 * 添加告警记录
* @param alarmType 告警类型 * @param alarmType 告警类型
* @param alarmStatus 状态,正常 异常 * @param alarmStatus 状态,正常 异常
* @param sourceId * @param sourceId
* @param orgCode * @param orgCode
* @param authOrg * @param authOrg
* @param eqpName 设备名称 * @param eqpName 设备名称
* @param cpblName 报警类型 * @param cpblName 报警类型
*/ */
private void addRecordAlarm(String alarmType, String alarmStatus,String sourceId,String orgCode,String authOrg,String eqpName,String cpblName) { private void addRecordAlarm(String alarmType, String alarmStatus,String sourceId,String orgCode,String authOrg,String eqpName,String cpblName,String alramContent) {
//告警记录 //告警记录
String queryColumn = sourceId + "_" + alarmType; String queryColumn = sourceId + "_" + cpblName;
//查出当前记录中的告警记录 //查出当前记录中的告警记录
List<Alarm> curAlarmList = alarmService.findByQueryColumn(queryColumn); List<Alarm> curAlarmList = alarmService.findByQueryColumn(queryColumn);
if (curAlarmList != null && curAlarmList.size() > 0) { if (curAlarmList != null && curAlarmList.size() > 0) {
...@@ -252,8 +335,8 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient { ...@@ -252,8 +335,8 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient {
String subtract = DateTimeKit.getSubtract(alarm.getHappenDate()); String subtract = DateTimeKit.getSubtract(alarm.getHappenDate());
alarm.setContinueDate(subtract); alarm.setContinueDate(subtract);
} }
if ("异常".equals(alarmStatus)) { if (AlarmPointEnum.异常.getName().equals(alarmStatus)||AlarmPointEnum.告警.getName().equals(alarmStatus)) {
alarm.setCurrentState(ALARM_ABNORMAL_STATUS); alarm.setCurrentState(ALARM_ABNORMAL_STATUS);
} else { } else {
alarm.setClearDate(DateTimeKit.now()); alarm.setClearDate(DateTimeKit.now());
...@@ -264,9 +347,9 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient { ...@@ -264,9 +347,9 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient {
} else {//记录无告警则新增 } else {//记录无告警则新增
Alarm alarm = new Alarm(); Alarm alarm = new Alarm();
alarm.setSourceId(sourceId); alarm.setSourceId(sourceId);
alarm.setAlarmReason(ALARM_DEVICE_AlARAM); alarm.setAlarmReason(cpblName);
alarm.setAlarmSourceName(eqpName); alarm.setAlarmSourceName(eqpName);
alarm.setAlarmLevel(ALARM_DEVICE); alarm.setAlarmLevel(ALARM_DEVICE_MAJOR);
// alarm.setAlarmSourceIp(sourceId); // alarm.setAlarmSourceIp(sourceId);
alarm.setAlarmSourceType(ALARM_DEVICE_TYPE); alarm.setAlarmSourceType(ALARM_DEVICE_TYPE);
alarm.setClearDate(""); alarm.setClearDate("");
...@@ -275,8 +358,9 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient { ...@@ -275,8 +358,9 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient {
alarm.setEnsurePerson(""); alarm.setEnsurePerson("");
alarm.setOrgCode(orgCode); alarm.setOrgCode(orgCode);
alarm.setHappenDate(DateTimeKit.now()); alarm.setHappenDate(DateTimeKit.now());
alarm.setQueryColumn( sourceId + "_" + alarmType); alarm.setQueryColumn( sourceId + "_" + cpblName);
if ("异常".equals(alarmStatus)) { List<Alarm> curAlarmRList = alarmService.findByQueryColumn(queryColumn);
if (AlarmPointEnum.异常.getName().equals(alarmStatus)||AlarmPointEnum.异常.getName().equals(alarmStatus)) {
alarm.setCurrentState(ALARM_ABNORMAL_STATUS); alarm.setCurrentState(ALARM_ABNORMAL_STATUS);
iAlarmDao.save(alarm); iAlarmDao.save(alarm);
} else { } else {
...@@ -295,21 +379,4 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient { ...@@ -295,21 +379,4 @@ public class ShiduAlarmWebSocketClient extends WebSocketClient {
public void onError(Exception e) { public void onError(Exception e) {
log.info("abnormal " + e); log.info("abnormal " + e);
} }
public static synchronized void synMonitorAlarmPoint() {
System.out.println("-------------------shidu Monitoring of ring alarms start-------------------------");
try {
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
String monitorAlarmWebSocketClientUrl = (String) props.get("params.remoteWebsocketUrl") + "metricData?subData=shiduAlarm";
ShiduAlarmWebSocketClient client = new ShiduAlarmWebSocketClient(monitorAlarmWebSocketClientUrl);
client.connect();
while (!client.getReadyState().equals(WebSocket.READYSTATE.OPEN)) {
log.info("connecting... shidu Dynamic ring alarm----" + client.getReadyState());
}
System.out.println("build " + monitorAlarmWebSocketClientUrl + "connected...");
} catch (URISyntaxException | IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
} }
...@@ -20,22 +20,22 @@ public interface EquipmentMapper extends BaseMapper { ...@@ -20,22 +20,22 @@ public interface EquipmentMapper extends BaseMapper {
Long countByMap(PageParam pageParam); Long countByMap(PageParam pageParam);
void insertEquipment(EquipmentVo vo); void insertEquipment(EquipmentVo vo);
//void updateEquipment(EquipmentVo vo); //void updateEquipment(EquipmentVo vo);
//void updateEquipmentAttrs(EquipmentQualityVo vo); //void updateEquipmentAttrs(EquipmentQualityVo vo);
void insertEquipmentAttrs( EquipmentQualityVo vo); void insertEquipmentAttrs( EquipmentQualityVo vo);
/** /**
* 更新指标关联表中指标的状态 * 更新指标关联表中指标的状态
* @param status * @param status
* @param id * @param id
*/ */
void updateEquipmentPointStatus(@Param("state")int state,@Param("equipmentsPointId") Long equipmentsPointId); void updateEquipmentPointStatus(@Param("state")int state,@Param("equipmentsPointId") Long equipmentsPointId);
/** /**
* 根据设备Id和指标名称查询指标详情 * 根据设备Id和指标名称查询指标详情
* @param equipmentId * @param equipmentId
...@@ -43,14 +43,14 @@ public interface EquipmentMapper extends BaseMapper { ...@@ -43,14 +43,14 @@ public interface EquipmentMapper extends BaseMapper {
* @return * @return
*/ */
EquipmentQualityVo queryEquipmentPoint(@Param("equipmentId") Long equipmentId,@Param("remark") String remark); EquipmentQualityVo queryEquipmentPoint(@Param("equipmentId") Long equipmentId,@Param("remark") String remark);
/** /**
* 判断关联关系表中该指标是否存在 * 判断关联关系表中该指标是否存在
* @param equipmentsPointId * @param equipmentsPointId
* @return * @return
*/ */
List<Long> judgeEquipmentExists(@Param("equipmentsPointId") Long equipmentsPointId); List<Long> judgeEquipmentExists(@Param("equipmentsPointId") Long equipmentsPointId);
/** /**
* 判断关联关系表中该指标是否存在 * 判断关联关系表中该指标是否存在
* @param equipmentsPointId * @param equipmentsPointId
...@@ -64,13 +64,23 @@ public interface EquipmentMapper extends BaseMapper { ...@@ -64,13 +64,23 @@ public interface EquipmentMapper extends BaseMapper {
Long querySelfDeviceCount( Long querySelfDeviceCount(
@Param("fname") String fname); @Param("fname") String fname);
TopographyNode queryNodeBySourceId( @Param("sourceId")String sourceId); TopographyNode queryNodeBySourceId( @Param("sourceId")String sourceId);
void updateNodeState(TopographyNode node); void updateNodeState(TopographyNode node);
void updateNodeDetail(@Param("nodeid")String nodeid,@Param("nodeDetail")String nodeDetail); void updateNodeDetail(@Param("nodeid")String nodeid,@Param("nodeDetail")String nodeDetail);
void deleteOneHourNormal(); void deleteOneHourNormal();
/**
* 装备同步的时候先删除f_fire_equipment表的所有信息
* @return
*/
void deleteAllEquipmentInfo();
/**
* 装备同步的时候先删除f_fire_equipment_point表装备参数信息
* @return
*/
void deleteAllEquipmentPoint();
} }
...@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Param;
import com.yeejoin.amos.bank.common.enums.PaymentEnum; import com.yeejoin.amos.bank.common.enums.PaymentEnum;
public interface InputItemMapper extends BaseMapper { public interface InputItemMapper extends BaseMapper {
void deleteInputItemByMeasureContentId(@Param("measureContentId") String id); void deleteInputItemByMeasureContentId(@Param("measureContentId") String id);
List<HashMap<String, Object>> queryPaymentByCode(@Param("itemNo") String itemNo,@Param("name") String name); List<HashMap<String, Object>> queryPaymentByCode(@Param("itemNo") String itemNo,@Param("name") String name);
...@@ -21,4 +21,9 @@ public interface InputItemMapper extends BaseMapper { ...@@ -21,4 +21,9 @@ public interface InputItemMapper extends BaseMapper {
List<HashMap<String, Object>> getcountyc(@Param("code") String code); List<HashMap<String, Object>> getcountyc(@Param("code") String code);
List<HashMap<String, Object>> getcountnum(@Param("code")String code); List<HashMap<String, Object>> getcountnum(@Param("code")String code);
List<HashMap<String, Object>> getxuncount(@Param("code") String code); List<HashMap<String, Object>> getxuncount(@Param("code") String code);
/**
* 统计七天之前每天的告警数量
* @return
*/
List<Long> getSevenDayscount (@Param("alarmLevel") String alarmLevel);
} }
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
<artifactId>AmosBankService</artifactId> <artifactId>AmosBankService</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>AmosBankService</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<!-- maven打包时将lib提取到jar同目录,将配置文件提取到jar目录/config/下 --> <!-- maven打包时将lib提取到jar同目录,将配置文件提取到jar目录/config/下 -->
......
...@@ -93,5 +93,7 @@ param.remoteurl=http://localhost:8080 ...@@ -93,5 +93,7 @@ param.remoteurl=http://localhost:8080
## emqx ## emqx
emqx.clean-session=true emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]} emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.11.20:1883 emqx.broker=tcp://172.16.10.85:1883
emqx.password=0 emqx.password=0
\ No newline at end of file
gateway.fegin.name=AMOS-BANK-SERVER-GATEWAY-WJK
\ No newline at end of file
...@@ -93,7 +93,7 @@ spring.rabbitmq.connection-timeout=1000 ...@@ -93,7 +93,7 @@ spring.rabbitmq.connection-timeout=1000
spring.redis.jedis.pool.min-idle=0 spring.redis.jedis.pool.min-idle=0
spring.redis.jedis.pool.max-wait=-1 spring.redis.jedis.pool.max-wait=-1
gateway.fegin.name=AMOS-BANK-SERVER-GATEWAY
param.remoteurl=http://localhost:8080 param.remoteurl=http://localhost:8080
#tcp.host=172.16.3.42 #tcp.host=172.16.3.42
#tcp.port=8888 #tcp.port=8888
......
...@@ -93,7 +93,7 @@ spring.rabbitmq.connection-timeout=1000 ...@@ -93,7 +93,7 @@ spring.rabbitmq.connection-timeout=1000
spring.redis.jedis.pool.min-idle=0 spring.redis.jedis.pool.min-idle=0
spring.redis.jedis.pool.max-wait=-1 spring.redis.jedis.pool.max-wait=-1
gateway.fegin.name=AMOS-BANK-SERVER-GATEWAY
param.remoteurl=http://localhost:8080 param.remoteurl=http://localhost:8080
#tcp.host=172.16.3.42 #tcp.host=172.16.3.42
#tcp.port=8888 #tcp.port=8888
\ No newline at end of file
...@@ -128,8 +128,8 @@ ...@@ -128,8 +128,8 @@
</if> </if>
</where> </where>
</select> </select>
<insert id="insertEquipment" <insert id="insertEquipment"
parameterType="com.yeejoin.amos.bank.entity.EquipmentVo" parameterType="com.yeejoin.amos.bank.entity.EquipmentVo"
useGeneratedKeys="true" keyProperty="id"> useGeneratedKeys="true" keyProperty="id">
...@@ -164,7 +164,7 @@ ...@@ -164,7 +164,7 @@
</if> </if>
</trim> </trim>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
<trim suffixOverrides=","> <trim suffixOverrides=",">
<if test="id !=null">`id`=#{id},</if> <if test="id !=null">`id`=#{id},</if>
<if test="orgCode !=null">`org_code`=#{orgCode},</if> <if test="orgCode !=null">`org_code`=#{orgCode},</if>
...@@ -172,8 +172,8 @@ ...@@ -172,8 +172,8 @@
<if test="name !=null">name=#{name}</if> <if test="name !=null">name=#{name}</if>
</trim> </trim>
</insert> </insert>
<insert id="insertEquipmentAttrs" <insert id="insertEquipmentAttrs"
parameterType="com.yeejoin.amos.bank.entity.EquipmentQualityVo" parameterType="com.yeejoin.amos.bank.entity.EquipmentQualityVo"
useGeneratedKeys="true" keyProperty="id" > useGeneratedKeys="true" keyProperty="id" >
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
</if> </if>
</trim> </trim>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
<trim suffixOverrides=","> <trim suffixOverrides=",">
<if test="id !=null">`id`=#{id},</if> <if test="id !=null">`id`=#{id},</if>
<if test="type !=null">`type`=#{type},</if> <if test="type !=null">`type`=#{type},</if>
...@@ -228,21 +228,21 @@ ...@@ -228,21 +228,21 @@
<if test="displayName !=null">`name`=#{displayName},</if> <if test="displayName !=null">`name`=#{displayName},</if>
<if test="code !=null">code=#{code},</if> <if test="code !=null">code=#{code},</if>
<if test="equipmentId !=null">fire_equipment_id=#{equipmentId}</if> <if test="equipmentId !=null">fire_equipment_id=#{equipmentId}</if>
</trim> </trim>
</insert> </insert>
<update id="updateEquipmentPointStatus" > <update id="updateEquipmentPointStatus" >
UPDATE UPDATE
r_risk_factor_equipment_index r_risk_factor_equipment_index
set set
state=#{state} state=#{state}
WHERE WHERE
equipment_point_id=#{equipmentsPointId} equipment_point_id=#{equipmentsPointId}
</update> </update>
<select id = "queryEquipmentPoint" resultType="com.yeejoin.amos.bank.entity.EquipmentQualityVo"> <select id = "queryEquipmentPoint" resultType="com.yeejoin.amos.bank.entity.EquipmentQualityVo">
SELECT SELECT
f.id as id, f.id as id,
...@@ -250,23 +250,23 @@ ...@@ -250,23 +250,23 @@
f.`code` as code, f.`code` as code,
f.fire_equipment_id as equipmentId, f.fire_equipment_id as equipmentId,
f.remark as remark f.remark as remark
FROM FROM
f_fire_equipment_point f f_fire_equipment_point f
WHERE WHERE
f.fire_equipment_id = #{equipmentId} f.fire_equipment_id = #{equipmentId}
AND AND
f.remark = #{remark} f.remark = #{remark}
</select> </select>
<select id = "judgeEquipmentExists" resultType="java.lang.Long"> <select id = "judgeEquipmentExists" resultType="java.lang.Long">
SELECT SELECT
f.risk_factor_id f.risk_factor_id
FROM FROM
r_risk_factor_equipment_index f r_risk_factor_equipment_index f
WHERE equipment_point_id=#{equipmentsPointId} WHERE equipment_point_id=#{equipmentsPointId}
</select> </select>
<select id="querySelfDeviceCount" resultType="long"> <select id="querySelfDeviceCount" resultType="long">
SELECT SELECT
count( DISTINCT fe.id) count( DISTINCT fe.id)
...@@ -276,11 +276,11 @@ ...@@ -276,11 +276,11 @@
<if test="fname != null" > <if test="fname != null" >
AND fe.`name` like concat('%',#{fname},'%') AND fe.`name` like concat('%',#{fname},'%')
</if> </if>
</select> </select>
<select id="querySelfDevice" resultType="com.yeejoin.amos.bank.entity.DeviceRecord"> <select id="querySelfDevice" resultType="com.yeejoin.amos.bank.entity.DeviceRecord">
SELECT SELECT
id, id,
...@@ -291,17 +291,17 @@ ...@@ -291,17 +291,17 @@
FROM FROM
b_device_record efe b_device_record efe
WHERE 1=1 WHERE 1=1
ORDER BY update_date DESC ORDER BY update_date DESC
<if test="fname != null"> <if test="fname != null">
AND efe.`name` like concat('%',#{fname},'%') AND efe.`name` like concat('%',#{fname},'%')
</if> </if>
<if test="length > 0"> <if test="length > 0">
LIMIT ${start},${length} ; LIMIT ${start},${length} ;
</if> </if>
</select> </select>
<select id="queryNodeBySourceId" resultType="com.yeejoin.amos.bank.TopographyNode"> <select id="queryNodeBySourceId" resultType="com.yeejoin.amos.bank.TopographyNode">
SELECT SELECT
* *
...@@ -311,9 +311,9 @@ ...@@ -311,9 +311,9 @@
<if test="sourceId != null"> <if test="sourceId != null">
AND efe.`source_id`= #{sourceId} AND efe.`source_id`= #{sourceId}
</if> </if>
</select> </select>
<update id="updateNodeState" parameterType="com.yeejoin.amos.bank.TopographyNode"> <update id="updateNodeState" parameterType="com.yeejoin.amos.bank.TopographyNode">
UPDATE b_topography_node UPDATE b_topography_node
<trim prefix="set" suffixOverrides=","> <trim prefix="set" suffixOverrides=",">
...@@ -322,24 +322,24 @@ ...@@ -322,24 +322,24 @@
</trim> </trim>
WHERE source_id=#{sourceId} WHERE source_id=#{sourceId}
</update > </update >
<update id="updateNodeDetail" > <update id="updateNodeDetail" >
UPDATE b_topography_node_detail UPDATE b_topography_node_detail
<trim prefix="set" suffixOverrides=","> <trim prefix="set" suffixOverrides=",">
<if test="nodeDetail != null">node_detail=#{nodeDetail},</if> <if test="nodeDetail != null">node_detail=#{nodeDetail},</if>
</trim> </trim>
WHERE nodeid=#{nodeid} WHERE nodeid=#{nodeid}
</update > </update >
<delete id="deleteOneHourNormal"> <delete id="deleteOneHourNormal">
DELETE DELETE
FROM FROM
b_device_record b_device_record
WHERE WHERE
id IN ( id IN (
SELECT a.id from( SELECT a.id from(
SELECT SELECT
`ID` `ID`
...@@ -350,4 +350,11 @@ ...@@ -350,4 +350,11 @@
) )
</delete> </delete>
<delete id="deleteAllEquipmentInfo">
DELETE FROM f_fire_equipment
</delete>
<delete id="deleteAllEquipmentPoint">
DELETE FROM f_fire_equipment_point
</delete>
</mapper> </mapper>
\ No newline at end of file
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
WHERE WHERE
original_id = #{measureContentId} original_id = #{measureContentId}
</update> </update>
<select id="queryPaymentByCode" parameterType="java.lang.String" resultType="java.util.HashMap"> <select id="queryPaymentByCode" parameterType="java.lang.String" resultType="java.util.HashMap">
<!-- select <!-- select
SUM(IFNULL(I.input_value,0)) as score,I.point_classify_name as payName,#{name} as name SUM(IFNULL(I.input_value,0)) as score,I.point_classify_name as payName,#{name} as name
from p_check C from p_check C
left join p_check_input I on C.id=I.check_id left join p_check_input I on C.id=I.check_id
...@@ -49,12 +49,12 @@ ...@@ -49,12 +49,12 @@
group by I.point_classify_name,M.name,M.item_no group by I.point_classify_name,M.name,M.item_no
order by M.item_no order by M.item_no
</select>--> </select>-->
<select id="queryPaymentByCodes" resultType="java.util.HashMap" parameterType="java.util.List"> <select id="queryPaymentByCodes" resultType="java.util.HashMap" parameterType="java.util.List">
select I.input_value as score,I.point_classify_name as payName,M.name,M.item_no select I.input_value as score,I.point_classify_name as payName,M.name,M.item_no
from p_check_input I from p_check_input I
left join p_input_item M ON M.id = I.input_id left join p_input_item M ON M.id = I.input_id
where where
I.is_ok != 3 I.is_ok != 3
AND I.id in AND I.id in
( SELECT max(I.id) FROM ( SELECT max(I.id) FROM
...@@ -77,29 +77,29 @@ ...@@ -77,29 +77,29 @@
group by I.point_classify_name,M.name,M.item_no group by I.point_classify_name,M.name,M.item_no
order by M.item_no order by M.item_no
</select> </select>
<delete id="deletePointAlarmByIds"> <delete id="deletePointAlarmByIds">
delete from p_alarm_point delete from p_alarm_point
where id IN where id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")"> <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</delete> </delete>
<select id="getcountnum" parameterType="java.lang.String" resultType="java.util.HashMap"> <select id="getcountnum" parameterType="java.lang.String" resultType="java.util.HashMap">
select COUNT(id) num select COUNT(id) num
from r_risk_source from r_risk_source
where is_region='FALSE' where is_region='FALSE'
<if test="code != null and code != ''"> <if test="code != null and code != ''">
and r_risk_source.org_code LIKE concat( #{code}, "%") and r_risk_source.org_code LIKE concat( #{code}, "%")
</if> </if>
</select> </select>
<select id="getcountxd" parameterType="java.lang.String" resultType="java.util.HashMap"> <select id="getcountxd" parameterType="java.lang.String" resultType="java.util.HashMap">
select select
CASE r_risk_level.`code` CASE r_risk_level.`code`
WHEN 1 THEN WHEN 1 THEN
'一级风险' '一级风险'
...@@ -111,26 +111,26 @@ ...@@ -111,26 +111,26 @@
'四级风险' '四级风险'
WHEN 5 THEN WHEN 5 THEN
'五级风险' '五级风险'
END END
name , name ,
r_risk_level.`code`, r_risk_level.`code`,
a.num a.num
from r_risk_level LEFT JOIN (select COUNT(r_risk_source.id) num,r_risk_level.`code` from r_risk_level LEFT JOIN (select COUNT(r_risk_source.id) num,r_risk_level.`code`
from r_risk_source RIGHT JOIN r_risk_level on r_risk_source.risk_level_id=r_risk_level.id from r_risk_source RIGHT JOIN r_risk_level on r_risk_source.risk_level_id=r_risk_level.id
where is_region='FALSE' where is_region='FALSE'
<if test="code != null and code != ''"> <if test="code != null and code != ''">
and r_risk_source.org_code LIKE concat( #{code}, "%") and r_risk_source.org_code LIKE concat( #{code}, "%")
</if> </if>
GROUP BY r_risk_level.id) a on a.code= r_risk_level.`code` GROUP BY r_risk_level.id) a on a.code= r_risk_level.`code`
</select> </select>
<select id="getcountyc" parameterType="java.lang.String" resultType="java.util.HashMap"> <select id="getcountyc" parameterType="java.lang.String" resultType="java.util.HashMap">
select select
CASE r_risk_level.`code` CASE r_risk_level.`code`
WHEN 1 THEN WHEN 1 THEN
'一级风险' '一级风险'
...@@ -142,31 +142,56 @@ from r_risk_level LEFT JOIN (select COUNT(r_risk_source.id) num,r_risk_leve ...@@ -142,31 +142,56 @@ from r_risk_level LEFT JOIN (select COUNT(r_risk_source.id) num,r_risk_leve
'四级风险' '四级风险'
WHEN 5 THEN WHEN 5 THEN
'五级风险' '五级风险'
END END
name , name ,
r_risk_level.`code`, r_risk_level.`code`,
a.num a.num
from r_risk_level LEFT JOIN (select COUNT(r_risk_source.id) num, r_risk_level.`code` from r_risk_level LEFT JOIN (select COUNT(r_risk_source.id) num, r_risk_level.`code`
from r_risk_source RIGHT JOIN r_risk_level on r_risk_source.risk_level_id=r_risk_level.id from r_risk_source RIGHT JOIN r_risk_level on r_risk_source.risk_level_id=r_risk_level.id
where is_region='FALSE' and r_risk_source.flicker_frequency >0 where is_region='FALSE' and r_risk_source.flicker_frequency >0
<if test="code != null and code != ''"> <if test="code != null and code != ''">
and r_risk_source.org_code LIKE concat( #{code}, "%") and r_risk_source.org_code LIKE concat( #{code}, "%")
</if> </if>
GROUP BY r_risk_level.id) a on a.code= r_risk_level.`code` GROUP BY r_risk_level.id) a on a.code= r_risk_level.`code`
</select> </select>
<select id="getxuncount" parameterType="java.lang.String" resultType="java.util.HashMap"> <select id="getxuncount" resultType="java.util.HashMap">
select status ,count(id) num from p_point where p_point.is_delete=0 and p_point.org_code LIKE concat( #{code}, "%") GROUP BY status select status ,count(id) num from p_point where p_point.is_delete=0 and p_point.org_code LIKE concat( #{code}, "%") GROUP BY status
</select> </select>
<select id="getSevenDayscount" parameterType="java.lang.String" resultType="java.lang.Long">
SELECT
ifnull( b.count, 0 ) AS count
FROM
(
SELECT
date_sub( curdate( ), INTERVAL 1 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 2 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 3 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 4 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 5 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 6 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 7 DAY ) AS click_date
) a
LEFT JOIN (
SELECT date( happen_date ) AS happen_date, count( * ) AS count FROM spc_alarm
WHERE alarm_level = #{alarmLevel} GROUP BY date( happen_date )
) b ON a.click_date = b.happen_date
ORDER BY a.click_date ASC
</select>
</mapper> </mapper>
\ No newline at end of file
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