ソースを参照

Merge remote-tracking branch 'origin/master' into master

姚云青 2 年 前
コミット
61512ada38

+ 8 - 3
imcs-admin-boot/imcs-authority-server/src/main/java/com/github/zuihou/interceptor/TokenHandlerInterceptor.java

@@ -29,6 +29,8 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import java.util.Date;
+
 import static com.github.zuihou.context.BaseContextConstants.BASIC_HEADER_KEY;
 import static com.github.zuihou.context.BaseContextConstants.BEARER_HEADER_KEY;
 import static com.github.zuihou.context.BaseContextConstants.JWT_KEY_TENANT;
@@ -108,12 +110,15 @@ public class TokenHandlerInterceptor extends HandlerInterceptorAdapter {
             log.debug("TokenHandlerInterceptor token="+token);
 
             //添加测试环境的特殊token
-            if (isDev() && (StrPool.TEST_TOKEN.equalsIgnoreCase(token) || StrPool.TEST.equalsIgnoreCase(token))) {
-                authInfo = new AuthInfo().setAccount("zuihou").setUserId(3L).setTokenType(BEARER_HEADER_KEY).setName("平台管理员");
-            }
+//            if (isDev() && (StrPool.TEST_TOKEN.equalsIgnoreCase(token) || StrPool.TEST.equalsIgnoreCase(token))) {
+//                authInfo = new AuthInfo().setAccount("zuihou").setUserId(3L).setTokenType(BEARER_HEADER_KEY).setName("平台管理员");
+//            }
             // 4, 解析 并 验证 token
             if (authInfo == null) {
                 authInfo = tokenUtil.getAuthInfo(token);
+            }else if(authInfo.getExpiration().before(new Date())){
+                //过期自动给token续期
+                authInfo = tokenUtil.parseRefreshToken(token);
             }
 
             // 5,验证 是否在其他设备登录或被挤下线

+ 9 - 18
imcs-admin-boot/imcs-authority-server/src/main/java/com/github/zuihou/job/DashboardJob.java

@@ -2,15 +2,12 @@ package com.github.zuihou.job;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ReflectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.annotation.TableField;
-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;
@@ -19,13 +16,11 @@ 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;
 import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.business.productionResourceCenter.service.RepairService;
 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;
@@ -33,10 +28,7 @@ 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.exception.BizException;
-import com.github.zuihou.exception.code.ExceptionCode;
-import com.github.zuihou.jwt.utils.JwtUtil;
-import com.github.zuihou.security.model.SysUser;
+import com.github.zuihou.jwt.TokenUtil;
 import com.github.zuihou.utils.Charsets;
 import com.github.zuihou.utils.DateUtils;
 import com.google.common.collect.Maps;
@@ -46,18 +38,15 @@ import io.jsonwebtoken.Jwts;
 import org.apache.commons.lang3.StringUtils;
 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.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
 import javax.websocket.Session;
-
 import java.lang.reflect.Field;
 import java.lang.reflect.ParameterizedType;
 import java.util.*;
@@ -93,6 +82,9 @@ public class DashboardJob {
     @Autowired
     private AAutoNodeLogMapper aAutoNodeLogMapper;
 
+    @Autowired
+    private TokenUtil tokenUtil;
+
     @Value("${zuihou.database.tenantDatabasePrefix}")
     private String database;
 
@@ -118,8 +110,6 @@ public class DashboardJob {
         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");
@@ -167,16 +157,16 @@ public class DashboardJob {
             orderMap.put("orderData", orderData);
             dataScreenMap.put("orderMap", orderMap);
 
-            QueryWrap repairWrap = this.handlerWrapper(null, params);
-            LbqWrapper repairWrapper = orderWrap.lambda();
-
-            IPage<Repair> repairData = repairService.pageList(new Page<Repair>(), wrapper);
+            Page<Repair> repairPage = new Page<Repair>(1L, 5);
+            repairPage.setSearchCount(false);
+            IPage<Repair> repairData = repairService.pageList(repairPage, new LbqWrapper<Repair>());
 
             Map repairMap = Maps.newHashMap();
             repairMap.put("repairData", repairData);
             dataScreenMap.put("repairMap", repairMap);
 
             //警报数据
+            datascope.setUserId(Long.parseLong(userid));
             QueryWrap<AAutoNodeLog> warnWrap = this.handlerWrapper(null, params);
             LbqWrapper<AAutoNodeLog> warnWrapper = warnWrap.lambda();
             //Date start = new Date();
@@ -264,4 +254,5 @@ public class DashboardJob {
             }
         }
     }
+
 }

+ 1 - 5
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/AgvHikOrderDetailInfoService.java

@@ -5,10 +5,6 @@ import com.github.zuihou.base.service.SuperCacheService;
 import com.github.zuihou.business.externalApi.entity.AgvHikOrderDetailInfo;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Future;
-
 /**
  * <p>
  * 业务接口
@@ -39,6 +35,6 @@ public interface AgvHikOrderDetailInfoService extends SuperCacheService<AgvHikOr
     /**
      * 异步调用,有返回值
      */
-    void asyncCallbackTask(String data);
+    void asyncCallbackTask(String data,String agvCallbackUrl);
 
 }

+ 4 - 7
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/AgvHikOrderDetailInfoServiceImpl.java

@@ -3,16 +3,17 @@ package com.github.zuihou.business.externalApi.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.authority.service.common.ParameterService;
 import com.github.zuihou.base.service.SuperCacheServiceImpl;
 import com.github.zuihou.business.externalApi.dao.AgvHikOrderDetailInfoMapper;
 import com.github.zuihou.business.externalApi.entity.AgvHikOrderDetailInfo;
 import com.github.zuihou.business.externalApi.service.AgvHikOrderDetailInfoService;
 import com.github.zuihou.common.constant.CacheKey;
-import com.github.zuihou.common.constant.ParameterKey;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.utils.BeanPlusUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -22,10 +23,6 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.Future;
 
 /**
  * <p>
@@ -73,7 +70,7 @@ public class AgvHikOrderDetailInfoServiceImpl extends SuperCacheServiceImpl<AgvH
 
     @Override
     @Async
-    public void asyncCallbackTask(String data){
+    public void asyncCallbackTask(String data,String agvCallbackUrl){
         // sleep10秒
         log.info("异步模拟agv回到参数data=",data);
         try {
@@ -98,7 +95,7 @@ public class AgvHikOrderDetailInfoServiceImpl extends SuperCacheServiceImpl<AgvH
 
             HttpEntity<String> formEntity = new HttpEntity<String>(jsonObject.toJSONString(),headers);
             log.info("agv模拟回到参数:{}", jsonObject.toJSONString());
-            String returnData = restTemplate.postForObject("http://localhost:8760/api/authority/agv/agvCallbackService/agvCallback",formEntity, String.class);
+            String returnData = restTemplate.postForObject(agvCallbackUrl,formEntity, String.class);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }

+ 5 - 7
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/AgvHikOrderInfoServiceImpl.java

@@ -10,14 +10,10 @@ import com.github.zuihou.authority.service.common.ParameterService;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.service.SuperCacheServiceImpl;
 import com.github.zuihou.business.externalApi.dao.AgvHikOrderInfoMapper;
-import com.github.zuihou.business.externalApi.dao.AgvOrderInfoMapper;
 import com.github.zuihou.business.externalApi.entity.AgvHikOrderDetailInfo;
 import com.github.zuihou.business.externalApi.entity.AgvHikOrderInfo;
-import com.github.zuihou.business.externalApi.entity.AgvOrderDetailInfo;
-import com.github.zuihou.business.externalApi.entity.AgvOrderInfo;
 import com.github.zuihou.business.externalApi.service.AgvHikOrderDetailInfoService;
 import com.github.zuihou.business.externalApi.service.AgvHikOrderInfoService;
-import com.github.zuihou.business.externalApi.service.AgvOrderInfoService;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.CacheKey;
 import com.github.zuihou.common.constant.ParameterKey;
@@ -25,7 +21,6 @@ import com.github.zuihou.common.util.UniqueKeyGenerator;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
-import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.utils.BeanPlusUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -34,7 +29,6 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
@@ -147,7 +141,11 @@ public class AgvHikOrderInfoServiceImpl extends SuperCacheServiceImpl<AgvHikOrde
         jsonObject.put("positionCodePath",positionCodePath.toJSONString());
         jsonObject.put("taskCode",taskCode);
         HttpEntity<String> addAgvTaskRequest = new HttpEntity<String>(jsonObject.toJSONString(), headers);
-        agvHikOrderDetailInfoService.asyncCallbackTask(jsonObject.toJSONString());
+
+        String agvCallbackUrl = parameterService.getValue(ParameterKey.AGVCALLBACKURL, null);
+
+
+        agvHikOrderDetailInfoService.asyncCallbackTask(jsonObject.toJSONString(),agvCallbackUrl);
 //        ResponseEntity<String> addAgvTaskEntity = restTemplate.postForEntity(addAgvTaskUrl, addAgvTaskRequest, String.class);
 
 //        String retData = addAgvTaskEntity.getBody();

+ 3 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -685,7 +685,9 @@ public class TaskWorkNode {
         String instructionUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
 
         // TODO 后续删除代码,目前条用模拟接口
-        if("safeguard".equals(zone.getNo())){
+        if("framework".equals(zone.getNo())){
+            instructionUrl = instructionUrl.replace("8086","8083");
+        }else{
             instructionUrl = instructionUrl.replace("8081","8083");
         }
 

+ 5 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/MachineNodeServiceImpl.java

@@ -145,8 +145,11 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         String paramKey = zZone.getNo() + "_plc";
         instructionUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
         // TODO 后续删除代码,目前条用模拟接口
-        instructionUrl = instructionUrl.replace("8081","8083");
-
+        if("framework".equals(zZone.getNo())){
+            instructionUrl = instructionUrl.replace("8086","8083");
+        }else{
+            instructionUrl = instructionUrl.replace("8081","8083");
+        }
     }
 
     @Override

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/RepairMapper.xml

@@ -20,7 +20,7 @@
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,
-        productionresource_id,repair_end_time,repair_status,status,remark,code,productionresourceName,GROUP_CONCAT(lineDesc) AS lineDesc,process,downTime,operationName,expireFlag,GROUP_CONCAT(org_id) AS org_id
+        productionresource_id,repair_end_time,repair_status,status,remark,code,productionresourceName, lineDesc,process,downTime,operationName,expireFlag,org_id
     </sql>
 
     <!-- 分页 -->

+ 1 - 0
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/constant/ParameterKey.java

@@ -57,6 +57,7 @@ public interface ParameterKey {
     String STATION_GA_SWITCH_FLAG = "stationGaSwitchFlag";
     // AGV下达任务请求地址
     String PARAMETERS = "parameters";
+    String AGVCALLBACKURL = "agvCallbackUrl";
 
 
 }