459242451@qq.com il y a 2 ans
Parent
commit
06e2967856
20 fichiers modifiés avec 678 ajouts et 434 suppressions
  1. 1 0
      ruoyi-admin/nacos/yjzh-sq-prod.yaml
  2. 4 3
      ruoyi-admin/nacos/yjzh-sq-test.yaml
  3. 51 21
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
  4. 165 73
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
  5. 26 6
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/ScheduleTask.java
  6. 127 70
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/SysGatewayUserTask.java
  7. 5 3
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhdd/DhController.java
  8. 1 0
      ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
  9. 0 2
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
  10. 1 1
      ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
  11. 3 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
  12. 20 3
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
  13. 0 5
      ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
  14. 16 1
      ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/domain/GatewayUserDetail.java
  15. 1 0
      ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/domain/GatewayUserPage.java
  16. 24 0
      ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/feign/FeignDocumentService.java
  17. 1 1
      ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/feign/FeignUserManageService.java
  18. 26 0
      ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/feign/fallback/FeignDocumentFallback.java
  19. 4 4
      ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/service/IDhService.java
  20. 202 241
      ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/service/impl/DhServiceImpl.java

+ 1 - 0
ruoyi-admin/nacos/yjzh-sq-prod.yaml

@@ -163,3 +163,4 @@ third:
     chemicalUrl: https://tocc.jtj.suqian.gov.cn:30030/sqmb/#/chemical/detail?id= # 危化品详情页面
     dhVideoUserName: huashe2
     dhPCUserName: huashe3
+    fileUrl: http://10.11.230.159:32905 # 第三方文件系统访问地址

+ 4 - 3
ruoyi-admin/nacos/yjzh-sq-test.yaml

@@ -154,12 +154,13 @@ ruoyi:
     profile: /home/tocc
 
 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 # 大华设备树
+    dhAuthorize: http://10.55.134.30:8314/videoService/accounts/authorize # 大华鉴权创建用户会话
+    keepalive: http://10.55.134.30:8314/videoService/accounts/token/keepalive # 大华会话保活
+    dhDeviceTree: http://10.55.134.30:8314/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= # 危化品详情页面
     dhVideoUserName: huashe4
     dhPCUserName: huashe5
+    fileUrl: http://10.11.208.21:32905 # 第三方文件系统访问地址

+ 51 - 21
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java

@@ -1,16 +1,21 @@
 package com.ruoyi.web.controller.common;
 
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.util.URLUtil;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONObject;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.FileUtils;
 import com.ruoyi.framework.config.ServerConfig;
+import com.ruoyi.zhdd.feign.FeignDocumentService;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -36,6 +41,10 @@ public class CommonController {
 
     @Autowired
     private ServerConfig serverConfig;
+    @Autowired
+    private FeignDocumentService feignDocumentService;
+    @Value("${third.fileUrl}")
+    private String fileUrl;
 
     /**
      * 通用下载请求
@@ -74,17 +83,29 @@ public class CommonController {
      */
     @SneakyThrows
     @PostMapping("/common/upload")
-    public AjaxResult<Map<String, Object>> uploadFile(MultipartFile file) {
-        // 上传文件路径
-        String filePath = RuoYiConfig.getUploadPath();
-        // 上传并返回新文件名称
-        String fileName = FileUploadUtils.upload(filePath, file);
-        String url = serverConfig.getUrl() + fileName;
-        Map<String, Object> result = new HashMap<>();
-        result.put("fileName", fileName.substring(fileName.lastIndexOf("/") + 1));
-        result.put("url", fileName);
-        Runtime.getRuntime().exec("chmod 777 -R " + filePath);
-        return AjaxResult.success(result);
+    public AjaxResult<?> uploadFile(MultipartFile file) {
+        JSONObject jsonObject = feignDocumentService.fileUpload(file, "yjzh");
+        log.info("文件上传结果:{}", jsonObject);
+        if (jsonObject != null) {
+            if (jsonObject.getInt("code") == 200) {
+                JSONObject data = jsonObject.getJSONObject("data");
+                Map<String, Object> result = new HashMap<>();
+                result.put("fileName", data.getStr("realName"));
+                result.put("url", URLUtil.getPath(data.getStr("url")));
+                return AjaxResult.success(result);
+            }
+        }
+        return AjaxResult.error("文件上传失败");
+//        // 上传文件路径
+//        String filePath = RuoYiConfig.getUploadPath();
+//        // 上传并返回新文件名称
+//        String fileName = FileUploadUtils.upload(filePath, file);
+//        String url = serverConfig.getUrl() + fileName;
+//        Map<String, Object> result = new HashMap<>();
+//        result.put("fileName", fileName.substring(fileName.lastIndexOf("/") + 1));
+//        result.put("url", fileName);
+//        Runtime.getRuntime().exec("chmod 777 -R " + filePath);
+//        return AjaxResult.success(result);
     }
 
     /**
@@ -97,15 +118,24 @@ public class CommonController {
             if (!FileUtils.checkAllowDownload(resource)) {
                 throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
             }
-            // 本地资源路径
-            String localPath = RuoYiConfig.getProfile();
-            // 数据库资源地址
-            String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
-            // 下载名称
-            String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
-            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
-            FileUtils.setAttachmentResponseHeader(response, downloadName);
-            FileUtils.writeBytes(downloadPath, response.getOutputStream());
+            if (StrUtil.startWith(resource, Constants.RESOURCE_PREFIX)) {
+                // 本地资源路径
+                String localPath = RuoYiConfig.getProfile();
+                // 数据库资源地址
+                String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
+                // 下载名称
+                String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
+                response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+                FileUtils.setAttachmentResponseHeader(response, downloadName);
+                FileUtils.writeBytes(downloadPath, response.getOutputStream());
+            } else {
+                // 网络资源
+                // 下载名称
+                String downloadName = StringUtils.substringAfterLast(resource, "/");
+                response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+                FileUtils.setAttachmentResponseHeader(response, downloadName);
+                HttpUtil.download(fileUrl + resource, response.getOutputStream(), true);
+            }
         } catch (Exception e) {
             log.error("下载文件失败", e);
         }

+ 165 - 73
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -1,15 +1,11 @@
 package com.ruoyi.web.controller.system;
 
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.convert.Convert;
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.annotation.Security;
@@ -26,7 +22,6 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.UserUtil;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.system.domain.vo.SysUserExportVo;
-import com.ruoyi.system.domain.vo.SysUserImportVo;
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.service.ISysRoleService;
 import com.ruoyi.system.service.ISysUserService;
@@ -36,12 +31,10 @@ import com.ruoyi.zhdd.domain.Resource;
 import com.ruoyi.zhdd.domain.bo.ResourceBo;
 import com.ruoyi.zhdd.feign.FeignUserManageService;
 import com.ruoyi.zhdd.service.IResourceService;
-import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
@@ -98,21 +91,6 @@ public class SysUserController extends BaseController {
         ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
     }
 
-    @Log(title = "用户管理", businessType = BusinessType.IMPORT)
-    @PostMapping("/importData")
-    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
-        List<SysUserImportVo> userListVo = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class);
-        List<SysUser> userList = BeanUtil.copyToList(userListVo, SysUser.class);
-        String operName = getUsername();
-        String message = userService.importUser(userList, updateSupport, operName);
-        return AjaxResult.success(message);
-    }
-
-    @GetMapping("/importTemplate")
-    public void importTemplate(HttpServletResponse response) {
-        ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
-    }
-
     /**
      * 根据用户编号获取详细信息
      */
@@ -377,63 +355,177 @@ public class SysUserController extends BaseController {
         return AjaxResult.success();
     }
 
-    @GetMapping("/compareDept")
-    public void compareDept() {
-        String s = FileUtil.readUtf8String("/Users/huangcheng/Desktop/siweidept");
-        JSONArray jsonArray = JSONUtil.parseArray(s);
-        List<SiweiDept> siweiDepts = JSONUtil.toList(jsonArray, SiweiDept.class);
-        List<SysDept> list = deptService.list();
-
-        /////////////////////////
-        List<String> siweiIds = siweiDepts.stream().map(SiweiDept::getId).collect(Collectors.toList());
-        List<String> hsIds = list.stream().map(SysDept::getDeptId).collect(Collectors.toList());
-        System.out.println("四维存在,华设不存在" + CollUtil.subtract(siweiIds, hsIds));
-        System.out.println("四维不存在,华设存在" + CollUtil.subtract(hsIds, siweiIds));
-
-        /////////////////////////
-
-
-        Map<String, SiweiDept> siweiDeptIds = siweiDepts.stream().collect(Collectors.toMap(SiweiDept::getId, a -> a));
-        for (SysDept sysDept : list) {
-            String deptid = sysDept.getDeptId();
-            SiweiDept siweiDept = siweiDeptIds.get(deptid);
-            if (siweiDept != null) {
-                if (StrUtil.isBlank(siweiDept.getParentId())) {
-                    siweiDept.setParentId("0");
-                }
-                if (StrUtil.isNotBlank(siweiDept.getFullName())) {
-                    siweiDept.setFullName(siweiDept.getFullName().replace("-", "/"));
-                }
-                try {
-                    if (!sysDept.getParentId().equals(siweiDept.getParentId()) || !sysDept.getDeptName().equals(siweiDept.getName()) || !sysDept.getFlag().equals(Convert.toStr(siweiDept.getFlag())) || !sysDept.getFullName().equals(siweiDept.getFullName())) {
-                        System.out.println("华设:" + sysDept.getDeptId() + "-" + sysDept.getParentId() + "-" + sysDept.getDeptName() + "-" + sysDept.getFullName());
-                        System.out.println("四维:" + siweiDept.getId() + "-" + siweiDept.getParentId() + "-" + siweiDept.getName() + "-" + siweiDept.getFullName());
+    @PostMapping("/syncUser")
+    public AjaxResult<Void> syncAllUser() {
+        GatewayUserPage gatewayUserPage = feignUserManageService.userPage("", 1, 10000);
+        if (gatewayUserPage != null && gatewayUserPage.getData().getRows().size() > 0) {
+            for (GatewayUserPage.UserDetail userPage : gatewayUserPage.getData().getRows()) {
+                // 查询四维用户详情
+                GatewayUserDetail userDetail = feignUserManageService.userDetail(userPage.getUserId());
+                if (userDetail != null) {
+                    log.info("四维用户详情:{}", userDetail);
+                    GatewayUserDetail.UserDetail data = userDetail.getData();
+                    SysUser newUser = new SysUser();
+                    // 如果是企业用户,则查询是否存在企业信息,存在则新增企业部门,同时往应急仓库新增一个数据
+                    if (data.getUserGroupId() == 4) {
+                        GatewayUserDetail.EntInfo entInfo = data.getEntInfo();
+                        if (entInfo != null && StrUtil.isAllNotBlank(entInfo.getEntName(), entInfo.getOwnerId(), entInfo.getOwnerCategory())) {
+                            newUser.setDeptId(entInfo.getOwnerId());
+                            newUser.setOrgId(entInfo.getOwnerId());
+                            SysDept sysDept = deptService.selectDeptById(entInfo.getOwnerId());
+                            String locationType = "2";
+                            if (sysDept == null) {
+                                sysDept = new SysDept();
+                                sysDept.setDeptId(entInfo.getOwnerId());
+                                sysDept.setDeptName(entInfo.getEntName());
+                                sysDept.setFlag("0");
+                                // 根据企业类型放置不同的目录中
+                                if ("危货业户".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10001");
+                                } else if ("普货业户".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10002");
+                                } else if ("客运业户".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10003");
+                                } else if ("出租车业户".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10004");
+                                } else if ("公交运输业户".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10005");
+                                } else if ("汽车租赁业户".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10006");
+                                } else if ("检测站业户".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10007");
+                                } else if ("网约车平台".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10008");
+                                } else if ("维修站".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10009");
+                                } else if ("其他".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10010");
+                                } else if ("公路工程".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10011");
+                                } else if ("水运工程".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10012");
+                                    locationType = "1";
+                                } else if ("航运企业".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10013");
+                                    locationType = "1";
+                                } else if ("港口码头".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10014");
+                                    locationType = "1";
+                                } else if ("水上游览经营".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10015");
+                                    locationType = "1";
+                                } else if ("货运场站".equals(entInfo.getOwnerCategory())) {
+                                    sysDept.setParentId("10016");
+                                }
+                                deptService.insertDept(sysDept);
+                            }
+                            List<Resource> resourcesList = resourceService.list(Wrappers.<Resource>lambdaQuery().eq(Resource::getManageUnitId, entInfo.getOwnerId()));
+                            if (resourcesList == null || resourcesList.size() == 0) {
+                                // 新增应急仓库
+                                ResourceBo resource = new ResourceBo();
+                                resource.setAdminOrgName(entInfo.getAdminOrgName());
+                                resource.setResourceType(1);
+                                resource.setName(entInfo.getEntName() + "仓库");
+                                resource.setManageUnit(entInfo.getEntName());
+                                resource.setContactName(data.getName());
+                                resource.setContactPhone(data.getMobile());
+                                resource.setLocationType(locationType);
+                                resource.setManageUnitId(entInfo.getOwnerId());
+                                // 默认为宿迁市交通局坐标
+                                resource.setLatitude("33.961569");
+                                resource.setLongitude("118.260139");
+                                resourceService.insertByBo(resource);
+                            }
+                        }
                     }
-//                    if (!sysDept.getDeptName().equals(siweiDept.getName())) {
-//                        System.out.println("华设:" + sysDept.getDeptId() + "-" + sysDept.getDeptName());
-//                        System.out.println("四维:" + siweiDept.getId() + "-" + siweiDept.getName());
-//                    }
-//                    if (!sysDept.getParentId().equals(siweiDept.getParentId()) || !sysDept.getFullName().equals(siweiDept.getFullName())) {
-//                        System.out.println("华设:" + sysDept.getDeptId() + "-" + sysDept.getParentId() + "-" + sysDept.getFullName());
-//                        System.out.println("四维:" + siweiDept.getId() + "-" + siweiDept.getParentId() + "-" + siweiDept.getFullName());
-//                    }
-
-                } catch (Exception e) {
-                    System.out.println("错误华设:" + sysDept);
-                    System.out.println("错误四维:" + siweiDept);
+                    newUser.setUserId(data.getUserId());
+                    if (data.getPosts() != null && data.getPosts().size() > 0) {
+                        newUser.setDeptId(data.getPosts().get(0).getDeptId());
+                        // 查询deptId对应的orgId
+                        if (StrUtil.isNotBlank(newUser.getDeptId())) {
+                            SysDept sysDept = deptService.selectDeptById(newUser.getDeptId());
+                            SysDept orgDept = deptService.getOrgDept(sysDept);
+                            if (orgDept != null) {
+                                newUser.setOrgId(orgDept.getDeptId());
+                            }
+                        }
+                    }
+                    newUser.setUserName(data.getUserName());
+                    newUser.setNickName(data.getName());
+                    newUser.setUserType(Convert.toStr(data.getUserGroupId()));
+                    newUser.setPhonenumber(StrUtil.cleanBlank(data.getMobile()));
+                    newUser.setPassword(SecurityUtils.encryptPassword("tocc!suqian"));
+                    newUser.setSex(data.getSex());
+                    newUser.setStatus(data.getStatus());
+                    newUser.setDelFlag("0");
+                    newUser.setUpdateBy("hs");
+                    newUser.setUpdateTime(new Date());
+                    newUser.setCreateBy("gateway");
+                    newUser.setCreateTime(new Date());
+                    userService.insertUser(newUser);
                 }
             }
         }
+        return AjaxResult.success();
     }
 
-    @Data
-    public static class SiweiDept {
-        private String id;
-        private String name;
-        private String parentId;
-        private Integer flag;
-        private String fullName;
-    }
+//    @GetMapping("/compareDept")
+//    public void compareDept() {
+//        String s = FileUtil.readUtf8String("/Users/huangcheng/Desktop/siweidept");
+//        JSONArray jsonArray = JSONUtil.parseArray(s);
+//        List<SiweiDept> siweiDepts = JSONUtil.toList(jsonArray, SiweiDept.class);
+//        List<SysDept> list = deptService.list();
+//
+//        /////////////////////////
+//        List<String> siweiIds = siweiDepts.stream().map(SiweiDept::getId).collect(Collectors.toList());
+//        List<String> hsIds = list.stream().map(SysDept::getDeptId).collect(Collectors.toList());
+//        System.out.println("四维存在,华设不存在" + CollUtil.subtract(siweiIds, hsIds));
+//        System.out.println("四维不存在,华设存在" + CollUtil.subtract(hsIds, siweiIds));
+//
+//        /////////////////////////
+//
+//
+//        Map<String, SiweiDept> siweiDeptIds = siweiDepts.stream().collect(Collectors.toMap(SiweiDept::getId, a -> a));
+//        for (SysDept sysDept : list) {
+//            String deptid = sysDept.getDeptId();
+//            SiweiDept siweiDept = siweiDeptIds.get(deptid);
+//            if (siweiDept != null) {
+//                if (StrUtil.isBlank(siweiDept.getParentId())) {
+//                    siweiDept.setParentId("0");
+//                }
+//                if (StrUtil.isNotBlank(siweiDept.getFullName())) {
+//                    siweiDept.setFullName(siweiDept.getFullName().replace("-", "/"));
+//                }
+//                try {
+//                    if (!sysDept.getParentId().equals(siweiDept.getParentId()) || !sysDept.getDeptName().equals(siweiDept.getName()) || !sysDept.getFlag().equals(Convert.toStr(siweiDept.getFlag())) || !sysDept.getFullName().equals(siweiDept.getFullName())) {
+//                        System.out.println("华设:" + sysDept.getDeptId() + "-" + sysDept.getParentId() + "-" + sysDept.getDeptName() + "-" + sysDept.getFullName());
+//                        System.out.println("四维:" + siweiDept.getId() + "-" + siweiDept.getParentId() + "-" + siweiDept.getName() + "-" + siweiDept.getFullName());
+//                    }
+////                    if (!sysDept.getDeptName().equals(siweiDept.getName())) {
+////                        System.out.println("华设:" + sysDept.getDeptId() + "-" + sysDept.getDeptName());
+////                        System.out.println("四维:" + siweiDept.getId() + "-" + siweiDept.getName());
+////                    }
+////                    if (!sysDept.getParentId().equals(siweiDept.getParentId()) || !sysDept.getFullName().equals(siweiDept.getFullName())) {
+////                        System.out.println("华设:" + sysDept.getDeptId() + "-" + sysDept.getParentId() + "-" + sysDept.getFullName());
+////                        System.out.println("四维:" + siweiDept.getId() + "-" + siweiDept.getParentId() + "-" + siweiDept.getFullName());
+////                    }
+//
+//                } catch (Exception e) {
+//                    System.out.println("错误华设:" + sysDept);
+//                    System.out.println("错误四维:" + siweiDept);
+//                }
+//            }
+//        }
+//    }
+
+//    @Data
+//    public static class SiweiDept {
+//        private String id;
+//        private String name;
+//        private String parentId;
+//        private Integer flag;
+//        private String fullName;
+//    }
 
 //    public static void main(String[] args) {
 //        String s = FileUtil.readUtf8String("/Users/huangcheng/Desktop/temp");

+ 26 - 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/ScheduleTask.java

@@ -1,6 +1,5 @@
 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;
@@ -65,23 +64,44 @@ public class ScheduleTask {
     @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);
+        boolean testToken = RedisUtils.exist(Constants.CACHE_DH_TOKEN);
+        boolean fuyongToken = RedisUtils.exist(Constants.CACHE_DH_FUYONG_TOKEN);
         if (pcToken) {
             long ttl = RedisUtils.getTtl(Constants.CACHE_DH_VIDEO_TOKEN);
             if (NumberUtil.compare(ttl, 0) == 1 && NumberUtil.compare(ttl, 30000) == -1) {
                 // 保活token
-                Map<String, Object> token = RedisUtils.getCacheMap(Constants.CACHE_DH_VIDEO_TOKEN);
-                dhService.tokenKeepalive(Convert.toStr(token.get("token")), 120, Constants.CACHE_DH_VIDEO_TOKEN);
+                Map<String, String> token = RedisUtils.getCacheMap(Constants.CACHE_DH_VIDEO_TOKEN);
+                dhService.tokenKeepalive(token.get("token"), 120, Constants.CACHE_DH_VIDEO_TOKEN);
+                log.info("大华token已保活:key={}.token={}", Constants.CACHE_DH_VIDEO_TOKEN, token.get("token"));
             }
         }
         if (hdToken) {
             long ttl = RedisUtils.getTtl(Constants.CACHE_DH_VIDEO_HD_TOKEN);
             if (NumberUtil.compare(ttl, 0) == 1 && NumberUtil.compare(ttl, 30000) == -1) {
                 // 保活token
-                Map<String, Object> token = RedisUtils.getCacheMap(Constants.CACHE_DH_VIDEO_HD_TOKEN);
-                dhService.tokenKeepalive(Convert.toStr(token.get("token")), 120, Constants.CACHE_DH_VIDEO_HD_TOKEN);
+                Map<String, String> token = RedisUtils.getCacheMap(Constants.CACHE_DH_VIDEO_HD_TOKEN);
+                dhService.tokenKeepalive(token.get("token"), 120, Constants.CACHE_DH_VIDEO_HD_TOKEN);
+                log.info("大华token已保活:key={}.token={}", Constants.CACHE_DH_VIDEO_HD_TOKEN, token.get("token"));
+            }
+        }
+        if (testToken) {
+            long ttl = RedisUtils.getTtl(Constants.CACHE_DH_TOKEN);
+            if (NumberUtil.compare(ttl, 0) == 1 && NumberUtil.compare(ttl, 30000) == -1) {
+                // 保活token
+                Map<String, String> token = RedisUtils.getCacheMap(Constants.CACHE_DH_TOKEN);
+                dhService.tokenKeepalive(token.get("token"), 120, Constants.CACHE_DH_TOKEN);
+                log.info("大华token已保活:key={}.token={}", Constants.CACHE_DH_TOKEN, token.get("token"));
+            }
+        }
+        if (fuyongToken) {
+            long ttl = RedisUtils.getTtl(Constants.CACHE_DH_FUYONG_TOKEN);
+            if (NumberUtil.compare(ttl, 0) == 1 && NumberUtil.compare(ttl, 30000) == -1) {
+                // 保活token
+                Map<String, String> token = RedisUtils.getCacheMap(Constants.CACHE_DH_FUYONG_TOKEN);
+                dhService.tokenKeepalive(token.get("token"), 120, Constants.CACHE_DH_FUYONG_TOKEN);
+                log.info("大华token已保活:key={}.token={}", Constants.CACHE_DH_FUYONG_TOKEN, token.get("token"));
             }
         }
     }

+ 127 - 70
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/SysGatewayUserTask.java

@@ -8,20 +8,30 @@ import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.common.core.domain.entity.SysDept;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.FindsDepartsChildrenUtil;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.service.ISysDictTypeService;
 import com.ruoyi.system.service.ISysUserService;
 import com.ruoyi.zhdd.domain.GatewayDeptList;
-import com.ruoyi.zhdd.domain.GatewaySUser;
+import com.ruoyi.zhdd.domain.GatewayUserDetail;
+import com.ruoyi.zhdd.domain.GatewayUserPage;
+import com.ruoyi.zhdd.domain.Resource;
 import com.ruoyi.zhdd.domain.SingleDevice;
+import com.ruoyi.zhdd.domain.bo.ResourceBo;
 import com.ruoyi.zhdd.domain.bo.SingleDeviceBo;
+import com.ruoyi.zhdd.feign.FeignUserManageService;
+import com.ruoyi.zhdd.service.IResourceService;
 import com.ruoyi.zhdd.service.ISingleDeviceService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.kafka.annotation.KafkaListener;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
+import java.util.List;
+
 @Component
 @Slf4j
 public class SysGatewayUserTask {
@@ -36,6 +46,12 @@ public class SysGatewayUserTask {
     private ISingleDeviceService singleDeviceService;
 
     @Autowired
+    private FeignUserManageService feignUserManageService;
+
+    @Autowired
+    private IResourceService resourceService;
+
+    @Autowired
     private ISysDictTypeService sysDictTypeService;
 
 //    @Autowired
@@ -50,75 +66,116 @@ public class SysGatewayUserTask {
     public void onUserMessage(String message) {
         log.info("kafka用户信息消费:{}", message);
         try {
-            GatewaySUser gatewaySUser = JSONUtil.toBean(message, GatewaySUser.class);
-//            if (gatewaySUser != null) {
-//                SysUser quser = new SysUser();
-//                quser.setUserId(gatewaySUser.getUserId());
-//                List<SysUser> userList = userService.selectUserList(quser);
-//                if (userList.isEmpty()) {
-//                    //插入
-//                    SysUser user = new SysUser();
-//                    user.setUserId(gatewaySUser.getUserId());
-//                    {
-//                        SysDept qdept = new SysDept();
-//                        qdept.setOtherId(gatewaySUser.getDeptId());
-//                        List<SysDept> deptList = deptService.selectDeptList(qdept);
-//                        if (!deptList.isEmpty()) {
-//                            user.setDeptId(deptList.get(0).getDeptId());
-//                        } else {
-//                            //还未有部门暂不设置  //需要先同步部门
-//                        }
-//                    }
-//                    user.setPhonenumber(gatewaySUser.getMobile());
-//                    user.setNickName(gatewaySUser.getName());
-//                    user.setUserName(gatewaySUser.getUserName());
-//                    user.setDeptId(gatewaySUser.getDeptId());
-//                    user.setUserType(Convert.toStr(gatewaySUser.getUserGroupId()));
-//                    user.setUpdateBy("kafka");
-//                    user.setUpdateTime(new Date());
-//                    user.setCreateBy("kafka");
-//                    user.setCreateTime(new Date());
-//                    user.setSex(gatewaySUser.getSex());
-//                    user.setOrgId(gatewaySUser.getOrgId());
-//                    user.setSuperior(gatewaySUser.getSuperior());
-//                    user.setIdNumber(gatewaySUser.getIdNumber());
-//                    user.setPassword(SecurityUtils.encryptPassword("tocc!suqian"));
-//                    user.setStatus(gatewaySUser.getStatus());
-//                    user.setDelFlag(gatewaySUser.getDelFlag());
-//                    userService.insertUser(user);
-//                } else {
-//                    //更新
-//                    SysUser user = userList.get(0);
-//                    {
-//                        SysDept qdept = new SysDept();
-//                        qdept.setOtherId(gatewaySUser.getDeptId());
-//                        List<SysDept> deptList = deptService.selectDeptList(qdept);
-//                        if (!deptList.isEmpty()) {
-//                            user.setDeptId(deptList.get(0).getDeptId());
-//                        } else {
-//                            //还未有部门暂不设置  //需要先同步部门
-//
-//                        }
-//                    }
-//                    user.setPhonenumber(gatewaySUser.getMobile());
-//                    user.setNickName(gatewaySUser.getName());
-//                    user.setUserName(gatewaySUser.getUserName());
-//                    user.setDeptId(gatewaySUser.getDeptId());
-//                    user.setUserType(Convert.toStr(gatewaySUser.getUserGroupId()));
-//                    user.setUpdateBy("kafka");
-//                    user.setUpdateTime(new Date());
-//                    user.setSex(gatewaySUser.getSex());
-//                    user.setOrgId(gatewaySUser.getOrgId());
-//                    user.setSuperior(gatewaySUser.getSuperior());
-//                    user.setIdNumber(gatewaySUser.getIdNumber());
-//                    user.setPassword(SecurityUtils.encryptPassword("tocc!suqian"));
-//                    user.setStatus(gatewaySUser.getStatus());
-//                    user.setDelFlag(gatewaySUser.getDelFlag());
-//                    user.setUpdateBy("kafka");
-//                    user.setUpdateTime(new Date());
-//                    userService.updateUser(user);
-//                }
-//            }
+            GatewayUserPage.UserDetail userPage = JSONUtil.toBean(message, GatewayUserPage.UserDetail.class);
+            if ("2".equals(userPage.getDelFlag())) {
+                // 代表删除
+                userService.deleteUserById(userPage.getUserId());
+                return;
+            }
+            // 查询四维用户详情
+            GatewayUserDetail userDetail = feignUserManageService.userDetail(userPage.getUserId());
+            if (userDetail != null) {
+                log.info("四维用户详情:{}", userDetail);
+                GatewayUserDetail.UserDetail data = userDetail.getData();
+                SysUser newUser = new SysUser();
+                // 如果是企业用户,则查询是否存在企业信息,存在则新增企业部门,同时往应急仓库新增一个数据
+                if (data.getUserGroupId() == 4) {
+                    GatewayUserDetail.EntInfo entInfo = data.getEntInfo();
+                    if (entInfo != null && StrUtil.isAllNotBlank(entInfo.getEntName(), entInfo.getOwnerId(), entInfo.getOwnerCategory())) {
+                        newUser.setDeptId(entInfo.getOwnerId());
+                        newUser.setOrgId(entInfo.getOwnerId());
+                        SysDept sysDept = deptService.selectDeptById(entInfo.getOwnerId());
+                        String locationType = "2";
+                        if (sysDept == null) {
+                            sysDept = new SysDept();
+                            sysDept.setDeptId(entInfo.getOwnerId());
+                            sysDept.setDeptName(entInfo.getEntName());
+                            sysDept.setFlag("0");
+                            // 根据企业类型放置不同的目录中
+                            if ("危货业户".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10001");
+                            } else if ("普货业户".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10002");
+                            } else if ("客运业户".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10003");
+                            } else if ("出租车业户".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10004");
+                            } else if ("公交运输业户".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10005");
+                            } else if ("汽车租赁业户".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10006");
+                            } else if ("检测站业户".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10007");
+                            } else if ("网约车平台".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10008");
+                            } else if ("维修站".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10009");
+                            } else if ("其他".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10010");
+                            } else if ("公路工程".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10011");
+                            } else if ("水运工程".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10012");
+                                locationType = "1";
+                            } else if ("航运企业".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10013");
+                                locationType = "1";
+                            } else if ("港口码头".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10014");
+                                locationType = "1";
+                            } else if ("水上游览经营".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10015");
+                                locationType = "1";
+                            } else if ("货运场站".equals(entInfo.getOwnerCategory())) {
+                                sysDept.setParentId("10016");
+                            }
+                            deptService.insertDept(sysDept);
+                        }
+                        List<Resource> resourcesList = resourceService.list(Wrappers.<Resource>lambdaQuery().eq(Resource::getManageUnitId, entInfo.getOwnerId()));
+                        if (resourcesList == null || resourcesList.size() == 0) {
+                            // 新增应急仓库
+                            ResourceBo resource = new ResourceBo();
+                            resource.setAdminOrgName(entInfo.getAdminOrgName());
+                            resource.setResourceType(1);
+                            resource.setName(entInfo.getEntName() + "仓库");
+                            resource.setManageUnit(entInfo.getEntName());
+                            resource.setContactName(data.getName());
+                            resource.setContactPhone(data.getMobile());
+                            resource.setLocationType(locationType);
+                            resource.setManageUnitId(entInfo.getOwnerId());
+                            // 默认为宿迁市交通局坐标
+                            resource.setLatitude("33.961569");
+                            resource.setLongitude("118.260139");
+                            resourceService.insertByBo(resource);
+                        }
+                    }
+                }
+                newUser.setUserId(data.getUserId());
+                if (data.getPosts() != null && data.getPosts().size() > 0) {
+                    newUser.setDeptId(data.getPosts().get(0).getDeptId());
+                    // 查询deptId对应的orgId
+                    if (StrUtil.isNotBlank(newUser.getDeptId())) {
+                        SysDept sysDept = deptService.selectDeptById(newUser.getDeptId());
+                        SysDept orgDept = deptService.getOrgDept(sysDept);
+                        if (orgDept != null) {
+                            newUser.setOrgId(orgDept.getDeptId());
+                        }
+                    }
+                }
+                newUser.setUserName(data.getUserName());
+                newUser.setNickName(data.getName());
+                newUser.setUserType(Convert.toStr(data.getUserGroupId()));
+                newUser.setPhonenumber(StrUtil.cleanBlank(data.getMobile()));
+                newUser.setPassword(SecurityUtils.encryptPassword("tocc!suqian"));
+                newUser.setSex(data.getSex());
+                newUser.setStatus(data.getStatus());
+                newUser.setDelFlag("0");
+                newUser.setUpdateBy("hs");
+                newUser.setUpdateTime(new Date());
+                newUser.setCreateBy("gateway");
+                newUser.setCreateTime(new Date());
+                userService.insertUser(newUser);
+            }
         } catch (Exception e) {
             log.error("t_uc_use的kafka消费异常:{}", e.getMessage());
         }

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

@@ -32,6 +32,8 @@ public class DhController {
     private final IDhService dhService;
     @Value("${third.dhPCUserName}")
     private String dhAccount;
+    @Value("${third.dhVideoUserName}")
+    private String dhVideoUserName;
 
     @ApiOperation("查询设备列表")
     @GetMapping("/deviceList")
@@ -43,20 +45,20 @@ public class DhController {
     @GetMapping("/getVideoToken")
     public AjaxResult getToken(@RequestParam(required = false) String account) {
         RedisUtils.publish(Constants.UPDATE_APP_PUSH, "hd");
-        return AjaxResult.success(dhService.getVideoToken(account, Constants.CACHE_DH_VIDEO_HD_TOKEN));
+        return AjaxResult.success(dhService.authorize(dhVideoUserName, "Dahua@4002", "winpc", 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, Constants.CACHE_DH_VIDEO_TOKEN));
+        return AjaxResult.success(dhService.authorize(dhAccount, "Dahua@4002", "winpc", Constants.CACHE_DH_VIDEO_TOKEN));
     }
 
     @ApiOperation("获取大华tokenV2.用于PC端业务")
     @GetMapping("/test/getVideoToken")
     public AjaxResult getTokenV2Fortest() {
-        return AjaxResult.success(dhService.getTestToken());
+        return AjaxResult.success(dhService.authorize("huashe", "Admin123", "winpc", Constants.CACHE_DH_TOKEN));
     }
 
     /*@ApiOperation("video的token下线")

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

@@ -159,6 +159,7 @@ public class Constants {
      * 大华tokon缓存
      */
     public static final String CACHE_DH_TOKEN = "dh:token";
+    public static final String CACHE_DH_FUYONG_TOKEN = "dh:fuyong:token";
     // PC
     public static final String CACHE_DH_VIDEO_TOKEN = "dh:videotoken";
     public static final String CACHE_DH_TEST_TOKEN = "dh:testtoken";

+ 0 - 2
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -182,8 +182,6 @@ public class SysUser implements Serializable {
     @TableField(exist = false)
     private Long[] postIds;
 
-    private String otherId;
-
     private String orgId;
 
     private String superior;

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java

@@ -116,7 +116,7 @@ public interface ISysUserService extends IService<SysUser> {
      * @param user 用户信息
      * @return 结果
      */
-    public int insertUser(SysUser user);
+    public boolean insertUser(SysUser user);
 
     /**
      * 注册用户信息

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -322,6 +322,9 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
 
     @Override
     public SysDept getOrgDept(SysDept sysDept) {
+        if (sysDept == null) {
+            return null;
+        }
         if ("0".equals(sysDept.getFlag())) {
             return sysDept;
         }

+ 20 - 3
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysRole;
@@ -251,11 +252,22 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
      */
     @Override
     @Transactional
-    public int insertUser(SysUser user) {
+    public boolean insertUser(SysUser user) {
         // 新增用户信息
-        int rows = baseMapper.insert(user);
+//        SysUser voById = this.getVoById(user.getUserId());
+        boolean rows = false;
+        try {
+            rows = this.saveOrUpdate(user);
+        } catch (Exception e) {
+            log.error("保存用户信息时异常:{}:{}", user, e.getMessage());
+        }
+//        if (voById == null) {
+//            rows = this.save(user);
+//        } else {
+//            rows = this.updateById(user);
+//        }
         // 新增用户岗位关联
-        insertUserPost(user);
+//        insertUserPost(user);
         // 新增用户与角色管理
         insertUserRole(user);
         return rows;
@@ -385,6 +397,11 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
      */
     public void insertUserRole(SysUser user) {
         String[] roles = user.getRoleIds();
+        // 先查询用户是否有角色数据,如果没有,则进行下一步
+        List<SysUserRole> sysUserRoles = userRoleMapper.selectList(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, user.getUserId()));
+        if (sysUserRoles != null && sysUserRoles.size() > 0) {
+            return;
+        }
         if (StringUtils.isNotNull(roles)) {
             // 新增用户与角色管理
             List<SysUserRole> list = new ArrayList<SysUserRole>();

+ 0 - 5
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -24,7 +24,6 @@
         <result property="updateBy" column="update_by"/>
         <result property="updateTime" column="update_time"/>
         <result property="remark" column="remark"/>
-        <result property="otherId" column="other_id"/>
         <result property="orgId" column="org_id"/>
         <association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult"/>
         <collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
@@ -78,7 +77,6 @@
                r.role_key,
                r.role_sort,
                r.data_scope,
-               u.other_id,
                u.org_id,
                r.status as role_status
         from sys_user u
@@ -132,9 +130,6 @@
         <if test="userId != null and userId != 0">
             AND u.user_id = #{userId}
         </if>
-        <if test="otherId != null and otherId != 0">
-            AND u.other_id = #{otherId}
-        </if>
         <if test="userName != null and userName != ''">
             AND u.user_name like concat('%', #{userName}, '%')
         </if>

+ 16 - 1
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/domain/GatewayUserDetail.java

@@ -2,6 +2,8 @@ package com.ruoyi.zhdd.domain;
 
 import lombok.Data;
 
+import java.util.List;
+
 @Data
 public class GatewayUserDetail {
     private Integer code;
@@ -12,13 +14,18 @@ public class GatewayUserDetail {
     public static class UserDetail {
         private String userId;
         private String name;
+        private String sex;
         private String userName;
-        private String orgId;
+        //        private String deptId;
+//        private String orgId;
+        private String status;
         private String idNumber;
         private String mobile;
         // (1:局领导,2:执法人员,3:从业人员,4:企业,5:公众,9:非执法人员)
         private int userGroupId;
         private EntInfo entInfo;
+        private String delFlag;
+        private List<Posts> posts;
     }
 
     @Data
@@ -31,4 +38,12 @@ public class GatewayUserDetail {
         private String adminOrgName;
     }
 
+    @Data
+    public static class Posts {
+        private String deptId;
+        private String deptName;
+        private String orgId;
+        private String orgName;
+    }
+
 }

+ 1 - 0
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/domain/GatewayUserPage.java

@@ -19,6 +19,7 @@ public class GatewayUserPage {
         private String orgName;
         // 本数据库标识。0:不存在,1:存在
         private String localFlag;
+        private String delFlag;
     }
 
     @Data

+ 24 - 0
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/feign/FeignDocumentService.java

@@ -0,0 +1,24 @@
+package com.ruoyi.zhdd.feign;
+
+import cn.hutool.json.JSONObject;
+import com.ruoyi.zhdd.feign.fallback.FeignDocumentFallback;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @Description: 联旺文件系统
+ * @Author: huangcheng
+ * @Date: 2022/1/12
+ * @Version V1.0
+ */
+@FeignClient(value = "document-system", fallback = FeignDocumentFallback.class)
+public interface FeignDocumentService {
+
+    @PostMapping(value = "/file/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    JSONObject fileUpload(@RequestPart(value = "file") MultipartFile file, @RequestParam(value = "bucketName") String bucketName);
+
+}

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

@@ -32,7 +32,7 @@ public interface FeignUserManageService {
     GatewayUserDetail userDetail(@RequestParam(value = "userId") String userId);
 
     @GetMapping("/user/pageList")
-    GatewayUserPage userPage(@RequestParam(value = "name") String name, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize);
+    GatewayUserPage userPage(@RequestParam(value = "name", required = false) String name, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize);
 
     /**
      * 部门详情

+ 26 - 0
ruoyi-zhdd/src/main/java/com/ruoyi/zhdd/feign/fallback/FeignDocumentFallback.java

@@ -0,0 +1,26 @@
+package com.ruoyi.zhdd.feign.fallback;
+
+import cn.hutool.json.JSONObject;
+import com.ruoyi.zhdd.feign.FeignDocumentService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @Description: TODO
+ * @Author: huangcheng
+ * @Date: 2022/1/12
+ * @Version V1.0
+ */
+@Slf4j
+@Component
+public class FeignDocumentFallback implements FeignDocumentService {
+
+    @Override
+    public JSONObject fileUpload(@RequestPart(value = "file") MultipartFile file, @RequestParam(value = "bucketName") String bucketName) {
+        log.error("文件上传失败");
+        return null;
+    }
+}

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

@@ -17,9 +17,9 @@ public interface IDhService {
      *
      * @return
      */
-    String getToken();
+//    String getToken();
 
-    String authorize();
+    Map<String, String> authorize(String userName, String password, String clientType, String cacheKey);
 
     void tokenKeepalive(String token, int duration, String tokenKey);
 
@@ -33,7 +33,7 @@ public interface IDhService {
      * @param account
      * @return
      */
-    Map<String, Object> getVideoToken(String account, String key);
+//    Map<String, Object> getVideoToken(String account, String key);
 
     void offlineVideoToken(String key);
 
@@ -42,5 +42,5 @@ public interface IDhService {
      *
      * @return
      */
-    Map<String, Object> getTestToken();
+//    Map<String, String> getTestToken();
 }

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

@@ -2,7 +2,6 @@ package com.ruoyi.zhdd.service.impl;
 
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
 import cn.hutool.crypto.SecureUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
@@ -44,76 +43,68 @@ public class DhServiceImpl implements IDhService {
     @Autowired
     private ISysConfigService sysConfigService;
 
-    @Override
-
-    public String getToken() {
-        String token = RedisUtils.getCacheObject(Constants.CACHE_DH_TOKEN);
-        if (token == null) {
-            token = authorize();
-        }
-        return token;
-    }
-
     /**
      * 创建会话
      *
      * @return
      */
-    public String authorize() {
-        // 从大华接口获取token
-        String token = "";
-        String userName = "jtj01";
-        JSONObject jsonOne = new JSONObject();
-        jsonOne.set("userName", userName);
-        jsonOne.set("clientType", "other");
-        String postOne = "";
-        try {
-            postOne = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
-        } catch (Exception e) {
-            log.error("大华接口请求异常:{}", e.getMessage());
-            throw new ServiceException("大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
-        }
-        JSONObject postOneJson = JSONUtil.parseObj(postOne);
-        log.info("大华创建会话的返回结果:{}", postOneJson);
-        if (postOneJson.containsKey("realm")) {
-            String randomKey = postOneJson.getStr("randomKey");
-            String realm = postOneJson.getStr("realm");
-            String encryptType = postOneJson.getStr("encryptType");
-            // 第二次交互
-            String password = "Dahua@4002";
-            String signature = SecureUtil.md5(
-                SecureUtil.md5(userName + ":" + realm + ":" +
-                    SecureUtil.md5(
+    public Map<String, String> authorize(String userName, String password, String clientType, String cacheKey) {
+        Map<String, String> tokenMap = RedisUtils.getCacheMap(cacheKey);
+        if (tokenMap.isEmpty()) {
+            tokenMap = new HashMap<>();
+            JSONObject jsonOne = new JSONObject();
+            jsonOne.set("userName", userName);
+            jsonOne.set("clientType", clientType);
+            String postOne = "";
+            try {
+                postOne = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
+            } catch (Exception e) {
+                log.error("大华接口请求异常:{}\n账号:{}\n密码:{}", e.getMessage(), userName, password);
+                throw new ServiceException("【" + userName + "】大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
+            }
+            JSONObject postOneJson = JSONUtil.parseObj(postOne);
+            if (postOneJson.containsKey("realm")) {
+                String randomKey = postOneJson.getStr("randomKey");
+                String realm = postOneJson.getStr("realm");
+                String encryptType = postOneJson.getStr("encryptType");
+                // 第二次交互
+                String signature = SecureUtil.md5(
+                    SecureUtil.md5(userName + ":" + realm + ":" +
                         SecureUtil.md5(
-                            userName +
-                                SecureUtil.md5(password)))) + ":" + randomKey);
-            jsonOne.set("signature", signature);
-            jsonOne.set("randomKey", randomKey);
-            jsonOne.set("encryptType", encryptType);
-            jsonOne.set("expiredTime", 86400);
-            String postTwo = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
-            JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
-            if (postTwoJson.containsKey("token")) {
-                token = postTwoJson.getStr("token");
-                int duration = postTwoJson.getInt("duration");
-                log.info("大华创建会话的过期时间:{}", duration);
-                if (ObjectUtil.isEmpty(duration)) {
-                    duration = 120;
+                            SecureUtil.md5(
+                                userName +
+                                    SecureUtil.md5(password)))) + ":" + randomKey);
+                jsonOne.set("signature", signature);
+                jsonOne.set("randomKey", randomKey);
+                jsonOne.set("encryptType", encryptType);
+                jsonOne.set("expiredTime", 120);
+                String postTwo = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
+                JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
+                if (postTwoJson.containsKey("token")) {
+                    String tokenStr = postTwoJson.getStr("token");
+                    int duration = postTwoJson.getInt("duration");
+                    String userId = postTwoJson.getStr("userId");
+                    tokenMap.put("userId", userId);
+                    tokenMap.put("token", tokenStr);
+                    tokenMap.put("userName", postTwoJson.getStr("userName"));
+                    log.info("大华创建会话:\n账号:{}\n过期时间:{}秒\nTokenMap:{}", userName, duration, tokenMap);
+                    if (ObjectUtil.isEmpty(duration)) {
+                        duration = 120;
+                    }
+                    // 存入redis缓存
+                    RedisUtils.setCacheMap(cacheKey, tokenMap);
+                    RedisUtils.expire(cacheKey, Convert.toInt(duration), TimeUnit.SECONDS);
+                } else {
+                    log.error("大华=第二次创建会话失败:\n账号:{}\n密码:{}\n返回体:{}", userName, password, postTwoJson);
+                    if ("user is repeated landing".equals(postTwoJson.getStr("message"))) {
+                        // 说明已经登录过,那么退出,重新获取
+                    }
                 }
-                // 存入redis缓存
-                RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN, token, Convert.toInt(duration), TimeUnit.SECONDS);
-//                RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN_REFRESH, token);
             } else {
-                log.error("大华=第二次创建会话失败:{}", postTwoJson);
-                if ("user is repeated landing".equals(postTwoJson.getStr("message"))) {
-                    // 说明已经登录过,那么退出,重新获取
-
-                }
+                log.error("大华=第一次创建会话失败:{}", postOneJson);
             }
-        } else {
-            log.error("大华=第一次创建会话失败:{}", postOneJson);
         }
-        return token;
+        return tokenMap;
     }
 
     /**
@@ -126,13 +117,11 @@ public class DhServiceImpl implements IDhService {
         json.set("token", token);
         json.set("duration", duration);
         String put = HttpRequest.put(keepaliveUrl).header("X-Subject-Token", token).contentType("application/json").timeout(-1).body(json.toString()).execute().body();
-
         if ("".equals(put)) {
             // 存入redis缓存
             RedisUtils.expire(tokenKey, Convert.toInt(duration), TimeUnit.SECONDS);
         } else {
             log.info("保活失败:{}。入参:{}", put, json);
-//            authorize();
         }
     }
 
@@ -165,14 +154,15 @@ public class DhServiceImpl implements IDhService {
     @Override
     public JSONArray querySingleStat() {
         Map<String, Object> param = new HashMap<>();
-        param.put("orgCode", "S4NbecfYB1DGB68AN187Q8");
+        param.put("orgCode", "");
         param.put("isSubOrg", 1);
         param.put("page", 1);
         param.put("pageSize", 3000);
         String get = "";
+        String token = this.authorize("jtj01", "Dahua@4002", "winpc", Constants.CACHE_DH_FUYONG_TOKEN).get("token");
         try {
-            get = HttpRequest.get("http://10.55.134.3:8314/videoService/devicesManager/searchDevices")
-                .header("X-Subject-Token", this.getToken())
+            get = HttpRequest.get("http://10.55.134.30:8314/videoService/devicesManager/searchDevices")
+                .header("X-Subject-Token", token)
                 .form(param)
                 .timeout(-1)
                 .execute().body();
@@ -189,214 +179,185 @@ public class DhServiceImpl implements IDhService {
         return getJson.getJSONArray("results");
     }
 
-    @Override
-    public Map<String, Object> getVideoToken(String account, String key) {
-        Map<String, Object> token = RedisUtils.getCacheMap(key);
-        if (token.isEmpty()) {
-            token = new HashMap<>();
-            // 从大华接口获取token
-            if (StrUtil.isBlank(account)) {
-                account = dhVideoUserName;
-            }
-            JSONObject jsonOne = new JSONObject();
-            jsonOne.set("userName", account);
-            jsonOne.set("clientType", "winpc");
-            String postOne = "";
-            try {
-                postOne = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
-            } catch (Exception e) {
-                log.error("【视频】大华接口请求异常,账号:{}:{}", account, e.getMessage());
-                throw new ServiceException("【视频】大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
-            }
-            JSONObject postOneJson = JSONUtil.parseObj(postOne);
-            log.info("【视频】大华创建会话,,账号:{}的返回结果:{}", account, postOneJson);
-            if (postOneJson.containsKey("realm")) {
-                String randomKey = postOneJson.getStr("randomKey");
-                String realm = postOneJson.getStr("realm");
-                String encryptType = postOneJson.getStr("encryptType");
-                // 第二次交互
-                String password = "Dahua@4002";
-                String signature = SecureUtil.md5(
-                    SecureUtil.md5(account + ":" + realm + ":" +
-                        SecureUtil.md5(
-                            SecureUtil.md5(
-                                account +
-                                    SecureUtil.md5(password)))) + ":" + randomKey);
-                jsonOne.set("signature", signature);
-                jsonOne.set("randomKey", randomKey);
-                jsonOne.set("encryptType", encryptType);
-                jsonOne.set("pid", 2548);
-                jsonOne.set("expiredTime", 120);
-                String postTwo = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
-                JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
-                if (postTwoJson.containsKey("token")) {
-                    String tokenStr = postTwoJson.getStr("token");
-                    int duration = postTwoJson.getInt("duration");
-                    String userId = postTwoJson.getStr("userId");
-                    token.put("userId", userId);
-                    token.put("token", tokenStr);
-                    token.put("userName", postTwoJson.getStr("userName"));
-                    log.info("【视频】大华创建会话,账号:{}的过期时间:{}", account, duration);
-                    log.info("【视频】大华创建会话,账号:{}的Token:{}", account, token);
-                    if (ObjectUtil.isEmpty(duration)) {
-                        duration = 120;
-                    }
-                    // 存入redis缓存
-                    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"))) {
-                        // 说明已经登录过,那么退出,重新获取
-                    }
-                }
-            } else {
-                log.error("【视频】大华,账号:{}第一次创建会话失败:{}", account, postOneJson);
-            }
-        }
-        return token;
-    }
+//    @Override
+//    public Map<String, Object> getVideoToken(String account, String key) {
+//        Map<String, Object> token = RedisUtils.getCacheMap(key);
+//        if (token.isEmpty()) {
+//            token = new HashMap<>();
+//            // 从大华接口获取token
+//            if (StrUtil.isBlank(account)) {
+//                account = dhVideoUserName;
+//            }
+//            JSONObject jsonOne = new JSONObject();
+//            jsonOne.set("userName", account);
+//            jsonOne.set("clientType", "winpc");
+//            String postOne = "";
+//            try {
+//                postOne = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
+//            } catch (Exception e) {
+//                log.error("【视频】大华接口请求异常,账号:{}:{}", account, e.getMessage());
+//                throw new ServiceException("【视频】大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
+//            }
+//            JSONObject postOneJson = JSONUtil.parseObj(postOne);
+//            log.info("【视频】大华创建会话,,账号:{}的返回结果:{}", account, postOneJson);
+//            if (postOneJson.containsKey("realm")) {
+//                String randomKey = postOneJson.getStr("randomKey");
+//                String realm = postOneJson.getStr("realm");
+//                String encryptType = postOneJson.getStr("encryptType");
+//                // 第二次交互
+//                String password = "Dahua@4002";
+//                String signature = SecureUtil.md5(
+//                    SecureUtil.md5(account + ":" + realm + ":" +
+//                        SecureUtil.md5(
+//                            SecureUtil.md5(
+//                                account +
+//                                    SecureUtil.md5(password)))) + ":" + randomKey);
+//                jsonOne.set("signature", signature);
+//                jsonOne.set("randomKey", randomKey);
+//                jsonOne.set("encryptType", encryptType);
+//                jsonOne.set("pid", 2548);
+//                jsonOne.set("expiredTime", 120);
+//                String postTwo = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
+//                JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
+//                if (postTwoJson.containsKey("token")) {
+//                    String tokenStr = postTwoJson.getStr("token");
+//                    int duration = postTwoJson.getInt("duration");
+//                    String userId = postTwoJson.getStr("userId");
+//                    token.put("userId", userId);
+//                    token.put("token", tokenStr);
+//                    token.put("userName", postTwoJson.getStr("userName"));
+//                    log.info("【视频】大华创建会话,账号:{}的过期时间:{}", account, duration);
+//                    log.info("【视频】大华创建会话,账号:{}的Token:{}", account, token);
+//                    if (ObjectUtil.isEmpty(duration)) {
+//                        duration = 120;
+//                    }
+//                    // 存入redis缓存
+//                    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"))) {
+//                        // 说明已经登录过,那么退出,重新获取
+//                    }
+//                }
+//            } else {
+//                log.error("【视频】大华,账号:{}第一次创建会话失败:{}", account, postOneJson);
+//            }
+//        }
+//        return token;
+//    }
 
     @Override
     public void offlineVideoToken(String key) {
         RedisUtils.deleteObject(key);
     }
 
-    @Override
-    public Map<String, Object> getTestToken() {
-        Map<String, Object> token = RedisUtils.getCacheMap(Constants.CACHE_DH_TEST_TOKEN);
-        if (token.isEmpty()) {
-            token = new HashMap<>();
-            // 从大华接口获取token
-            JSONObject jsonOne = new JSONObject();
-            String account = "system";
-            jsonOne.set("userName", account);
-            jsonOne.set("clientType", "winpc");
-            String postOne = "";
-            try {
-                postOne = HttpUtil.post("http://10.55.134.30:8314/videoService/accounts/authorize", jsonOne.toString());
-            } catch (Exception e) {
-                log.error("【视频测试】大华接口请求异常,账号:{}:{}", account, e.getMessage());
-                throw new ServiceException("【视频测试】大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
-            }
-            JSONObject postOneJson = JSONUtil.parseObj(postOne);
-            log.info("【视频测试】大华创建会话,,账号:{}的返回结果:{}", account, postOneJson);
-            if (postOneJson.containsKey("realm")) {
-                String randomKey = postOneJson.getStr("randomKey");
-                String realm = postOneJson.getStr("realm");
-                String encryptType = postOneJson.getStr("encryptType");
-                // 第二次交互
-                String password = "Admin123";
-                String signature = SecureUtil.md5(
-                    SecureUtil.md5(account + ":" + realm + ":" +
-                        SecureUtil.md5(
-                            SecureUtil.md5(
-                                account +
-                                    SecureUtil.md5(password)))) + ":" + randomKey);
-                jsonOne.set("signature", signature);
-                jsonOne.set("randomKey", randomKey);
-                jsonOne.set("encryptType", encryptType);
-                jsonOne.set("pid", 2548);
-                jsonOne.set("expiredTime", 120);
-                String postTwo = HttpUtil.post("http://10.55.134.30:8314/videoService/accounts/authorize", jsonOne.toString());
-                JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
-                if (postTwoJson.containsKey("token")) {
-                    String tokenStr = postTwoJson.getStr("token");
-                    int duration = postTwoJson.getInt("duration");
-                    String userId = postTwoJson.getStr("userId");
-                    token.put("userId", userId);
-                    token.put("token", tokenStr);
-                    token.put("userName", postTwoJson.getStr("userName"));
-                    log.info("【视频测试】大华创建会话,账号:{}的过期时间:{}", account, duration);
-                    log.info("【视频测试】大华创建会话,账号:{}的Token:{}", account, token);
-                    if (ObjectUtil.isEmpty(duration)) {
-                        duration = 120;
-                    }
-                    // 存入redis缓存
-                    RedisUtils.setCacheMap(Constants.CACHE_DH_TEST_TOKEN, token);
-                    RedisUtils.expire(Constants.CACHE_DH_TEST_TOKEN, Convert.toInt(duration), TimeUnit.SECONDS);
-                } else {
-                    log.error("【视频测试】大华,账号:{}第二次创建会话失败:{}", account, postTwoJson);
-                    if ("user is repeated landing".equals(postTwoJson.getStr("message"))) {
-                        // 说明已经登录过,那么退出,重新获取
-                    }
-                }
-            } else {
-                log.error("【视频测试】大华,账号:{}第一次创建会话失败:{}", account, postOneJson);
-            }
-        }
-        return token;
-    }
+//    @Override
+//    public Map<String, String> getTestToken() {
+//        Map<String, String> token = RedisUtils.getCacheMap(Constants.CACHE_DH_TEST_TOKEN);
+//        if (token.isEmpty()) {
+//            token = new HashMap<>();
+//            // 从大华接口获取token
+//            JSONObject jsonOne = new JSONObject();
+//            String account = "huashe";
+//            jsonOne.set("userName", account);
+//            jsonOne.set("clientType", "winpc");
+//            String postOne = "";
+//            try {
+//                postOne = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
+//            } catch (Exception e) {
+//                log.error("【视频测试】大华接口请求异常,账号:{}:{}", account, e.getMessage());
+//                throw new ServiceException("【视频测试】大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
+//            }
+//            JSONObject postOneJson = JSONUtil.parseObj(postOne);
+//            log.info("【视频测试】大华创建会话,,账号:{}的返回结果:{}", account, postOneJson);
+//            if (postOneJson.containsKey("realm")) {
+//                String randomKey = postOneJson.getStr("randomKey");
+//                String realm = postOneJson.getStr("realm");
+//                String encryptType = postOneJson.getStr("encryptType");
+//                // 第二次交互
+//                String password = "Admin123";
+//                String signature = SecureUtil.md5(
+//                    SecureUtil.md5(account + ":" + realm + ":" +
+//                        SecureUtil.md5(
+//                            SecureUtil.md5(
+//                                account +
+//                                    SecureUtil.md5(password)))) + ":" + randomKey);
+//                jsonOne.set("signature", signature);
+//                jsonOne.set("randomKey", randomKey);
+//                jsonOne.set("encryptType", encryptType);
+//                jsonOne.set("pid", 2548);
+//                jsonOne.set("expiredTime", 120);
+//                String postTwo = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
+//                JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
+//                if (postTwoJson.containsKey("token")) {
+//                    String tokenStr = postTwoJson.getStr("token");
+//                    int duration = postTwoJson.getInt("duration");
+//                    String userId = postTwoJson.getStr("userId");
+//                    token.put("userId", userId);
+//                    token.put("token", tokenStr);
+//                    token.put("userName", postTwoJson.getStr("userName"));
+//                    log.info("【视频测试】大华创建会话,账号:{}的过期时间:{}", account, duration);
+//                    log.info("【视频测试】大华创建会话,账号:{}的Token:{}", account, token);
+//                    if (ObjectUtil.isEmpty(duration)) {
+//                        duration = 120;
+//                    }
+//                    // 存入redis缓存
+//                    RedisUtils.setCacheMap(Constants.CACHE_DH_TEST_TOKEN, token);
+//                    RedisUtils.expire(Constants.CACHE_DH_TEST_TOKEN, Convert.toInt(duration), TimeUnit.SECONDS);
+//                } else {
+//                    log.error("【视频测试】大华,账号:{}第二次创建会话失败:{}", account, postTwoJson);
+//                    if ("user is repeated landing".equals(postTwoJson.getStr("message"))) {
+//                        // 说明已经登录过,那么退出,重新获取
+//                    }
+//                }
+//            } else {
+//                log.error("【视频测试】大华,账号:{}第一次创建会话失败:{}", account, postOneJson);
+//            }
+//        }
+//        return token;
+//    }
 
+    /**
+     * 组装设备树数据
+     *
+     * @param param
+     * @return
+     */
     private JSONArray getList(Map<String, Object> param) {
         param.put("nodeType", 1);
         param.put("typeCode", "01;0;ALL;ALL");
         param.put("page", 1);
         param.put("pageSize", 3000);
         String get = "";
+        String token = this.authorize("jtj01", "Dahua@4002", "winpc", Constants.CACHE_DH_FUYONG_TOKEN).get("token");
         try {
             get = HttpRequest.get(dhDeviceTreeUrl)
-                .header("X-Subject-Token", this.getToken())
+                .header("X-Subject-Token", token)
                 .form(param)
                 .timeout(-1)
                 .execute().body();
         } catch (Exception e) {
+            log.info("请求的参数:{}。token={}", dhDeviceTreeUrl, token);
             log.error("大华接口2请求异常:{}", e.getMessage());
-            throw new ServiceException("大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
+            throw new ServiceException("【jtj01】大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
         }
+        log.info("请求的参数:{}。token={}", dhDeviceTreeUrl, token);
+        log.info("设备数返回数据:{}", get);
         JSONObject getJson = JSONUtil.parseObj(get);
         if (getJson.containsKey("code")) {
             // 说明有错误
             log.error("获取设备树出错:{}", getJson);
             if (401 == getJson.getInt("code")) {
-                RedisUtils.deleteObject(Constants.CACHE_DH_TOKEN);
+                RedisUtils.deleteObject(Constants.CACHE_DH_FUYONG_TOKEN);
             }
-            throw new ServiceException("调用大华融合通信平台接口创建会话出错,错误:" + getJson.getStr("message"));
+            throw new ServiceException("【jtj01】调用大华融合通信平台接口创建会话出错,错误:" + getJson.getStr("message"));
         }
         return getJson.getJSONArray("results");
     }
 
     public static void main(String[] args) {
-        /*String token = "";
-        String userName = "shujuceshi";
-        JSONObject jsonOne = new JSONObject();
-        jsonOne.set("userName", userName);
-        jsonOne.set("clientType", "other");
-        String postOne = HttpUtil.post("http://10.211.55.3:6699/videoService/accounts/authorize", jsonOne.toString());
-        JSONObject postOneJson = JSONUtil.parseObj(postOne);
-        if (postOneJson.containsKey("realm")) {
-            String randomKey = postOneJson.getStr("randomKey");
-            String realm = postOneJson.getStr("realm");
-            String encryptType = postOneJson.getStr("encryptType");
-            // 第二次交互
-            String password = "Admin123";
-            String signature = SecureUtil.md5(
-                SecureUtil.md5(userName + ":" + realm + ":" +
-                    SecureUtil.md5(
-                        SecureUtil.md5(
-                            userName +
-                                SecureUtil.md5(password)))) + ":" + randomKey);
-            jsonOne.set("signature", signature);
-            jsonOne.set("randomKey", randomKey);
-            jsonOne.set("encryptType", encryptType);
-            String postTwo = HttpUtil.post("http://10.211.55.3:6699/videoService/accounts/authorize", jsonOne.toString());
-            JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
-            if (postTwoJson.containsKey("token")) {
-                token = postTwoJson.getStr("token");
-                // 存入redis缓存
-//                RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN, token, 120, TimeUnit.SECONDS);
-//                RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN_REFRESH, token);
-            } else {
-                log.error("大华=第二次创建会话失败:{}", postTwoJson);
-                if ("user is repeated landing".equals(postTwoJson.getStr("message"))) {
-                    // 说明已经登录过,那么退出,重新获取
 
-                }
-            }
-        } else {
-            log.error("大华=第一次创建会话失败:{}", postOneJson);
-        }
-        System.out.println(token);*/
     }
 
 }