Commit 519c1bae authored by chenzhao's avatar chenzhao

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents a585c478 f3a598ab
...@@ -256,7 +256,7 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -256,7 +256,7 @@ public class BigScreenAnalyseController extends BaseController {
HashMap<String, Integer> wxMap = new HashMap<>(); HashMap<String, Integer> wxMap = new HashMap<>();
HashMap<String, Integer> zyMap = new HashMap<>(); HashMap<String, Integer> zyMap = new HashMap<>();
HashMap<String, Integer> jgMap = new HashMap<>(); HashMap<String, Integer> jgMap = new HashMap<>();
Set<String> list = new HashSet<>(); LinkedHashSet<String> list = new LinkedHashSet<>();
allEquipAlarmInfo.forEach(item -> { allEquipAlarmInfo.forEach(item -> {
if ("危险".equals(item.get("warningName"))) { if ("危险".equals(item.get("warningName"))) {
wxMap.put(item.get("station").toString(), Integer.parseInt(item.get("num").toString())); wxMap.put(item.get("station").toString(), Integer.parseInt(item.get("num").toString()));
...@@ -436,8 +436,8 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -436,8 +436,8 @@ public class BigScreenAnalyseController extends BaseController {
} else { } else {
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备"); query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizFanHealthLevel::getStatus, stationBasic.getStationName()); query.eq(IdxBizFanHealthLevel::getStatus, item.get("station"));
query.le(IdxBizFanHealthLevel::getGroupLowerLimit, equipmentHealthScore); query.lt(IdxBizFanHealthLevel::getGroupLowerLimit, equipmentHealthScore);
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, equipmentHealthScore); query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, equipmentHealthScore);
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query); IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query);
item.put("warningName", idxBizFanHealthLevel.getHealthLevel()); item.put("warningName", idxBizFanHealthLevel.getHealthLevel());
...@@ -514,7 +514,7 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -514,7 +514,7 @@ public class BigScreenAnalyseController extends BaseController {
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备"); query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizFanHealthLevel::getStatus, item.get("station")); query.eq(IdxBizFanHealthLevel::getStatus, item.get("station"));
query.le(IdxBizFanHealthLevel::getGroupLowerLimit, equipmentHealthScore); query.lt(IdxBizFanHealthLevel::getGroupLowerLimit, equipmentHealthScore);
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, equipmentHealthScore); query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, equipmentHealthScore);
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query); IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query);
item.put("warningName", idxBizFanHealthLevel.getHealthLevel()); item.put("warningName", idxBizFanHealthLevel.getHealthLevel());
...@@ -549,13 +549,13 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -549,13 +549,13 @@ public class BigScreenAnalyseController extends BaseController {
if (100.0 == equipmentHealthScore) { if (100.0 == equipmentHealthScore) {
item.put("warningName", "安全"); item.put("warningName", "安全");
} else { } else {
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备"); query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizFanHealthLevel::getStatus, stationBasic.getStationName()); query.eq(IdxBizPvHealthLevel::getStatus, item.get("station").toString());
query.le(IdxBizFanHealthLevel::getGroupLowerLimit, equipmentHealthScore); query.lt(IdxBizPvHealthLevel::getGroupLowerLimit, equipmentHealthScore);
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, equipmentHealthScore); query.ge(IdxBizPvHealthLevel::getGroupUpperLimit, equipmentHealthScore);
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query); IdxBizPvHealthLevel idxBizPvHealthLevel = idxBizPvHealthLevelMapper.selectOne(query);
item.put("warningName", idxBizFanHealthLevel.getHealthLevel()); item.put("warningName", idxBizPvHealthLevel.getHealthLevel());
} }
item.put("healthIndex", equipmentHealthScore); item.put("healthIndex", equipmentHealthScore);
String subarray = CharSequenceUtil.replace(item.get("subarray").toString(), "#", ""); String subarray = CharSequenceUtil.replace(item.get("subarray").toString(), "#", "");
...@@ -616,13 +616,13 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -616,13 +616,13 @@ public class BigScreenAnalyseController extends BaseController {
if (100.0 == equipmentHealthScore) { if (100.0 == equipmentHealthScore) {
item.put("warningName", "安全"); item.put("warningName", "安全");
} else { } else {
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备"); query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizFanHealthLevel::getStatus, stationBasic.getStationName()); query.eq(IdxBizPvHealthLevel::getStatus, item.get("station").toString());
query.le(IdxBizFanHealthLevel::getGroupLowerLimit, equipmentHealthScore); query.lt(IdxBizPvHealthLevel::getGroupLowerLimit, equipmentHealthScore);
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, equipmentHealthScore); query.ge(IdxBizPvHealthLevel::getGroupUpperLimit, equipmentHealthScore);
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query); IdxBizPvHealthLevel idxBizPvHealthLevel = idxBizPvHealthLevelMapper.selectOne(query);
item.put("warningName", idxBizFanHealthLevel.getHealthLevel()); item.put("warningName", idxBizPvHealthLevel.getHealthLevel());
} }
item.put("healthIndex", equipmentHealthScore); item.put("healthIndex", equipmentHealthScore);
}); });
...@@ -708,7 +708,7 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -708,7 +708,7 @@ public class BigScreenAnalyseController extends BaseController {
String stationType = "风电站"; String stationType = "风电站";
List<IdxBizFanHealthLevel> collect = healthLevelInfoList.stream().filter(item -> item.getAnalysisObjType().contains(station)).collect(Collectors.toList()); List<IdxBizFanHealthLevel> collect = healthLevelInfoList.stream().filter(item -> item.getAnalysisObjType().contains(station)).collect(Collectors.toList());
for (IdxBizFanHealthLevel item : collect) { for (IdxBizFanHealthLevel item : collect) {
if (item.getAnalysisObjType().contains("子系统")) { if (!item.getAnalysisObjType().contains("子系统")) {
stationType = "光伏站"; stationType = "光伏站";
} }
} }
...@@ -784,7 +784,7 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -784,7 +784,7 @@ public class BigScreenAnalyseController extends BaseController {
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.isNull(IdxBizFanHealthLevel::getStatus); query.isNull(IdxBizFanHealthLevel::getStatus);
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "全域"); query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "全域");
query.le(IdxBizFanHealthLevel::getGroupLowerLimit, healthScoreInfo); query.lt(IdxBizFanHealthLevel::getGroupLowerLimit, healthScoreInfo);
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, healthScoreInfo); query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, healthScoreInfo);
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query); IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query);
...@@ -808,7 +808,7 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -808,7 +808,7 @@ public class BigScreenAnalyseController extends BaseController {
LambdaQueryWrapper<IdxBizFanHealthLevel> areaQuery = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> areaQuery = new LambdaQueryWrapper<>();
areaQuery.isNull(IdxBizFanHealthLevel::getStatus); areaQuery.isNull(IdxBizFanHealthLevel::getStatus);
areaQuery.eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区"); areaQuery.eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区");
areaQuery.le(IdxBizFanHealthLevel::getGroupLowerLimit, areaHealthScoreInfo); areaQuery.lt(IdxBizFanHealthLevel::getGroupLowerLimit, areaHealthScoreInfo);
areaQuery.ge(IdxBizFanHealthLevel::getGroupUpperLimit, areaHealthScoreInfo); areaQuery.ge(IdxBizFanHealthLevel::getGroupUpperLimit, areaHealthScoreInfo);
IdxBizFanHealthLevel areaIdxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(areaQuery); IdxBizFanHealthLevel areaIdxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(areaQuery);
...@@ -848,7 +848,7 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -848,7 +848,7 @@ public class BigScreenAnalyseController extends BaseController {
LambdaQueryWrapper<IdxBizFanHealthLevel> stationQuery = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> stationQuery = new LambdaQueryWrapper<>();
stationQuery.like(IdxBizFanHealthLevel::getStatus, stationMap.getKey()); stationQuery.like(IdxBizFanHealthLevel::getStatus, stationMap.getKey());
stationQuery.eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站"); stationQuery.eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站");
stationQuery.le(IdxBizFanHealthLevel::getGroupLowerLimit, areaHealthScoreInfo); stationQuery.lt(IdxBizFanHealthLevel::getGroupLowerLimit, areaHealthScoreInfo);
stationQuery.ge(IdxBizFanHealthLevel::getGroupUpperLimit, areaHealthScoreInfo); stationQuery.ge(IdxBizFanHealthLevel::getGroupUpperLimit, areaHealthScoreInfo);
IdxBizFanHealthLevel stationLevel = idxBizFanHealthLevelMapper.selectOne(stationQuery); IdxBizFanHealthLevel stationLevel = idxBizFanHealthLevelMapper.selectOne(stationQuery);
stationDto.setStatus(ObjectUtils.isNotEmpty(stationLevel) ? stationLevel.getHealthLevel() : ""); stationDto.setStatus(ObjectUtils.isNotEmpty(stationLevel) ? stationLevel.getHealthLevel() : "");
...@@ -856,7 +856,7 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -856,7 +856,7 @@ public class BigScreenAnalyseController extends BaseController {
LambdaQueryWrapper<IdxBizPvHealthLevel> stationPvQuery = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvHealthLevel> stationPvQuery = new LambdaQueryWrapper<>();
stationPvQuery.like(IdxBizPvHealthLevel::getStatus, stationMap.getKey()); stationPvQuery.like(IdxBizPvHealthLevel::getStatus, stationMap.getKey());
stationPvQuery.eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站"); stationPvQuery.eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站");
stationPvQuery.le(IdxBizPvHealthLevel::getGroupLowerLimit, areaHealthScoreInfo); stationPvQuery.lt(IdxBizPvHealthLevel::getGroupLowerLimit, areaHealthScoreInfo);
stationPvQuery.ge(IdxBizPvHealthLevel::getGroupUpperLimit, areaHealthScoreInfo); stationPvQuery.ge(IdxBizPvHealthLevel::getGroupUpperLimit, areaHealthScoreInfo);
IdxBizPvHealthLevel stationPvLevel = idxBizPvHealthLevelMapper.selectOne(stationPvQuery); IdxBizPvHealthLevel stationPvLevel = idxBizPvHealthLevelMapper.selectOne(stationPvQuery);
if (ObjectUtils.isNotEmpty(stationPvLevel)) { if (ObjectUtils.isNotEmpty(stationPvLevel)) {
...@@ -977,4 +977,17 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -977,4 +977,17 @@ public class BigScreenAnalyseController extends BaseController {
} }
return ResponseHelper.buildResponse(maps); return ResponseHelper.buildResponse(maps);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风电-场站风速")
@GetMapping("/getFanWindSpeedInfo")
public ResponseModel<Map<String, String>> getFanWindSpeedInfo(@RequestParam("stationId") String stationId) throws Exception {
if (StrUtil.isNotEmpty(stationId)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
stationId = stationBasic.getFanGatewayId();
}
return ResponseHelper.buildResponse(null);
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.emqx; package com.yeejoin.amos.boot.module.jxiop.biz.emqx;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.HealthStatusIndicatorServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRecordServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRecordServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -16,9 +18,10 @@ import org.typroject.tyboot.component.emq.EmqKeeper; ...@@ -16,9 +18,10 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener; import org.typroject.tyboot.component.emq.EmqxListener;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.Date; import java.util.*;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
...@@ -26,11 +29,15 @@ public class WarningRecordStatusMessage extends EmqxListener { ...@@ -26,11 +29,15 @@ public class WarningRecordStatusMessage extends EmqxListener {
@Autowired @Autowired
protected EmqKeeper emqKeeper; protected EmqKeeper emqKeeper;
/**
* 预警状态修改消息 - 标准化
*/
public static final String WARNING_CHANGE_MESSAGE = "+/warning/change";
// 江西电建接收红黄绿码主题
private static final String QUESTION_STATUS_CHANGE = "question/status/change";
private static final BlockingQueue<JSONObject> blockingQueue = new LinkedBlockingQueue<JSONObject>(); private static final BlockingQueue<JSONArray> blockingQueueFan = new LinkedBlockingQueue<JSONArray>();
private static final BlockingQueue<JSONArray> blockingQueuePv = new LinkedBlockingQueue<JSONArray>();
@Autowired @Autowired
private IdxBizFanWarningRecordServiceImpl idxBizFanWarningRecordService; private IdxBizFanWarningRecordServiceImpl idxBizFanWarningRecordService;
...@@ -41,14 +48,21 @@ public class WarningRecordStatusMessage extends EmqxListener { ...@@ -41,14 +48,21 @@ public class WarningRecordStatusMessage extends EmqxListener {
@PostConstruct @PostConstruct
void init() throws Exception { void init() throws Exception {
new Thread(taskRunnable).start(); new Thread(taskRunnable).start();
emqKeeper.subscript(QUESTION_STATUS_CHANGE, 2, this); emqKeeper.subscript(WARNING_CHANGE_MESSAGE, 2, this);
} }
@Override @Override
public void processMessage(String topic, MqttMessage message) throws Exception { public void processMessage(String topic, MqttMessage message) throws Exception {
log.info("人员赋码消息{}", new String(message.getPayload())); if (topic.contains(HealthStatusIndicatorServiceImpl.SMART_ANALYSE_PV)) {
JSONObject ja = JSON.parseObject(new String(message.getPayload())); log.info("预警状态改变消息-光伏{}", new String(message.getPayload()));
blockingQueue.add(ja); JSONArray ja = JSON.parseArray(new String(message.getPayload()));
blockingQueuePv.add(ja);
} else if (topic.contains(HealthStatusIndicatorServiceImpl.SMART_ANALYSE_FAN)) {
log.info("预警状态改变消息-风电{}", new String(message.getPayload()));
JSONArray ja = JSON.parseArray(new String(message.getPayload()));
blockingQueueFan.add(ja);
}
} }
Runnable taskRunnable = new Runnable() { Runnable taskRunnable = new Runnable() {
...@@ -60,8 +74,10 @@ public class WarningRecordStatusMessage extends EmqxListener { ...@@ -60,8 +74,10 @@ public class WarningRecordStatusMessage extends EmqxListener {
k++; k++;
isRun = k < Integer.MAX_VALUE; isRun = k < Integer.MAX_VALUE;
try { try {
JSONObject analysisResult = blockingQueue.take(); JSONArray analysisResultFan = blockingQueueFan.take();
jxIopUpdate(analysisResult); jxIopUpdateFan(analysisResultFan);
JSONArray analysisResultPv = blockingQueuePv.take();
jxIopUpdatePv(analysisResultPv);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -69,22 +85,28 @@ public class WarningRecordStatusMessage extends EmqxListener { ...@@ -69,22 +85,28 @@ public class WarningRecordStatusMessage extends EmqxListener {
} }
}; };
public void jxIopUpdate(JSONObject analysisResult) { public void jxIopUpdateFan(JSONArray analysisResult) {
log.info("修改预警状态信息:{}", analysisResult); log.info("修改预警状态信息:{}", analysisResult);
if (ObjectUtils.isNotEmpty(analysisResult) && analysisResult.get("warningObjectType").toString().equals("pv")) { List<JSONObject> taskList = JSONObject.parseArray(analysisResult.toJSONString(), JSONObject.class);
List<String> traceIds = taskList.stream().map(t -> t.get("traceId").toString()).collect(Collectors.toList());
LambdaUpdateWrapper<IdxBizFanWarningRecord> lambda = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<IdxBizFanWarningRecord> lambda = new LambdaUpdateWrapper<>();
lambda.set(IdxBizFanWarningRecord::getDisposotionState, "已处置"); lambda.set(IdxBizFanWarningRecord::getDisposotionState, "已处置");
lambda.set(IdxBizFanWarningRecord::getStatus, "1"); lambda.set(IdxBizFanWarningRecord::getStatus, "1");
lambda.set(IdxBizFanWarningRecord::getDisposotionDate, new Date()); lambda.set(IdxBizFanWarningRecord::getDisposotionDate, new Date());
lambda.eq(IdxBizFanWarningRecord::getSequenceNbr, analysisResult.get("objectId")); lambda.in(IdxBizFanWarningRecord::getSequenceNbr, traceIds);
idxBizFanWarningRecordService.update(lambda); idxBizFanWarningRecordService.update(lambda);
} else if (ObjectUtils.isNotEmpty(analysisResult) && analysisResult.get("warningObjectType").toString().equals("fan")) {
}
public void jxIopUpdatePv(JSONArray analysisResult) {
log.info("修改预警状态信息:{}", analysisResult);
List<JSONObject> taskList = JSONObject.parseArray(analysisResult.toJSONString(), JSONObject.class);
List<String> traceIds = taskList.stream().map(t -> t.get("traceId").toString()).collect(Collectors.toList());
LambdaUpdateWrapper<IdxBizPvWarningRecord> lambda = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<IdxBizPvWarningRecord> lambda = new LambdaUpdateWrapper<>();
lambda.set(IdxBizPvWarningRecord::getDisposotionState, "已处置"); lambda.set(IdxBizPvWarningRecord::getDisposotionState, "已处置");
lambda.set(IdxBizPvWarningRecord::getStatus, "1"); lambda.set(IdxBizPvWarningRecord::getStatus, "1");
lambda.set(IdxBizPvWarningRecord::getDisposotionDate, new Date()); lambda.set(IdxBizPvWarningRecord::getDisposotionDate, new Date());
lambda.eq(IdxBizPvWarningRecord::getSequenceNbr, analysisResult.get("objectId")); lambda.in(IdxBizPvWarningRecord::getSequenceNbr, traceIds);
idxBizPvWarningRecordService.update(lambda); idxBizPvWarningRecordService.update(lambda);
} }
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.emqx; //package com.yeejoin.amos.boot.module.jxiop.biz.emqx;
//
import com.alibaba.fastjson.JSON; //import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; //import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; //import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord; //import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord; //import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl; //import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRecordServiceImpl; //import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRecordServiceImpl;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage; //import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper; //import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener; //import org.typroject.tyboot.component.emq.EmqxListener;
//
import javax.annotation.PostConstruct; //import javax.annotation.PostConstruct;
import java.util.Date; //import java.util.Date;
import java.util.List; //import java.util.List;
import java.util.concurrent.BlockingQueue; //import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; //import java.util.concurrent.LinkedBlockingQueue;
//
/** ///**
* 处理无需处置情况 // * 处理无需处置情况
*/ // */
@Component //@Component
@Slf4j //@Slf4j
public class WarningRecordStatusMessage2 extends EmqxListener { //public class WarningRecordStatusMessage2 extends EmqxListener {
//
@Autowired // @Autowired
protected EmqKeeper emqKeeper; // protected EmqKeeper emqKeeper;
//
/** // /**
* 无需处置 // * 无需处置
*/ // */
public static final String NOT_DISPOSE_AMOS = "not/dispose/amos"; // public static final String NOT_DISPOSE_AMOS = "not/dispose/amos";
//
private static final BlockingQueue<JSONObject> blockingQueue = new LinkedBlockingQueue<JSONObject>(); // private static final BlockingQueue<JSONObject> blockingQueue = new LinkedBlockingQueue<JSONObject>();
//
@Autowired // @Autowired
private IdxBizFanWarningRecordServiceImpl idxBizFanWarningRecordService; // private IdxBizFanWarningRecordServiceImpl idxBizFanWarningRecordService;
//
@Autowired // @Autowired
private IdxBizPvWarningRecordServiceImpl idxBizPvWarningRecordService; // private IdxBizPvWarningRecordServiceImpl idxBizPvWarningRecordService;
//
@PostConstruct // @PostConstruct
void init() throws Exception { // void init() throws Exception {
new Thread(taskRunnable).start(); // new Thread(taskRunnable).start();
emqKeeper.subscript(NOT_DISPOSE_AMOS, 2, this); // emqKeeper.subscript(NOT_DISPOSE_AMOS, 2, this);
} // }
//
@Override // @Override
public void processMessage(String topic, MqttMessage message) throws Exception { // public void processMessage(String topic, MqttMessage message) throws Exception {
log.info("修改预警状态消息{}", new String(message.getPayload())); // log.info("修改预警状态消息{}", new String(message.getPayload()));
JSONObject ja = JSON.parseObject(new String(message.getPayload())); // JSONObject ja = JSON.parseObject(new String(message.getPayload()));
blockingQueue.add(ja); // blockingQueue.add(ja);
} // }
//
Runnable taskRunnable = new Runnable() { // Runnable taskRunnable = new Runnable() {
@Override // @Override
public void run() { // public void run() {
boolean isRun = true; // boolean isRun = true;
int k = 0; // int k = 0;
while (isRun) { // while (isRun) {
k++; // k++;
isRun = k < Integer.MAX_VALUE; // isRun = k < Integer.MAX_VALUE;
try { // try {
JSONObject analysisResult = blockingQueue.take(); // JSONObject analysisResult = blockingQueue.take();
jxIopUpdate(analysisResult); // jxIopUpdate(analysisResult);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
} // }
}; // };
//
public void jxIopUpdate(JSONObject analysisResult) { // public void jxIopUpdate(JSONObject analysisResult) {
log.info("修改预警状态信息:{}", analysisResult); // log.info("修改预警状态信息:{}", analysisResult);
if (ObjectUtils.isNotEmpty(analysisResult) && analysisResult.get("warningObjectType").toString().equals("pv")) { // if (ObjectUtils.isNotEmpty(analysisResult) && analysisResult.get("warningObjectType").toString().equals("fan")) {
LambdaUpdateWrapper<IdxBizFanWarningRecord> lambda = new LambdaUpdateWrapper<>(); // LambdaUpdateWrapper<IdxBizFanWarningRecord> lambda = new LambdaUpdateWrapper<>();
lambda.set(IdxBizFanWarningRecord::getDisposotionState, "已处置"); // lambda.set(IdxBizFanWarningRecord::getDisposotionState, "已处置");
lambda.set(IdxBizFanWarningRecord::getStatus, "1"); // lambda.set(IdxBizFanWarningRecord::getStatus, "1");
lambda.set(IdxBizFanWarningRecord::getDisposotionDate, new Date()); // lambda.set(IdxBizFanWarningRecord::getDisposotionDate, new Date());
List<String> traceIds = (List<String>) analysisResult.get("traceIds"); // List<String> traceIds = (List<String>) analysisResult.get("traceIds");
lambda.in(IdxBizFanWarningRecord::getSequenceNbr, traceIds); // lambda.in(IdxBizFanWarningRecord::getSequenceNbr, traceIds);
idxBizFanWarningRecordService.update(lambda); // idxBizFanWarningRecordService.update(lambda);
} else if (ObjectUtils.isNotEmpty(analysisResult) && analysisResult.get("warningObjectType").toString().equals("fan")) { // } else if (ObjectUtils.isNotEmpty(analysisResult) && analysisResult.get("warningObjectType").toString().equals("pv")) {
LambdaUpdateWrapper<IdxBizPvWarningRecord> lambda = new LambdaUpdateWrapper<>(); // LambdaUpdateWrapper<IdxBizPvWarningRecord> lambda = new LambdaUpdateWrapper<>();
lambda.set(IdxBizPvWarningRecord::getDisposotionState, "已处置"); // lambda.set(IdxBizPvWarningRecord::getDisposotionState, "已处置");
lambda.set(IdxBizPvWarningRecord::getStatus, "1"); // lambda.set(IdxBizPvWarningRecord::getStatus, "1");
lambda.set(IdxBizPvWarningRecord::getDisposotionDate, new Date()); // lambda.set(IdxBizPvWarningRecord::getDisposotionDate, new Date());
List<String> traceIds = (List<String>) analysisResult.get("traceIds"); // List<String> traceIds = (List<String>) analysisResult.get("traceIds");
lambda.eq(IdxBizPvWarningRecord::getSequenceNbr, traceIds); // lambda.in(IdxBizPvWarningRecord::getSequenceNbr, traceIds);
idxBizPvWarningRecordService.update(lambda); // idxBizPvWarningRecordService.update(lambda);
} // }
} // }
} //}
...@@ -162,4 +162,9 @@ public class IdxBizFanHealthIndex { ...@@ -162,4 +162,9 @@ public class IdxBizFanHealthIndex {
@TableField("ANALYSIS_TIME") @TableField("ANALYSIS_TIME")
private String ANALYSISTIME; private String ANALYSISTIME;
/**
* KKS码
*/
@TableField("KKS")
private String kks;
} }
...@@ -145,4 +145,10 @@ public class IdxBizFanWarningRecord{ ...@@ -145,4 +145,10 @@ public class IdxBizFanWarningRecord{
@TableField("DISPOSOTION_DATE") @TableField("DISPOSOTION_DATE")
private Date disposotionDate; private Date disposotionDate;
/**
* KKS码
*/
@TableField("KKS")
private String kks;
} }
...@@ -172,4 +172,10 @@ public class IdxBizPvHealthIndex{ ...@@ -172,4 +172,10 @@ public class IdxBizPvHealthIndex{
@TableField("ANALYSIS_TIME") @TableField("ANALYSIS_TIME")
private String ANALYSISTIME; private String ANALYSISTIME;
/**
* KKS码
*/
@TableField("KKS")
private String kks;
} }
...@@ -146,4 +146,10 @@ public class IdxBizPvWarningRecord{ ...@@ -146,4 +146,10 @@ public class IdxBizPvWarningRecord{
@TableField("DISPOSOTION_DATE") @TableField("DISPOSOTION_DATE")
private Date disposotionDate; private Date disposotionDate;
/**
* KKS码
*/
@TableField("KKS")
private String kks;
} }
...@@ -12,6 +12,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; ...@@ -12,6 +12,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningNameEnum; import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningNameEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.*; import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -28,6 +29,7 @@ import java.util.*; ...@@ -28,6 +29,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@EnableScheduling @EnableScheduling
@Service @Service
@Slf4j
public class HealthStatusIndicatorServiceImpl { public class HealthStatusIndicatorServiceImpl {
// @Value("${healthValue_Warn}") // @Value("${healthValue_Warn}")
...@@ -93,9 +95,14 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -93,9 +95,14 @@ public class HealthStatusIndicatorServiceImpl {
public static final String INDEX_KEY_PV = "THFX#FXGF#ZNFX"; public static final String INDEX_KEY_PV = "THFX#FXGF#ZNFX";
/** /**
* 智能分析触发预警系统标识 * 智能分析触发预警系统标识 - 光伏
*/ */
public static final String SMART_ANALYSE = "smartAnalyse"; public static final String SMART_ANALYSE_PV = "smartAnalysePv";
/**
* 智能分析触发预警系统标识 - 风电
*/
public static final String SMART_ANALYSE_FAN = "smartAnalyseFan";
/*** /***
...@@ -130,7 +137,15 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -130,7 +137,15 @@ public class HealthStatusIndicatorServiceImpl {
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress)));
List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>(); List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
LambdaQueryWrapper<StationBasic> basicLambdaQueryWrapper = new LambdaQueryWrapper<>();
basicLambdaQueryWrapper.eq(StationBasic::getFanGatewayId, gateWayId);
basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address); List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address);
...@@ -200,6 +215,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -200,6 +215,7 @@ public class HealthStatusIndicatorServiceImpl {
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord(); IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord();
idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks());
idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord()); idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord());
idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae()); idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae());
idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation()); idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation());
...@@ -225,7 +241,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -225,7 +241,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList); idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataPv(idxBizPvWarningRecordList); fetchDataPv(idxBizPvWarningRecordList, stationMap);
} }
...@@ -261,7 +277,15 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -261,7 +277,15 @@ public class HealthStatusIndicatorServiceImpl {
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress)));
List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>(); List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
LambdaQueryWrapper<StationBasic> basicLambdaQueryWrapper = new LambdaQueryWrapper<>();
basicLambdaQueryWrapper.eq(StationBasic::getFanGatewayId, gateWayId);
basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address); List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address);
...@@ -335,6 +359,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -335,6 +359,7 @@ public class HealthStatusIndicatorServiceImpl {
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord(); IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord();
idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks());
idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord()); idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord());
idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae()); idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae());
idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation()); idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation());
...@@ -359,7 +384,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -359,7 +384,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList); idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataPv(idxBizPvWarningRecordList); fetchDataPv(idxBizPvWarningRecordList, stationMap);
} }
/*** /***
...@@ -394,7 +419,15 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -394,7 +419,15 @@ public class HealthStatusIndicatorServiceImpl {
List<IdxBizPvWarningRuleSet> idxBizPvWarningRules = idxBizPvWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizPvWarningRuleSet> idxBizPvWarningRules = idxBizPvWarningRuleSetMapper.selectList(queryWrapper);
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress)));
List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>(); List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
LambdaQueryWrapper<StationBasic> basicLambdaQueryWrapper = new LambdaQueryWrapper<>();
basicLambdaQueryWrapper.eq(StationBasic::getFanGatewayId, gateWayId);
basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address); List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address);
...@@ -464,6 +497,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -464,6 +497,7 @@ public class HealthStatusIndicatorServiceImpl {
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord(); IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord();
idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks());
idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord()); idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord());
idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae()); idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae());
idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation()); idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation());
...@@ -488,7 +522,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -488,7 +522,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList); idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataPv(idxBizPvWarningRecordList); fetchDataPv(idxBizPvWarningRecordList, stationMap);
} }
...@@ -519,7 +553,14 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -519,7 +553,14 @@ public class HealthStatusIndicatorServiceImpl {
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>(); List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
LambdaQueryWrapper<StationBasic> basicLambdaQueryWrapper = new LambdaQueryWrapper<>();
basicLambdaQueryWrapper.eq(StationBasic::getFanGatewayId, gateWayId);
basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address); List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address);
...@@ -596,6 +637,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -596,6 +637,7 @@ public class HealthStatusIndicatorServiceImpl {
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord(); IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks());
idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord()); idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord());
idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae()); idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation()); idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
...@@ -620,7 +662,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -620,7 +662,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList); idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataFan(idxBizFanWarningRecordList); fetchDataFan(idxBizFanWarningRecordList, stationMap);
} }
/*** /***
...@@ -655,7 +697,15 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -655,7 +697,15 @@ public class HealthStatusIndicatorServiceImpl {
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>(); List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
LambdaQueryWrapper<StationBasic> basicLambdaQueryWrapper = new LambdaQueryWrapper<>();
basicLambdaQueryWrapper.eq(StationBasic::getFanGatewayId, gateWayId);
basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address); List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address);
...@@ -726,6 +776,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -726,6 +776,7 @@ public class HealthStatusIndicatorServiceImpl {
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord(); IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks());
idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord()); idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord());
idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae()); idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation()); idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
...@@ -749,7 +800,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -749,7 +800,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList); idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataFan(idxBizFanWarningRecordList); fetchDataFan(idxBizFanWarningRecordList, stationMap);
} }
/*** /***
...@@ -784,7 +835,15 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -784,7 +835,15 @@ public class HealthStatusIndicatorServiceImpl {
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>(); List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
LambdaQueryWrapper<StationBasic> basicLambdaQueryWrapper = new LambdaQueryWrapper<>();
basicLambdaQueryWrapper.eq(StationBasic::getFanGatewayId, gateWayId);
basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address); List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address);
...@@ -858,6 +917,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -858,6 +917,7 @@ public class HealthStatusIndicatorServiceImpl {
int flag = ObjectUtils.isEmpty(idxBizFanWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizFanWarningRecords.get(0).getWarningName()) ? 0 :1; int flag = ObjectUtils.isEmpty(idxBizFanWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizFanWarningRecords.get(0).getWarningName()) ? 0 :1;
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord(); IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks());
idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord()); idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord());
idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae()); idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation()); idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
...@@ -882,7 +942,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -882,7 +942,7 @@ public class HealthStatusIndicatorServiceImpl {
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList); idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataFan(idxBizFanWarningRecordList); fetchDataFan(idxBizFanWarningRecordList, stationMap);
} }
...@@ -892,7 +952,8 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -892,7 +952,8 @@ public class HealthStatusIndicatorServiceImpl {
* @return * @return
*/ */
@Async @Async
public void fetchDataPv(List<IdxBizPvWarningRecord> idxBizPvWarningRecords) { public void fetchDataPv(List<IdxBizPvWarningRecord> idxBizPvWarningRecords, HashMap<String, StationBasic> stationMap) {
log.info("===开始触发风险预警模型===数量为:{}", idxBizPvWarningRecords.size());
idxBizPvWarningRecords.stream().forEach(idxBizPvWarningRecord -> { idxBizPvWarningRecords.stream().forEach(idxBizPvWarningRecord -> {
BizMessage bizMessage = new BizMessage(); BizMessage bizMessage = new BizMessage();
bizMessage.setIndexKey(INDEX_KEY_PV); bizMessage.setIndexKey(INDEX_KEY_PV);
...@@ -900,14 +961,10 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -900,14 +961,10 @@ public class HealthStatusIndicatorServiceImpl {
bizMessage.setTraceId(idxBizPvWarningRecord.getSequenceNbr()); bizMessage.setTraceId(idxBizPvWarningRecord.getSequenceNbr());
RiskBizInfoVo riskBizInfoVo = new RiskBizInfoVo(); RiskBizInfoVo riskBizInfoVo = new RiskBizInfoVo();
riskBizInfoVo.setWarningObjectName(idxBizPvWarningRecord.getEquipmentName()); riskBizInfoVo.setWarningObjectName(idxBizPvWarningRecord.getEquipmentName());
riskBizInfoVo.setWarningObjectCode(idxBizPvWarningRecord.getSequenceNbr()); riskBizInfoVo.setWarningObjectCode(idxBizPvWarningRecord.getKks());
LambdaQueryWrapper<StationBasic> basicLambdaQueryWrapper = new LambdaQueryWrapper<>(); riskBizInfoVo.setSourceAttribution(stationMap.get(idxBizPvWarningRecord.getGatewayId()).getProjectOrgCode());
basicLambdaQueryWrapper.eq(StationBasic::getFanGatewayId, idxBizPvWarningRecord.getGatewayId());
basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
riskBizInfoVo.setSourceAttribution(stationBasic.getProjectOrgCode());
riskBizInfoVo.setSourceAttributionDesc(idxBizPvWarningRecord.getStation()); riskBizInfoVo.setSourceAttributionDesc(idxBizPvWarningRecord.getStation());
riskBizInfoVo.setWarningObjectType("pv"); riskBizInfoVo.setWarningObjectType("equip");
List<RiskDynamicDetailsVo> detailsVos = new ArrayList<>(); List<RiskDynamicDetailsVo> detailsVos = new ArrayList<>();
RiskDynamicDetailsVo dynamicDetailsVo = new RiskDynamicDetailsVo(); RiskDynamicDetailsVo dynamicDetailsVo = new RiskDynamicDetailsVo();
dynamicDetailsVo.setTabName("预警详情"); dynamicDetailsVo.setTabName("预警详情");
...@@ -915,7 +972,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -915,7 +972,7 @@ public class HealthStatusIndicatorServiceImpl {
riskBizInfoVo.setDynamicDetails(detailsVos); riskBizInfoVo.setDynamicDetails(detailsVos);
bizMessage.setBizInfo(riskBizInfoVo); bizMessage.setBizInfo(riskBizInfoVo);
try { try {
emqKeeper.getMqttClient().publish(SMART_ANALYSE + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false); emqKeeper.getMqttClient().publish(SMART_ANALYSE_PV + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -929,7 +986,8 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -929,7 +986,8 @@ public class HealthStatusIndicatorServiceImpl {
* @return * @return
*/ */
@Async @Async
public void fetchDataFan(List<IdxBizFanWarningRecord> idxBizFanWarningRecords) { public void fetchDataFan(List<IdxBizFanWarningRecord> idxBizFanWarningRecords, HashMap<String, StationBasic> stationMap) {
log.info("===开始触发风险预警模型===数量为:{}", idxBizFanWarningRecords.size());
idxBizFanWarningRecords.stream().forEach(idxBizFanWarningRecord -> { idxBizFanWarningRecords.stream().forEach(idxBizFanWarningRecord -> {
BizMessage bizMessage = new BizMessage(); BizMessage bizMessage = new BizMessage();
bizMessage.setIndexKey(String.format(INDEX_KEY_FAN, idxBizFanWarningRecord.getNumber())); bizMessage.setIndexKey(String.format(INDEX_KEY_FAN, idxBizFanWarningRecord.getNumber()));
...@@ -937,14 +995,10 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -937,14 +995,10 @@ public class HealthStatusIndicatorServiceImpl {
bizMessage.setTraceId(idxBizFanWarningRecord.getSequenceNbr()); bizMessage.setTraceId(idxBizFanWarningRecord.getSequenceNbr());
RiskBizInfoVo riskBizInfoVo = new RiskBizInfoVo(); RiskBizInfoVo riskBizInfoVo = new RiskBizInfoVo();
riskBizInfoVo.setWarningObjectName(idxBizFanWarningRecord.getEquipmentName()); riskBizInfoVo.setWarningObjectName(idxBizFanWarningRecord.getEquipmentName());
riskBizInfoVo.setWarningObjectCode(idxBizFanWarningRecord.getSequenceNbr()); riskBizInfoVo.setWarningObjectCode(idxBizFanWarningRecord.getKks());
LambdaQueryWrapper<StationBasic> basicLambdaQueryWrapper = new LambdaQueryWrapper<>(); riskBizInfoVo.setSourceAttribution(stationMap.get(idxBizFanWarningRecord.getGatewayId()).getProjectOrgCode());
basicLambdaQueryWrapper.eq(StationBasic::getFanGatewayId, idxBizFanWarningRecord.getGatewayId());
basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
riskBizInfoVo.setSourceAttribution(stationBasic.getProjectOrgCode());
riskBizInfoVo.setSourceAttributionDesc(idxBizFanWarningRecord.getStation()); riskBizInfoVo.setSourceAttributionDesc(idxBizFanWarningRecord.getStation());
riskBizInfoVo.setWarningObjectType("fan"); riskBizInfoVo.setWarningObjectType("equip");
List<RiskDynamicDetailsVo> detailsVos = new ArrayList<>(); List<RiskDynamicDetailsVo> detailsVos = new ArrayList<>();
RiskDynamicDetailsVo dynamicDetailsVo = new RiskDynamicDetailsVo(); RiskDynamicDetailsVo dynamicDetailsVo = new RiskDynamicDetailsVo();
dynamicDetailsVo.setTabName("预警详情"); dynamicDetailsVo.setTabName("预警详情");
...@@ -952,7 +1006,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -952,7 +1006,7 @@ public class HealthStatusIndicatorServiceImpl {
riskBizInfoVo.setDynamicDetails(detailsVos); riskBizInfoVo.setDynamicDetails(detailsVos);
bizMessage.setBizInfo(riskBizInfoVo); bizMessage.setBizInfo(riskBizInfoVo);
try { try {
emqKeeper.getMqttClient().publish(SMART_ANALYSE + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false); emqKeeper.getMqttClient().publish(SMART_ANALYSE_FAN + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<select id="getHealthScoreInfo" resultType="java.math.BigDecimal"> <select id="getHealthScoreInfo" resultType="java.math.BigDecimal">
SELECT SELECT
avg( a.avgHealthIndex ) AS healthIndex round(avg( a.avgHealthIndex ), 2) AS healthIndex
FROM FROM
( (
SELECT SELECT
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<select id="getHealthScoreInfoByStation" resultType="java.math.BigDecimal"> <select id="getHealthScoreInfoByStation" resultType="java.math.BigDecimal">
SELECT SELECT
IFNULL( HEALTH_INDEX , 100 ) AS healthIndex round(IFNULL( HEALTH_INDEX , 100 ), 2) AS healthIndex
FROM FROM
${tableName} ${tableName}
<where> <where>
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
WARNING_NAME WARNING_NAME
) a ) a
ORDER BY ORDER BY
a.allNum DESC a.allNum ASC
</select> </select>
...@@ -291,10 +291,18 @@ ...@@ -291,10 +291,18 @@
<select id="getAllEquipAlarmInfoAnalysisByStationType" resultType="java.util.Map"> <select id="getAllEquipAlarmInfoAnalysisByStationType" resultType="java.util.Map">
SELECT SELECT
<!-- ( SELECT POINT_NAME FROM ${tableName2} WHERE GATEWAY_ID = a.GATEWAY_ID AND INDEX_ADDRESS = a.INDEX_ADDRESS ) AS pointName,-->
concat(#{stationType}, '-', a.POINT_NAME) as pointName, concat(#{stationType}, '-', a.POINT_NAME) as pointName,
a.WARNING_NAME as warningName, a.WARNING_NAME as warningName,
count(1) as num count(1) as num,
(select count(1) from ${tableName} as tb
<where>
tb.DISPOSOTION_STATE = '未处置'
and tb.POINT_NAME = a.POINT_NAME
<if test="areaCode != null and areaCode != ''">
and tb.ARAE like concat('%', #{areaCode}, '%')
</if>
</where>
) AS totalNum
FROM FROM
${tableName} a ${tableName} a
<where> <where>
...@@ -307,7 +315,7 @@ ...@@ -307,7 +315,7 @@
warningName warningName
having pointName IS NOT NULL having pointName IS NOT NULL
AND pointName != '' AND pointName != ''
order by num desc order by totalNum asc
</select> </select>
<select id="getAllEquipAlarmInfoAnalysisByArea" resultType="java.util.Map"> <select id="getAllEquipAlarmInfoAnalysisByArea" resultType="java.util.Map">
...@@ -318,7 +326,16 @@ ...@@ -318,7 +326,16 @@
SELECT SELECT
wr.WARNING_NAME AS warningName, wr.WARNING_NAME AS warningName,
concat('光伏-', wr.POINT_NAME) AS pointName, concat('光伏-', wr.POINT_NAME) AS pointName,
count( 1 ) AS num count( 1 ) AS num,
( SELECT count( 1 ) FROM idx_biz_pv_warning_record
<where>
DISPOSOTION_STATE = '未处置' AND wr.POINT_NAME = POINT_NAME
<if test="areaCode != null and areaCode != ''">
and ARAE like concat('%', #{areaCode}, '%')
</if>
</where>
) AS allNum
FROM FROM
idx_biz_pv_warning_record wr idx_biz_pv_warning_record wr
<where> <where>
...@@ -333,7 +350,16 @@ ...@@ -333,7 +350,16 @@
SELECT SELECT
wr.WARNING_NAME AS warningName, wr.WARNING_NAME AS warningName,
concat('风电-', wr.POINT_NAME) AS pointName, concat('风电-', wr.POINT_NAME) AS pointName,
count( 1 ) AS num count( 1 ) AS num,
( SELECT count( 1 ) FROM idx_biz_fan_warning_record
<where>
DISPOSOTION_STATE = '未处置' AND wr.POINT_NAME = POINT_NAME
<if test="areaCode != null and areaCode != ''">
and ARAE like concat('%', #{areaCode}, '%')
</if>
</where>
) AS allNum
FROM FROM
idx_biz_fan_warning_record wr idx_biz_fan_warning_record wr
<where> <where>
...@@ -349,7 +375,7 @@ ...@@ -349,7 +375,7 @@
WHERE WHERE
a.pointName IS NOT NULL a.pointName IS NOT NULL
AND a.pointName != '' AND a.pointName != ''
order by a.num desc order by a.allNum ASC
</select> </select>
<select id="getSubSystemInfo" resultType="java.util.Map"> <select id="getSubSystemInfo" resultType="java.util.Map">
...@@ -489,7 +515,8 @@ ...@@ -489,7 +515,8 @@
<select id="getPvInfoByPage" resultType="java.util.Map"> <select id="getPvInfoByPage" resultType="java.util.Map">
SELECT SELECT
SUBARRAY as subarray SUBARRAY as subarray,
STATION AS station
FROM FROM
idx_biz_pv_point_process_variable_classification idx_biz_pv_point_process_variable_classification
<where> <where>
...@@ -594,7 +621,8 @@ ...@@ -594,7 +621,8 @@
<select id="getPvPointNameListBySumSystem" resultType="java.util.Map"> <select id="getPvPointNameListBySumSystem" resultType="java.util.Map">
SELECT SELECT
POINT_NAME as pointName, POINT_NAME as pointName,
INDEX_ADDRESS as indexAddress INDEX_ADDRESS as indexAddress,
STATION AS station
FROM FROM
idx_biz_pv_point_process_variable_classification idx_biz_pv_point_process_variable_classification
<where> <where>
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
AND a.recDate >= concat(#{startDate}, ' 00:00:00') AND a.recDate >= concat(#{startDate}, ' 00:00:00')
</if> </if>
<if test="endDate != '' and endDate != null"> <if test="endDate != '' and endDate != null">
AND concat(#{startDate}, ' 23:59:59') >= a.recDate AND concat(#{endDate}, ' 23:59:59') >= a.recDate
</if> </if>
</where> </where>
order by warningName DESC, recDate DESC order by warningName DESC, recDate DESC
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
AND a.recDate >= concat(#{startDate}, ' 00:00:00') AND a.recDate >= concat(#{startDate}, ' 00:00:00')
</if> </if>
<if test="endDate != '' and endDate != null"> <if test="endDate != '' and endDate != null">
AND concat(#{startDate}, ' 23:59:59') >= a.recDate AND concat(#{endDate}, ' 23:59:59') >= a.recDate
</if> </if>
</where>) b </where>) b
</select> </select>
......
package com.yeejoin.amos.boot.module.jxiop.api.mapper; package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mysql.cj.x.protobuf.MysqlxCrud;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator; import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -17,22 +14,7 @@ import java.util.Map; ...@@ -17,22 +14,7 @@ import java.util.Map;
* @createDate: 2023/7/3 * @createDate: 2023/7/3
*/ */
public interface MonitorFanIndicatorMapper extends BaseMapper<MonitorFanIndicator> { public interface MonitorFanIndicatorMapper extends BaseMapper<MonitorFanIndicator> {
//批量修改
void UpdateMonitorFanIndicator(@Param(value = "list") List<IndexDto> list);
Integer queryByPageTotal(@Param("equipmentNumber") String equipmentNumber,
@Param("gateway") String gateway,
@Param("frontModule") String frontModule);
List<MonitorFanIndicator> queryByPage(@Param("size") long size,
@Param("equipmentNumber") String equipmentNumber,
@Param("gateway") String gateway,
@Param("frontModule") String frontModule,
@Param("offset") int offset);
Object getIndicatoralueAvage(String gateway,String indicator);
Object getIndicatoralueTotal(String gateway,String indicator);
List<Map<String, String>> getFanConfigPower(@Param("gatewayId") String gatewayId, List<Map<String, String>> getFanConfigPower(@Param("gatewayId") String gatewayId,
@Param("equipmentNum") String equipmentNum); @Param("equipmentNum") String equipmentNum);
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper"> <mapper namespace="com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper">
<update id="UpdateMonitorFanIndicator">
update monitor_fan_indicator
<trim prefix="set" suffixOverrides=",">
<trim prefix="indicator_value=case" suffix="end,">
<foreach collection="list" item="item" index="index">
when address_gateway=#{item.equipmentsIdx} then #{item.valueLabel}
</foreach>
</trim>
<trim prefix="indicator_time=case" suffix="end,">
<foreach collection="list" item="item" index="index">
when address_gateway=#{item.equipmentsIdx} then #{item.createdTime}
</foreach>
</trim>
</trim>
where address_gateway in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.equipmentsIdx}
</foreach>
</update>
<select id="queryByPage" resultType="com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator">
select * from monitor_fan_indicator
<where>
<if test="equipmentNumber != null and equipmentNumber !=''">
equipment_number = #{equipmentNumber}
</if>
<if test="gateway != null and gateway !=''">
AND gateway = #{gateway}
</if>
<if test="frontModule != null and frontModule !=''">
AND front_module = #{frontModule}
</if>
</where>
limit #{offset}, #{size}
</select>
<select id="queryByPageTotal" resultType="java.lang.Integer">
select count(1) from monitor_fan_indicator
<where>
<if test="equipmentNumber != null and equipmentNumber !=''">
equipment_number = #{equipmentNumber}
</if>
<if test="gateway != null and gateway !=''">
AND gateway = #{gateway}
</if>
<if test="frontModule != null and frontModule !=''">
AND front_module = #{frontModule}
</if>
</where>
</select>
<select id="getIndicatoralueAvage" resultType="Object">
SELECT AVG(indicator_value) wind_speed
FROM monitor_fan_indicator
WHERE gateway=#{gateway} and
indicator like concat('%',#{indicator},'%')
</select>
<select id="getIndicatoralueTotal" resultType="Object">
SELECT SUM(indicator_value) wind_speed
FROM monitor_fan_indicator
WHERE gateway=#{gateway} and
indicator like concat('%',#{indicator},'%')
</select>
<select id="getFanConfigPower" resultType="java.util.Map"> <select id="getFanConfigPower" resultType="java.util.Map">
select select
sequence_nbr as id, sequence_nbr as id,
......
...@@ -1019,6 +1019,117 @@ public class MonitorFanIdxController extends BaseController { ...@@ -1019,6 +1019,117 @@ public class MonitorFanIdxController extends BaseController {
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "电站排名")
@GetMapping("/stationRankingtype")
public ResponseModel stationRanking(String day,String type,String areaCode ) {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(areaCode!=null,StationBasic::getAreaCode,areaCode);
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
List<Map<String, Object>> datDataFJ = new ArrayList<>();
List<Map<String, Object>> monthDataFJ = new ArrayList<>();
List<Map<String, Object>> yearDataFJ = new ArrayList<>();
List<Map<String, Object>> datDataGF = new ArrayList<>();
List<Map<String, Object>> monthDataGF = new ArrayList<>();
List<Map<String, Object>> yearDataGF = new ArrayList<>();
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getFanGatewayId();
String boosterGatewayId = stationBasic.getBoosterGatewayId();
String querySql = null;
String name = stationBasic.getStationName();
if (stationBasic.getStationType().equals("FDZ")) {
Map<String, Object> map = monitorFanIndicator.generatingCapacity(gatewayId, querySql);
Map<String, Object> dayMap = new HashMap<>();
Map<String, Object> monthMap = new HashMap<>();
Map<String, Object> yearMap = new HashMap<>();
dayMap.put("name", name);
dayMap.put("value", map.get("日发电量") == null ? 0 : String.format("%.4f", map.get("日发电量")));
dayMap.put("gateWayId", stationBasic.getFanGatewayId());
monthMap.put("name", name);
monthMap.put("value", map.get("月发电量") == null ? 0 : String.format("%.4f", map.get("月发电量")));
monthMap.put("gateWayId", stationBasic.getFanGatewayId());
yearMap.put("name", name);
yearMap.put("gateWayId", stationBasic.getFanGatewayId());
yearMap.put("value", map.get("年发电量") == null ? 0 : String.format("%.4f", map.get("年发电量")));
datDataFJ.add(dayMap);
monthDataFJ.add(monthMap);
yearDataFJ.add(yearMap);
} else {
querySql = "逆变器";
Map<String, Object> map = monitorFanIndicator.generatingCapacity(boosterGatewayId, querySql);
Map<String, Object> dayMap = new HashMap<>();
Map<String, Object> monthMap = new HashMap<>();
Map<String, Object> yearMap = new HashMap<>();
dayMap.put("name", name);
dayMap.put("gateWayId", stationBasic.getFanGatewayId());
dayMap.put("value", map.get("日发电量") == null ? 0 : String.format("%.4f", Double.parseDouble(map.get("日发电量").toString())));
monthMap.put("name", name);
monthMap.put("gateWayId", stationBasic.getFanGatewayId());
monthMap.put("value", map.get("月发电量") == null ? 0 : String.format("%.4f", Double.parseDouble(map.get("月发电量").toString())));
yearMap.put("name", name);
yearMap.put("gateWayId", stationBasic.getFanGatewayId());
yearMap.put("value", map.get("年发电量") == null ? 0 : String.format("%.4f", Double.parseDouble(map.get("年发电量").toString())));
datDataGF.add(dayMap);
monthDataGF.add(monthMap);
yearDataGF.add(yearMap);
}
}
// monitorFanIndicator.sendMqttByRanking(datDataFJ, GeneratingCapacity.DAY.getCode(), "fjpm");
// monitorFanIndicator.sendMqttByRanking(monthDataFJ, GeneratingCapacity.MONTH.getCode(), "fjpm");
// monitorFanIndicator.sendMqttByRanking(yearDataFJ, GeneratingCapacity.YEAR.getCode(), "fjpm");
// monitorFanIndicator.sendMqttByRanking(datDataGF, GeneratingCapacity.DAY.getCode(), "gfpm");
// monitorFanIndicator.sendMqttByRanking(monthDataGF, GeneratingCapacity.MONTH.getCode(), "gfpm");
// monitorFanIndicator.sendMqttByRanking(yearDataGF, GeneratingCapacity.YEAR.getCode(), "gfpm");
Page<Map<String, Object>> socialContributionDtoPage = new Page<Map<String, Object>>();
socialContributionDtoPage.setCurrent(1);
socialContributionDtoPage.setTotal(100);
if("gf".equals(type)){
if("0".equals(day)){
socialContributionDtoPage.setRecords(datDataGF);
}else if("1".equals(day)){
socialContributionDtoPage.setRecords(monthDataGF);
} else if("2".equals(day)){
socialContributionDtoPage.setRecords(yearDataGF);
}
}else{
if("0".equals(day)){
socialContributionDtoPage.setRecords(datDataFJ);
}else if("1".equals(day)){
socialContributionDtoPage.setRecords(monthDataFJ);
} else if("2".equals(day)){
socialContributionDtoPage.setRecords(yearDataFJ);
}
}
return CommonResponseUtil.success(socialContributionDtoPage);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "运维数据 ") @ApiOperation(value = "运维数据 ")
@GetMapping("/operationData") @GetMapping("/operationData")
......
...@@ -165,10 +165,10 @@ public class PersonQrCodeController extends BaseController { ...@@ -165,10 +165,10 @@ public class PersonQrCodeController extends BaseController {
} else if ("job".equals(dataType)) { } else if ("job".equals(dataType)) {
countAll = sjglZsjZsbtzMapper.getJobYardByPageCount(parentCode, null, null, null); countAll = sjglZsjZsbtzMapper.getJobYardByPageCount(parentCode, null, null, null);
} }
result.put("redToGreenPercent", getPercent(new BigDecimal(red), new BigDecimal(countAll))); result.put("redPercent", getPercent(new BigDecimal(red), new BigDecimal(countAll)));
result.put("redPercent", getPercent(new BigDecimal(redToGreen), new BigDecimal(countAll))); result.put("redToGreenPercent", getPercent(new BigDecimal(redToGreen), new BigDecimal(countAll)));
result.put("yellowToGreenPercent", getPercent(new BigDecimal(yellow), new BigDecimal(countAll))); result.put("yellowPercent", getPercent(new BigDecimal(yellow), new BigDecimal(countAll)));
result.put("yellowPercent", getPercent(new BigDecimal(yellowToGreen), new BigDecimal(countAll))); result.put("yellowToGreenPercent", getPercent(new BigDecimal(yellowToGreen), new BigDecimal(countAll)));
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(null);
...@@ -217,7 +217,7 @@ public class PersonQrCodeController extends BaseController { ...@@ -217,7 +217,7 @@ public class PersonQrCodeController extends BaseController {
* @return 百分比 * @return 百分比
*/ */
private double getPercent(BigDecimal numerator, BigDecimal denominator) { private double getPercent(BigDecimal numerator, BigDecimal denominator) {
BigDecimal multiply = numerator.divide(denominator.compareTo(BigDecimal.ZERO) != 0 ? denominator : new BigDecimal(1), 4, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)); BigDecimal multiply = numerator.divide(denominator.compareTo(BigDecimal.ZERO) != 0 ? denominator : new BigDecimal(1), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
return Math.abs(multiply.doubleValue()); return Math.abs(multiply.doubleValue());
} }
......
...@@ -14,7 +14,7 @@ import java.util.Map; ...@@ -14,7 +14,7 @@ import java.util.Map;
*/ */
public interface IMonitorFanIndicator { public interface IMonitorFanIndicator {
//批量修改指标值 //批量修改指标值
void UpdateMonitorFanIndicator(List<IndexDto> list); // void UpdateMonitorFanIndicator(List<IndexDto> list);
// ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber); // ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
// ResultsData getLsNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber); // ResultsData getLsNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
......
...@@ -115,13 +115,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -115,13 +115,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
private List<Map> list; private List<Map> list;
@Override
public void UpdateMonitorFanIndicator(List<IndexDto> list) {
monitorFanIndicatorregionMapper.UpdateMonitorFanIndicator(list);
}
public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) { public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) {
...@@ -287,9 +280,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -287,9 +280,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
* @param indicator * @param indicator
* @return * @return
*/ */
public Object getIndicatoralueAvage(String gateway, String indicator) { // public Object getIndicatoralueAvage(String gateway, String indicator) {
return monitorFanIndicatorregionMapper.getIndicatoralueAvage(gateway, indicator); // return monitorFanIndicatorregionMapper.getIndicatoralueAvage(gateway, indicator);
} // }
/** /**
...@@ -299,9 +292,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -299,9 +292,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
* @param indicator * @param indicator
* @return * @return
*/ */
public Object getIndicatoralueTotal(String gateway, String indicator) { // public Object getIndicatoralueTotal(String gateway, String indicator) {
return monitorFanIndicatorregionMapper.getIndicatoralueTotal(gateway, indicator); // return monitorFanIndicatorregionMapper.getIndicatoralueTotal(gateway, indicator);
} // }
public StationBasic getOneByStationNumber(String stationId) { public StationBasic getOneByStationNumber(String stationId) {
......
...@@ -101,8 +101,8 @@ ...@@ -101,8 +101,8 @@
ifnull(a.SBMC, '') as objectName , ifnull(a.SBMC, '') as objectName ,
ifnull(a.QRCODE_COLOR, '') AS qrCodeColor, ifnull(a.QRCODE_COLOR, '') AS qrCodeColor,
ifnull(b.COMPANY_NAME, '') AS stationName, ifnull(b.COMPANY_NAME, '') AS stationName,
ifnull(a.UPDATE_TIME, '') as recDate, ifnull(a.UPDATE_STAMP, '') as recDate,
SBBM as objectId a.SBBM as objectId
FROM FROM
sjgl_zsj_zsbtz a sjgl_zsj_zsbtz a
INNER JOIN privilege_company b ON a.WERKS = b.COMPANY_CODE and b.IS_DELETED = false AND b.`LEVEL` = 'station' INNER JOIN privilege_company b ON a.WERKS = b.COMPANY_CODE and b.IS_DELETED = false AND b.`LEVEL` = 'station'
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
AND b.ORG_CODE like concat(#{parentCode},'%') AND b.ORG_CODE like concat(#{parentCode},'%')
</if> </if>
<if test="date != null and date != ''"> <if test="date != null and date != ''">
AND a.UPDATE_TIME like concat(#{date},'%') AND a.UPDATE_STAMP like concat(#{date},'%')
</if> </if>
<if test="qrCodeColor != null and qrCodeColor != ''"> <if test="qrCodeColor != null and qrCodeColor != ''">
AND a.QRCODE_COLOR = #{qrCodeColor} AND a.QRCODE_COLOR = #{qrCodeColor}
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
AND a.QRCODE_COLOR != #{ne} AND a.QRCODE_COLOR != #{ne}
</if> </if>
</where> </where>
ORDER BY a.CREATE_TIME DESC ORDER BY a.UPDATE_STAMP DESC
limit #{current},#{size} limit #{current},#{size}
</select> </select>
......
package com.yeejoin.amos.boot.module.jxiop.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.github.classgraph.json.Id;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* CREATE TABLE `equipments_jxiop_doc_mysql` (
* `id` varchar(50) NOT NULL,
* `address` varchar(50) DEFAULT NULL,
* `equipment_specific_name` varchar(255) DEFAULT NULL,
* `gateway_id` varchar(50) DEFAULT NULL,
* `is_alarm` varchar(20) DEFAULT NULL,
* `created_time` date DEFAULT NULL,
* `unit` varchar(50) DEFAULT NULL,
* `value` varchar(50) DEFAULT NULL,
* `value_F` float DEFAULT NULL,
* `value_label` varchar(255) DEFAULT NULL,
* `trace_id` varchar(50) DEFAULT NULL,
* `equipment_index_name` varchar(255) DEFAULT NULL,
* `equipment_number` varchar(50) DEFAULT NULL,
* `front_module` varchar(200) DEFAULT NULL,
* `system_type` varchar(200) DEFAULT NULL,
* `picture_name` varchar(255) DEFAULT NULL,
* `display_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
* `data_type` varchar(50) DEFAULT NULL,
* PRIMARY KEY (`id`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
*/
@Data
@Accessors(chain = true)
@TableName("equipments_jxiop_doc_mysql")
public class EquipmentsJxiopDocMysql {
@Id
private String id;
@TableField("address")
private String address;
@TableField("data_type")
private String dataType;
@TableField("equipment_specific_name")
private String equipmentSpecificName;
@TableField("gateway_id")
private String gatewayId;
@TableField("is_alarm")
private String isAlarm;
@TableField("created_time")
private Date createdTime;
@TableField("unit")
private String unit;
@TableField("value")
private String value;
@TableField("value_F")
private Float valueF ;
@TableField("value_label")
private String valueLabel;
@TableField("trace_id")
private String traceId;
@TableField("equipment_index_name")
private String equipmentIndexName;
@TableField("equipment_number")
private String equipmentNumber;
@TableField("front_module")
private String frontModule;
@TableField("system_type")
private String systemType;
@TableField("picture_name")
private String pictureName;
@TableField("display_name")
private String displayName;
}
package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentsJxiopDocMysql;
public interface EquipmentsJxiopDocMysqlMapper extends BaseMapper<EquipmentsJxiopDocMysql> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.EquipmentsJxiopDocMysqlMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments; import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.PointImportDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentsJxiopDocMysql;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test; import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESEquipmentsRepository; import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESEquipmentsRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*;
//import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils; //import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
//import com.yeejoin.amos.component.influxdb.InfluxDbConnection; //import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.ElasticSearchUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -32,12 +36,14 @@ import org.elasticsearch.search.aggregations.metrics.ParsedSum; ...@@ -32,12 +36,14 @@ import org.elasticsearch.search.aggregations.metrics.ParsedSum;
import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
...@@ -45,63 +51,59 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -45,63 +51,59 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource; import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
@RestController @RestController
@Api(tags = "Demo-test") @Api(tags = "Demo-test")
@RequestMapping(value = "/demo") @RequestMapping(value = "/demo")
public class DemoController extends BaseController { public class DemoController extends BaseController {
Logger logger = LoggerFactory.getLogger(DemoController.class); // @Autowired
// LargeScreenImpl largeScreenImpl;
@Autowired private final String ss = "瞬时风速";
StationBasicServiceImpl stationBasicServiceimpl; private final String zfs = "WTX-801_25_WTX-801_总辐射";
@Autowired private final String zfslj = "WTX-801_25_WTX-801_总辐射累计";
TestServiceImpl testServiceimpl;
// @Resource // @Resource
// InfluxDbConnection influxDbConnection; // InfluxDbConnection influxDbConnection;
// @Autowired // @Autowired
// InfluxDButils influxDButils; // InfluxDButils influxDButils;
private final String dayvalue = "日发电量";
private final String moonValue = "月发电量";
private final String yearValue = "年发电量";
private final String dayDateFormat = "yyyy-MM-dd";
private final String moonDateFormat = "yyyy-MM";
private final String yearDateFormat = "yyyy";
// @Autowired
// PowerGenerationImpl powerGenerationImpl;
private final String dayType = "day";
private final String moonType = "moon";
private final String yearType = "year";
Logger logger = LoggerFactory.getLogger(DemoController.class);
@Autowired @Autowired
EmqKeeper emqKeeper; StationBasicServiceImpl stationBasicServiceimpl;
@Autowired @Autowired
private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper; TestServiceImpl testServiceimpl;
@Autowired @Autowired
private ElasticsearchRestTemplate elasticsearchTemplate; EmqKeeper emqKeeper;
@Autowired @Autowired
ESEquipmentsRepository equipmentsRepository; ESEquipmentsRepository equipmentsRepository;
@Autowired @Autowired
CommonServiceImpl commonServiceImpl; CommonServiceImpl commonServiceImpl;
// @Autowired @Autowired
// PowerGenerationImpl powerGenerationImpl; ElasticSearchUtil elasticSearchUtil;
@Autowired
// @Autowired private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper;
// LargeScreenImpl largeScreenImpl; @Autowired
private final String ss= "瞬时风速"; private ElasticsearchRestTemplate elasticsearchTemplate;
private final String zfs= "WTX-801_25_WTX-801_总辐射";
private final String zfslj= "WTX-801_25_WTX-801_总辐射累计";
private final String dayvalue="日发电量";
private final String moonValue="月发电量";
private final String yearValue="年发电量";
private final String dayDateFormat="yyyy-MM-dd";
private final String moonDateFormat="yyyy-MM";
private final String yearDateFormat="yyyy";
private final String dayType="day";
private final String moonType="moon";
private final String yearType="year";
@Autowired
private EquipmentsJxiopDocMysqlMapper equipmentsJxiopDocMysqlMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "手动更新场站缓存信息接口") @ApiOperation(value = "手动更新场站缓存信息接口")
...@@ -117,78 +119,46 @@ public class DemoController extends BaseController { ...@@ -117,78 +119,46 @@ public class DemoController extends BaseController {
return updateResult; return updateResult;
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "demo测试prodcutcion 库")
@GetMapping("/test")
public StationBasic demoTest() {
return stationBasicServiceimpl.getById(1660231556607774721L);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "demo测试中间库")
@GetMapping("/test1")
public List<Test> demoTest1() {
return testServiceimpl.getList();
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "demo测试influxdb")
@GetMapping("/test3")
public void demoTest2() {
String sql = "SELECT * FROM indicators_1668801435891929089";
String sql1 = "SELECT * FROM indicators_1668801570352926721";
// List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class);
// List<IndicatorsDto> list2 = influxDButils.getListData(sql1, IndicatorsDto.class);
// System.out.println(list.size());
// System.out.println(list2.size());
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "初始化influxdb-风电、光伏、升压站") @ApiOperation(value = "初始化influxdb-风电、光伏、升压站")
@GetMapping("doc/test4") @GetMapping("doc/test4")
public ResponseModel<Integer> demoTest3() { public ResponseModel<Integer> demoTest3() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站 //数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801435891929089","1669524885619085313","1668801570352926721","1669525017559306241"}; String[] strings = {"1668801435891929089", "1669524885619085313", "1668801570352926721", "1669525017559306241"};
// String [] strings = {"1669524885619085313"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
elasticsearchTemplate.deleteIndex(ESEquipments.class); elasticsearchTemplate.deleteIndex(ESEquipments.class);
int num=0; int num = 0;
for (int i = 0; i < strings.length; i++) { for (int i = 0; i < strings.length; i++) {
QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>(); QueryWrapper<EquipmentsJxiopDocMysql> QueryWrapper = new QueryWrapper<>();
// 夏造风电 // 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089"); // QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏 // 泰和光伏
QueryWrapper.eq("gateway", strings[i]); QueryWrapper.eq("gateway", strings[i]);
long DATE = new Date().getTime(); long DATE = new Date().getTime();
System.out.println(DATE); System.out.println(DATE);
List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper); List<EquipmentsJxiopDocMysql> list = equipmentsJxiopDocMysqlMapper.selectList(QueryWrapper);
num=num+list.size(); num = num + list.size();
List<ESEquipments> listit =new ArrayList<>(); List<ESEquipments> listit = new ArrayList<>();
for (MonitorFanIndicator monitorFanIndicator : list) { for (EquipmentsJxiopDocMysql monitorFanIndicator : list) {
ESEquipments eSEquipments=new ESEquipments( ESEquipments eSEquipments = new ESEquipments(
null, monitorFanIndicator.getValueF(),
monitorFanIndicator.getAddressGateway(), monitorFanIndicator.getId(),
monitorFanIndicator.getIndexAddress(), monitorFanIndicator.getAddress(),
monitorFanIndicator.getDataType(), monitorFanIndicator.getDataType(),
monitorFanIndicator.getFanCode(), monitorFanIndicator.getEquipmentSpecificName(),
monitorFanIndicator.getGateway(), monitorFanIndicator.getGatewayId(),
monitorFanIndicator.getIsAlarm(), monitorFanIndicator.getIsAlarm(),
new Date(), monitorFanIndicator.getCreatedTime(),
monitorFanIndicator.getUnit(), monitorFanIndicator.getUnit(),
"", monitorFanIndicator.getValue(),
"" , monitorFanIndicator.getValueLabel(),
"", monitorFanIndicator.getTraceId(),
monitorFanIndicator.getIndicator(), monitorFanIndicator.getEquipmentIndexName(),
monitorFanIndicator.getEquipmentNumber(), monitorFanIndicator.getEquipmentNumber(),
monitorFanIndicator.getFrontModule(), monitorFanIndicator.getFrontModule(),
monitorFanIndicator.getSystemType(), monitorFanIndicator.getSystemType(),
monitorFanIndicator.getPictureName(), monitorFanIndicator.getPictureName(),
monitorFanIndicator.getEquipmentNumber()); monitorFanIndicator.getDisplayName());
listit.add(eSEquipments); listit.add(eSEquipments);
...@@ -223,6 +193,100 @@ public class DemoController extends BaseController { ...@@ -223,6 +193,100 @@ public class DemoController extends BaseController {
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "从ES获取数据反向插入mysql")
@GetMapping("doc/getDatafromEsToMysql")
public void getDatafromEsToMysql() {
try {
List<ESEquipments> result = elasticSearchUtil.searchResponse("jxiop_equipments", null, hit -> JSONObject.parseObject(hit.getSourceAsString(), ESEquipments.class));
result.forEach(esEquipments -> {
EquipmentsJxiopDocMysql equipmentsJxiopDocMysql = new EquipmentsJxiopDocMysql();
BeanUtils.copyProperties(esEquipments, equipmentsJxiopDocMysql);
if (ObjectUtils.isEmpty(equipmentsJxiopDocMysqlMapper.selectList(new QueryWrapper<EquipmentsJxiopDocMysql>().eq("id", equipmentsJxiopDocMysql.getId())))) {
equipmentsJxiopDocMysqlMapper.insert(equipmentsJxiopDocMysql);
} else {
equipmentsJxiopDocMysqlMapper.updateById(equipmentsJxiopDocMysql);
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "从Mysql同步数据到ES")
@GetMapping("doc/getDatafromMySqlToES")
public void getDatafromMySqlToES() {
// List<EquipmentsJxiopDocMysql> equipmentsJxiopDocMysqlList = equipmentsJxiopDocMysqlMapper.selectList(new QueryWrapper<EquipmentsJxiopDocMysql>().eq("id","24_1669525017559306241"));
List<EquipmentsJxiopDocMysql> equipmentsJxiopDocMysqlList = equipmentsJxiopDocMysqlMapper.selectList(new QueryWrapper<EquipmentsJxiopDocMysql>().isNotNull("id"));
equipmentsJxiopDocMysqlList.forEach(equipmentsJxiopDocMysql -> {
ESEquipments esEquipments = equipmentsRepository.findById(equipmentsJxiopDocMysql.getId()).get();
esEquipments.setEquipmentIndexName(equipmentsJxiopDocMysql.getEquipmentIndexName());
esEquipments.setEquipmentNumber(ObjectUtils.isEmpty(equipmentsJxiopDocMysql.getEquipmentNumber())?"":equipmentsJxiopDocMysql.getEquipmentNumber());
esEquipments.setIsAlarm(equipmentsJxiopDocMysql.getIsAlarm());
esEquipments.setDataType(equipmentsJxiopDocMysql.getDataType());
esEquipments.setGatewayId(equipmentsJxiopDocMysql.getGatewayId());
esEquipments.setAddress(equipmentsJxiopDocMysql.getAddress());
esEquipments.setEquipmentSpecificName(equipmentsJxiopDocMysql.getEquipmentSpecificName());
//更新显示名称
esEquipments.setDisplayName(ObjectUtils.isEmpty(equipmentsJxiopDocMysql.getDisplayName())?"":equipmentsJxiopDocMysql.getDisplayName());
//更新排序号
esEquipments.setTraceId(ObjectUtils.isEmpty(equipmentsJxiopDocMysql.getTraceId())?"":equipmentsJxiopDocMysql.getTraceId());
//更新单位
esEquipments.setUnit(ObjectUtils.isEmpty(equipmentsJxiopDocMysql.getUnit())?"":equipmentsJxiopDocMysql.getUnit());
//更新frontModule
esEquipments.setFrontModule(ObjectUtils.isEmpty(equipmentsJxiopDocMysql.getFrontModule())?"":equipmentsJxiopDocMysql.getFrontModule());
//更新systemType
esEquipments.setSystemType(ObjectUtils.isEmpty(equipmentsJxiopDocMysql.getSystemType())?"":equipmentsJxiopDocMysql.getSystemType());
//更新图片名称
esEquipments.setPictureName(ObjectUtils.isEmpty(equipmentsJxiopDocMysql.getPictureName())?"":equipmentsJxiopDocMysql.getPictureName());
equipmentsRepository.save(esEquipments);
});
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导入整理的测点数据到MySQL同时更新es")
@PostMapping("doc/importDatafAndUpdateEs")
public void getDatafromMySqlToES(@RequestParam String filePath) {
try {
InputStream inputStream = new FileInputStream(filePath);
List<Object> pointImportDtoList = EasyExcel.read(inputStream).head(PointImportDto.class).sheet(0).headRowNumber(1).doReadSync();
pointImportDtoList.forEach(o -> {
PointImportDto pointImportDto = (PointImportDto) o;
List<EquipmentsJxiopDocMysql> equipmentsJxiopDocMysqlList = equipmentsJxiopDocMysqlMapper.selectList(new QueryWrapper<EquipmentsJxiopDocMysql>().eq("gateway_id", pointImportDto.getGatewayId()).eq("equipment_index_name",pointImportDto.getEquipmentIndexName()));
if(!ObjectUtils.isEmpty(equipmentsJxiopDocMysqlList)){
equipmentsJxiopDocMysqlList.forEach(equipmentsJxiopDocMysql -> {
ESEquipments esEquipments = equipmentsRepository.findById(equipmentsJxiopDocMysql.getId()).get();
//更新模块
equipmentsJxiopDocMysql.setFrontModule(pointImportDto.getFrontModule());
esEquipments.setFrontModule(pointImportDto.getFrontModule());
//更新类型
equipmentsJxiopDocMysql.setSystemType(pointImportDto.getSystemType());
esEquipments.setSystemType(pointImportDto.getSystemType());
//更新排序号
equipmentsJxiopDocMysql.setTraceId(pointImportDto.getTraceId());
esEquipments.setTraceId(pointImportDto.getTraceId());
//更新显示名称
equipmentsJxiopDocMysql.setDisplayName(pointImportDto.getDisplayName());
esEquipments.setDisplayName(pointImportDto.getDisplayName());
//更新单位
if(!ObjectUtils.isEmpty(pointImportDto.getUnit())){
equipmentsJxiopDocMysql.setUnit(pointImportDto.getUnit());
esEquipments.setUnit(pointImportDto.getUnit());
}
equipmentsJxiopDocMysqlMapper.updateById(equipmentsJxiopDocMysql);
equipmentsRepository.save(esEquipments);
});
}
});
} catch (Exception e) {
}
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "测试消息发送") @ApiOperation(value = "测试消息发送")
@GetMapping("/test5") @GetMapping("/test5")
public void demoTest4() { public void demoTest4() {
...@@ -243,55 +307,50 @@ public class DemoController extends BaseController { ...@@ -243,55 +307,50 @@ public class DemoController extends BaseController {
@GetMapping("/test6") @GetMapping("/test6")
public ResponseModel<Integer> demoTest5() { public ResponseModel<Integer> demoTest5() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站 //数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801570352926721","1669525017559306241"}; String[] strings = {"1668801570352926721", "1669525017559306241"};
// String [] strings = {"1669525017559306241"}; // String [] strings = {"1669525017559306241"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速"); // Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString()); // System.out.println(o.toString());
int num=0; int num = 0;
for (int i = 0; i < strings.length; i++) { for (int i = 0; i < strings.length; i++) {
QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>(); QueryWrapper<EquipmentsJxiopDocMysql> QueryWrapper = new QueryWrapper<>();
// 夏造风电 // 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089"); // QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏 // 泰和光伏
QueryWrapper.eq("gateway", strings[i]); QueryWrapper.eq("gateway", strings[i]);
long DATE = new Date().getTime(); long DATE = new Date().getTime();
System.out.println(DATE); System.out.println(DATE);
List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper); List<EquipmentsJxiopDocMysql> list = equipmentsJxiopDocMysqlMapper.selectList(QueryWrapper);
num=num+list.size(); num = num + list.size();
List<ESEquipments> listit =new ArrayList<>(); List<ESEquipments> listit = new ArrayList<>();
for (MonitorFanIndicator monitorFanIndicator : list) { for (EquipmentsJxiopDocMysql monitorFanIndicator : list) {
ESEquipments eSEquipments=new ESEquipments( ESEquipments eSEquipments = new ESEquipments(
null, monitorFanIndicator.getValueF(),
monitorFanIndicator.getAddressGateway(), monitorFanIndicator.getId(),
monitorFanIndicator.getIndexAddress(), monitorFanIndicator.getAddress(),
monitorFanIndicator.getDataType(), monitorFanIndicator.getDataType(),
monitorFanIndicator.getFanCode(), monitorFanIndicator.getEquipmentSpecificName(),
monitorFanIndicator.getGateway(), monitorFanIndicator.getGatewayId(),
monitorFanIndicator.getIsAlarm(), monitorFanIndicator.getIsAlarm(),
new Date(), monitorFanIndicator.getCreatedTime(),
monitorFanIndicator.getUnit(), monitorFanIndicator.getUnit(),
"", monitorFanIndicator.getValue(),
"" , monitorFanIndicator.getValueLabel(),
"", monitorFanIndicator.getTraceId(),
monitorFanIndicator.getIndicator(), monitorFanIndicator.getEquipmentIndexName(),
monitorFanIndicator.getEquipmentNumber(), monitorFanIndicator.getEquipmentNumber(),
monitorFanIndicator.getFrontModule(), monitorFanIndicator.getFrontModule(),
monitorFanIndicator.getSystemType(), monitorFanIndicator.getSystemType(),
monitorFanIndicator.getPictureName(), monitorFanIndicator.getPictureName(),
monitorFanIndicator.getEquipmentNumber() ); monitorFanIndicator.getDisplayName());
listit.add(eSEquipments); listit.add(eSEquipments);
// Map<String, String> tag = new HashMap<>(); // Map<String, String> tag = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>(); // Map<String, Object> maps2 = new HashMap<>();
// //
...@@ -330,6 +389,7 @@ public class DemoController extends BaseController { ...@@ -330,6 +389,7 @@ public class DemoController extends BaseController {
return ResponseHelper.buildResponse(hashMap); return ResponseHelper.buildResponse(hashMap);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "测试求和") @ApiOperation(value = "测试求和")
@GetMapping("/test8") @GetMapping("/test8")
...@@ -347,6 +407,7 @@ public class DemoController extends BaseController { ...@@ -347,6 +407,7 @@ public class DemoController extends BaseController {
return ResponseHelper.buildResponse(search); return ResponseHelper.buildResponse(search);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "测试平均数") @ApiOperation(value = "测试平均数")
@GetMapping("/test9") @GetMapping("/test9")
...@@ -374,7 +435,6 @@ public class DemoController extends BaseController { ...@@ -374,7 +435,6 @@ public class DemoController extends BaseController {
QueryBuilder queryBuilder = QueryBuilders.matchQuery("equipmentIndexName", "年发电量"); QueryBuilder queryBuilder = QueryBuilders.matchQuery("equipmentIndexName", "年发电量");
// 如果只对一个字段进行分组写一个就好 // 如果只对一个字段进行分组写一个就好
TermsAggregationBuilder tb1 = AggregationBuilders.terms("group_gatewayId").field("gatewayId.keyword");//gatewayId 是分组字段名,group_gatewayId是查询结果的别名 TermsAggregationBuilder tb1 = AggregationBuilders.terms("group_gatewayId").field("gatewayId.keyword");//gatewayId 是分组字段名,group_gatewayId是查询结果的别名
// TermsAggregationBuilder tb2 = AggregationBuilders.terms("group_equipmentNumber").field("equipmentNumber.keyword");//equipmentNumber 是分组字段名,group_equipmentNumber是查询结果的别名 // TermsAggregationBuilder tb2 = AggregationBuilders.terms("group_equipmentNumber").field("equipmentNumber.keyword");//equipmentNumber 是分组字段名,group_equipmentNumber是查询结果的别名
...@@ -403,19 +463,20 @@ public class DemoController extends BaseController { ...@@ -403,19 +463,20 @@ public class DemoController extends BaseController {
@GetMapping("/test11") @GetMapping("/test11")
public Map demoTest11() { public Map demoTest11() {
List<QueryDto> queryDto=new ArrayList<>(); List<QueryDto> queryDto = new ArrayList<>();
QueryDto ff1=new QueryDto("gatewayId.keyword","1668801435891929089"); QueryDto ff1 = new QueryDto("gatewayId.keyword", "1668801435891929089");
QueryDto ff2=new QueryDto("equipmentIndexName.keyword","有功功率"); QueryDto ff2 = new QueryDto("equipmentIndexName.keyword", "有功功率");
queryDto.add(ff1); queryDto.add(ff1);
queryDto.add(ff2); queryDto.add(ff2);
Double avg= commonServiceImpl.getavg(queryDto,"valueF",ESEquipments.class); Double avg = commonServiceImpl.getavg(queryDto, "valueF", ESEquipments.class);
Double sum= commonServiceImpl.getsum(queryDto,"valueF",ESEquipments.class); Double sum = commonServiceImpl.getsum(queryDto, "valueF", ESEquipments.class);
Map<String,Double> map=new HashMap(); Map<String, Double> map = new HashMap();
map.put("1668801435891929089_avg",avg); map.put("1668801435891929089_avg", avg);
map.put("1668801435891929089_sum",sum); map.put("1668801435891929089_sum", sum);
return map; return map;
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "取缓存数据") @ApiOperation(value = "取缓存数据")
@GetMapping("/test12") @GetMapping("/test12")
...@@ -423,205 +484,13 @@ public class DemoController extends BaseController { ...@@ -423,205 +484,13 @@ public class DemoController extends BaseController {
return commonServiceImpl.getListStationCacheInfoDto(); return commonServiceImpl.getListStationCacheInfoDto();
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分组平均数")
@GetMapping("/test13")
public Map demoTest13() {
List<String> value=new ArrayList<>();
value.add(ss);
value.add(zfs);
value.add(zfslj);
Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value);
// List<String> value1=new ArrayList<>();
// value1.add("1668801435891929089");
// map.put("gatewayId.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupavg(map,"valueF" ,"equipmentIndexName.keyword",ESEquipments.class);
Map<String,Object> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
for (Terms.Bucket bucket : lidate) {
Aggregations aggregation= bucket.getAggregations();
List<Aggregation> listdata= Objects.nonNull(aggregation)?aggregation.asList():null;
for (Aggregation agg : listdata) {
ParsedAvg parsedAvg =(ParsedAvg)agg;
mapdta.put(bucket.getKeyAsString(), format2.format(parsedAvg.getValue()));
}
}
return mapdta;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分组求和数")
@GetMapping("/test14")
public Map demoTest14() {
List<String> value=new ArrayList<>();
value.add("年发电量");
Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value);
List<String> value1=new ArrayList<>();
value1.add("1668801435891929089");
map.put("gatewayId.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueF" ,"equipmentIndexName.keyword",ESEquipments.class);
Map<String,Object> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
for (Terms.Bucket bucket : lidate) {
Aggregations aggregation= bucket.getAggregations();
List<Aggregation> listdata= Objects.nonNull(aggregation)?aggregation.asList():null;
for (Aggregation agg : listdata) {
ParsedSum parsedSum =(ParsedSum)agg;
mapdta.put(bucket.getKeyAsString(), format2.format(parsedSum.getValue()));
}
}
return mapdta;
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "分组求和数")
// @GetMapping("/test15")
// public Map test15() {
//
//// Map<String,Double> map= largeScreenImpl.getqg();
//
// return map;
// }
//
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "分组求和数")
// @GetMapping("/test16")
// public Map test16() {
//
// //获取每个区域下所有风机网管
// List<StationCacheInfoDto> listk =commonServiceImpl.getListStationCacheInfoDto();
//
// Map<String, List<StationCacheInfoDto>> map = listk.stream().filter(v -> StringUtils.isNotEmpty(v.getBelongArea())).collect(Collectors.groupingBy(StationCacheInfoDto :: getBelongArea));
// Map<String,Double> maps=null;
//
// for(String key:map.keySet()){
// List<String> value1=new ArrayList<>();
//
// List<StationCacheInfoDto> list= map.get(key);
//
// for (StationCacheInfoDto stationCacheInfoDto : list) {
// value1.add(stationCacheInfoDto.getBoosterGatewayId());
// value1.add(stationCacheInfoDto.getFanGatewayId());
// }
//
// maps= largeScreenImpl.getqy(value1);
// break;
// }
//
// return maps;
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "初始化inlfuxdb-new")
@GetMapping("/test17")
public ResponseModel<Integer> demoTest17() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801570352926721","1669525017559306241"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
int num=0;
for (int i = 0; i < strings.length; i++) {
QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>();
// 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏
QueryWrapper.eq("gateway", strings[i]);
QueryWrapper.eq("front_module","电量表计");
QueryWrapper.eq("system_type","模拟量");
long DATE = new Date().getTime();
System.out.println(DATE);
List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper);
num=num+list.size();
List<ESEquipments> listit =new ArrayList<>();
for (MonitorFanIndicator monitorFanIndicator : list) {
Map<String, String> tag = new HashMap<>();
Map<String, Object> maps2 = new HashMap<>();
tag.put("equipmentsIdx", monitorFanIndicator.getAddressGateway());
// maps2.put("address", monitorFanIndicator.getIndexAddress());
// maps2.put("dataType", monitorFanIndicator.getDataType());
// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode());
// maps2.put("gatewayId", monitorFanIndicator.getGateway());
// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm());
// maps2.put("createdTime", "2023-07-05 18:30:26");
// maps2.put("unit", monitorFanIndicator.getUnit());
// maps2.put("value", "");
// maps2.put("traceId", "");
// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator());
// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber());
maps2.put("frontModule","模拟量");
// maps2.put("systemType", monitorFanIndicator.getSystemType());
// maps2.put("pictureName", monitorFanIndicator.getPictureName());
//升压站的字段显示名称
// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2,1688558007051L, TimeUnit.MILLISECONDS);
}
}
return ResponseHelper.buildResponse(num);
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "分组求和数")
// @GetMapping("/test18")
// public Map test18() {
// List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
// //获取时间天字符串
//
// String datyvalue= "2023-08-11";
// elasticsearchTemplate.deleteIndex(ESDailyPowerGeneration.class);
// elasticsearchTemplate.deleteIndex(ESMoonPowerGeneration.class);
// elasticsearchTemplate.deleteIndex(ESYearPowerGeneration.class);
//
// for (StationCacheInfoDto stationCacheInfoDto : list) {
// if("FDZ".equals(stationCacheInfoDto.getStationType())){
//
// //风机
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"FDZ",datyvalue);
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"FDZ",datyvalue);
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"FDZ",datyvalue);
//
// }else{
//
// //光伏
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"GFDZ",datyvalue);
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"GFDZ",datyvalue);
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"GFDZ",datyvalue);
//
// }
// }
//
// return null;
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "es获取数据") @ApiOperation(value = "es获取数据")
@GetMapping("/test19") @GetMapping("/test19")
public void test19() { public void test19() {
Map<String,List<String>> queryConditon = new HashMap<>(); Map<String, List<String>> queryConditon = new HashMap<>();
queryConditon.put("equipmentIndexName.keyword",Arrays.asList("日发电量","月发电量","年发电量")); queryConditon.put("equipmentIndexName.keyword", Arrays.asList("日发电量", "月发电量", "年发电量"));
commonServiceImpl.getListDataByCondtions(queryConditon,null,ESEquipments.class); commonServiceImpl.getListDataByCondtions(queryConditon, null, ESEquipments.class);
} }
} }
...@@ -39,6 +39,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -39,6 +39,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.Collator;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -351,6 +352,34 @@ public class MonitorFanIdxController extends BaseController { ...@@ -351,6 +352,34 @@ public class MonitorFanIdxController extends BaseController {
result.setTotal(statusMonitoring.size()); result.setTotal(statusMonitoring.size());
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "升压站光字牌/开关-通用")
@GetMapping("/getStatusGzpnew")
public ResponseModel<IPage<Map<String, Object>>> getStatusGzpnew(@RequestParam(required = false) String name,@RequestParam(value = "stationId") String stationId, String frontModule, String systemType, String equipNum, @RequestParam(required = false) String stationType) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
if (null != stationType) {
gatewayId = stationBasic.getFanGatewayId();
}
List<Map<String, Object>> statusMonitoring = monitorFanIndicator.getStatusGzp(gatewayId, systemType, frontModule, equipNum,stationBasic.getStationType());
if(name!=null){
statusMonitoring= statusMonitoring.stream().filter(s-> s.get("data").toString().contains(name)).collect(Collectors.toList());
}
IPage<Map<String, Object>> result = new Page<>();
result.setRecords(statusMonitoring);
result.setCurrent(1);
result.setTotal(statusMonitoring.size());
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class PointImportDto {
@ExcelProperty("网关")
private String gatewayId ;
@ExcelProperty("模块")
private String frontModule;
@ExcelProperty("类型")
private String systemType;
@ExcelProperty("排序号")
private String traceId;
@ExcelProperty("测点名称")
private String equipmentIndexName;
@ExcelProperty("显示名称")
private String displayName;
@ExcelProperty("单位")
private String unit;
}
package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.github.classgraph.json.Id;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* CREATE TABLE `equipments_jxiop_doc_mysql` (
* `id` varchar(50) NOT NULL,
* `address` varchar(50) DEFAULT NULL,
* `equipment_specific_name` varchar(255) DEFAULT NULL,
* `gateway_id` varchar(50) DEFAULT NULL,
* `is_alarm` varchar(20) DEFAULT NULL,
* `created_time` date DEFAULT NULL,
* `unit` varchar(50) DEFAULT NULL,
* `value` varchar(50) DEFAULT NULL,
* `value_F` float DEFAULT NULL,
* `value_label` varchar(255) DEFAULT NULL,
* `trace_id` varchar(50) DEFAULT NULL,
* `equipment_index_name` varchar(255) DEFAULT NULL,
* `equipment_number` varchar(50) DEFAULT NULL,
* `front_module` varchar(200) DEFAULT NULL,
* `system_type` varchar(200) DEFAULT NULL,
* `picture_name` varchar(255) DEFAULT NULL,
* `display_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
* `data_type` varchar(50) DEFAULT NULL,
* PRIMARY KEY (`id`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
*/
@Data
@Accessors(chain = true)
@TableName("equipments_jxiop_doc_mysql")
public class EquipmentsJxiopDocMysql {
@Id
private String id;
@TableField("address")
private String address;
@TableField("data_type")
private String dataType;
@TableField("equipment_specific_name")
private String equipmentSpecificName;
@TableField("gateway_id")
private String gatewayId;
@TableField("is_alarm")
private String isAlarm;
@TableField("created_time")
private Date createdTime;
@TableField("unit")
private String unit;
@TableField("value")
private String value;
@TableField("value_F")
private Float valueF ;
@TableField("value_label")
private String valueLabel;
@TableField("trace_id")
private String traceId;
@TableField("equipment_index_name")
private String equipmentIndexName;
@TableField("equipment_number")
private String equipmentNumber;
@TableField("front_module")
private String frontModule;
@TableField("system_type")
private String systemType;
@TableField("picture_name")
private String pictureName;
@TableField("display_name")
private String displayName;
}
package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import lombok.Getter;
/**
*
* @author LiuLin
* @date 2023年10月11日 09:31
*/
@Getter
public final class EsEntity<T> {
private String id;
private T data;
public EsEntity() {
}
public EsEntity(String id, T data) {
this.data = data;
this.id = id;
}
public void setId(String id) {
this.id = id;
}
public void setData(T data) {
this.data = data;
}
}
...@@ -13,8 +13,6 @@ import java.util.Map; ...@@ -13,8 +13,6 @@ import java.util.Map;
* @createDate: 2023/7/3 * @createDate: 2023/7/3
*/ */
public interface IMonitorFanIndicator { public interface IMonitorFanIndicator {
//批量修改指标值
void UpdateMonitorFanIndicator(List<IndexDto> list);
ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber); ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
ResultsData getLsNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber); ResultsData getLsNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
......
...@@ -599,7 +599,7 @@ public class CommonServiceImpl { ...@@ -599,7 +599,7 @@ public class CommonServiceImpl {
List<T> list = searchHitList.stream().map(hit -> hit.getContent()).collect(Collectors.toList()); List<T> list = searchHitList.stream().map(hit -> hit.getContent()).collect(Collectors.toList());
return list; return list;
} }
return null; return new ArrayList<>();
} }
......
...@@ -46,6 +46,7 @@ import org.springframework.util.ObjectUtils; ...@@ -46,6 +46,7 @@ import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.ws.rs.HEAD;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
...@@ -116,10 +117,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -116,10 +117,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
private List<Map> list; private List<Map> list;
@Override
public void UpdateMonitorFanIndicator(List<IndexDto> list) {
monitorFanIndicatorregionMapper.UpdateMonitorFanIndicator(list);
}
@Override @Override
public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) { public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) {
...@@ -293,28 +291,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -293,28 +291,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return treeDto; return treeDto;
} }
/**
* 根据网关与指标获取指标的平均值
*
* @param gateway
* @param indicator
* @return
*/
public Object getIndicatoralueAvage(String gateway, String indicator) {
return monitorFanIndicatorregionMapper.getIndicatoralueAvage(gateway, indicator);
}
/**
* 根据网关与指标获取指标的总值
*
* @param gateway
* @param indicator
* @return
*/
public Object getIndicatoralueTotal(String gateway, String indicator) {
return monitorFanIndicatorregionMapper.getIndicatoralueTotal(gateway, indicator);
}
public StationBasic getOneByStationNumber(String stationId) { public StationBasic getOneByStationNumber(String stationId) {
...@@ -840,21 +820,28 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -840,21 +820,28 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
Map<String, String> likeMap = new HashMap<>(); Map<String, String> likeMap = new HashMap<>();
likeMap.put(CommonConstans.QueryStringFrontMoudle, frontModule); likeMap.put(CommonConstans.QueryStringFrontMoudle, frontModule);
if (stationType.equals("FDZ")) { if (stationType.equals("FDZ")) {
queryCondtion.put(CommonConstans.QueryStringSystemTypeKeyword, Arrays.asList(systemType)); queryCondtion.put(CommonConstans.QueryStringSystemTypeKeyword, Arrays.asList(systemType));
} else { } else {
likeMap.put(CommonConstans.QueryStringSystemTypeKeyword, systemType); likeMap.put(CommonConstans.QueryStringSystemTypeKeyword, systemType);
} }
List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeMap); List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeMap);
Integer traceIdCount = indicatorsDtoList.stream().filter(esEquipments -> !StringUtils.isEmpty(esEquipments.getTraceId())).collect(Collectors.toList()).size();
List<Map<String, Object>> statusMaps = new ArrayList<>(); List<Map<String, Object>> statusMaps = new ArrayList<>();
for (ESEquipments listDatum : indicatorsDtoList) { for (ESEquipments listDatum : indicatorsDtoList) {
Map<String, Object> statusMap = new HashMap<>(); Map<String, Object> statusMap = new HashMap<>();
statusMap.put("traceId",listDatum.getTraceId());
String data = listDatum.getDisplayName(); String data = listDatum.getDisplayName();
if (StringUtils.isEmpty(data) || (!ObjectUtils.isEmpty(listDatum.getEquipmentNumber()) && data.equals(listDatum.getEquipmentNumber()))) { if (StringUtils.isEmpty(data) || (!ObjectUtils.isEmpty(listDatum.getEquipmentNumber()) && data.equals(listDatum.getEquipmentNumber()))) {
data = listDatum.getEquipmentIndexName(); data = listDatum.getEquipmentIndexName();
} }
statusMap.put("displayName",listDatum.getDisplayName());
statusMap.put("equipmentIndexName",listDatum.getEquipmentIndexName());
statusMap.put("unit",listDatum.getUnit());
statusMap.put("value",listDatum.getValue());
statusMap.put("addres", listDatum.getAddress()); statusMap.put("addres", listDatum.getAddress());
statusMap.put("id", listDatum.getId());
statusMap.put("data", data); statusMap.put("data", data);
statusMap.put("state", listDatum.getValue().equals("false") ? 0 : 1); statusMap.put("state", listDatum.getValue().equals("false") ? 0 : 1);
statusMap.put("status", listDatum.getValue().equals("false") ? 0 : 1); statusMap.put("status", listDatum.getValue().equals("false") ? 0 : 1);
...@@ -864,7 +851,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -864,7 +851,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
statusMaps.add(statusMap); statusMaps.add(statusMap);
} }
statusMaps.sort(Comparator.comparingLong(o -> Long.parseLong(o.get("addres").toString()))); // Collator instance = Collator.getInstance(Local);
String sortField;
if(traceIdCount == statusMaps.size()){
sortField = "traceId";
} else {
sortField = "addres";
}
// Collections.sort(statusMaps, (e1, e2) -> {
// return instance.compare(Integer.valueOf(e1.get(sortField).toString()), Integer.valueOf(e2.get(sortField).toString()));
// });
statusMaps.sort(Comparator.comparingInt(o -> Integer.parseInt(o.get(sortField).toString())));
return statusMaps; return statusMaps;
} }
...@@ -878,8 +875,16 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -878,8 +875,16 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap); List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);
List<ESEquipments> listData = esEquipmentsList.stream().filter(esEquipments -> !esEquipments.getDisplayName().equals("")).collect(Collectors.toList()); List<ESEquipments> listData = esEquipmentsList.stream().filter(esEquipments -> !esEquipments.getDisplayName().equals("")).collect(Collectors.toList());
List<Map<String, Object>> statusMaps = new ArrayList<>(); List<Map<String, Object>> statusMaps = new ArrayList<>();
Integer traceIdCount = listData.stream().filter(esEquipments -> !StringUtils.isEmpty(esEquipments.getTraceId())).collect(Collectors.toList()).size();
for (ESEquipments listDatum : listData) { for (ESEquipments listDatum : listData) {
Map<String, Object> statusMap = new HashMap<>(); Map<String, Object> statusMap = new HashMap<>();
statusMap.put("traceId",listDatum.getTraceId());
statusMap.put("displayName",listDatum.getDisplayName());
statusMap.put("equipmentIndexName",listDatum.getEquipmentIndexName());
statusMap.put("equipmentIndexName",listDatum.getEquipmentIndexName());
statusMap.put("unit",listDatum.getUnit());
statusMap.put("value",listDatum.getValue());
statusMap.put("id", listDatum.getId());
if (StringUtils.isEmpty(listDatum.getValue())) { if (StringUtils.isEmpty(listDatum.getValue())) {
statusMap.put("title", 0.00 + (StringUtils.isNotEmpty(listDatum.getUnit()) ? listDatum.getUnit() : "")); statusMap.put("title", 0.00 + (StringUtils.isNotEmpty(listDatum.getUnit()) ? listDatum.getUnit() : ""));
} else { } else {
...@@ -888,13 +893,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -888,13 +893,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
statusMap.put("title1", listDatum.getDisplayName()); statusMap.put("title1", listDatum.getDisplayName());
statusMaps.add(statusMap); statusMaps.add(statusMap);
} }
Collator instance = Collator.getInstance(Locale.CHINA); Collator instance = Collator.getInstance(Locale.CHINA);
String sortField;
if(traceIdCount == statusMaps.size()){
sortField = "traceId";
statusMaps.sort(Comparator.comparingInt(o -> Integer.parseInt(o.get(sortField).toString())));
} else {
sortField = "title1";
Collections.sort(statusMaps, (e1, e2) -> { Collections.sort(statusMaps, (e1, e2) -> {
return instance.compare(e1.get("title1"), e2.get("title1")); return instance.compare(e1.get(sortField), e2.get(sortField));
}); });
}
return statusMaps; return statusMaps;
} }
...@@ -2211,8 +2220,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -2211,8 +2220,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
c = -c; c = -c;
} }
double pcv = c / avageValue; double pcv = c / avageValue;
pcv = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, pcv)); pcv=pcv*100;
resultMap.put("pcv", pcv); pcv=Math.round(pcv);
//pcv = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, pcv));
resultMap.put("pcv", (int)pcv+"%");
resultList.add(resultMap); resultList.add(resultMap);
} }
} }
......
package com.yeejoin.amos.boot.module.jxiop.biz.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EsEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.ClearScrollRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchScrollRequest;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.Scroll;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* @author LiuLin
* @date 2023年08月08日 16:30
*/
@Slf4j
@Component
public class ElasticSearchUtil {
private static final long SCROLL_TIMEOUT = 180000;
private static final int SIZE = 1000;
@Autowired
private RestHighLevelClient restHighLevelClient;
/**
* ES修改数据
*
* @param indexName 索引名称
* @param id 主键
* @param paramJson 参数JSON
* @return
*/
public boolean updateData(String indexName, String id, String paramJson) {
log.info("更新ES数据,value:{}", id);
UpdateRequest updateRequest = new UpdateRequest(indexName, id);
//如果修改索引中不存在则进行新增
updateRequest.docAsUpsert(true);
//立即刷新数据
updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
updateRequest.doc(paramJson, XContentType.JSON);
try {
UpdateResponse updateResponse = restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);
//log.info("索引[{}],主键:【{}】操作结果:[{}]", indexName, id, updateResponse.getResult());
if (DocWriteResponse.Result.CREATED.equals(updateResponse.getResult())) {
log.info("索引:【{}】,主键:【{}】新增成功", indexName, id);
return true;
} else if (DocWriteResponse.Result.UPDATED.equals(updateResponse.getResult())) {
log.info("索引:【{}】,主键:【{}】修改成功", indexName, id);
return true;
} else if (DocWriteResponse.Result.NOOP.equals(updateResponse.getResult())) {
log.info("索引:[{}],主键:[{}]无变化", indexName, id);
return true;
}
} catch (IOException e) {
log.error("索引:[{}],主键:【{}】", indexName, id, e);
return false;
}
return false;
}
/**
* 单条更新
*
* @param indexName
* @param id
* @param data
* @return
* @throws IOException
*/
public boolean updateData(String indexName, String id, Object data) throws IOException {
UpdateRequest updateRequest = new UpdateRequest(indexName, id);
//准备文档
String jsonString = JSONObject.toJSONString(data);
Map jsonMap = JSONObject.parseObject(jsonString, Map.class);
updateRequest.doc(jsonMap);
updateRequest.timeout(TimeValue.timeValueSeconds(1));
updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL);
//数据为存储而不是更新
UpdateResponse update = restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);
return update.getGetResult().equals(DocWriteResponse.Result.UPDATED);
}
/**
* 必须传递ids集合
*
* @param indexName
* @param idList
* @param map
* @return
*/
public boolean update(String indexName, List<String> idList, Map map) {
// 创建批量请求
BulkRequest bulkRequest = new BulkRequest();
for (String id : idList) {
UpdateRequest updateRequest = new UpdateRequest(indexName, id).doc(map);
bulkRequest.add(updateRequest);
}
try {
bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
BulkResponse bulk = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);
return bulk.hasFailures();
} catch (IOException e) {
return false;
}
}
/**
* Description: 批量修改数据
*
* @param index index
* @param list 更新列表
* @author LiuLin
*/
public <T> void updateBatch(String index, List<EsEntity<T>> list) {
BulkRequest request = new BulkRequest();
list.forEach(item -> request.add(new UpdateRequest(index, item.getId())
.doc(JSON.toJSONString(item.getData()), XContentType.JSON)));
try {
restHighLevelClient.bulk(request, RequestOptions.DEFAULT);
list.forEach(s -> log.info("===========索引:【{}】,主键:【{}】修改成功", index, s.getId()));
} catch (Exception e) {
log.error("索引:[{}]", index, e);
}
}
/**
* Description: 批量插入数据
*
* @param index index
* @param list 插入列表
* @author LiuLin
*/
public <T> void insertBatch(String index, List<EsEntity<T>> list) {
BulkRequest request = new BulkRequest();
list.forEach(item -> request.add(new IndexRequest(index).id(item.getId())
.source(JSON.toJSONString(item.getData()), XContentType.JSON)));
try {
restHighLevelClient.bulk(request, RequestOptions.DEFAULT);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* ES异步修改数据
*
* @param indexName 索引名称
* @param id 主键
* @param paramJson 参数JSON
*/
public void updateDataAsync(String indexName, String id, String paramJson) throws IOException {
UpdateRequest updateRequest = new UpdateRequest(indexName, id);
updateRequest.docAsUpsert(true);
updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
updateRequest.doc(paramJson, XContentType.JSON);
restHighLevelClient.updateAsync(updateRequest, RequestOptions.DEFAULT, new ActionListener<UpdateResponse>() {
@Override
public void onResponse(UpdateResponse updateResponse) {
if (DocWriteResponse.Result.UPDATED.equals(updateResponse.getResult())) {
log.info("索引:【{}】,主键:【{}】修改成功", indexName, id);
}
}
@Override
public void onFailure(Exception e) {
log.error("索引:[{}],主键:【{}】", indexName, id, e);
}
});
}
/**
* 构建SearchResponse
*
* @param indices 索引
* @param query queryBuilder
* @param fun 返回函数
* @param <T> 返回类型
* @return List, 可以使用fun转换为T结果
* @throws Exception e
*/
public <T> List<T> searchResponse(String indices, QueryBuilder query, Function<SearchHit, T> fun) throws Exception {
SearchRequest request = new SearchRequest(indices);
Scroll scroll = new Scroll(TimeValue.timeValueMillis(SCROLL_TIMEOUT));
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(query);
sourceBuilder.size(SIZE);
request.scroll(scroll);
request.source(sourceBuilder);
List<String> scrollIdList = new ArrayList<>();
List<T> result = new ArrayList<>();
SearchResponse searchResponse = restHighLevelClient.search(request, RequestOptions.DEFAULT);
String scrollId = searchResponse.getScrollId();
SearchHit[] hits = searchResponse.getHits().getHits();
scrollIdList.add(scrollId);
try {
while (ArrayUtils.isNotEmpty(hits)) {
for (SearchHit hit : hits) {
result.add(fun.apply(hit));
}
if (hits.length < SIZE) {
break;
}
SearchScrollRequest searchScrollRequest = new SearchScrollRequest(scrollId);
searchScrollRequest.scroll(scroll);
SearchResponse searchScrollResponse = restHighLevelClient.scroll(searchScrollRequest, RequestOptions.DEFAULT);
scrollId = searchScrollResponse.getScrollId();
hits = searchScrollResponse.getHits().getHits();
scrollIdList.add(scrollId);
}
} finally {
ClearScrollRequest clearScrollRequest = new ClearScrollRequest();
clearScrollRequest.setScrollIds(scrollIdList);
restHighLevelClient.clearScroll(clearScrollRequest, RequestOptions.DEFAULT);
}
return result;
}
}
...@@ -4,11 +4,9 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller; ...@@ -4,11 +4,9 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments; import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test; import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
...@@ -45,10 +43,8 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -45,10 +43,8 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
@RestController @RestController
...@@ -146,81 +142,81 @@ public class DemoController extends BaseController { ...@@ -146,81 +142,81 @@ public class DemoController extends BaseController {
// System.out.println(list2.size()); // System.out.println(list2.size());
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) // @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "初始化influxdb-风电、光伏、升压站") // @ApiOperation(value = "初始化influxdb-风电、光伏、升压站")
@GetMapping("doc/test4") // @GetMapping("doc/test4")
public ResponseModel<Integer> demoTest3() { // public ResponseModel<Integer> demoTest3() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站 // //数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801435891929089","1669524885619085313","1668801570352926721","1669525017559306241"}; // String [] strings = {"1668801435891929089","1669524885619085313","1668801570352926721","1669525017559306241"};
// String [] strings = {"1669524885619085313"}; //// String [] strings = {"1669524885619085313"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速"); //// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString()); //// System.out.println(o.toString());
elasticsearchTemplate.deleteIndex(ESEquipments.class); // elasticsearchTemplate.deleteIndex(ESEquipments.class);
int num=0; // int num=0;
for (int i = 0; i < strings.length; i++) { // for (int i = 0; i < strings.length; i++) {
QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>(); // QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>();
// 夏造风电 //// 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089"); //// QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏 //// 泰和光伏
QueryWrapper.eq("gateway", strings[i]); // QueryWrapper.eq("gateway", strings[i]);
long DATE = new Date().getTime(); // long DATE = new Date().getTime();
System.out.println(DATE); // System.out.println(DATE);
List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper); // List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper);
num=num+list.size(); // num=num+list.size();
List<ESEquipments> listit =new ArrayList<>(); // List<ESEquipments> listit =new ArrayList<>();
for (MonitorFanIndicator monitorFanIndicator : list) { // for (MonitorFanIndicator monitorFanIndicator : list) {
ESEquipments eSEquipments=new ESEquipments(
null,
monitorFanIndicator.getAddressGateway(),
monitorFanIndicator.getIndexAddress(),
monitorFanIndicator.getDataType(),
monitorFanIndicator.getFanCode(),
monitorFanIndicator.getGateway(),
monitorFanIndicator.getIsAlarm(),
new Date(),
monitorFanIndicator.getUnit(),
"",
"" ,
"",
monitorFanIndicator.getIndicator(),
monitorFanIndicator.getEquipmentNumber(),
monitorFanIndicator.getFrontModule(),
monitorFanIndicator.getSystemType(),
monitorFanIndicator.getPictureName(),
monitorFanIndicator.getEquipmentNumber());
listit.add(eSEquipments);
// Map<String, String> tag = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
// //
// maps2.put("address", monitorFanIndicator.getIndexAddress()); // ESEquipments eSEquipments=new ESEquipments(
// maps2.put("dataType", monitorFanIndicator.getDataType()); // null,
// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode()); // monitorFanIndicator.getAddressGateway(),
// tag.put("equipmentsIdx", monitorFanIndicator.getAddressGateway()); // monitorFanIndicator.getIndexAddress(),
// maps2.put("gatewayId", monitorFanIndicator.getGateway()); // monitorFanIndicator.getDataType(),
// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm()); // monitorFanIndicator.getFanCode(),
// maps2.put("createdTime", "2023-07-05 18:30:26"); // monitorFanIndicator.getGateway(),
// maps2.put("unit", monitorFanIndicator.getUnit()); // monitorFanIndicator.getIsAlarm(),
// maps2.put("value", ""); // new Date(),
// maps2.put("valueLabel","" ); // monitorFanIndicator.getUnit(),
// maps2.put("traceId", ""); // "",
// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator()); // "" ,
// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber()); // "",
// maps2.put("frontModule", monitorFanIndicator.getFrontModule()); // monitorFanIndicator.getIndicator(),
// maps2.put("systemType", monitorFanIndicator.getSystemType()); // monitorFanIndicator.getEquipmentNumber(),
// maps2.put("pictureName", monitorFanIndicator.getPictureName()); // monitorFanIndicator.getFrontModule(),
// //升压站的字段显示名称 // monitorFanIndicator.getSystemType(),
// maps2.put("displayName", ""); // monitorFanIndicator.getPictureName(),
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2, 1688558007051L, TimeUnit.MILLISECONDS); // monitorFanIndicator.getEquipmentNumber());
//
} // listit.add(eSEquipments);
equipmentsRepository.saveAll(listit); //
} //
return ResponseHelper.buildResponse(num); //// Map<String, String> tag = new HashMap<>();
} //// Map<String, Object> maps2 = new HashMap<>();
////
//// maps2.put("address", monitorFanIndicator.getIndexAddress());
//// maps2.put("dataType", monitorFanIndicator.getDataType());
//// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode());
//// tag.put("equipmentsIdx", monitorFanIndicator.getAddressGateway());
//// maps2.put("gatewayId", monitorFanIndicator.getGateway());
//// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm());
//// maps2.put("createdTime", "2023-07-05 18:30:26");
//// maps2.put("unit", monitorFanIndicator.getUnit());
//// maps2.put("value", "");
//// maps2.put("valueLabel","" );
//// maps2.put("traceId", "");
//// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator());
//// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber());
//// maps2.put("frontModule", monitorFanIndicator.getFrontModule());
//// maps2.put("systemType", monitorFanIndicator.getSystemType());
//// maps2.put("pictureName", monitorFanIndicator.getPictureName());
//// //升压站的字段显示名称
//// maps2.put("displayName", "");
//// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2, 1688558007051L, TimeUnit.MILLISECONDS);
//
// }
// equipmentsRepository.saveAll(listit);
// }
// return ResponseHelper.buildResponse(num);
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "测试消息发送") @ApiOperation(value = "测试消息发送")
...@@ -238,88 +234,88 @@ public class DemoController extends BaseController { ...@@ -238,88 +234,88 @@ public class DemoController extends BaseController {
} }
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) // @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "初始化升压站") // @ApiOperation(value = "初始化升压站")
@GetMapping("/test6") // @GetMapping("/test6")
public ResponseModel<Integer> demoTest5() { // public ResponseModel<Integer> demoTest5() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站 // //数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801570352926721","1669525017559306241"}; // String [] strings = {"1668801570352926721","1669525017559306241"};
// String [] strings = {"1669525017559306241"}; //// String [] strings = {"1669525017559306241"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速"); //// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString()); //// System.out.println(o.toString());
int num=0;
for (int i = 0; i < strings.length; i++) {
QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>();
// 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏
QueryWrapper.eq("gateway", strings[i]);
long DATE = new Date().getTime();
System.out.println(DATE);
List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper);
num=num+list.size();
List<ESEquipments> listit =new ArrayList<>();
for (MonitorFanIndicator monitorFanIndicator : list) {
ESEquipments eSEquipments=new ESEquipments(
null,
monitorFanIndicator.getAddressGateway(),
monitorFanIndicator.getIndexAddress(),
monitorFanIndicator.getDataType(),
monitorFanIndicator.getFanCode(),
monitorFanIndicator.getGateway(),
monitorFanIndicator.getIsAlarm(),
new Date(),
monitorFanIndicator.getUnit(),
"",
"" ,
"",
monitorFanIndicator.getIndicator(),
monitorFanIndicator.getEquipmentNumber(),
monitorFanIndicator.getFrontModule(),
monitorFanIndicator.getSystemType(),
monitorFanIndicator.getPictureName(),
monitorFanIndicator.getEquipmentNumber() );
listit.add(eSEquipments);
// Map<String, String> tag = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
// //
// maps2.put("address", monitorFanIndicator.getIndexAddress()); // int num=0;
// maps2.put("dataType", monitorFanIndicator.getDataType()); // for (int i = 0; i < strings.length; i++) {
// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode()); // QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>();
// tag.put("equipmentsIdx", monitorFanIndicator.getAddressGateway()); //// 夏造风电
// maps2.put("gatewayId", monitorFanIndicator.getGateway()); //// QueryWrapper.eq("gateway", "1668801435891929089");
// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm()); //// 泰和光伏
// maps2.put("createdTime", "2023-07-05 18:30:26"); // QueryWrapper.eq("gateway", strings[i]);
// maps2.put("unit", monitorFanIndicator.getUnit()); // long DATE = new Date().getTime();
// maps2.put("value", ""); // System.out.println(DATE);
// maps2.put("valueLabel","" ); // List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper);
// maps2.put("traceId", ""); // num=num+list.size();
// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator()); //
// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber()); // List<ESEquipments> listit =new ArrayList<>();
// maps2.put("frontModule", monitorFanIndicator.getFrontModule()); // for (MonitorFanIndicator monitorFanIndicator : list) {
// maps2.put("systemType", monitorFanIndicator.getSystemType()); //
// maps2.put("pictureName", monitorFanIndicator.getPictureName()); //
// //升压站的字段显示名称 // ESEquipments eSEquipments=new ESEquipments(
// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber()); // null,
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2, 1688558007051L, TimeUnit.MILLISECONDS); // monitorFanIndicator.getAddressGateway(),
} // monitorFanIndicator.getIndexAddress(),
// monitorFanIndicator.getDataType(),
equipmentsRepository.saveAll(listit); // monitorFanIndicator.getFanCode(),
} // monitorFanIndicator.getGateway(),
return ResponseHelper.buildResponse(num); // monitorFanIndicator.getIsAlarm(),
} // new Date(),
// monitorFanIndicator.getUnit(),
// "",
// "" ,
// "",
// monitorFanIndicator.getIndicator(),
// monitorFanIndicator.getEquipmentNumber(),
// monitorFanIndicator.getFrontModule(),
// monitorFanIndicator.getSystemType(),
// monitorFanIndicator.getPictureName(),
// monitorFanIndicator.getEquipmentNumber() );
//
// listit.add(eSEquipments);
//
//
//
//
//
//
//
//// Map<String, String> tag = new HashMap<>();
//// Map<String, Object> maps2 = new HashMap<>();
////
//// maps2.put("address", monitorFanIndicator.getIndexAddress());
//// maps2.put("dataType", monitorFanIndicator.getDataType());
//// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode());
//// tag.put("equipmentsIdx", monitorFanIndicator.getAddressGateway());
//// maps2.put("gatewayId", monitorFanIndicator.getGateway());
//// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm());
//// maps2.put("createdTime", "2023-07-05 18:30:26");
//// maps2.put("unit", monitorFanIndicator.getUnit());
//// maps2.put("value", "");
//// maps2.put("valueLabel","" );
//// maps2.put("traceId", "");
//// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator());
//// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber());
//// maps2.put("frontModule", monitorFanIndicator.getFrontModule());
//// maps2.put("systemType", monitorFanIndicator.getSystemType());
//// maps2.put("pictureName", monitorFanIndicator.getPictureName());
//// //升压站的字段显示名称
//// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
//// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2, 1688558007051L, TimeUnit.MILLISECONDS);
// }
//
// equipmentsRepository.saveAll(listit);
// }
// return ResponseHelper.buildResponse(num);
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "测试动态图片") @ApiOperation(value = "测试动态图片")
...@@ -527,57 +523,57 @@ public class DemoController extends BaseController { ...@@ -527,57 +523,57 @@ public class DemoController extends BaseController {
// return maps; // return maps;
// } // }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) // @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "初始化inlfuxdb-new") // @ApiOperation(value = "初始化inlfuxdb-new")
@GetMapping("/test17") // @GetMapping("/test17")
public ResponseModel<Integer> demoTest17() { // public ResponseModel<Integer> demoTest17() {
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站 // //数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String [] strings = {"1668801570352926721","1669525017559306241"}; // String [] strings = {"1668801570352926721","1669525017559306241"};
//
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速"); //// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString()); //// System.out.println(o.toString());
//
int num=0; // int num=0;
for (int i = 0; i < strings.length; i++) { // for (int i = 0; i < strings.length; i++) {
QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>(); // QueryWrapper<MonitorFanIndicator> QueryWrapper = new QueryWrapper<>();
// 夏造风电 //// 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089"); //// QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏 //// 泰和光伏
QueryWrapper.eq("gateway", strings[i]); // QueryWrapper.eq("gateway", strings[i]);
QueryWrapper.eq("front_module","电量表计"); // QueryWrapper.eq("front_module","电量表计");
QueryWrapper.eq("system_type","模拟量"); // QueryWrapper.eq("system_type","模拟量");
long DATE = new Date().getTime(); // long DATE = new Date().getTime();
System.out.println(DATE); // System.out.println(DATE);
List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper); // List<MonitorFanIndicator> list = monitorFanIndicatorregionMapper.selectList(QueryWrapper);
num=num+list.size(); // num=num+list.size();
//
List<ESEquipments> listit =new ArrayList<>(); // List<ESEquipments> listit =new ArrayList<>();
for (MonitorFanIndicator monitorFanIndicator : list) { // for (MonitorFanIndicator monitorFanIndicator : list) {
Map<String, String> tag = new HashMap<>(); // Map<String, String> tag = new HashMap<>();
Map<String, Object> maps2 = new HashMap<>(); // Map<String, Object> maps2 = new HashMap<>();
//
tag.put("equipmentsIdx", monitorFanIndicator.getAddressGateway()); // tag.put("equipmentsIdx", monitorFanIndicator.getAddressGateway());
// maps2.put("address", monitorFanIndicator.getIndexAddress()); // // maps2.put("address", monitorFanIndicator.getIndexAddress());
// maps2.put("dataType", monitorFanIndicator.getDataType()); // // maps2.put("dataType", monitorFanIndicator.getDataType());
// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode()); // // maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode());
// maps2.put("gatewayId", monitorFanIndicator.getGateway()); // // maps2.put("gatewayId", monitorFanIndicator.getGateway());
// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm()); // // maps2.put("isAlarm", monitorFanIndicator.getIsAlarm());
// maps2.put("createdTime", "2023-07-05 18:30:26"); // // maps2.put("createdTime", "2023-07-05 18:30:26");
// maps2.put("unit", monitorFanIndicator.getUnit()); // // maps2.put("unit", monitorFanIndicator.getUnit());
// maps2.put("value", ""); // // maps2.put("value", "");
// maps2.put("traceId", ""); // // maps2.put("traceId", "");
// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator()); // // maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator());
// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber()); // // maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber());
maps2.put("frontModule","模拟量"); // maps2.put("frontModule","模拟量");
// maps2.put("systemType", monitorFanIndicator.getSystemType()); // // maps2.put("systemType", monitorFanIndicator.getSystemType());
// maps2.put("pictureName", monitorFanIndicator.getPictureName()); // // maps2.put("pictureName", monitorFanIndicator.getPictureName());
//升压站的字段显示名称 // //升压站的字段显示名称
// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber()); // // maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2,1688558007051L, TimeUnit.MILLISECONDS); //// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2,1688558007051L, TimeUnit.MILLISECONDS);
} // }
} // }
return ResponseHelper.buildResponse(num); // return ResponseHelper.buildResponse(num);
} // }
......
...@@ -69,4 +69,12 @@ public class EventController { ...@@ -69,4 +69,12 @@ public class EventController {
resultsData = equipAlarmEventServiceImpl.getEquipEvent(current, size, fanGatewayId, equipIndex, frontModule); resultsData = equipAlarmEventServiceImpl.getEquipEvent(current, size, fanGatewayId, equipIndex, frontModule);
return ResponseHelper.buildResponse(resultsData); return ResponseHelper.buildResponse(resultsData);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "刷新字典API")
@GetMapping("/dic/refresh")
public ResponseModel<String> refresh() {
alarmEventServiceImpl.init();
return ResponseHelper.buildResponse("success");
}
} }
...@@ -47,4 +47,7 @@ public class EquipAlarmEvent { ...@@ -47,4 +47,7 @@ public class EquipAlarmEvent {
@TableField(exist = false) @TableField(exist = false)
private String time; private String time;
@TableField("alarm_group_name")
private String alarmGroupName;
} }
package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@Data
@Accessors(chain = true)
@TableName("wl_equipment_specific_index_alarm_dic")
public class EquipmentSpecificIndexAlarmDic {
@TableField("value")
private int value;
@TableField("name")
private String name;
}
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndexAlarmDic;
public interface EquipmentSpecificIndexAlarmDicMapper extends BaseMapper<EquipmentSpecificIndexAlarmDic> {
}
...@@ -19,7 +19,6 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -19,7 +19,6 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -31,6 +30,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData; ...@@ -31,6 +30,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.AlarmEvent; import com.yeejoin.amos.boot.module.jxiop.biz.entity.AlarmEvent;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipAlarmEvent; import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipAlarmEvent;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndex; import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndexAlarmDic;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipmentSpecificIndexAlarmDicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipmentSpecificIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipmentSpecificIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.AlarmEventMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.AlarmEventMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.EquipAlarmEventMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.EquipAlarmEventMapper;
...@@ -45,11 +46,17 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -45,11 +46,17 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper; private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Autowired @Autowired
private EquipmentSpecificIndexAlarmDicMapper equipmentSpecificIndexAlarmDicMapper;
@Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired @Autowired
private static Map<String, EquipmentSpecificIndex> map; private static Map<String, EquipmentSpecificIndex> map;
@Autowired
private static Map<Integer, String> typeMap;
@PostConstruct @PostConstruct
public void init() { public void init() {
QueryWrapper<EquipmentSpecificIndex> wrapper = new QueryWrapper<>(); QueryWrapper<EquipmentSpecificIndex> wrapper = new QueryWrapper<>();
...@@ -57,12 +64,16 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -57,12 +64,16 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
List<EquipmentSpecificIndex> list = equipmentSpecificIndexMapper.selectList(wrapper); List<EquipmentSpecificIndex> list = equipmentSpecificIndexMapper.selectList(wrapper);
map = list.stream().collect(Collectors.toMap(EquipmentSpecificIndex::getEquipmentSpecificName, map = list.stream().collect(Collectors.toMap(EquipmentSpecificIndex::getEquipmentSpecificName,
Function.identity(), (key1, key2) -> key2)); Function.identity(), (key1, key2) -> key2));
List<EquipmentSpecificIndexAlarmDic> typelist = equipmentSpecificIndexAlarmDicMapper.selectList(null);
typeMap = typelist.stream().collect(
Collectors.toMap(EquipmentSpecificIndexAlarmDic::getValue, EquipmentSpecificIndexAlarmDic::getName));
} }
@Async("jxiopAsyncExecutor") @Async("jxiopAsyncExecutor")
public void handleMessage(List<ConsumerRecord<String, String>> record) { public void handleMessage(List<ConsumerRecord<String, String>> record) {
List<AlarmEvent> alarmEvents = new ArrayList<>(); List<AlarmEvent> alarmEvents = new ArrayList<>();
List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>(); List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>();
String group = null;
for (ConsumerRecord<String, String> one : record) { for (ConsumerRecord<String, String> one : record) {
JSONObject obj = JSONObject.parseObject(one.value()); JSONObject obj = JSONObject.parseObject(one.value());
String objName = obj.getString("equipmentSpecificName"); String objName = obj.getString("equipmentSpecificName");
...@@ -70,13 +81,19 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -70,13 +81,19 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
String gatewayId = obj.getString("gatewayId"); String gatewayId = obj.getString("gatewayId");
String value = obj.getString("value"); String value = obj.getString("value");
String valueLabel = obj.getString("valueLabel"); String valueLabel = obj.getString("valueLabel");
Integer isAlarm = Integer.valueOf(obj.getString("isAlarm"));
if (!typeMap.containsKey(isAlarm)) {
continue;
} else {
group=typeMap.get(isAlarm);
}
if ("升压站".equals(objName)) { if ("升压站".equals(objName)) {
AlarmEvent alarmEvent = new AlarmEvent(); AlarmEvent alarmEvent = new AlarmEvent();
alarmEvent.setEventDesc(indexName); alarmEvent.setEventDesc(indexName);
// alarmEvent.setStationId(""); // alarmEvent.setStationId("");
// alarmEvent.setStationName(""); // alarmEvent.setStationName("");
alarmEvent.setGatewayId(gatewayId); alarmEvent.setGatewayId(gatewayId);
alarmEvent.setAlarmGroupName("运行告警"); alarmEvent.setAlarmGroupName(group);
alarmEvent.setValue(value); alarmEvent.setValue(value);
alarmEvents.add(alarmEvent); alarmEvents.add(alarmEvent);
} else { } else {
...@@ -102,6 +119,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -102,6 +119,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
equipAlarmEvent.setEventDesc(indexName); equipAlarmEvent.setEventDesc(indexName);
equipAlarmEvent.setGatewayId(gatewayId); equipAlarmEvent.setGatewayId(gatewayId);
equipAlarmEvent.setValue(warn); equipAlarmEvent.setValue(warn);
equipAlarmEvent.setAlarmGroupName(group);
equipAlarmEvents.add(equipAlarmEvent); equipAlarmEvents.add(equipAlarmEvent);
} }
} }
...@@ -113,6 +131,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -113,6 +131,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
// equipAlarmEvent.setFrontModule(value); // equipAlarmEvent.setFrontModule(value);
equipAlarmEvent.setGatewayId(gatewayId); equipAlarmEvent.setGatewayId(gatewayId);
equipAlarmEvent.setValue(value); equipAlarmEvent.setValue(value);
equipAlarmEvent.setAlarmGroupName(group);
equipAlarmEvents.add(equipAlarmEvent); equipAlarmEvents.add(equipAlarmEvent);
} }
} }
...@@ -154,7 +173,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -154,7 +173,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
ColModel colModelStationName = new ColModel("stationName", "stationName", "名称", "名称", "dataGrid", ColModel colModelStationName = new ColModel("stationName", "stationName", "名称", "名称", "dataGrid",
"stationName"); "stationName");
ColModel colModelEventDesc = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc"); ColModel colModelEventDesc = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc");
ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件告警组", "事件告警组", "dataGrid", ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件类型", "事件类型", "dataGrid",
"alarmGroupName"); "alarmGroupName");
ColModel colModelEventTime = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", "time"); ColModel colModelEventTime = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", "time");
ColModel colModelEventMovement = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value"); ColModel colModelEventMovement = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value");
......
...@@ -43,7 +43,7 @@ public class EquipAlarmEventServiceImpl ...@@ -43,7 +43,7 @@ public class EquipAlarmEventServiceImpl
equipName = s[0] + "子阵/逆变器" + s[1]; equipName = s[0] + "子阵/逆变器" + s[1];
} else if ("汇流箱".equals(frontModule)) { } else if ("汇流箱".equals(frontModule)) {
String[] s = equipIndex.split("-"); String[] s = equipIndex.split("-");
if (s[2].indexOf("0")==0) { if (s[2].indexOf("0") == 0) {
s[2] = s[2].substring(1); s[2] = s[2].substring(1);
} }
equipName = s[0] + "子阵/逆变器" + s[1] + "/#" + s[2] + "汇流箱"; equipName = s[0] + "子阵/逆变器" + s[1] + "/#" + s[2] + "汇流箱";
...@@ -64,12 +64,12 @@ public class EquipAlarmEventServiceImpl ...@@ -64,12 +64,12 @@ public class EquipAlarmEventServiceImpl
} else if ("false".equals(i.getValue())) { } else if ("false".equals(i.getValue())) {
i.setValue("分"); i.setValue("分");
} }
long mills = i.getCreatedTime()/1000000; long mills = i.getCreatedTime() / 1000000;
car.setTimeInMillis(mills); car.setTimeInMillis(mills);
//System.out.println(sdf.format(car.getTime())); // System.out.println(sdf.format(car.getTime()));
i.setTime(sdf.format(car.getTime())); i.setTime(sdf.format(car.getTime()));
//car.add(Calendar.HOUR, 12); // car.add(Calendar.HOUR, 12);
//System.out.println(sdf.format(car.getTime())); // System.out.println(sdf.format(car.getTime()));
}); });
PageInfo<EquipAlarmEvent> page = new PageInfo(alarmEventList); PageInfo<EquipAlarmEvent> page = new PageInfo(alarmEventList);
...@@ -79,11 +79,12 @@ public class EquipAlarmEventServiceImpl ...@@ -79,11 +79,12 @@ public class EquipAlarmEventServiceImpl
ColModel colModelEventMovement = new ColModel("equipName", "equipName", "设备名称", "设备名称", "dataGrid", ColModel colModelEventMovement = new ColModel("equipName", "equipName", "设备名称", "设备名称", "dataGrid",
"equipName"); "equipName");
ColModel colModelStationName = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc"); ColModel colModelStationName = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc");
ColModel colModelEventDesc = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件类型", "事件类型", "dataGrid",
"time"); "alarmGroupName");
ColModel colModelEventDesc = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", "time");
ColModel colModelValueDesc = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value"); ColModel colModelValueDesc = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value");
List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelEventDesc, List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelAlarmGroupName,
colModelValueDesc); colModelEventDesc, colModelValueDesc);
ResultsData resultsData = new ResultsData(DataGridMock, listColModel); ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData; return resultsData;
} }
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipmentSpecificIndexAlarmDicMapper">
</mapper>
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
</select> </select>
<insert id="save"> <insert id="save">
INSERT INTO INSERT INTO
equip_alarm_event(created_time,staion_name,staion_id,gateway_id,equip_index,event_desc,equip_name,front_module,value) equip_alarm_event(created_time,staion_name,staion_id,gateway_id,equip_index,event_desc,equip_name,front_module,value,alarm_group_name)
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(NOW(),#{item.stationName},#{item.stationId},#{item.gatewayId},#{item.equipIndex},'#{item.eventDesc}','#{item.equipName}',#{item.frontModule},'#{item.value}') (NOW(),#{item.stationName},#{item.stationId},#{item.gatewayId},#{item.equipIndex},'#{item.eventDesc}','#{item.equipName}',#{item.frontModule},'#{item.value}','#{item.alarmGroupName}')
</foreach> </foreach>
</insert> </insert>
</mapper> </mapper>
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