|
|
@@ -10,12 +10,14 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.github.zuihou.authority.entity.auth.User;
|
|
|
import com.github.zuihou.base.request.PageParams;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.Order;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.Plan;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.OrderService;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.PlanService;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.TaskService;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.dao.AAutoNodeLogMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.Repair;
|
|
|
@@ -25,27 +27,38 @@ import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
|
|
|
import com.github.zuihou.business.websocket.WebSocketServer;
|
|
|
import com.github.zuihou.common.util.DateUtil;
|
|
|
import com.github.zuihou.common.util.StringUtil;
|
|
|
+import com.github.zuihou.context.BaseContextConstants;
|
|
|
import com.github.zuihou.context.BaseContextHandler;
|
|
|
+import com.github.zuihou.database.mybatis.auth.DataScope;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
|
|
|
+import com.github.zuihou.jwt.utils.JwtUtil;
|
|
|
+import com.github.zuihou.security.model.SysUser;
|
|
|
import com.github.zuihou.utils.DateUtils;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import io.jsonwebtoken.Claims;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.cxf.security.claims.authorization.Claim;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.slf4j.MDC;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.websocket.Session;
|
|
|
+import javax.ws.rs.core.SecurityContext;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
|
import java.util.*;
|
|
|
|
|
|
+
|
|
|
@Component
|
|
|
public class DashboardJob {
|
|
|
|
|
|
@@ -74,7 +87,7 @@ public class DashboardJob {
|
|
|
private RepairService repairService;
|
|
|
|
|
|
@Autowired
|
|
|
- private AAutoNodeLogService autoNodeLogService;
|
|
|
+ private AAutoNodeLogMapper aAutoNodeLogMapper;
|
|
|
|
|
|
@Value("${zuihou.database.tenantDatabasePrefix}")
|
|
|
private String database;
|
|
|
@@ -85,7 +98,35 @@ public class DashboardJob {
|
|
|
public void updateDashboardJob(){
|
|
|
//taskService.pushTask();
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
+
|
|
|
+ List<String> userIds = webSocketServer.getUserIds();
|
|
|
+ //List<Session> sessions = webSocketServer.getSessions();
|
|
|
+ userIds.forEach(item->{
|
|
|
+ List<Session> sessions = webSocketServer.getSessions(item);
|
|
|
+ String userid = JwtUtil.parseJWT(item).get("userid").toString();
|
|
|
+ this.broadCastData(userid, sessions);
|
|
|
+ //webSocketServer.BroadCastInfo(pushMsg, sessions);
|
|
|
+ });
|
|
|
+
|
|
|
+ //logger.info("推送前端======"+pushMsg);
|
|
|
+ //webSocketServer.BroadCastInfo(pushMsg);
|
|
|
+ //更新推送状态
|
|
|
+// if(CollectionUtil.isNotEmpty(warnData.getRecords())) {
|
|
|
+// Long[] ids = warnData.getRecords().stream().map(item -> {
|
|
|
+// return item.getId();
|
|
|
+// }).toArray(Long[]::new);
|
|
|
+// UpdateWrapper<AAutoNodeLog> updateWrapper = new UpdateWrapper<AAutoNodeLog>();
|
|
|
+// updateWrapper.lambda().set(AAutoNodeLog::getSendStatus, "1").in(AAutoNodeLog::getId, ids);
|
|
|
+// autoNodeLogService.update(null, updateWrapper);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void broadCastData(String userid, List<Session> sessions){
|
|
|
+ String pushMsg = null;
|
|
|
try {
|
|
|
+ DataScope datascope = new DataScope();
|
|
|
+ datascope.setUserId(Long.parseLong(userid));
|
|
|
+
|
|
|
Map<String, Map<String, Object>> dataScreenMap = new HashMap<String, Map<String, Object>>();
|
|
|
Map zoneData = Maps.newHashMap();
|
|
|
zoneData.put("resourceStatus", "1");
|
|
|
@@ -97,7 +138,7 @@ public class DashboardJob {
|
|
|
zoneMap.put("zoneData", zoneList);
|
|
|
dataScreenMap.put("zoneMap", zoneMap);
|
|
|
|
|
|
- PageParams params = new PageParams();
|
|
|
+ PageParams params = new PageParams();
|
|
|
params.setCurrent(1L);
|
|
|
params.setSize(5l);
|
|
|
params.setOrder("descending");
|
|
|
@@ -110,12 +151,12 @@ public class DashboardJob {
|
|
|
LbqWrapper wrapper = wrap.lambda();
|
|
|
|
|
|
Plan plan = BeanUtil.toBean(params.getModel(), Plan.class);
|
|
|
- plan.setOrderProduceStatus(StringUtil.isEmpty(plan.getOrderProduceStatus())?"":StringUtil.changeIdsArrToSubQueryStr(plan.getOrderProduceStatus()));
|
|
|
+ plan.setOrderProduceStatus(StringUtil.isEmpty(plan.getOrderProduceStatus()) ? "" : StringUtil.changeIdsArrToSubQueryStr(plan.getOrderProduceStatus()));
|
|
|
plan.setPlanStatus("2");
|
|
|
Page<Plan> planPage = new Page<Plan>();
|
|
|
planPage.setSearchCount(false);
|
|
|
|
|
|
- IPage<Plan> planData = planService.pageList(planPage, plan.getBomDesc(), plan.getOrderName(),plan.getTaskBatchNo(),plan.getOrderProduceStatus(),null,null,null,null, wrapper);
|
|
|
+ IPage<Plan> planData = planService.pageList(planPage, plan.getBomDesc(), plan.getOrderName(), plan.getTaskBatchNo(), plan.getOrderProduceStatus(), null, null, null, null, wrapper);
|
|
|
//planData = planData.getRecords().stream().map(obj -> obj.setEndTime() );
|
|
|
|
|
|
Map planMap = Maps.newHashMap();
|
|
|
@@ -127,7 +168,7 @@ public class DashboardJob {
|
|
|
|
|
|
Page<Order> orderPage = new Page<Order>();
|
|
|
orderPage.setSearchCount(false);
|
|
|
- IPage<Order> orderData = orderService.pageList(orderPage,null, OrderWrapper);
|
|
|
+ IPage<Order> orderData = orderService.pageList(orderPage, null, OrderWrapper);
|
|
|
|
|
|
Map orderMap = Maps.newHashMap();
|
|
|
orderMap.put("orderData", orderData);
|
|
|
@@ -148,9 +189,9 @@ public class DashboardJob {
|
|
|
//Date start = new Date();
|
|
|
//警报弹框只执行一次
|
|
|
//返回还未处理、执行状态为失败、需要人工处理,并且还未推送的日志记录
|
|
|
- warnWrapper.eq(AAutoNodeLog::getExeResult,"0").eq(AAutoNodeLog::getStatus,"0").eq(AAutoNodeLog::getManual, "1")
|
|
|
- .orderByDesc(AAutoNodeLog::getCreateTime);
|
|
|
- IPage<AAutoNodeLog> warnData = autoNodeLogService.pageList(new Page<AAutoNodeLog>(1L, 5), warnWrapper);
|
|
|
+ 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);
|
|
|
|
|
|
Map warnMap = Maps.newHashMap();
|
|
|
warnMap.put("warnData", warnData);
|
|
|
@@ -162,25 +203,15 @@ public class DashboardJob {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
objectMapper.findAndRegisterModules();
|
|
|
//String pushMsg = JSON.toJSONString(pushMap);
|
|
|
- String pushMsg = objectMapper.writeValueAsString(pushMap);
|
|
|
- //logger.info("推送前端======"+pushMsg);
|
|
|
- webSocketServer.BroadCastInfo(pushMsg);
|
|
|
-
|
|
|
- //更新推送状态
|
|
|
-// if(CollectionUtil.isNotEmpty(warnData.getRecords())) {
|
|
|
-// Long[] ids = warnData.getRecords().stream().map(item -> {
|
|
|
-// return item.getId();
|
|
|
-// }).toArray(Long[]::new);
|
|
|
-// UpdateWrapper<AAutoNodeLog> updateWrapper = new UpdateWrapper<AAutoNodeLog>();
|
|
|
-// updateWrapper.lambda().set(AAutoNodeLog::getSendStatus, "1").in(AAutoNodeLog::getId, ids);
|
|
|
-// autoNodeLogService.update(null, updateWrapper);
|
|
|
-// }
|
|
|
+ pushMsg = objectMapper.writeValueAsString(pushMap);
|
|
|
+ webSocketServer.BroadCastInfo(pushMsg, sessions);
|
|
|
}
|
|
|
catch (Exception e){
|
|
|
- logger.error("推送异常======"+e.getMessage());
|
|
|
+ logger.error("推送异常======"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private QueryWrap handlerWrapper(Object model, PageParams params) {
|
|
|
QueryWrap wrapper = model == null ? Wraps.q() : Wraps.q(model);
|
|
|
if (CollUtil.isNotEmpty(params.getMap())) {
|