459242451@qq.com 3 年之前
父節點
當前提交
a912daf46f

+ 4 - 4
ruoyi-admin/nacos/yjzh-sq-prod.yaml

@@ -157,9 +157,9 @@ third:
     dhAuthorize: http://10.55.134.3:6699/videoService/accounts/authorize # 大华鉴权创建用户会话
     keepalive: http://10.55.134.3:6699/videoService/accounts/token/keepalive # 大华会话保活
     dhDeviceTree: http://10.55.134.3:6699/videoService/devicesManager/deviceTree # 大华设备树
-    incidentUrl: http://sqmb.xt.wenhq.top:8083/#/status/3/detaillite?id=#incidentId&taskid=#taskId # 移动端待办跳转链接
-    incidentDetailUrl: http://sqmb.xt.wenhq.top:8083/#/status/3/detail?id=#incidentId # 事件详情页面
-    resourceUrl: http://sqmb.xt.wenhq.top:8083/#/warehouse/list?taskid=#taskId # 移动端资源跳转链接
-    chemicalUrl: http://sqmb.xt.wenhq.top:8083/#/chemical/detail?id= # 危化品详情页面
+    incidentUrl: https://tocc.jtj.suqian.gov.cn:30030/sqmb/#/status/3/detaillite?id=#incidentId&taskid=#taskId # 移动端待办跳转链接
+    incidentDetailUrl: https://tocc.jtj.suqian.gov.cn:30030/sqmb/#/status/3/detail?id=#incidentId # 事件详情页面
+    resourceUrl: https://tocc.jtj.suqian.gov.cn:30030/sqmb/#/warehouse/list?taskid=#taskId # 移动端资源跳转链接
+    chemicalUrl: https://tocc.jtj.suqian.gov.cn:30030/sqmb/#/chemical/detail?id= # 危化品详情页面
     dhVideoUserName: huashe2
     dhPCUserName: huashe3

+ 0 - 32
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/DhTask.java

@@ -1,32 +0,0 @@
-package com.ruoyi.web.controller.task;
-
-import cn.hutool.core.util.NumberUtil;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.utils.RedisUtils;
-import com.ruoyi.zhdd.service.IDhService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @Description: 大华相关定时任务
- * @Author: huangcheng
- * @Date: 2022/1/20
- * @Version V1.0
- */
-@Component("dhTask")
-public class DhTask {
-
-    @Autowired
-    private IDhService dhService;
-
-    /**
-     * 大华token保活处理
-     */
-    public void keepalive() {
-        long ttl = RedisUtils.getTtl(Constants.CACHE_DH_TOKEN);
-        if (NumberUtil.compare(ttl, 0) == 1 && NumberUtil.compare(ttl, 20) == -1) {
-            // 保活token
-            dhService.tokenKeepalive(RedisUtils.getCacheObject(Constants.CACHE_DH_TOKEN));
-        }
-    }
-}

+ 30 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/ScheduleTask.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.controller.task;
 
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.NumberUtil;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.utils.RedisUtils;
@@ -14,6 +15,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
+import java.util.Map;
 
 /**
  * @Description: TODO
@@ -37,6 +39,7 @@ public class ScheduleTask {
     private final IPlanService planService;
     private final IResourceService resourceService;
     private final IResourceDetailService resourceDetailService;
+    private final IDhService dhService;
 
 
     @Async
@@ -55,4 +58,31 @@ public class ScheduleTask {
         BigDecimal add = NumberUtil.add(count, count1, count2, count3, count4, count5, count6, count7, count8);
         RedisUtils.setCacheObject(Constants.DATA_TOTAL_COUNT, add);
     }
+
+    /**
+     * 对大华token保活
+     */
+    @Async
+    @Scheduled(cron = "0/10 * * * * ?")
+    public void keepliveDhToken() {
+        log.info("开始保活大华token");
+        boolean pcToken = RedisUtils.exist(Constants.CACHE_DH_VIDEO_TOKEN);
+        boolean hdToken = RedisUtils.exist(Constants.CACHE_DH_VIDEO_HD_TOKEN);
+        if (pcToken) {
+            long ttl = RedisUtils.getTtl(Constants.CACHE_DH_VIDEO_TOKEN);
+            if (NumberUtil.compare(ttl, 0) == 1 && NumberUtil.compare(ttl, 20) == -1) {
+                // 保活token
+                Map<String, Object> token = RedisUtils.getCacheObject(Constants.CACHE_DH_VIDEO_TOKEN);
+                dhService.tokenKeepalive(Convert.toStr(token.get("token")), 120);
+            }
+        }
+        if (hdToken) {
+            long ttl = RedisUtils.getTtl(Constants.CACHE_DH_VIDEO_HD_TOKEN);
+            if (NumberUtil.compare(ttl, 0) == 1 && NumberUtil.compare(ttl, 20) == -1) {
+                // 保活token
+                Map<String, Object> token = RedisUtils.getCacheObject(Constants.CACHE_DH_VIDEO_HD_TOKEN);
+                dhService.tokenKeepalive(Convert.toStr(token.get("token")), 120);
+            }
+        }
+    }
 }

+ 5 - 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhdd/DhController.java

@@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -40,24 +39,24 @@ public class DhController {
         return AjaxResult.success(dhService.getDeviceTree());
     }
 
-    @ApiOperation("获取大华token")
+    @ApiOperation("获取大华token.用于大屏")
     @GetMapping("/getVideoToken")
     public AjaxResult getToken(@RequestParam(required = false) String account) {
         RedisUtils.publish(Constants.UPDATE_APP_PUSH, "hd");
-        return AjaxResult.success(dhService.getVideoToken(account));
+        return AjaxResult.success(dhService.getVideoToken(account, Constants.CACHE_DH_VIDEO_HD_TOKEN));
     }
 
     @ApiOperation("获取大华tokenV2.用于PC端业务")
     @GetMapping("/v2/getVideoToken")
     public AjaxResult getTokenV2() {
         RedisUtils.publish(Constants.UPDATE_APP_PUSH, "pc");
-        return AjaxResult.success(dhService.getVideoToken(dhAccount));
+        return AjaxResult.success(dhService.getVideoToken(dhAccount, Constants.CACHE_DH_VIDEO_TOKEN));
     }
 
-    @ApiOperation("video的token下线")
+    /*@ApiOperation("video的token下线")
     @PostMapping("/offlineVideoToken")
     public AjaxResult offlineVideoToken() {
         dhService.offlineVideoToken();
         return AjaxResult.success();
-    }
+    }*/
 }

+ 13 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhdd/DutyReportRecordController.java

@@ -1,5 +1,9 @@
 package com.ruoyi.web.controller.zhdd;
 
+import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import cn.afterturn.easypoi.view.PoiBaseView;
 import cn.hutool.core.collection.CollUtil;
 import com.ruoyi.common.annotation.Security;
 import com.ruoyi.common.core.controller.BaseController;
@@ -7,7 +11,6 @@ import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.core.validate.QueryGroup;
 import com.ruoyi.common.utils.UserUtil;
-import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.zhdd.domain.bo.DutyReportRecordBo;
 import com.ruoyi.zhdd.domain.vo.DutyReportRecordVo;
 import com.ruoyi.zhdd.service.IDutyReportRecordService;
@@ -15,11 +18,13 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ui.ModelMap;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Set;
@@ -61,7 +66,7 @@ public class DutyReportRecordController extends BaseController {
     @ApiOperation("导出值班报告信息列表")
     @GetMapping("/export")
     @Security
-    public void export(@Validated DutyReportRecordBo bo, HttpServletResponse response) {
+    public void export(@Validated DutyReportRecordBo bo, HttpServletResponse response, HttpServletRequest request, ModelMap modelMap) {
         // 根据当前用户的角色
         LoginUser cacheLoginUser = UserUtil.getCacheLoginUser();
         // 查询角色如果包含admin的,直接查询全部
@@ -72,6 +77,11 @@ public class DutyReportRecordController extends BaseController {
             bo.setReceiveUser(cacheLoginUser.getUsername());
         }
         List<DutyReportRecordVo> list = iDutyReportRecordService.queryList(bo);
-        ExcelUtil.exportExcel(list, "交接日志", DutyReportRecordVo.class, response);
+        ExportParams params = new ExportParams("交接日志", "交接日志", ExcelType.XSSF);
+        modelMap.put(NormalExcelConstants.DATA_LIST, list);
+        modelMap.put(NormalExcelConstants.CLASS, DutyReportRecordVo.class);
+        modelMap.put(NormalExcelConstants.PARAMS, params);
+        modelMap.put(NormalExcelConstants.FILE_NAME, "交接日志");
+        PoiBaseView.render(modelMap, request, response, NormalExcelConstants.EASYPOI_EXCEL_VIEW);
     }
 }

+ 4 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhdd/IncidentController.java

@@ -211,6 +211,10 @@ public class IncidentController extends BaseController {
         if (any.isPresent()) {
             resourceSendTime = any.get().getCreateTime();
         }
+        // 查询有没有发送过指令
+        Optional<IncidentTaskVo> sendAny = incidentTaskVos.stream().filter(a -> StrUtil.equals(a.getTaskSend(), "1")).findAny();
+        map.put("taskSendFlag", sendAny.isPresent());
+
         map.put("resourceSendTime", resourceSendTime);
         List<IncidentProcess> list = processService.list(Wrappers.<IncidentProcess>lambdaQuery()
             .eq(IncidentProcess::getIncidentId, id)

+ 3 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -159,7 +159,10 @@ public class Constants {
      * 大华tokon缓存
      */
     public static final String CACHE_DH_TOKEN = "dh:token";
+    // PC
     public static final String CACHE_DH_VIDEO_TOKEN = "dh:videotoken";
+    // HD(大屏)
+    public static final String CACHE_DH_VIDEO_HD_TOKEN = "dh:videotoken:hd";
     /**
      * 大华tokon缓存=用于刷新
      */

+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/FeignConfig.java

@@ -82,7 +82,7 @@ public class FeignConfig {
 
     @Bean
     public Logger.Level feignLoggerLevel() {
-        return Logger.Level.FULL;
+        return Logger.Level.BASIC;
     }
 
     @Bean

+ 4 - 0
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/domain/AppInfo.java

@@ -49,5 +49,9 @@ public class AppInfo {
     private String version;
     // 系统使用量
     private Integer visit;
+    // 目标用户
+    private String targetUser;
+    // 具体负责人
+    private String projectLeader2;
 
 }

+ 2 - 2
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/domain/vo/DutyReportRecordVo.java

@@ -51,7 +51,7 @@ public class DutyReportRecordVo {
 
     // 接班人员
     private String receiveUser;
-    @Excel(name = "交班时间", orderNum = "3")
+    @Excel(name = "交班时间", orderNum = "3", format = "yyyy-MM-dd HH:mm:ss")
     private Date passDateTime;
 
     @Excel(name = "接班人员", orderNum = "5")
@@ -59,7 +59,7 @@ public class DutyReportRecordVo {
 
     private Date deadline;
 
-    @Excel(name = "接班时间", orderNum = "2")
+    @Excel(name = "接班时间", orderNum = "2", format = "yyyy-MM-dd HH:mm:ss")
     private Date receiveDateTime;
 
 }

+ 20 - 0
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/feign/FeignUserManageService.java

@@ -38,4 +38,24 @@ public interface FeignUserManageService {
      */
     @PostMapping("/app/updateApp/systemInfo")
     JSONObject updateSystemInfo(@RequestBody AppInfo appInfo);
+
+    /**
+     * 更新系统数据量
+     *
+     * @param appId
+     * @param dataCount
+     * @return
+     */
+    @PostMapping("/app-update/updateDataCount")
+    JSONObject updateDataCount(@RequestParam(value = "appId") String appId, @RequestParam(value = "dataCount") Integer dataCount);
+
+    /**
+     * 更新数据用户数
+     *
+     * @param appId
+     * @param userCount
+     * @return
+     */
+    @PostMapping("/app-update/updateUserCount")
+    JSONObject updateUserCount(@RequestParam(value = "appId") String appId, @RequestParam(value = "userCount") Integer userCount);
 }

+ 12 - 0
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/feign/fallback/FeignUserManageFallback.java

@@ -36,4 +36,16 @@ public class FeignUserManageFallback implements FeignUserManageService {
         log.error("更新应用信息失败");
         return null;
     }
+
+    @Override
+    public JSONObject updateDataCount(String appId, Integer dataCount) {
+        log.error("更新系统数据量失败");
+        return null;
+    }
+
+    @Override
+    public JSONObject updateUserCount(String appId, Integer userCount) {
+        log.error("更新数据用户数失败");
+        return null;
+    }
 }

+ 3 - 3
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/service/IDhService.java

@@ -21,7 +21,7 @@ public interface IDhService {
 
     String authorize();
 
-    void tokenKeepalive(String token);
+    void tokenKeepalive(String token, int duration);
 
     Object getDeviceTree();
 
@@ -33,8 +33,8 @@ public interface IDhService {
      * @param account
      * @return
      */
-    Map<String, Object> getVideoToken(String account);
+    Map<String, Object> getVideoToken(String account, String key);
 
-    void offlineVideoToken();
+    void offlineVideoToken(String key);
 
 }

+ 11 - 11
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/service/impl/DhServiceImpl.java

@@ -121,18 +121,18 @@ public class DhServiceImpl implements IDhService {
      *
      * @param token
      */
-    public void tokenKeepalive(String token) {
+    public void tokenKeepalive(String token, int duration) {
         JSONObject json = new JSONObject();
         json.set("token", token);
-        json.set("duration", 86400);
+        json.set("duration", duration);
         String put = HttpRequest.put(keepaliveUrl).timeout(-1).body(json.toString()).execute().body();
         JSONObject putJson = JSONUtil.parseObj(put);
         if (putJson.getInt("code") == 200) {
             // 存入redis缓存
-            RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN, token, 86400, TimeUnit.SECONDS);
+            RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN, token, duration, TimeUnit.SECONDS);
         } else {
             log.info("保活失败:{}。重新获取", putJson);
-            authorize();
+//            authorize();
         }
     }
 
@@ -190,8 +190,8 @@ public class DhServiceImpl implements IDhService {
     }
 
     @Override
-    public Map<String, Object> getVideoToken(String account) {
-        Map<String, Object> token = RedisUtils.getCacheMap(Constants.CACHE_DH_VIDEO_TOKEN);
+    public Map<String, Object> getVideoToken(String account, String key) {
+        Map<String, Object> token = RedisUtils.getCacheMap(key);
         if (token.isEmpty()) {
             token = new HashMap<>();
             // 从大华接口获取token
@@ -226,7 +226,7 @@ public class DhServiceImpl implements IDhService {
                 jsonOne.set("randomKey", randomKey);
                 jsonOne.set("encryptType", encryptType);
                 jsonOne.set("pid", 2548);
-                jsonOne.set("expiredTime", 86400);
+                jsonOne.set("expiredTime", 120);
                 String postTwo = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
                 JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
                 if (postTwoJson.containsKey("token")) {
@@ -242,8 +242,8 @@ public class DhServiceImpl implements IDhService {
                         duration = 120;
                     }
                     // 存入redis缓存
-                    RedisUtils.setCacheMap(Constants.CACHE_DH_VIDEO_TOKEN, token);
-                    RedisUtils.expire(Constants.CACHE_DH_VIDEO_TOKEN, Convert.toInt(duration), TimeUnit.SECONDS);
+                    RedisUtils.setCacheMap(key, token);
+                    RedisUtils.expire(key, Convert.toInt(duration), TimeUnit.SECONDS);
                 } else {
                     log.error("【视频】大华,账号:{}第二次创建会话失败:{}", account, postTwoJson);
                     if ("user is repeated landing".equals(postTwoJson.getStr("message"))) {
@@ -258,8 +258,8 @@ public class DhServiceImpl implements IDhService {
     }
 
     @Override
-    public void offlineVideoToken() {
-        RedisUtils.deleteObject(Constants.CACHE_DH_VIDEO_TOKEN);
+    public void offlineVideoToken(String key) {
+        RedisUtils.deleteObject(key);
     }
 
     private JSONArray getList(Map<String, Object> param) {

+ 2 - 0
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/service/impl/ResourceDetailServiceImpl.java

@@ -55,6 +55,8 @@ public class ResourceDetailServiceImpl extends ServicePlusImpl<ResourceDetailMap
     @Override
     public TableDataInfo<ResourceDetailVo> queryPageList(ResourceDetailBo bo) {
         PagePlus<ResourceDetail, ResourceDetailVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo));
+        // 由于postgres数据库对中文排序不友好
+        result.setRecordsVo(CollUtil.sortByProperty(result.getRecordsVo(), "name"));
         return PageUtils.buildDataInfo(result);
     }
 

+ 1 - 1
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/service/impl/ResourceServiceImpl.java

@@ -54,7 +54,7 @@ public class ResourceServiceImpl extends ServicePlusImpl<ResourceMapper, Resourc
         }
 //        if (voById.getResourceType() == 1) {
         // 应急仓库的类型查询仓库物资
-        List<ResourceDetail> list = resourceDetailService.list(Wrappers.<ResourceDetail>lambdaQuery().eq(ResourceDetail::getResourceId, id).orderByAsc(ResourceDetail::getName));
+        List<ResourceDetail> list = resourceDetailService.list(Wrappers.<ResourceDetail>lambdaQuery().eq(ResourceDetail::getResourceId, id).last("order by name collate \"zh_CN.utf8\""));
         voById.setResourceDetailList(list);
 //        }
         // 对管理单位使用数组返回

+ 6 - 0
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/service/impl/ThirdInterfaceServiceImpl.java

@@ -62,6 +62,9 @@ public class ThirdInterfaceServiceImpl implements IThirdInterfaceService {
             appInfo.setIcon("");
             configService.update(Wrappers.<SysConfig>lambdaUpdate().eq(SysConfig::getConfigKey, "app.info.pc").set(SysConfig::getConfigValue, JSONUtil.toJsonStr(appInfo)));
 
+            /*// 更新系统数据量和用户数
+            feignUserManageService.updateDataCount(appInfo.getAppId(), dataTotalCount);
+            feignUserManageService.updateUserCount(appInfo.getAppId(), userCount);*/
         } else if ("hd".equals(channel)) {
             Integer incr = Convert.toInt(RedisUtils.incr(Constants.VISIT_HD));
             String value = configService.getOne(Wrappers.<SysConfig>lambdaQuery().eq(SysConfig::getConfigKey, "app.info.hd")).getConfigValue();
@@ -78,6 +81,9 @@ public class ThirdInterfaceServiceImpl implements IThirdInterfaceService {
             // 将结果再保存到数据库中
             appInfo.setIcon("");
             configService.update(Wrappers.<SysConfig>lambdaUpdate().eq(SysConfig::getConfigKey, "app.info.hd").set(SysConfig::getConfigValue, JSONUtil.toJsonStr(appInfo)));
+            /*// 更新系统数据量和用户数
+            feignUserManageService.updateDataCount(appInfo.getAppId(), dataTotalCount);
+            feignUserManageService.updateUserCount(appInfo.getAppId(), userCount);*/
         }
     }
 }