|
@@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.zuihou.base.request.PageParams;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.Order;
|
|
@@ -47,6 +48,7 @@ import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.websocket.Session;
|
|
|
+import java.io.IOException;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
|
import java.util.*;
|
|
@@ -94,7 +96,7 @@ public class DashboardJob {
|
|
|
public void updateDashboardJob(){
|
|
|
//taskService.pushTask();
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
-
|
|
|
+ /*
|
|
|
List<String> userIds = webSocketServer.getUserIds();
|
|
|
if(userIds.size()>0) {
|
|
|
userIds.forEach(item -> {
|
|
@@ -103,14 +105,16 @@ public class DashboardJob {
|
|
|
this.broadCastData(userid, sessions);
|
|
|
//webSocketServer.BroadCastInfo(pushMsg, sessions);
|
|
|
});
|
|
|
- }
|
|
|
+ } */
|
|
|
+ this.broadCastData();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- private void broadCastData(String userid, List<Session> sessions){
|
|
|
+ private void broadCastData(){
|
|
|
String pushMsg = null;
|
|
|
try {
|
|
|
- DataScope datascope = new DataScope();
|
|
|
Map<String, Map<String, Object>> dataScreenMap = new HashMap<String, Map<String, Object>>();
|
|
|
+
|
|
|
Map zoneData = Maps.newHashMap();
|
|
|
zoneData.put("resourceStatus", "1");
|
|
|
zoneData.put("group", "0");
|
|
@@ -170,15 +174,14 @@ public class DashboardJob {
|
|
|
dataScreenMap.put("repairMap", repairMap);
|
|
|
|
|
|
//警报数据
|
|
|
- datascope.setUserId(Long.parseLong(userid));
|
|
|
- QueryWrap<AAutoNodeLog> warnWrap = this.handlerWrapper(null, params);
|
|
|
- LbqWrapper<AAutoNodeLog> warnWrapper = warnWrap.lambda();
|
|
|
+
|
|
|
+ LbqWrapper<AAutoNodeLog> warnWrapper = new LbqWrapper<AAutoNodeLog>();
|
|
|
//Date start = new Date();
|
|
|
//警报弹框只执行一次
|
|
|
//返回还未处理、执行状态为失败、需要人工处理,并且还未推送的日志记录
|
|
|
warnWrapper.eq(AAutoNodeLog::getExeResult, "0").eq(AAutoNodeLog::getStatus, "0").eq(AAutoNodeLog::getManual, "1")
|
|
|
.orderByDesc(AAutoNodeLog::getCreateTime);
|
|
|
- IPage<AAutoNodeLog> warnData = aAutoNodeLogMapper.pageList(new Page<AAutoNodeLog>(1L, 5), warnWrapper, datascope, null);
|
|
|
+ IPage<AAutoNodeLog> warnData = aAutoNodeLogMapper.pageList(new Page<AAutoNodeLog>(1L, 5), warnWrapper, new DataScope(), null);
|
|
|
|
|
|
Map warnMap = Maps.newHashMap();
|
|
|
warnMap.put("warnData", warnData);
|
|
@@ -187,17 +190,56 @@ public class DashboardJob {
|
|
|
Map<String, Object> pushMap = new HashMap<>();
|
|
|
pushMap.put("type", WebSocketServer.PUSH_TYPE_DATA_SCREEN);
|
|
|
pushMap.put("data", dataScreenMap);
|
|
|
+
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
objectMapper.findAndRegisterModules();
|
|
|
//String pushMsg = JSON.toJSONString(pushMap);
|
|
|
pushMsg = objectMapper.writeValueAsString(pushMap);
|
|
|
- webSocketServer.BroadCastInfo(pushMsg, sessions);
|
|
|
+ webSocketServer.BroadCastInfo(pushMsg);
|
|
|
}
|
|
|
catch (Exception e){
|
|
|
logger.error("推送异常======"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Scheduled(cron="0 0/1 * * * ?")
|
|
|
+ public void updateExceptionJob(){
|
|
|
+ List<String> userIds = webSocketServer.getUserIds();
|
|
|
+ if(userIds.size()>0) {
|
|
|
+ userIds.forEach(item -> {
|
|
|
+ List<Session> sessions = webSocketServer.getSessions(item);
|
|
|
+ String userid = this.parseJWT(item).get("userid").toString();
|
|
|
+ String pushMsg = null;
|
|
|
+ try {
|
|
|
+ //警报数据
|
|
|
+ Map<String, Map<String, Object>> exceptionMap = new HashMap<String, Map<String, Object>>();
|
|
|
+ DataScope datascope = new DataScope();
|
|
|
+ datascope.setUserId(Long.parseLong(userid));
|
|
|
+ LbqWrapper<AAutoNodeLog> warnWrapper = new LbqWrapper<AAutoNodeLog>();
|
|
|
+ warnWrapper.eq(AAutoNodeLog::getExeResult, "0").eq(AAutoNodeLog::getStatus, "0").eq(AAutoNodeLog::getManual, "1")
|
|
|
+ .orderByDesc(AAutoNodeLog::getCreateTime);
|
|
|
+ IPage<AAutoNodeLog> warnData = aAutoNodeLogMapper.pageList(new Page<AAutoNodeLog>(1L, 5), warnWrapper, datascope, null);
|
|
|
+ Map warnMap = Maps.newHashMap();
|
|
|
+ warnMap.put("warnData", warnData);
|
|
|
+ exceptionMap.put("warnMap", warnMap);
|
|
|
+
|
|
|
+ Map<String, Object> exMap = new HashMap<>();
|
|
|
+ exMap.put("type", WebSocketServer.PUSH_TYPE_GLOBAL_EXCEPTION);
|
|
|
+ exMap.put("data", exceptionMap);
|
|
|
+
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ objectMapper.findAndRegisterModules();
|
|
|
+
|
|
|
+ pushMsg = objectMapper.writeValueAsString(exMap);
|
|
|
+ webSocketServer.BroadCastInfo(pushMsg, sessions);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("全局推送异常======"+e.getMessage());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private Claims parseJWT(String token){
|
|
|
final String BASE64_SECURITY = Base64.getEncoder().encodeToString(BaseContextConstants.JWT_SIGN_KEY.getBytes(Charsets.UTF_8));
|
|
|
Claims claims = null;
|