From 0a174de50acac68ace26d852b62aeec249faf6de Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 1 Dec 2022 17:30:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=B5=84=E6=BA=90=E5=B7=A6?= =?UTF-8?q?=E4=BE=A7=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ResourceController.java | 15 ++- .../AbstractDataResourceService.java | 8 ++ .../domain/TsingtaoDataResourceService.java | 102 +++++++++++++++++- .../TsingtaoXHADataResourceService.java | 10 ++ 4 files changed, 131 insertions(+), 4 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index a7faaf6d..1697749f 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -690,11 +690,24 @@ public class ResourceController { Optional factory = DataResourceFactory.build(); if (factory.isPresent()) { Object dataResource = factory.get().getDataResource(dto); - return new Result().ok(dataResource); + return new Result<>().ok(dataResource); } return null; } + @PostMapping("/getDataResourceDeptList") + @ApiOperation("获取各部门数据资源数量") + @LogOperation("获取各部门数据资源数量") + public Result getDataResourceDeptList(@RequestBody GetDataResourceListDto dto) { + Optional factory = DataResourceFactory.build(); + if (factory.isPresent()) { + Object dataResource = factory.get().getDataResourceDeptList(); + return new Result<>().ok(dataResource); + } + return null; + } + + @GetMapping("/getApplyCameraList/{instanceId}") @ApiOperation("根据流程实例ID获取申请摄像头列表") @LogOperation("根据流程实例ID获取申请摄像头列表") diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/AbstractDataResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/AbstractDataResourceService.java index 641b049f..9b7b0361 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/AbstractDataResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/AbstractDataResourceService.java @@ -15,4 +15,12 @@ public abstract class AbstractDataResourceService { * @return */ public abstract Object getDataResource(GetDataResourceListDto dto); + + + /** + * 获取各部门上架数据资源的数目情况 + * + * @return + */ + public abstract Object getDataResourceDeptList(); } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java index 74ebaa7a..8459dda4 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java @@ -1,5 +1,6 @@ package io.renren.modules.resource.dataResource.domain; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.renren.common.utils.SpringContextUtils; import io.renren.modules.resource.dataResource.AbstractDataResourceService; @@ -13,9 +14,7 @@ import org.springframework.web.client.ResourceAccessException; import org.springframework.web.client.RestTemplate; import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -85,4 +84,101 @@ public class TsingtaoDataResourceService extends AbstractDataResourceService { return null; } } + + /** + * 获取各部门上架数据资源的数目情况 + * + * @return + */ + @Override + public Object getDataResourceDeptList() { + String url = "http://15.72.158.81/zyjk/ZywMessage.asmx?op=ZyFbCountPort"; + String parame = "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + ""; + HttpHeaders requestHeaders = new HttpHeaders(); + requestHeaders.set("SOAPAction", "http://tempuri.org/ZyFbCountPort"); + requestHeaders.setContentType(new MediaType("text", "xml", Charset.forName("utf-8"))); + HttpEntity requestEntity = new HttpEntity(parame, requestHeaders); + try { + String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody(); + String startTag = ""; + String endTag = ""; + String json = body.substring(body.indexOf(startTag) + startTag.length(), body.indexOf(endTag)); + List result = JSONArray.parseArray(json, Map.class); + + List> allDept = new ArrayList<>(); + + LinkedHashMap allInfo = new LinkedHashMap<>(); // 所有单位 + allInfo.put("total", result.stream().mapToInt(index -> Integer.parseInt(index.get("Lenth").toString())).sum()); + allInfo.put("type", "全部能力目录"); + + allDept.add(allInfo); // 所有单位 + + LinkedHashMap cityInfo = new LinkedHashMap<>(); // 市级单位 + + List> cityList = result.stream().filter(index -> "青岛市".equals(index.getOrDefault("ssqs", "").toString())) + .map(index -> { + LinkedHashMap temp = new LinkedHashMap<>(); + temp.put("districtName", index.get("ssqs").toString()); + temp.put("districtId", "250000"); + temp.put("deptName", index.get("BMName").toString()); + temp.put("deptId", index.get("TGBM").toString()); + temp.put("deptCount", index.get("Lenth").toString()); + return temp; + }) + .collect(Collectors.toList()); // 获取市级单位 + cityInfo.put("dataList", cityList); + cityInfo.put("total", cityList.stream().mapToInt(index -> Integer.parseInt(index.get("deptCount").toString())).sum()); + cityInfo.put("type", "市级"); + + allDept.add(cityInfo); //市级部门 + + + LinkedHashMap qyInfo = new LinkedHashMap<>(); // 区级单位 + + Map>> group = result.stream() + .filter(index -> !"青岛市".equals(index.getOrDefault("ssqs", "").toString())) + .map(index -> { + LinkedHashMap temp = new LinkedHashMap<>(); + temp.put("districtName", index.get("ssqs").toString()); + temp.put("districtId", "250000"); + temp.put("deptName", index.get("BMName").toString()); + temp.put("deptId", index.get("TGBM").toString()); + temp.put("deptCount", index.get("Lenth")); + return temp; + }) + .collect(Collectors.groupingBy(t -> t.get("districtName").toString())); // 获取非市级单位 + qyInfo.put("dataList", group.keySet().stream().map(index -> { + LinkedHashMap temp = new LinkedHashMap<>(); + temp.put("dataList", group.get(index).stream().map(i -> { + LinkedHashMap temp1 = new LinkedHashMap<>(); + temp1.put("districtName", i.get("districtName").toString()); + temp1.put("districtId", i.get("districtId").toString()); + temp1.put("deptName", i.get("deptName").toString()); + temp1.put("deptId", i.get("deptId").toString()); + temp1.put("deptCount", i.get("deptCount").toString()); + temp1.put("type", i.get("deptName")); + return temp1; // 每个区县下 + }).collect(Collectors.toList())); + temp.put("total", group.get(index).stream().mapToInt(index_ -> Integer.parseInt(index_.get("deptCount").toString())).sum()); + temp.put("type", index); + return temp; + }).collect(Collectors.toList())); + qyInfo.put("total", result.stream().filter(index -> !"青岛市".equals(index.getOrDefault("ssqs", "").toString())) + .mapToInt(index -> Integer.parseInt(index.get("Lenth").toString())).sum()); + qyInfo.put("type", "区级"); + allDept.add(qyInfo); //市级部门 + return allDept; + } catch (ResourceAccessException e) { + logger.error("青岛市资源数据接口连接超时!!!"); + return null; + } catch (Exception e) { + logger.error("青岛市资源数据调用失败!!!", e); + return null; + } + } } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoXHADataResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoXHADataResourceService.java index 4b2fc8bb..01a73e0b 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoXHADataResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoXHADataResourceService.java @@ -57,4 +57,14 @@ public class TsingtaoXHADataResourceService extends AbstractDataResourceService } return result; } + + /** + * 获取各部门上架数据资源的数目情况 + * + * @return + */ + @Override + public Object getDataResourceDeptList() { + return null; + } }