From 0d514ca5405b42b3d31e2e68d7a1e9e834cae706 Mon Sep 17 00:00:00 2001
From: wangwh <2397901735@qq.com>
Date: Fri, 25 Oct 2024 09:24:34 +0800
Subject: [PATCH] fix:调试待办工单
---
dyh-service/dyh-sys/src/main/java/cn/huge/module/grid/service/GridUserService.java | 154 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 145 insertions(+), 9 deletions(-)
diff --git a/dyh-service/dyh-sys/src/main/java/cn/huge/module/grid/service/GridUserService.java b/dyh-service/dyh-sys/src/main/java/cn/huge/module/grid/service/GridUserService.java
index 5bc1fc6..2ecadc2 100644
--- a/dyh-service/dyh-sys/src/main/java/cn/huge/module/grid/service/GridUserService.java
+++ b/dyh-service/dyh-sys/src/main/java/cn/huge/module/grid/service/GridUserService.java
@@ -2,19 +2,32 @@
import cn.huge.base.common.bo.R;
import cn.huge.base.common.utils.HttpClientUtils;
+import cn.huge.base.common.utils.SpringContextUtil;
+import cn.huge.module.grid.domain.dto.GridSysRoleDTO;
import cn.huge.module.grid.domain.vo.*;
+import cn.huge.module.sys.dto.GridRoleMenuDTO;
+import cn.huge.module.sys.dto.GridUserRoleDTO;
+import cn.huge.module.sys.vo.GridOrgUsersVo;
+import cn.huge.module.sys.vo.GridRoleMenuVo;
+import cn.huge.module.sys.vo.GridUserRoleVo;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import java.util.HashMap;
-import java.util.UUID;
+import java.util.*;
@Slf4j
@Service
public class GridUserService {
- private String gridUrl = "http://219.137.166.84:8061";
+ @Value("${grid.url:http://219.137.166.84:8061}")
+ private String gridUrl;
+ @Value("${grid.username:mtxt0011}")
+ private String userName;
+ @Value("${grid.password:aek8CdcaM}")
+ private String passWord;
private String testUrl = "http://183.2.142.46:9007";
public R<GridUserVo> getUserInfo(GridTokenVo gridTokenVo) {
@@ -24,10 +37,15 @@
requestVo.setHeadVo(headVo);
requestVo.setBodyVo(gridTokenVo);
try {
- log.info("xsdobject:{}",JSON.toJSONString(requestVo));
-// log.info("xsdurl:{}",gridUrl + "/sys/getUserByToken");
- log.info("xsdurl:{}",testUrl + "/sys/getUserByToken");
- s = HttpClientUtils.httpPostRaw(testUrl + "/api/thrid/grid/user/get-userinfo", JSON.toJSONString(requestVo), new HashMap<>(), "utf-8");
+// log.info("xsdobject:{}",JSON.toJSONString(requestVo));
+ // 开发环境
+ if (SpringContextUtil.checkDev()) {
+ log.info("xsdurl:{}",testUrl + "/sys/getUserByToken");
+ s = HttpClientUtils.httpPostRaw(testUrl + "/sys/getUserByToken", JSON.toJSONString(requestVo), new HashMap<>(), "utf-8");
+ }else {
+ log.info("xsdurl:{}",gridUrl + "/sys/getUserByToken");
+ s = HttpClientUtils.httpPostRaw(gridUrl + "/sys/getUserByToken", JSON.toJSONString(requestVo), new HashMap<>(), "utf-8");
+ }
log.info("xsd:{}",s);
} catch (Exception e) {
log.info("xsderror:{}",e.getLocalizedMessage());
@@ -37,12 +55,130 @@
return R.ok(gridUserVo);
}
+ public R<List<GridUserRoleDTO>> getUserRoleList(GridUserRoleVo gridUserRoleVo) {
+ String s = null;
+ HeadVo headVo = initHeadVo();
+ GridUserRoleRequestVo requestVo = new GridUserRoleRequestVo();
+ requestVo.setHeadVo(headVo);
+ requestVo.setBodyVo(gridUserRoleVo);
+ try {
+// log.info("xsdobject:{}",JSON.toJSONString(requestVo));
+ log.info("xsdurl:{}",gridUrl + "/sys/getOrgRole");
+// log.info("xsdurl:{}",testUrl + "/sys/getUserByToken");
+ s = HttpClientUtils.httpPostRaw(gridUrl + "/sys/getOrgRole", JSON.toJSONString(requestVo), new HashMap<>(), "utf-8");
+ log.info("xsd:{}",s);
+ } catch (Exception e) {
+ log.info("xsderror:{}",e.getLocalizedMessage());
+ throw new RuntimeException(e);
+ }
+ JSONArray data = JSONObject.parseObject(s).getJSONArray("data");
+ List<GridUserRoleDTO> gridUserRoleDTOList = data.toJavaList(GridUserRoleDTO.class);
+ return R.ok(gridUserRoleDTOList);
+ }
+
+
+
public HeadVo initHeadVo() {
HeadVo headVo = new HeadVo();
- headVo.setUsername("mtxt001");
- headVo.setPassword("aek8CdcaM");
+ headVo.setUsername(userName);
+ headVo.setPassword(passWord);
headVo.setRequestId(UUID.randomUUID().toString());
headVo.setSource("string");
return headVo;
}
+
+ public R<GridSysRoleDTO> getSysRoleList(GridOrgVo gridOrgVo) {
+ HeadVo headVo = initHeadVo();
+ GridOrgRequestVo requestVo = new GridOrgRequestVo();
+ requestVo.setHeadVo(headVo);
+ requestVo.setBodyVo(gridOrgVo);
+ log.info("xsd:{}", JSON.toJSONString(requestVo));
+ log.info("xsd:{}", gridUrl + "/sys/getRoleList");
+ String s = null;
+ try {
+ s = HttpClientUtils.httpPostRaw(gridUrl + "/sys/getRoleList", JSON.toJSONString(requestVo), new HashMap<>(), "utf-8");
+ } catch (Exception e) {
+ log.info("xsderror:{}", e);
+ throw new RuntimeException(e);
+ }
+ log.info("xsd:{}", s);
+ JSONObject object = JSONObject.parseObject(s);
+ if (object.getInteger("code") != null && object.getInteger("code") == 0) {
+ GridSysRoleDTO data = object.getObject("data", GridSysRoleDTO.class);
+ return R.ok(data);
+ } else {
+ return R.fail("获取企业信息失败");
+ }
+ }
+
+ public R<List<GridRoleMenuDTO>> getRoleMenu(GridRoleMenuVo gridRoleMenuVo) {
+ String s = null;
+ HeadVo headVo = initHeadVo();
+ GridRoleMenuRequestVo requestVo = new GridRoleMenuRequestVo();
+ requestVo.setHeadVo(headVo);
+ requestVo.setBodyVo(gridRoleMenuVo);
+ try {
+// log.info("xsdobject:{}",JSON.toJSONString(requestVo));
+ log.info("xsdurl:{}",gridUrl + "/sys/getUserMenuRecur");
+// log.info("xsdurl:{}",testUrl + "/sys/getUserByToken");
+ s = HttpClientUtils.httpPostRaw(gridUrl + "/sys/getUserMenuRecur", JSON.toJSONString(requestVo), new HashMap<>(), "utf-8");
+ log.info("xsd:{}",s);
+ } catch (Exception e) {
+ log.info("xsderror:{}",e.getLocalizedMessage());
+ throw new RuntimeException(e);
+ }
+ JSONArray data = JSONObject.parseObject(s).getJSONArray("data");
+ List<GridRoleMenuDTO> gridRoleMenuDTOList = data.toJavaList(GridRoleMenuDTO.class);
+ return R.ok(gridRoleMenuDTOList);
+ }
+
+ public R<String> initNewUsers(GridUserRoleVo gridUserRoleVo) {
+ //根据用户id获取用户信息
+
+ //拿到用户机构信息
+
+ //拿到用户角色菜单权限信息
+
+ //如果全部菜单权限,分配管理员角色;如果部分菜单权限,分配纠纷化解员角色
+
+
+ //初始化完成用户信息,返回给前端登录
+ return R.fail();
+ }
+
+ public R<List<GridUserVo>> getUserListByOrg(GridOrgUsersVo gridOrgUsersVo) {
+ String s = null;
+ HeadVo headVo = initHeadVo();
+ GridOrgUserRequestVo requestVo = new GridOrgUserRequestVo();
+ requestVo.setHeadVo(headVo);
+ List<String> roleIds = new ArrayList<>();
+ roleIds.add("43fc22e6-7276-11ef-a6d1-005056820c5f");
+ roleIds.add("442be8dd-7276-11ef-a6d1-005056820c5f");
+ roleIds.add("679b1846-71c5-11ef-a6d1-005056820c5f");
+ roleIds.add("67affc74-71c5-11ef-a6d1-005056820c5f");
+ gridOrgUsersVo.setRoleIds(roleIds);
+ requestVo.setBodyVo(gridOrgUsersVo);
+ try {
+// log.info("xsdobject:{}",JSON.toJSONString(requestVo));
+ // 开发环境
+ if (SpringContextUtil.checkDev()) {
+ log.info("xsdurl:{}",testUrl + "/api/thrid/grid/user/get-org-users"+JSON.toJSONString(gridOrgUsersVo));
+ Map<String, String> header = new HashMap<>();
+ String authorizationValue = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJIVUdFSU5GTyIsImV4cCI6MTcyOTcwNzA3NywiaWF0IjoxNzI5NjYzODc3LCJ1c2VySWQiOiJkNjY2ZTUzZGMwMjU0NjNkYTllZTkwOTUyNjk5MTljNCYyMl8wMDAyNC0zIn0.a0TfTkKKDQpUJRyGUSVnfghIWvGy5hrTzxX26SpW7kA";
+ header.put("Authorization", authorizationValue);
+ s = HttpClientUtils.httpPostRaw(testUrl + "/api/thrid/grid/user/get-org-users", JSON.toJSONString(gridOrgUsersVo), new HashMap<>(), "utf-8");
+ }else {
+ log.info("xsdurl:{}",gridUrl + "/sys/user/getUserListByOrg");
+ s = HttpClientUtils.httpPostRaw(gridUrl + "/sys/user/getUserListByOrg", JSON.toJSONString(requestVo), new HashMap<>(), "utf-8");
+ }
+ log.info("xsd:{}",s);
+ } catch (Exception e) {
+ log.info("xsderror:{}",e.getLocalizedMessage());
+ throw new RuntimeException(e);
+ }
+ JSONArray data = JSONObject.parseObject(s).getJSONArray("data");
+ List<GridUserVo> gridUserVos = data.toJavaList(GridUserVo.class);
+ return R.ok(gridUserVos);
+
+ }
}
--
Gitblit v1.8.0