From 054a15a6f0fe2948a45a24fc3278127ce72c2382 Mon Sep 17 00:00:00 2001 From: liuguijing <123456> Date: Tue, 27 Feb 2024 15:07:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E7=9A=84=E6=A0=91=E7=8A=B6?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +- .../controller/RoleController.java | 14 +- xymanager_common/pom.xml | 8 +- .../model/PermissionDyLineTreeListModel.java | 88 +++++++++++ .../util/http/OkHttpUtils.java | 140 ++++++++--------- xymanager_framework/pom.xml | 8 +- .../impl/CacheServiceImpl.java | 148 ------------------ .../impl/RoleServiceImpl.java | 64 +++++++- .../service/RoleService.java | 4 +- 9 files changed, 245 insertions(+), 239 deletions(-) create mode 100644 xymanager_common/src/main/java/com/shxy/xymanager_common/model/PermissionDyLineTreeListModel.java diff --git a/pom.xml b/pom.xml index 5d3a5c9..38db8bc 100644 --- a/pom.xml +++ b/pom.xml @@ -151,11 +151,11 @@ - - io.github.admin4j - http - 0.4.0 - + + + + + diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/RoleController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/RoleController.java index 0926b49..3821cc7 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/RoleController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/RoleController.java @@ -2,8 +2,12 @@ package com.shxy.xymanager_admin.controller; import com.shxy.xymanager_common.base.BaseController; import com.shxy.xymanager_common.base.ResponseReult; +import com.shxy.xymanager_common.bean.ServiceBody; +import com.shxy.xymanager_common.bean.ServiceStatus; import com.shxy.xymanager_common.entity.TbPermission; import com.shxy.xymanager_common.entity.TbRole; +import com.shxy.xymanager_common.model.DyLineTreeListModel; +import com.shxy.xymanager_common.model.PermissionDyLineTreeListModel; import com.shxy.xymanager_common.model.PermissionModel; import com.shxy.xymanager_service.service.RoleService; @@ -73,9 +77,13 @@ public class RoleController extends BaseController { @GetMapping("getPermissionTree") @ApiOperation("查询权限树状图") - public ResponseReult> getPermissionTree() throws Exception { - List result = service.getPermissionTree(); - return ResponseReult.success(result); + public ResponseReult getPermissionTree() throws Exception { + ServiceBody serviceBody = service.getPermissionTree(); + if (serviceBody.getCode() == ServiceStatus.SUCCESS) { + return ResponseReult.success(serviceBody.getData()); + } else { + return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg()); + } } } diff --git a/xymanager_common/pom.xml b/xymanager_common/pom.xml index f3f627c..4e3d63b 100644 --- a/xymanager_common/pom.xml +++ b/xymanager_common/pom.xml @@ -139,10 +139,10 @@ - - io.github.admin4j - http - + + + + diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/PermissionDyLineTreeListModel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/PermissionDyLineTreeListModel.java new file mode 100644 index 0000000..cbe3d9b --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/PermissionDyLineTreeListModel.java @@ -0,0 +1,88 @@ +package com.shxy.xymanager_common.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 权限电压线路树状图列表 + */ +@Data +@ApiModel(value = "权限电压线路树状图列表", description = "权限电压线路树状图列表") +public class PermissionDyLineTreeListModel implements Serializable { + + @ApiModelProperty(value = "电压列表", example = "[]") + private List list; + + @Data + public static class DyListBean { + @ApiModelProperty(value = "电压编号", example = "123456") + private Integer id; + + @ApiModelProperty(value = "电压名称", example = "AAAA") + private String name; + + @ApiModelProperty(value = "电压大小", example = "AAAA") + private Integer dyValue; + + @ApiModelProperty(value = "线路列表", example = "[]") + private List list; + } + + @Data + public static class LineBean { + + @ApiModelProperty(value = "线路编号", example = "123456") + private Integer id; + + @ApiModelProperty(value = "线路名称", example = "AAAA") + private String name; + + @ApiModelProperty(value = "单位", example = "123456") + private String bsManufacturer; + + @ApiModelProperty(value = "装置信息", example = "123456") + private List list; + + } + + @Data + public static class TerminalBean { + + @ApiModelProperty(value = "装置编号", example = "123456") + private Integer id; + + @ApiModelProperty(value = "杆塔编号", example = "123456") + private Integer towerid; + + @ApiModelProperty(value = "图像监测装置 ID(17 位编码)", example = "12345678") + private String cmdid; + + @ApiModelProperty(value = "装置名称", example = "名称名称") + private String equipname; + + @ApiModelProperty(value = "杆塔显示名", example = "名称名称") + private String name; + + @ApiModelProperty(value = "杆塔地址", example = "名称名称") + private String address; + + @ApiModelProperty(value = "规约", example = "规约") + private Integer protocol; + + @ApiModelProperty(value = "装置显示名", example = "名称名称") + private String displayname; + + @ApiModelProperty(value = "装置型号", example = "型号型号") + private String model; + + + + + + + } +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/util/http/OkHttpUtils.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/util/http/OkHttpUtils.java index 70c2adf..7377ca8 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/util/http/OkHttpUtils.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/util/http/OkHttpUtils.java @@ -1,70 +1,70 @@ -package com.shxy.xymanager_common.util.http; -import com.alibaba.fastjson.JSONObject; -import io.github.admin4j.http.HttpRequest; -import io.github.admin4j.http.core.Pair; -import io.github.admin4j.http.util.HttpUtil; -import okhttp3.Response; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class OkHttpUtils { - - public static JSONObject get(String url, Map queryParams) throws IOException { - Response response = HttpUtil.get(url, queryParams); - return JSONObject.parseObject(response.body().string()); - } - - public static JSONObject get(String url, Map queryParams, Map headers) throws IOException { - HttpRequest httpRequest = HttpRequest.get(url); - setParams(queryParams, httpRequest); - Response response = httpRequest.queryParams().headers(headers).execute(); - return JSONObject.parseObject(response.body().string()); - } - - public static JSONObject post(String url, String json) throws IOException { - Response response = HttpUtil.post(url, json); - assert response.body() != null; - return JSONObject.parseObject(response.body().string()); - } - - public static JSONObject postForm(String url, Map formParams) throws IOException { - Response response = HttpUtil.postForm(url, formParams); - assert response.body() != null; - return JSONObject.parseObject(response.body().string()); - } - - public static JSONObject post(String url, String json, Map headers) throws IOException { - HttpRequest httpRequest = HttpRequest.post(url); - httpRequest.setBody(json); - Response response = httpRequest.headers(headers).execute(); - return JSONObject.parseObject(response.body().string()); - } - - private static void setParams(Map queryParams, HttpRequest httpRequest) { - List pairs = new ArrayList<>(queryParams.size()); - queryParams.forEach((x, y) -> pairs.add(Pair.of(x, y))); - if (pairs.size() > 0) { - pairs.forEach(httpRequest::queryParams); - } - } - - private static JSONObject upload() throws IOException { - File file = new File("C:\\Users\\andanyang\\Downloads\\Sql.txt"); - Map formParams = new HashMap<>(); - formParams.put("key", "test"); - formParams.put("file", file); - formParams.put("token", "WXyUseb-D4sCum-EvTIDYL-mEehwDtrSBg-Zca7t:qgOcR2gUoKmxt-VnsNb657Oatzo=:eyJzY29wZSI6InpoYW56aGkiLCJkZWFkbGluZSI6MTY2NTMwNzUxNH0="); - Response response = HttpUtil.upload("https://upload.qiniup.com/", formParams); - return JSONObject.parseObject(response.body().string()); - } - - private static void download() throws IOException { - HttpUtil.down("https://gitee.com/admin4j/common-http","path/"); - } - -} \ No newline at end of file +//package com.shxy.xymanager_common.util.http; +//import com.alibaba.fastjson.JSONObject; +//import io.github.admin4j.http.HttpRequest; +//import io.github.admin4j.http.core.Pair; +//import io.github.admin4j.http.util.HttpUtil; +//import okhttp3.Response; +// +//import java.io.File; +//import java.io.IOException; +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//public class OkHttpUtils { +// +// public static JSONObject get(String url, Map queryParams) throws IOException { +// Response response = HttpUtil.get(url, queryParams); +// return JSONObject.parseObject(response.body().string()); +// } +// +// public static JSONObject get(String url, Map queryParams, Map headers) throws IOException { +// HttpRequest httpRequest = HttpRequest.get(url); +// setParams(queryParams, httpRequest); +// Response response = httpRequest.queryParams().headers(headers).execute(); +// return JSONObject.parseObject(response.body().string()); +// } +// +// public static JSONObject post(String url, String json) throws IOException { +// Response response = HttpUtil.post(url, json); +// assert response.body() != null; +// return JSONObject.parseObject(response.body().string()); +// } +// +// public static JSONObject postForm(String url, Map formParams) throws IOException { +// Response response = HttpUtil.postForm(url, formParams); +// assert response.body() != null; +// return JSONObject.parseObject(response.body().string()); +// } +// +// public static JSONObject post(String url, String json, Map headers) throws IOException { +// HttpRequest httpRequest = HttpRequest.post(url); +// httpRequest.setBody(json); +// Response response = httpRequest.headers(headers).execute(); +// return JSONObject.parseObject(response.body().string()); +// } +// +// private static void setParams(Map queryParams, HttpRequest httpRequest) { +// List pairs = new ArrayList<>(queryParams.size()); +// queryParams.forEach((x, y) -> pairs.add(Pair.of(x, y))); +// if (pairs.size() > 0) { +// pairs.forEach(httpRequest::queryParams); +// } +// } +// +// private static JSONObject upload() throws IOException { +// File file = new File("C:\\Users\\andanyang\\Downloads\\Sql.txt"); +// Map formParams = new HashMap<>(); +// formParams.put("key", "test"); +// formParams.put("file", file); +// formParams.put("token", "WXyUseb-D4sCum-EvTIDYL-mEehwDtrSBg-Zca7t:qgOcR2gUoKmxt-VnsNb657Oatzo=:eyJzY29wZSI6InpoYW56aGkiLCJkZWFkbGluZSI6MTY2NTMwNzUxNH0="); +// Response response = HttpUtil.upload("https://upload.qiniup.com/", formParams); +// return JSONObject.parseObject(response.body().string()); +// } +// +// private static void download() throws IOException { +// HttpUtil.down("https://gitee.com/admin4j/common-http","path/"); +// } +// +//} \ No newline at end of file diff --git a/xymanager_framework/pom.xml b/xymanager_framework/pom.xml index c1ea8ce..f4de349 100644 --- a/xymanager_framework/pom.xml +++ b/xymanager_framework/pom.xml @@ -40,10 +40,10 @@ ch.qos.logback logback-classic - - org.springframework.boot - spring-boot-starter-tomcat - + + + + diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/CacheServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/CacheServiceImpl.java index f74265c..7245c58 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/CacheServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/CacheServiceImpl.java @@ -49,154 +49,6 @@ public class CacheServiceImpl implements CacheService { @Autowired ProtocolsDao protocolsDao; -// @Override -// @Cacheable(value = "globalParams", key = "#param") -// public GlobalParams getGlobalParams(String param) { -// System.out.println("测试缓存:" + param); -// return globalParamsDao.selectByParam(param); -// } -// -// @Override -// @CachePut(value = "globalParams", key = "#result.paramName") -// public GlobalParams updateGlobalParams(GlobalParams record) { -// globalParamsDao.updateByParamName(record, new Date()); -// return record; -// -// } -// -// @Override -// @Cacheable(value = "linesMap", key = "#id") -// public Lines getLine(Integer id) { -// Lines lines = linesDao.selectByPrimaryKey(id); -// return lines; -// } -// -// @Override -// @CacheEvict(value = "linesMap", allEntries = true) -// public Integer deleteLine(List lines) { -// int i = linesDao.deleteById(lines, CommonStatus.DELETE.value(), new Date()); -// return i; -// } -// -// @Override -// @CachePut(value = "linesMap", key = "#result.id") -// public Lines updateLine(Lines lines) { -// int i = linesDao.updateByPrimaryKeySelective(lines, new Date()); -// if (i == 0) { -// return null; -// } else { -// return lines; -// } -// } -// -// @Override -// @Cacheable(value = "towerMap", key = "#id") -// public TowerDto getTower(Integer id) { -// TowerDto dto = towerDao.getInfoByPrimaryKey(id, CommonStatus.EFFECTIVE.value()); -// return dto; -// } -// -// @Override -// @CacheEvict(value = "towerMap", allEntries = true) -// public Integer deleteTower(List list) { -// int i = towerDao.deleteById(list, CommonStatus.DELETE.value(), new Date()); -// return i; -// } -// -// @Override -// @CachePut(value = "towerMap", key = "#result.id") -// public Towers updateTower(Towers towers) { -// int i = towerDao.updateByPrimaryKeySelective(towers, new Date()); -// if (i == 0) { -// return null; -// } else { -// return towers; -// } -// } -// -// @Override -// @Cacheable(value = "terminalMap", key = "#id") -// public Terminals getTerminal(Integer id) { -// Terminals terminals = terminalsDao.selectById(id, CommonStatus.EFFECTIVE.value()); -// return terminals; -// } -// -// @Override -// @CacheEvict(value = "terminalMap", allEntries = true) -// public Integer deleteTerminal(List list) { -// int i = terminalsDao.deleteById(list, CommonStatus.DELETE.value(), new Date()); -// return i; -// } -// -// @Override -// @CachePut(value = "terminalMap", key = "#result.id") -// public Towers updateTerminal(Towers towers) { -// int i = towerDao.updateByPrimaryKeySelective(towers, new Date()); -// if (i == 0) { -// return null; -// } else { -// return towers; -// } -// } -// -// -// @Override -// @Cacheable(value = "termchannelMap", key = "#id") -// public TerminalChannels getTermchannelMap(Integer id) { -// TerminalChannels terminalChannels = terminalChannelsDao.selectByPrimaryKey(id, CommonStatus.EFFECTIVE.value()); -// return terminalChannels; -// } -// -// @Override -// @CacheEvict(value = "termchannelMap", allEntries = true) -// public Integer deleteTermchannelMap(List list) { -// int i = terminalChannelsDao.deleteList(list, CommonStatus.DELETE.value(), new Date()); -// return i; -// } -// -// @Override -// @CachePut(value = "termchannelMap", key = "#result.id") -// public TerminalChannels updateTermchannelMap(TerminalChannels terminalChannels) { -// int i = terminalChannelsDao.updateByPrimaryKeySelective(terminalChannels, new Date()); -// if (i == 0) { -// return null; -// } else { -// return terminalChannels; -// } -// } -// -// -// @Override -// @Cacheable(value = "termchannelMapMap", key = "#id") -// public TerminalChannelMapper getTermchannelMapMap(Integer id, Integer channelid) { -// TerminalChannelMapper terminalChannels = terminalChannelMapperDao.selectByTermidAndChannelid(id, channelid, CommonStatus.EFFECTIVE.value()); -// return terminalChannels; -// } -// -// @Override -// @CacheEvict(value = "termchannelMapMap", allEntries = true) -// public Integer deleteTermchannelMapMap(Integer id) { -// int i = terminalChannelMapperDao.deleteByTermId(id); -// return i; -// } -// -// @Override -// @Cacheable(value = "alarmParamMap") -// public List getAlarmParsms() { -// List terminalImgAlarmParams = terminalImgAlarmParamsDao.selectAll(); -// return terminalImgAlarmParams; -// } -// -// @Override -// @CacheEvict(value = "alarmParamMap", allEntries = true) -// public List updateAlarmParsms(List list) { -// int i = terminalImgAlarmParamsDao.updateList(list, new Date()); -// if (i == 0) { -// return null; -// } else { -// return list; -// } -// } @Override diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/RoleServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/RoleServiceImpl.java index 4424fbe..609da08 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/RoleServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/RoleServiceImpl.java @@ -1,12 +1,19 @@ package com.shxy.xymanager_service.impl; +import cn.hutool.core.collection.CollectionUtil; +import com.shxy.xymanager_common.bean.ServiceBody; import com.shxy.xymanager_common.dto.DyLineAndTerminalWithHeartDto; +import com.shxy.xymanager_common.dto.LineAndTerminalWithHeartDto; +import com.shxy.xymanager_common.dto.TerminalsWithHeart; import com.shxy.xymanager_common.entity.TbPermission; import com.shxy.xymanager_common.entity.TbPermissionExample; import com.shxy.xymanager_common.entity.TbRole; import com.shxy.xymanager_common.entity.TbRoleExample; import com.shxy.xymanager_common.enums.CommonStatus; +import com.shxy.xymanager_common.exception.Asserts; import com.shxy.xymanager_common.model.DyLineTreeListModel; +import com.shxy.xymanager_common.model.PermissionDyLineTreeListModel; +import com.shxy.xymanager_common.util.xinyin.TerminalUtils; import com.shxy.xymanager_dao.dao.DyLevelDao; import com.shxy.xymanager_dao.dao.TbPermissionMapper; import com.shxy.xymanager_dao.dao.TbRoleMapper; @@ -16,6 +23,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.math.BigInteger; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -91,11 +100,58 @@ public class RoleServiceImpl implements RoleService { * 查询权限树状列表 * */ @Override - public List getPermissionTree() { - DyLineTreeListModel model = new DyLineTreeListModel(); + public ServiceBody getPermissionTree() { + PermissionDyLineTreeListModel model = new PermissionDyLineTreeListModel(); List list = dyLevelDao.selectPermissionListTreeList(); - - return null; + boolean empty = CollectionUtil.isEmpty(list); + if (empty) { + model.setList(new ArrayList<>()); + } else { + ArrayList dyListBeans = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + DyLineAndTerminalWithHeartDto dyDto = list.get(i); + List linelist = dyDto.getList(); + if (CollectionUtil.isEmpty(linelist)) { + continue; + } + PermissionDyLineTreeListModel.DyListBean dyModel = new PermissionDyLineTreeListModel.DyListBean(); + dyModel.setId(dyDto.getId()); + dyModel.setDyValue(dyDto.getDyValue()); + dyModel.setName(dyDto.getName()); + ArrayList lineBeans = new ArrayList<>(); + for (int j = 0; j < linelist.size(); j++) { + LineAndTerminalWithHeartDto lineDto = linelist.get(j); + List termlist = lineDto.getList(); + if (CollectionUtil.isEmpty(termlist)) { + continue; + } + PermissionDyLineTreeListModel.LineBean lineBean = new PermissionDyLineTreeListModel.LineBean(); + lineBean.setId(lineDto.getId()); + lineBean.setName(lineDto.getName()); + lineBean.setBsManufacturer(lineDto.getBsManufacturer()); + + ArrayList beanlist = new ArrayList<>(); + for (int k = 0; k < termlist.size(); k++) { + TerminalsWithHeart terminalsWithHeart = termlist.get(k); + + PermissionDyLineTreeListModel.TerminalBean bean = new PermissionDyLineTreeListModel.TerminalBean(); + bean.setId(terminalsWithHeart.getId()); + bean.setAddress(terminalsWithHeart.getAddress()); + bean.setCmdid(terminalsWithHeart.getCmdid()); + bean.setDisplayname(terminalsWithHeart.getDisplayname()); + bean.setEquipname(terminalsWithHeart.getEquipname()); + bean.setModel(terminalsWithHeart.getModel()); + bean.setName(terminalsWithHeart.getName()); + bean.setTowerid(terminalsWithHeart.getTowerid()); + } + lineBean.setList(beanlist); + lineBeans.add(lineBean); + } + dyModel.setList(lineBeans); + dyListBeans.add(dyModel); + } + } + return Asserts.success(model); } } diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/RoleService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/RoleService.java index 5a9d33d..bb2ee61 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/RoleService.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/RoleService.java @@ -1,7 +1,9 @@ package com.shxy.xymanager_service.service; +import com.shxy.xymanager_common.bean.ServiceBody; import com.shxy.xymanager_common.entity.TbPermission; import com.shxy.xymanager_common.entity.TbRole; +import com.shxy.xymanager_common.model.PermissionDyLineTreeListModel; import java.util.List; @@ -19,6 +21,6 @@ public interface RoleService { void changePermission(Integer roleId, List list) throws Exception; - List getPermissionTree() throws Exception; + ServiceBody getPermissionTree() throws Exception; }