数据资源左侧树

This commit is contained in:
wangliwen 2022-12-01 17:30:28 +08:00
parent 3a87c7381d
commit 0a174de50a
4 changed files with 131 additions and 4 deletions

View File

@ -690,11 +690,24 @@ public class ResourceController {
Optional<AbstractDataResourceService> factory = DataResourceFactory.build();
if (factory.isPresent()) {
Object dataResource = factory.get().getDataResource(dto);
return new Result<Object>().ok(dataResource);
return new Result<>().ok(dataResource);
}
return null;
}
@PostMapping("/getDataResourceDeptList")
@ApiOperation("获取各部门数据资源数量")
@LogOperation("获取各部门数据资源数量")
public Result<Object> getDataResourceDeptList(@RequestBody GetDataResourceListDto dto) {
Optional<AbstractDataResourceService> 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获取申请摄像头列表")

View File

@ -15,4 +15,12 @@ public abstract class AbstractDataResourceService {
* @return
*/
public abstract Object getDataResource(GetDataResourceListDto dto);
/**
* 获取各部门上架数据资源的数目情况
*
* @return
*/
public abstract Object getDataResourceDeptList();
}

View File

@ -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 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <soap:Body>\n" +
" <ZyFbCountPort xmlns=\"http://tempuri.org/\" />\n" +
" </soap:Body>\n" +
"</soap:Envelope>";
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("SOAPAction", "http://tempuri.org/ZyFbCountPort");
requestHeaders.setContentType(new MediaType("text", "xml", Charset.forName("utf-8")));
HttpEntity<String> requestEntity = new HttpEntity(parame, requestHeaders);
try {
String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody();
String startTag = "<ZyFbCountPortResult>";
String endTag = "</ZyFbCountPortResult>";
String json = body.substring(body.indexOf(startTag) + startTag.length(), body.indexOf(endTag));
List<Map> result = JSONArray.parseArray(json, Map.class);
List<LinkedHashMap<String, Object>> allDept = new ArrayList<>();
LinkedHashMap<String, Object> allInfo = new LinkedHashMap<>(); // 所有单位
allInfo.put("total", result.stream().mapToInt(index -> Integer.parseInt(index.get("Lenth").toString())).sum());
allInfo.put("type", "全部能力目录");
allDept.add(allInfo); // 所有单位
LinkedHashMap<String, Object> cityInfo = new LinkedHashMap<>(); // 市级单位
List<LinkedHashMap<String, Object>> cityList = result.stream().filter(index -> "青岛市".equals(index.getOrDefault("ssqs", "").toString()))
.map(index -> {
LinkedHashMap<String, Object> 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<String, Object> qyInfo = new LinkedHashMap<>(); // 区级单位
Map<String, List<LinkedHashMap<String, Object>>> group = result.stream()
.filter(index -> !"青岛市".equals(index.getOrDefault("ssqs", "").toString()))
.map(index -> {
LinkedHashMap<String, Object> 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<String, Object> temp = new LinkedHashMap<>();
temp.put("dataList", group.get(index).stream().map(i -> {
LinkedHashMap<String, Object> 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;
}
}
}

View File

@ -57,4 +57,14 @@ public class TsingtaoXHADataResourceService extends AbstractDataResourceService
}
return result;
}
/**
* 获取各部门上架数据资源的数目情况
*
* @return
*/
@Override
public Object getDataResourceDeptList() {
return null;
}
}