* 'master' of http://221.0.232.152:9393/ability-center/share-platform: (49 commits)
  标识所有未读资源为已读
  排查加日志
  屮
  。。。
  通知的历史数据 来源处理
  通知来源类型
  基础设施
  用户表加字段
  云图数据资源总况
  1、修改获取金宏数据库中用户名和地区信息,将 JhUserTask和JhDeptTask删除,改为在SysUserController中分别通过/getDeptInfoFromJH和/getUserInfoFromJH手动调用。
  。。。
  1、将金宏数据库中用户和地区信息整合进来,并做成任务调度 JhUserTask和JhDeptTask,需要通过前端配置一下才能启动。
  基础设施统计接口
  。。。
  ...
  获取预览地址接口
  视频预览 工厂模式下各区域的实现
  ....
  ...
  现有区域配置文件 加入
  ...

# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java
This commit is contained in:
huangweixiong 2022-06-21 20:53:46 +08:00
commit b1e489bc27
60 changed files with 4274 additions and 305 deletions

1866
config/db/V1.0__Base_DDL.sql Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
/*
Navicat Premium Data Transfer
Source Server : 15.2.21.238
Source Server Type : MySQL
Source Server Version : 50732
Source Host : 15.2.21.238:3310
Source Schema : share_platform
Target Server Type : MySQL
Target Server Version : 50732
File Encoding : 65001
Date: 14/06/2022 15:48:36
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Records of act_re_model
-- ----------------------------
INSERT INTO `act_re_model` VALUES ('1', 51, '能力申请', 'abilityprocess', NULL, '2022-04-13 18:36:31.681', '2022-05-30 10:58:37.536', 1, '{\"name\":\"能力申请\",\"description\":\"能力申请表单\",\"revision\":1}', NULL, '2', '3', '');
INSERT INTO `act_re_model` VALUES ('252725', 32, '能力资源上架', 'resourcemountapply', NULL, '2022-04-24 14:08:13.296', '2022-05-30 10:50:31.746', 1, '{\"name\":\"能力资源上架\",\"description\":\"能力资源上架审批流程\",\"revision\":1}', NULL, '252726', '252727', '');
INSERT INTO `act_re_model` VALUES ('277501', 20, '能力需求申请', 'abilitydemandapply', NULL, '2022-04-25 10:49:42.466', '2022-06-02 10:53:36.595', 1, '{\"name\":\"能力需求申请\",\"description\":\"能力需求申请\",\"revision\":1}', NULL, '277502', '277503', '');
INSERT INTO `act_re_model` VALUES ('485001', 18, '能力资源下架', 'resourcundercarriageapply', NULL, '2022-05-10 10:23:05.802', '2022-05-30 10:48:13.801', 1, '{\"name\":\"能力资源下架\",\"description\":\"能力资源下架\",\"revision\":1}', NULL, '485002', '485003', '');
INSERT INTO `act_re_model` VALUES ('5019', 8, '转正申请', 'correctionprocess', NULL, '2022-04-14 17:44:34.122', '2022-04-14 20:27:14.548', 1, '{\"name\":\"转正申请\",\"description\":\"\",\"revision\":1}', NULL, '5020', '5021', '');

View File

@ -0,0 +1,2 @@
ALTER TABLE `share_platform`.`t_resource_mount_apply` ADD COLUMN `resource_dto` json NULL COMMENT '挂载资源对象';
UPDATE `share_platform`.`t_resource_mount_apply` SET resource_dto = parameter_content;

View File

@ -0,0 +1,3 @@
ALTER TABLE `share_platform`.`tb_data_attr`
ADD INDEX `resource_id`(`data_resource_id`),
ADD FULLTEXT INDEX `attr_value`(`attr_type`, `attr_value`);

View File

@ -0,0 +1 @@
ALTER TABLE `share_platform`.`tb_data_resource` ADD COLUMN `info_list` json NULL COMMENT '属性信息';

View File

@ -0,0 +1,2 @@
ALTER TABLE `share_platform`.`tb_work_dynamics`
MODIFY COLUMN `note1` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '摘要';

View File

@ -302,7 +302,9 @@
<directory>src/main/resources</directory>
<excludes>
<!-- 排除生产环境配置 -->
<!-- <exclude>application-prod.yml</exclude>-->
<exclude>application-prod.yml</exclude>
<!-- 排除flyway管理的sql -->
<!-- <exclude>db/*.sql</exclude>-->
</excludes>
</resource>
<resource>

View File

@ -172,6 +172,7 @@ public class ActivitiNoticeAspect {
dto.setSenderDate(new Date());
dto.setCreator(sysUserService.getByUsername("admin").getId());
dto.setCreateDate(new Date());
dto.setFrom("通知");
sysNoticeService.save(dto);
}).thenRunAsync(() -> {
// 防止重放
@ -319,6 +320,7 @@ public class ActivitiNoticeAspect {
String finalCreator = creator;
CompletableFuture.runAsync(() -> { // 发起人
SysUserDTO assignee = sysUserService.get(Long.valueOf(delegateTask.getAssignee()));
logger.error("审核人:" + assignee.getId());
String content = "【通知】您发起的流程 " + activitiNoticeOperation.process() + " 当前审核节点为:" + activitiNoticeOperation.value() + ";当前审核人为:\"" + assignee.getDeptName() + "\"审核负责人\"" + assignee.getRealName() + "\"";
SysNoticeDTO dto = new SysNoticeDTO();
dto.setType(2);

View File

@ -61,15 +61,7 @@ public class CensusController {
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
List<String> temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList());
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型
if (index.equals("知识库")) {
Map<String, Object> nullMap = new HashMap<String, Object>() {
{
put("amount", 14);
put("type", "知识库");
}
};
dbAmount.add(nullMap);
} else if (index.equals("数据资源")) {
if (index.equals("数据资源")) {
Map<String, Object> nullMap = new HashMap<String, Object>() {
{
put("amount", 10413);

View File

@ -0,0 +1,542 @@
package io.renren.common.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant;
import io.renren.common.domain.Tsingtao_xhaProperties;
import io.renren.common.utils.Result;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
/**
* 2022.6.19 版本
*/
@Api(tags = "全局统计中心v2")
@RestController
@RequestMapping("/census/center/v2")
public class CensusControllerV2 {
@Value("${project.place}")
private Integer projectPlace;
private static final Logger logger = LoggerFactory.getLogger(CensusControllerV2.class);
@Autowired
private ResourceService resourceService;
@Autowired
private SysUserService sysUserService;
@Autowired
private TAbilityApplicationService tAbilityApplicationService;
@Autowired
private ResourceBrowseService resourceBrowseService;
@Autowired
private SysDeptService sysDeptService;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private Tsingtao_xhaProperties tsingtao_xhaProperties;
@Value("${census.type}")
private String[] censusTypes; // 需要进行统计的资源类型
@GetMapping(value = "/whole_amount")
@ApiOperation("平台概览")
public Result<List<Map<String, Object>>> wholeAmount() {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
CompletableFuture<Void> userAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数
return sysUserService.countAllUser();
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "用户量");
}
});
});
CompletableFuture<Void> pvAmount = CompletableFuture.supplyAsync(() -> { // 平台访问量
return resourceService.countAllVisits();
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "平台访问量");
}
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(userAmount, pvAmount);
all.join();
result.sort(Comparator.comparing(x -> x.get("type").toString()));
return new Result<List<Map<String, Object>>>().ok(result);
}
@PostMapping("/trafficStatistics")
@ApiOperation("浏览量统计")
@LogOperation("浏览量统计")
public Result trafficStatistics(@RequestBody JSONObject jsonObject) {
HashMap<String, Object> resultMap = new HashMap<>();
String startDate = jsonObject.getString("startDate");
String endDate = jsonObject.getString("endDate");
resultMap.put("browseAvg", resourceBrowseService.selectDayAvg());
resultMap.put("browseMax", resourceBrowseService.selectDayMax());
resultMap.put("browseDayList", resourceBrowseService.selectDayList(startDate, endDate));
return new Result().ok(resultMap);
}
@GetMapping("/applicationNum")
@ApiOperation("应用资源数量统计")
@LogOperation("应用资源数量统计")
public Result<List<Map<String, Object>>> applicationNum() {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
CompletableFuture<Void> allApplicationAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总应用数目
return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type ='应用资源';", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "总应用数");
}
});
});
CompletableFuture<Void> buildingApplicationAmount = CompletableFuture.supplyAsync(() -> { // 获取平台建设中数目
return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT data_resource_id) FROM tb_data_attr WHERE attr_type = '应用状态' AND attr_value = '建设中';", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "建设中应用数");
}
});
});
CompletableFuture<Void> endApplicationAmount = CompletableFuture.supplyAsync(() -> { // 获取平台建设中数目
return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT data_resource_id) FROM tb_data_attr WHERE attr_type = '应用状态' AND attr_value = '停用';", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "停用应用数");
}
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(allApplicationAmount, buildingApplicationAmount, endApplicationAmount);
all.join();
return new Result().ok(result);
}
@GetMapping("/districtResourceRank")
@ApiOperation("应用资源区县市排名")
@LogOperation("应用资源区县市排名")
public Result<List<Map<String, Object>>> districtResourceRank() {
List<Map<String, Object>> result = resourceRank(3);
return new Result().ok(result);
}
@GetMapping("/cityResourceRank")
@ApiOperation("应用资源委办局排名")
@LogOperation("应用资源委办局排名")
public Result<List<Map<String, Object>>> cityResourceRank() {
List<Map<String, Object>> result = resourceRank(2);
return new Result().ok(result);
}
private List<Map<String, Object>> resourceRank(Integer type) {
List<Map<String, Object>> result;
List<Map<String, Object>> district = jdbcTemplate.queryForList("SELECT * FROM sys_dept WHERE type = " + type);
List<Map<String, Long>> listMap =
district.stream().map(index -> {
Map<String, Long> re = new LinkedHashMap<>();
String sql = String.format("SELECT COUNT(id) FROM tb_data_resource WHERE dept_id = %s AND type = '应用资源' AND del_flag = 0;", index.get("id").toString());
logger.info(sql);
Long count = jdbcTemplate.queryForObject(sql, Long.class);
if (!"0".equals(index.get("pid").toString())) { // 有上级部门
Optional<SysDeptDTO> sysDeptDTO =
Optional.ofNullable(sysDeptService.get(Long.valueOf(index.get("pid").toString())));
if (sysDeptDTO.isPresent() && sysDeptDTO.get().getType() != null && sysDeptDTO.get().getType() >= 2) {
re.put(index.get("id").toString(), count);
} else {
re.put(index.get("pid").toString(), count);
}
} else {
re.put(index.get("id").toString(), count);
}
return re;
}).collect(Collectors.toList());
Map<String, List<Map<String, Long>>> i =
listMap.stream().collect(Collectors.groupingBy(m -> m.keySet().stream().findFirst().get()));
result = i.keySet().stream().map(index -> {
Map<String, Object> re = new LinkedHashMap<>();
re.put("deptName", sysDeptService.get(Long.valueOf(index)).getName());
re.put("count", i.get(index).stream().mapToLong(index_ -> index_.values().stream().mapToLong(count_ -> count_).sum()).sum());
return re;
}).collect(Collectors.toList());
result.sort(Comparator.comparing(x -> {
ObjectMapper mapper = new ObjectMapper();
try {
Map m = mapper.readValue(mapper.writeValueAsString(x), Map.class);
return Long.valueOf(m.get("count").toString());
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
).reversed());
return result;
}
@GetMapping("/assemblerInfo")
@ApiOperation("组件服务简况")
@LogOperation("组件服务简况")
public Result<List<Map<String, Object>>> assemblerInfo() {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
CompletableFuture<Void> allAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总组件服务数目
return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type ='组件服务' AND del_flag = 0;", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "上架总数");
}
});
});
CompletableFuture<Void> aiAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台智能算法组件服务数目
return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT tb_data_resource.id) FROM tb_data_resource WHERE tb_data_resource.del_flag = 0 AND EXISTS(SELECT tb_data_attr.id FROM tb_data_attr WHERE tb_data_attr.data_resource_id = tb_data_resource.id AND tb_data_attr.attr_value = '智能算法' AND attr_type = '组件类型')", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "智能算法");
}
});
});
CompletableFuture<Void> gisAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台图层服务组件服务数目
return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT tb_data_resource.id) FROM tb_data_resource WHERE tb_data_resource.del_flag = 0 AND EXISTS(SELECT tb_data_attr.id FROM tb_data_attr WHERE tb_data_attr.data_resource_id = tb_data_resource.id AND tb_data_attr.attr_value = '图层服务' AND attr_type = '组件类型')", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "图层服务");
}
});
});
CompletableFuture<Void> busAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台业务组件组件服务数目
return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT tb_data_resource.id) FROM tb_data_resource WHERE tb_data_resource.del_flag = 0 AND EXISTS(SELECT tb_data_attr.id FROM tb_data_attr WHERE tb_data_attr.data_resource_id = tb_data_resource.id AND tb_data_attr.attr_value = '业务组件' AND attr_type = '组件类型')", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "业务组件");
}
});
});
CompletableFuture<Void> devAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台业务组件组件服务数目
return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT tb_data_resource.id) FROM tb_data_resource WHERE tb_data_resource.del_flag = 0 AND EXISTS(SELECT tb_data_attr.id FROM tb_data_attr WHERE tb_data_attr.data_resource_id = tb_data_resource.id AND tb_data_attr.attr_value = '开发组件' AND attr_type = '组件类型')", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "开发组件");
}
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(allAssemblyAmount, aiAssemblyAmount, gisAssemblyAmount, busAssemblyAmount, devAssemblyAmount);
all.join();
return new Result().ok(result);
}
@GetMapping("/knowledgeInfo")
@ApiOperation("知识库简况")
@LogOperation("知识库简况")
public Result<List<Map<String, Object>>> knowledgeInfo() {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
CompletableFuture<Void> allKnowledgeAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总知识库数目
return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "知识库上架总量");
}
});
});
CompletableFuture<Void> allKnowledgeVisitsAmount = CompletableFuture.supplyAsync(() -> { // 获取平台知识库浏览量
return jdbcTemplate.queryForObject("SELECT SUM(visits)visits FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "知识库总浏览量");
}
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(allKnowledgeAmount, allKnowledgeVisitsAmount);
all.join();
return new Result().ok(result);
}
@GetMapping("/componentServiceRank")
@ApiOperation("组件服务排名")
@LogOperation("组件服务排名")
public Result componentServiceRank(String type) {
return new Result().ok(resourceService.componentServiceRank(type));
}
@GetMapping("/infrastructureInfo")
@ApiOperation("基础设施简况")
@LogOperation("基础设施简况")
public Result<List<Map<String, Object>>> infrastructureInfo() {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
CompletableFuture<Void> allAmount = null;
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO: // 青岛市局
case BAOTOU: { // 包头
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type = '基础设施' AND del_flag = 0", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "视频资源数量");
}
});
});
}
break;
case TSINGTAO_XHA: { // 青岛西海岸
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
List<Long> result_ = new CopyOnWriteArrayList<>();
CompletableFuture cloud =
CompletableFuture.runAsync(() -> { // 云脑专网
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10);
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
result_.add(jsonObject.getJSONObject("data").getLongValue("total"));
}
} else {
logger.error("包头获取失败");
}
} catch (Exception exception) {
logger.error("包头失败", exception);
}
});
CompletableFuture local =
CompletableFuture.runAsync(() -> { // 金宏网
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getLocalcam(), "", 1, 10);
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
result_.add(jsonObject.getJSONObject("data").getLongValue("total"));
}
} else {
logger.error("包头获取失败");
}
} catch (Exception exception) {
logger.error("包头失败", exception);
}
});
CompletableFuture.allOf(cloud, local);
return result_.stream().filter(index -> index != null).findAny().orElse(0l);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "视频资源数量");
}
});
});
}
break;
}
CompletableFuture<Void> all = CompletableFuture.allOf(allAmount);
all.join();
return new Result().ok(result);
}
@GetMapping("/dataResourceInfo")
@ApiOperation("数据资源简况")
@LogOperation("数据资源简况")
public Result<List<Map<String, Object>>> dataResourceInfo() {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
CompletableFuture<Void> allAmount = null;
CompletableFuture<Void> applyInfo = null; // 申请情况
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case BAOTOU: { // TODO 包头
result.add(new HashMap<String, Object>() {
{
put("amount", 0L);
put("type", "总数据量");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 0l);
put("type", "总申请次数");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 1);
put("type", "满足率");
}
});
result.add(new HashMap<String, Object>() {
{
put("resourceTop5", new ArrayList<>());
}
});
}
break;
case TSINGTAO: { // TODO 青岛大数据局
result.add(new HashMap<String, Object>() {
{
put("amount", 0L);
put("type", "总数据量");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 0l);
put("type", "总申请次数");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 1);
put("type", "满足率");
}
});
result.add(new HashMap<String, Object>() {
{
put("resourceTop5", new ArrayList<>());
}
});
}
break;
case TSINGTAO_XHA: { // 青岛西海岸
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台数据资源总数目
OkHttpClient client = new OkHttpClient();
Long total = 0L;
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
total = jsonObject.getJSONObject("data").getLongValue("total");
}
} else {
logger.error("包头获取失败");
}
} catch (Exception exception) {
logger.error("包头失败", exception);
}
return total;
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "总数据量");
}
});
}); // 处理总数目
applyInfo = CompletableFuture.runAsync(() -> {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourceapplyinfo()).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
result.add(new HashMap<String, Object>() {
{
put("amount", jsonObject.getJSONObject("data").getLongValue("requestCount"));
put("type", "总申请次数");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", jsonObject.getJSONObject("data").getIntValue("satisfactionRate"));
put("type", "满足率");
}
});
result.add(new HashMap<String, Object>() {
{
put("resourceTop5", jsonObject.getJSONObject("data").getJSONArray("resourceTop5").stream().map(index -> (JSONObject) JSON.toJSON(index)).map(index -> new HashMap<String, Object>() {
{
put("服务名称", index.getString("service_name"));
put("申请次数", index.getLongValue("count"));
}
}).collect(Collectors.toList()));
}
});
}
} else {
logger.error("包头获取失败");
}
} catch (Exception exception) {
logger.error("包头失败", exception);
}
});
}
break;
}
if (allAmount == null) {
allAmount = CompletableFuture.runAsync(() -> {
try {
Thread.sleep(100l);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
if (applyInfo == null) {
applyInfo = CompletableFuture.runAsync(() -> {
try {
Thread.sleep(100l);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}
CompletableFuture<Void> all = CompletableFuture.allOf(allAmount, applyInfo);
all.join();
return new Result().ok(result);
}
}

View File

@ -0,0 +1,19 @@
package io.renren.common.domain;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* 包头区域配置项
*/
@Data
@Component
@PropertySource("classpath:/domain/baotou.properties")
@ConfigurationProperties(prefix = "baotou")
public class BaoTouProperties {
private String hlsurl;
}

View File

@ -0,0 +1,18 @@
package io.renren.common.domain;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* 青岛市区
*/
@Data
@Component
@PropertySource("classpath:/domain/tsingtao.properties")
@ConfigurationProperties(prefix = "tsingtao")
public class TsingtaoProperties {
}

View File

@ -0,0 +1,23 @@
package io.renren.common.domain;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* 青岛西海岸
*/
@Data
@Component
@PropertySource("classpath:/domain/tsingtao-xha.properties")
@ConfigurationProperties(prefix = "tsingtao-xha")
public class Tsingtao_xhaProperties {
private String cloudhls;
private String localhls;
private String cloudcam;
private String localcam;
private String resourcecount;
private String resourceapplyinfo;
}

View File

@ -91,6 +91,7 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao
dto.setSenderDate(new Date());
dto.setCreator(sysUserService.getByUsername("admin").getId());
dto.setCreateDate(new Date());
dto.setFrom("评论");
sysNoticeService.save(dto);
});
}

View File

@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/**
* 操作日志
@ -54,7 +55,9 @@ public class SysLogOperationServiceImpl extends BaseServiceImpl<SysLogOperationD
@Override
@Transactional(rollbackFor = Exception.class)
public void save(SysLogOperationEntity entity) {
CompletableFuture.runAsync(() -> {
insert(entity);
});
}
}

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -37,6 +38,8 @@ public class SysNoticeController {
private SysNoticeService sysNoticeService;
@Autowired
private SysNoticeUserService sysNoticeUserService;
@Autowired
private JdbcTemplate jdbcTemplate;
@GetMapping("page")
@ApiOperation("分页")
@ -75,7 +78,8 @@ public class SysNoticeController {
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "readStatus", value = "阅读状态 0未读 1已读", paramType = "query", dataType = "Integer")
@ApiImplicitParam(name = "readStatus", value = "阅读状态 0未读 1已读", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "from", value = "通知来源 (通知、评论、其他)", paramType = "query", dataType = "String")
})
public Result<PageData<SysNoticeDTO>> myNoticePage(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<SysNoticeDTO> page = sysNoticeService.getMyNoticePage(params);
@ -91,6 +95,13 @@ public class SysNoticeController {
return new Result();
}
@PutMapping("mynotice/readall")
@ApiOperation("标记我的所有未读通知为已读")
public Result readAll() {
jdbcTemplate.update(String.format("UPDATE sys_notice_user SET read_status = 1,read_date =NOW() WHERE receiver_id = %s AND read_status = 0;"), SecurityUser.getUserId().toString());
return new Result();
}
@GetMapping("mynotice/unread")
@ApiOperation("我的通知未读数")
public Result<Integer> unRead() {

View File

@ -48,4 +48,6 @@ public class SysNoticeDTO implements Serializable {
private Date readDate;
@ApiModelProperty(value = "阅读状态 0未读 1已读")
private Integer readStatus;
@ApiModelProperty(value = "通知来源 (通知、评论、其他)")
private String from;
}

View File

@ -10,7 +10,6 @@ import java.util.Date;
/**
* 通知管理
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ -65,4 +64,9 @@ public class SysNoticeEntity extends BaseEntity {
*/
@TableField(exist = false)
private Date readDate;
/**
* 通知来源 (通知评论其他)
*/
private String from;
}

View File

@ -14,10 +14,13 @@ import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.excel.ResourceExcelImportListener;
import io.renren.modules.resource.service.ResourceService;
import io.swagger.annotations.*;
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
import io.renren.modules.resource.videoPreview.VideoPreviewFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -38,6 +41,7 @@ import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import java.util.concurrent.CompletableFuture;
/**
* 资源表
*
@ -88,6 +92,7 @@ public class ResourceController {
@Autowired
private RestTemplate restTemplate;
@Lazy
@Autowired
private JdbcTemplate jdbcTemplate;
@ -205,7 +210,7 @@ public class ResourceController {
@ApiOperation("导入")
@LogOperation("导入")
@ApiImplicitParams({
@ApiImplicitParam(name = "source", value = "请求来源", paramType = "string", dataType = "string")
@ApiImplicitParam(name = "file", value = "数据文件文件", paramType = "file", dataType = "file")
})
public Result importResource(@RequestParam("file") MultipartFile uploadFile, HttpServletRequest request) {
List<Map<String, Object>> dept =
@ -284,7 +289,6 @@ public class ResourceController {
HashMap map = JSONObject.parseObject(json, HashMap.class);
return new Result().ok(map);
} catch (Exception e) {
e.printStackTrace();
return new Result().ok(new HashMap<String, Object>() {{
put("sxmlcount", 0);
put("yfbfwcount", 0);
@ -320,7 +324,6 @@ public class ResourceController {
parame = parame + String.format("<zyname>%s</zyname>",zyname);
}
parame = parame + "</ZWCJ_mainPort></soap:Body></soap:Envelope>";
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("SOAPAction", "http://tempuri.org/ZWCJ_mainPort");
requestHeaders.setContentType(new MediaType("text","xml", Charset.forName("utf-8")));
@ -411,4 +414,15 @@ public class ResourceController {
}
*/
@GetMapping("getHls")
@ApiOperation("对接知识库数据")
public Result<String> getHls(String key) {
Optional<AbstractVideoPreviewService> factory = VideoPreviewFactory.build();
if (factory.isPresent()) {
String hls = factory.get().getHls(key);
return new Result<String>().ok(hls);
}
return null;
}
}

View File

@ -25,7 +25,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
@Param("orderField") String orderField,
@Param("orderType") String orderType);
List<Map> selectTypeCount();
List<Map> selectTypeCount(String type);
List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap);
@ -106,4 +106,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<Map> selectAppAreaCountList();
List<Map> selectTopFiveComponentServiceApplications();
List<Map> selectTopFiveComponentServiceScore();
}

View File

@ -1,11 +1,15 @@
package io.renren.modules.resource.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import io.renren.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 资源表
@ -130,4 +134,7 @@ public class ResourceEntity extends BaseEntity {
* 提起下架人员
*/
private String undercarriageUserName;
@TableField(value = "info_list", typeHandler = FastjsonTypeHandler.class)
private List<AttrEntity> infoList;
}

View File

@ -85,7 +85,7 @@ public class ResourceExcelImportListener extends AnalysisEventListener<Map<Integ
logger.info("找不到部门:{}", index.toString());
deptOptional = Optional.of(new LinkedHashMap<String, Object>() {
{
put("id", 1L);
put("id", 1516728214814113793L); // 包头市行政审批和政务服务服务局
}
});
}
@ -367,7 +367,7 @@ public class ResourceExcelImportListener extends AnalysisEventListener<Map<Integ
}
resourceDTO.setInfoList(infoList.stream().distinct().filter(info -> StringUtils.isNotEmpty(info.getAttrValue())).collect(Collectors.toList())); // infoList内空属性不导入
resourceDTO.setDelFlag(0);
// resourceDTO.setDeptId(deptId); // 所属部门
resourceDTO.setDeptId(deptId); // 所属部门
return resourceDTO;
}

View File

@ -79,4 +79,8 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
* 同步知识库
*/
void KnowledgeBase();
Object componentServiceRank(String type);
Integer getProjectPlace();
}

View File

@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.constant.Constant;
import io.renren.common.domain.Tsingtao_xhaProperties;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.resource.dao.AttrDao;
import io.renren.modules.resource.dao.ResourceDao;
@ -38,6 +40,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
@ -55,7 +59,12 @@ import java.util.stream.Collectors;
*/
@Service
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
@Value("${project.place}")
private Integer projectPlace;
@Value("${zsk.appid}")
private String appId;
@ -108,6 +117,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private Tsingtao_xhaProperties tsingtao_xhaProperties;
@Override
public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>();
@ -216,6 +228,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
String orderField = StringUtils.isBlank(jsonObject.getString("orderField")) ? "total" : jsonObject.getString("orderField");
String orderType = StringUtils.isBlank(jsonObject.getString("orderType")) ? "DESC" : jsonObject.getString("orderType");
Page<ResourceDTO> resultPage = new Page<>(pageNum, pageSize);
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO:
case BAOTOU: { // 包头青岛
logger.info("包头、青岛");
if (resourceDTO.getInfoList().isEmpty()) {
List<ResourceDTO> resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType);
resultPage.setRecords(resourceDTOS);
@ -235,6 +251,120 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resultPage.setTotal(resourceDTOS.size());
}
}
}
break;
case TSINGTAO_XHA: {
if ("基础设施".equals(resourceDTO.getType())) { // 基础设施
logger.info("西海岸基础设施");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
CompletableFuture cloud =
CompletableFuture.runAsync(() -> { // 云脑专网
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getCloudcam(), resourceDTO.getName(), pageNum, pageSize);
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject_ = JSON.parseObject(response.body().string());
if (jsonObject_.containsKey("data")) {
if (jsonObject_.getJSONObject("data").containsKey("list")) {
resultPage.setTotal(jsonObject_.getJSONObject("data").getLongValue("total"));
resultPage.setRecords(jsonObject_.getJSONObject("data").getJSONArray("list").stream().map(index -> (JSONObject) JSON.toJSON(index))
.map(index -> {
ResourceDTO resourceDTO1 = new ResourceDTO();
resourceDTO1.setId(Long.valueOf(index.getString("id")));
resourceDTO1.setDelFlag(index.getIntValue("delFlag"));
resourceDTO1.setLink(index.getString("cameraIndexCode"));
resourceDTO1.setName(index.getString("name"));
resourceDTO1.setType("基础设施");
try {
resourceDTO1.setCreateDate(sdf.parse(index.getString("createdTime")));
} catch (ParseException e) {
logger.error("时间异常");
resourceDTO1.setCreateDate(new Date());
}
return resourceDTO1;
}).collect(Collectors.toList()));
} else {
resultPage.setRecords(null);
resultPage.setTotal(0);
}
}
} else {
logger.error("获取失败");
}
} catch (Exception exception) {
logger.error("失败", exception);
}
});
CompletableFuture local =
CompletableFuture.runAsync(() -> { // 金宏网
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getLocalcam(), resourceDTO.getName(), pageNum, pageSize);
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject_ = JSON.parseObject(response.body().string());
if (jsonObject_.containsKey("data")) {
if (jsonObject_.getJSONObject("data").containsKey("list")) {
resultPage.setTotal(jsonObject_.getJSONObject("data").getLongValue("total"));
resultPage.setRecords(jsonObject_.getJSONObject("data").getJSONArray("list").stream().map(index -> (JSONObject) JSON.toJSON(index))
.map(index -> {
ResourceDTO resourceDTO1 = new ResourceDTO();
resourceDTO1.setId(Long.valueOf(index.getString("id")));
resourceDTO1.setDelFlag(index.getIntValue("delFlag"));
resourceDTO1.setLink(index.getString("cameraIndexCode"));
resourceDTO1.setName(index.getString("name"));
resourceDTO1.setType("基础设施");
try {
resourceDTO1.setCreateDate(sdf.parse(index.getString("createdTime")));
} catch (ParseException e) {
logger.error("时间异常");
resourceDTO1.setCreateDate(new Date());
}
return resourceDTO1;
}).collect(Collectors.toList()));
} else {
resultPage.setRecords(null);
resultPage.setTotal(0);
}
}
} else {
logger.error("获取失败");
}
} catch (Exception exception) {
logger.error("失败", exception);
}
});
CompletableFuture.allOf(cloud, local);
} else {
logger.info("西海岸基普通");
if (resourceDTO.getInfoList().isEmpty()) {
List<ResourceDTO> resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType);
resultPage.setRecords(resourceDTOS);
resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size());
} else {
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
if (resourceDTOS.isEmpty()) {
resultPage.setRecords(null);
resultPage.setTotal(0);
} else {
ArrayList<ResourceDTO> recordLists = new ArrayList<>();
for (int i = (pageNum - 1) * pageSize; i < j; i++) {
recordLists.add(resourceDTOS.get(i));
}
resultPage.setRecords(recordLists);
resultPage.setTotal(resourceDTOS.size());
}
}
}
}
break;
}
return resultPage;
}
@ -250,7 +380,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectTotal() {
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("total", resourceDao.selectTypeCount());
resultMap.put("total", resourceDao.selectTypeCount(null));
return resultMap;
}
@ -291,7 +421,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
.eq(ResourceEntity::getId, resourceEntity.getId())
.eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
resourceDao.update(entity, updateWrapper);
ResourceBrowseEntity browseEntity = new ResourceBrowseEntity();
browseEntity.setResourceId(id);
browseEntity.setUserId(SecurityUser.getUserId());
@ -372,17 +501,21 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).forEach(item -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
map.put("total", resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")));
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
map.put("total", integer);
item.getValue().forEach(item1 -> item1.remove("type"));
map.put("dataList", item.getValue());
if (integer != 0) {
resultList.add(map);
}
});
Optional<List<Map<String, Object>>> areaList = Optional.ofNullable(listMap.get("区级"));
Optional<Map<String, List<Map<String, Object>>>> areaTypeList = Optional.ofNullable(areaList.orElse(new ArrayList<>()).stream()
.collect(Collectors.groupingBy(m -> m.get("districtName").toString())));
HashMap<Object, Object> areaMap = new HashMap<>();
areaMap.put("type", "区级");
areaMap.put("total", resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type")));
Integer integer = resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type"));
areaMap.put("total", integer);
ArrayList<Map> areaListTemp = new ArrayList<>();
areaTypeList.orElse(new HashMap<>()).forEach((key, value) -> {
HashMap<String, Object> map = new HashMap<>();
@ -393,7 +526,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
areaListTemp.add(map);
});
areaMap.put("dataList", areaListTemp);
if (integer != 0) {
resultList.add(areaMap);
}
return resultList;
}
@ -712,4 +847,20 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}).collect(Collectors.toList());
}
@Override
public Object componentServiceRank(String type) {
switch (type) {
case "total":
return resourceDao.selectTopFiveComponentServiceApplications();
case "score":
return resourceDao.selectTopFiveComponentServiceScore();
default:
return new HashMap<>();
}
}
@Override
public Integer getProjectPlace() {
return this.projectPlace;
}
}

View File

@ -0,0 +1,16 @@
package io.renren.modules.resource.videoPreview;
/**
* 视频预览抽象类
*/
public abstract class AbstractVideoPreviewService {
/**
* 获取hls预览地址
*
* @param key 获取hls地址的键
* @return
*/
public abstract String getHls(String key);
}

View File

@ -0,0 +1,72 @@
package io.renren.modules.resource.videoPreview;
import io.renren.common.constant.Constant;
import io.renren.common.domain.BaoTouProperties;
import io.renren.common.domain.TsingtaoProperties;
import io.renren.common.domain.Tsingtao_xhaProperties;
import io.renren.common.utils.SpringContextUtils;
import io.renren.modules.monitor.service.MonitorService;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resource.videoPreview.domain.BaoTouVideoPreviewService;
import io.renren.modules.resource.videoPreview.domain.TsingtaoVideoPreviewService;
import io.renren.modules.resource.videoPreview.domain.TsingtaoXHAVideoPreviewService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Optional;
/**
* 视频预览工厂类
*/
public final class VideoPreviewFactory {
private static Logger logger = LoggerFactory.getLogger(VideoPreviewFactory.class);
private static ResourceService resourceService;
private static int projectPlace;
private static BaoTouProperties baoTouProperties; // 包头配置
private static MonitorService monitorService;
private static TsingtaoProperties tsingtaoProperties; // 青岛市区配置
private static Tsingtao_xhaProperties tsingtao_xhaProperties; // 青岛西海岸配置
static {
VideoPreviewFactory.resourceService = SpringContextUtils.getBean(ResourceService.class);
VideoPreviewFactory.projectPlace = resourceService.getProjectPlace();
VideoPreviewFactory.baoTouProperties = SpringContextUtils.getBean(BaoTouProperties.class);
VideoPreviewFactory.monitorService = SpringContextUtils.getBean(MonitorService.class);
VideoPreviewFactory.tsingtaoProperties = SpringContextUtils.getBean(TsingtaoProperties.class);
VideoPreviewFactory.tsingtao_xhaProperties = SpringContextUtils.getBean(Tsingtao_xhaProperties.class);
}
/**
* 获取预览服务实现
*
* @return
*/
public static Optional<AbstractVideoPreviewService> build() {
AbstractVideoPreviewService abstractVideoPreviewService = null;
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO: { // 青岛市局
abstractVideoPreviewService = new TsingtaoVideoPreviewService(monitorService);
}
break;
case TSINGTAO_XHA: { // 青岛西海岸
abstractVideoPreviewService = new TsingtaoXHAVideoPreviewService(tsingtao_xhaProperties);
}
break;
case BAOTOU: { // 包头
abstractVideoPreviewService = new BaoTouVideoPreviewService(baoTouProperties);
}
break;
case UNKNOWN: { // 未知区域
logger.error("区域未知");
}
break;
}
return Optional.ofNullable(abstractVideoPreviewService);
}
}

View File

@ -0,0 +1,51 @@
package io.renren.modules.resource.videoPreview.domain;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.domain.BaoTouProperties;
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 包头预览
*/
public class BaoTouVideoPreviewService extends AbstractVideoPreviewService {
private static Logger logger = LoggerFactory.getLogger(BaoTouVideoPreviewService.class);
private static final OkHttpClient client = new OkHttpClient();
private BaoTouProperties baoTouProperties;
public BaoTouVideoPreviewService(BaoTouProperties baoTouProperties) {
this.baoTouProperties = baoTouProperties;
}
/**
* 获取hls预览地址
*
* @param key 获取hls地址的键
* @return
*/
@Override
public String getHls(String key) {
String hls = null;
Request request = new Request.Builder().url(String.format(baoTouProperties.getHlsurl(), key)).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
hls = jsonObject.getString("data");
}
} else {
logger.error("包头预览地址获取失败");
}
} catch (Exception exception) {
logger.error("包头预览地址获取失败", exception);
}
return hls;
}
}

View File

@ -0,0 +1,37 @@
package io.renren.modules.resource.videoPreview.domain;
import io.renren.modules.monitor.service.MonitorService;
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
* 青岛市局预览
*/
public class TsingtaoVideoPreviewService extends AbstractVideoPreviewService {
private static Logger logger = LoggerFactory.getLogger(BaoTouVideoPreviewService.class);
private MonitorService monitorService;
public TsingtaoVideoPreviewService(MonitorService monitorService) {
this.monitorService = monitorService;
}
/**
* 获取hls预览地址
*
* @param key 获取hls地址的键
* @return
*/
@Override
public String getHls(String key) {
try {
return monitorService.fileCode(key);
} catch (IOException e) {
logger.error("青岛市局获取预览地址失败", e);
return null;
}
}
}

View File

@ -0,0 +1,76 @@
package io.renren.modules.resource.videoPreview.domain;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.domain.Tsingtao_xhaProperties;
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* 青岛西海岸
*/
public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService {
private static Logger logger = LoggerFactory.getLogger(TsingtaoXHAVideoPreviewService.class);
Tsingtao_xhaProperties tsingtao_xhaProperties;
public TsingtaoXHAVideoPreviewService(Tsingtao_xhaProperties tsingtao_xhaProperties) {
this.tsingtao_xhaProperties = tsingtao_xhaProperties;
}
/**
* 获取hls预览地址
*
* @param key 获取hls地址的键
* @return
*/
@Override
public String getHls(String key) {
List<String> result = new CopyOnWriteArrayList<>();
CompletableFuture cloud =
CompletableFuture.runAsync(() -> { // 云脑专网
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(String.format(tsingtao_xhaProperties.getCloudhls(), key)).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
result.add(jsonObject.getString("data"));
}
} else {
logger.error("西海岸预览地址获取失败");
}
} catch (Exception exception) {
logger.error("西海岸预览地址获取失败", exception);
}
});
CompletableFuture local =
CompletableFuture.runAsync(() -> { // 金宏网
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(String.format(tsingtao_xhaProperties.getLocalhls(), key)).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
result.add(jsonObject.getString("data"));
}
} else {
logger.error("西海岸预览地址获取失败");
}
} catch (Exception exception) {
logger.error("西海案预览地址获取失败", exception);
}
});
CompletableFuture.allOf(cloud, local);
return result.stream().filter(index -> StringUtils.isNotEmpty(index)).findAny().orElse(null);
}
}

View File

@ -9,10 +9,8 @@ import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSource
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.servlet.Filter;
import java.util.HashMap;
@ -83,8 +81,7 @@ public class ShiroConfig {
*/
filterMap.put("/upload", "anon");
filterMap.put("/upload/**", "anon");
filterMap.put("/census/center/**", "anon"); // 全局各类统计
filterMap.put("/census/center/**", "anon"); // 全局各类统计 包含 /census/center/v2
filterMap.put("/**", "oauth2");
shiroFilter.setFilterChainDefinitionMap(filterMap);

View File

@ -162,4 +162,16 @@ public class SysUserController {
ExcelUtils.exportExcelToTarget(response, null, "用户管理", list, SysUserExcel.class);
}
@GetMapping("getDeptInfoFromJH")
@ApiOperation("从金宏获取行政区划信息并保存到表中")
public Result getDeptInfoFromJH(){
return sysUserService.getDeptInfoFromJH();
}
@GetMapping("getUserInfoFromJH")
@ApiOperation("从金宏获取用户信息并保存到表中")
public Result getUserInfoFromJH() {
return sysUserService.getUserInfoFromJH();
}
}

View File

@ -41,4 +41,8 @@ public interface SysUserDao extends BaseDao<SysUserEntity> {
SysUserEntity getByDeptIdAndRoleId(@Param("deptId") Long deptId, @Param("roleId") Long roleId);
Long countAllUser();
void batchSaveUser(@Param("list")List<Map> list);
SysUserEntity getUserByName(@Param("username") String username);
}

View File

@ -73,5 +73,10 @@ public class SysUserEntity extends BaseEntity {
*/
@TableField(exist=false)
private String deptName;
/**
* 用户guid
* 2022-06-21 ytl根据黄工的需求新增
*/
private String guid;
}

View File

@ -0,0 +1,114 @@
package io.renren.modules.sys.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 金宏项目LDAP查询用户的根节点enum
*/
public enum JhDeptEnum {
//人大常委会("1","人大常委会"),
即墨区("即墨区",new String[]{
"即墨区人大","即墨区委办公室","即墨区委宣传部","即墨区委组织部","即墨区推进大数据发展","即墨区政协办公室",
"即墨区新型冠状病毒感染肺炎疫情防控指挥部","即墨区监察委","即墨区直单位","即墨区纪委","即墨区街道办事处","即墨区项目指挥部"
})
, 城阳区("城阳区",new String[]{
"区属机关","城阳区乡镇及街道办事处","城阳区人大","城阳区委办公室","城阳区政协","城阳区政府办公室","城阳区网上审批","工作机构"
})
, 崂山区("崂山区",new String[]{
"中共崂山区纪委监委机关","区委区政府议事协调机构","区直事业单位","区直企业","崂山区人大机关","崂山区党委部门","崂山区政协机关",
"崂山区政府部门","崂山区武装部","崂山区科技创新委员会","群团部门","街道科室及社区","青岛东亿实业总公司","青岛金家岭金融聚集区管委会",
"驻区企业","驻区单位"
})
,市南区("市南区",new String[]{
"市南区人大","市南区公检法","市南区区委","市南区政协","市南区政府","市南区电子政务和信息资源管理办公室","市南区纪委"
})
,市直企业("市直企业",new String[]{"世园集团","中石化青岛石油分公司","中石化经纬有限公司","中路财产保险股份有限公司",
"二轻总公司","交运集团","华电青岛热力有限公司","国信实业有限公司","国际机场集团","市政集团","海尔集团技术研发中心",
"纺织总公司","青岛万通证券公司","青岛中泰集团","青岛公交集团","青岛区域经济合作有限公司","青岛华通国有资本运营(集团)有限责任公司",
"青岛华青公司","青岛双星集团","青岛啤酒股份有限公司制造中心","青岛啤酒集团","青岛国信集团","青岛国投有限公司", "青岛城市发展集团有限公司",
"青岛城市建设集团有限公司","青岛旅游集团","青岛水务集团有限公司","青岛海信集团","青岛海尔集团","青岛海湾集团有限公司","青岛港集团",
"青岛澳柯玛集团","青岛红星化工集团有限责任公司","青岛能源集团有限公司","青岛西海岸有限公司","青岛银行","青岛饮料集团有限公司",
"青钢集团"
})
,市直机关("市直机关",new String[]{
"中共青岛中德生态园党组","中级法院","人力资源和社会保障局","人防办","企业托管中心","供销社","侨联","信访局","公安局","其他单位",
"出版社","医疗保障局","卫生健康委","司法局","商务局","团市委","国家统计局青岛调查队","国资委","外办","妇联","审计局","宣传部",
"崂山风景区管理局","工商联","市农业农村局","市发展改革委","市场监督管理局","市城市管理局","市委党校","市委军民融合办","市委政研室",
"市委网信办","市工业和信息化局","市政府研究室","市政府驻京办","市直机关工委","市纪委监委机关","市经济发展研究院","市自然资源和规划局",
"广播电视局","应急管理局","建管局","总工会","政法委","教育局","文联","日报社","机关事务局","档案馆","检察院","残联","民政局",
"气象局","电大","畜牧兽医局","社科院","科协","科技局","红十字会","组织部","统战部","统计局","综合行政执法支队","编委办",
"老干局","财政局","贸促会","退役军人事务局","青岛仲裁委员会办公室","青岛前湾保税港区","青岛国际邮轮港管理局","青岛工程职业学院",
"青岛市乡村振兴局","青岛市交通运输局","青岛市住房公积金管理中心","青岛市住房和城乡建设局","青岛市体育局","青岛市信息产业局",
"青岛市园林和林业局","青岛市地铁工程建设指挥部","青岛市大数据发展管理局","青岛市委党史研究院","青岛市委台港澳工作办公室",
"青岛市政府驻沪办","青岛市文化和旅游局","青岛市民营经济发展局","青岛市水务管理局","青岛市水文局","青岛市海洋发展局","青岛市深圳联络办事处",
"青岛市生态环境局","青岛市董家口港区开发建设指挥部","青岛市行政审批服务局","青岛市金融工作办公室","青岛市驻济南办事办",
"青岛技师学院","青岛技院","青岛海洋科学与技术国家实验室发展中心","青岛蓝谷管理局","青岛蓝谷管理局"
})
,平度市("平度市",new String[]{
"人大","企业用户","市委办","市直各单位","政协","政府办"
})
,新市北区("新市北区",new String[]{
"区属企业","四方区","市北区","市北区人大","市北区委","市北区政协","市北区政府","市北区政法机关","市北区纪委","驻区单位"
})
,李沧区("李沧区",new String[]{
"“五位一体”联合督查","其他企业","区属机关","李沧区人大办公室","李沧区委“作风能力提升年”活动领导小组","李沧区委办公室",
"李沧区政协办公室","李沧区政府办公室","李沧区街道办事处","青岛市李沧区行政审批大厅"
})
,胶州市("胶州市",new String[]{
"12345","365便民服务中心","中共胶州市纪律检查委员会机关(胶州市监察委员会机关)","垂直管理机构","市委机构","政协胶州市委员会机构",
"政府机构","胶州市人大常委会","胶州市人民团体","胶州市人民检察院","胶州市人民武装部","胶州市人民法院","胶州市企业发展局",
"胶州市发展和改革局","胶州市镇及街道办事处","集团公司"
})
,莱西市用户("",new String[]{
"人大办","区属机关","双管单位","市委办","市级领导","政协办","政府办","省青岛市驻莱西机构","莱西市疫情防控指挥部",
"重点企业"
})
,青岛市级("青岛市级",new String[]{
})
,驻青单位("驻青单位",new String[]{
"中国农科院烟草研究所","中国动物卫生与流行病学中心","中国铁塔股份有限公司青岛市分公司","交通运输部北海航海保障中心青岛通信中心",
"国家体育总局青岛航海运动学校","安全局","山东广电网络有限公司青岛分公司","山东省海警第二支队","市邮政管理局",
"民航青岛安监管理局","气象局","海事局","烟草专卖局","省胶东调水局青岛分局","财政部青岛监管局","铁路分局","青岛出入境检验检疫局",
"青岛地质勘查开发局","青岛大学","青岛市税务局","青岛市驻青国企党建研究会","青岛广电影视传媒集团有限公司","青岛机场检验检疫局",
"青岛海关"
})
,黄岛区("黄岛区",new String[]{
"中共青岛市黄岛区委军民融合发展委员会办公室","中央驻区单位","公众投诉热线","其他联网单位","凤凰岛南岛片区村庄拆迁工作指挥部",
"垂直机构","胶南市委办公室","董家口管委","西海岸中央公园建设指挥部","西海岸新区新型冠状病毒感染肺炎疫情防控指挥部",
"西海岸新区涉稳隐患排查化解指挥部","西海岸新区解放思想大讨论工作推进小组办公室","西海岸经济新区中央商务区开发建设指挥部",
"西海岸经济新区工委管委","西海岸轨道交通指挥部","转型发展区建设推进指挥部","青岛中央活力区规划建设指挥部","青岛海洋高新区管理委员会",
"青岛西海岸新区“啤酒之城”攻坚战指挥部","青岛西海岸新区六大攻坚战总指挥部","青岛西海岸新区教育卫生项目建设推进工作领导小组",
"驻青单位","黄岛区人大","黄岛区企业","黄岛区区直机关","黄岛区委","黄岛区政协","黄岛区政府办公室","黄岛区督导巡查组","黄岛区骨干企业(原胶南市骨干企业)"
})
;
private String[] value;
private String code;
JhDeptEnum(String code,String[] value) {
this.code = code;
this.value = value;
}
public String[] getValue(){
return value;
}
public String getCode(){
return code;
}
public static List<Map> getAllToList() {
List<Map> list = new ArrayList<>();
JhDeptEnum[] values = values();
for(JhDeptEnum r:values){
Map pd = new HashMap();
pd.put(r.getCode(),r.getValue());
list.add(pd);
}
return list;
}
}

View File

@ -0,0 +1,50 @@
package io.renren.modules.sys.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum JhDeptsEnum {
即墨区("1","即墨区"),
城阳区("2","城阳区"),
崂山区("3","崂山区"),
市南区("4","市南区"),
市直企业("5","市直企业"),
市直机关("6","市直机关"),
平度市("7","平度市"),
新市北区("8","新市北区"),
李沧区("9","李沧区"),
胶州市("10","胶州市"),
莱西市用户("11","莱西市用户"),
青岛市级("12","青岛市级"),
驻青单位("13","驻青单位"),
黄岛区("14","黄岛区")
;
private String value;
private String code;
JhDeptsEnum(String code,String value) {
this.code = code;
this.value = value;
}
public String getValue(){
return value;
}
public String getCode(){
return code;
}
public static List<Map> getAllToList() {
List<Map> list = new ArrayList<>();
JhDeptsEnum[] values = values();
for(JhDeptsEnum r:values){
Map pd = new HashMap();
pd.put(r.getCode(),r.getValue());
list.add(pd);
}
return list;
}
}

View File

@ -2,6 +2,7 @@ package io.renren.modules.sys.service;
import io.renren.common.page.PageData;
import io.renren.common.service.BaseService;
import io.renren.common.utils.Result;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.entity.SysUserEntity;
@ -55,4 +56,8 @@ public interface SysUserService extends BaseService<SysUserEntity> {
*/
Long countAllUser();
Result getDeptInfoFromJH();
Result getUserInfoFromJH();
}

View File

@ -1,16 +1,25 @@
package io.renren.modules.sys.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.renren.common.constant.Constant;
import io.renren.common.page.PageData;
import io.renren.common.service.impl.BaseServiceImpl;
import io.renren.common.utils.ConvertUtils;
import io.renren.common.utils.JhlDAPTool;
import io.renren.common.utils.Result;
import io.renren.modules.security.password.PasswordUtils;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail;
import io.renren.modules.sys.dao.SysDeptDao;
import io.renren.modules.sys.dao.SysRegionDao;
import io.renren.modules.sys.dao.SysUserDao;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.entity.SysDeptEntity;
import io.renren.modules.sys.entity.SysRegionEntity;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.enums.JhDeptEnum;
import io.renren.modules.sys.enums.JhDeptsEnum;
import io.renren.modules.sys.enums.SuperAdminEnum;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRoleUserService;
@ -21,9 +30,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.naming.ldap.LdapContext;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
/**
@ -37,6 +48,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
private SysDeptService sysDeptService;
@Autowired
private SysUserPostService sysUserPostService;
@Autowired
private JhlDAPTool jhlDAPTool;
@Autowired
private SysDeptDao sysDeptDao;
@Autowired
private SysUserDao sysUserDao;
@Autowired
private SysRegionDao regionDao;
@Override
public PageData<SysUserDTO> page(Map<String, Object> params) {
@ -177,4 +196,265 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
return baseDao.countAllUser();
}
@Override
public Result getDeptInfoFromJH(){
List<Map> deptList = JhDeptEnum.getAllToList();
int size = deptList.size();
try{
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
for (int n = 0; n < size; n++) {
Map map1 = deptList.get(n);
Set<String> set = map1.keySet();
String mName = "";
for(String s:set){
mName = s;
}
String key = mName;//区名即墨区
String[] ouStr = (String[])map1.get(key);
for(String ou:ouStr){
String OU = ou+","+"OU="+mName;
LdapContext ldapContext = jhlDAPTool.LDAP_connect(OU);
List<Map<String,Object>> lists = jhlDAPTool.readLdap(ldapContext,"(&(OU=*)(ou=*)(!(sAMAccountType=*))(instanceType=4))");
//Iterator<Map<String,Object>> iterator = lists.iterator();
//给pid pids赋值
if (lists.size() > 0) {
lists.forEach(dept->{//1.遍历每一个map
String namespace = dept.get("namespace").toString();
//OU=地税局分局,OU=驻区单位,OU=新市北区,DC=qd,DC=gov,DC=cn
String[] namespaces = namespace.split(",");
//判断namespaces的长度
for(int i=1;i<namespaces.length-3;i++) {//遍历每一个map的namespace
String dName = namespaces[i].split("=")[1];//具体的上级部门名称
int c = i;
for (int j = 0; j < lists.size(); j++) {
Map<String, Object> map = new HashMap<>();
if (dName.equals(lists.get(j).get("name").toString())) {
String id = lists.get(j).get("id").toString();
String pidsOld = dept.get("pids").toString() == ""? "" : (dept.get("pids").toString() + ",");
if (c == 1) {
dept.put("pid", id);
dept.put("pids", pidsOld + id);
} else {
dept.put("pids", pidsOld + id);
}
break;
}
}
}
});
//给district和type赋值
String districtName,type;
Long distict;
switch (key){
case "新市北区":
districtName = "市北区";
distict = getDistict(districtName);
lists.forEach(l->{
l.put("district",distict);
String name = l.get("name").toString();
if(name.contains("企业") || name.contains("集团") || name.contains("公司")){
l.put("type",4);
}else{
l.put("type",3);
}
});
break;
case "青岛市级":
districtName = "青岛市";
distict = getDistict(districtName);
lists.forEach(l->{
l.put("district",distict);
l.put("type",2);
});
break;
case "莱西市用户":
districtName = "莱西市";
distict = getDistict(districtName);
lists.forEach(l->{
l.put("district",distict);
String name = l.get("name").toString();
if(name.contains("企业") || name.contains("集团") || name.contains("公司")){
l.put("type",4);
}else{
l.put("type",3);
}
});
break;
case "黄岛区":
districtName = "西海岸新区";
distict = getDistict(districtName);
lists.forEach(l->{
l.put("district",distict);
String name = l.get("name").toString();
if(name.contains("企业") || name.contains("集团") || name.contains("公司")){
l.put("type",4);
}else{
l.put("type",3);
}
});
break;
case "市直企业":
distict = getDistict("青岛市");
lists.forEach(l->{
l.put("district",distict);
l.put("type",4);
});
break;
case "市直机关":
distict = getDistict("青岛市");
lists.forEach(l->{
l.put("district",distict);
l.put("type",2);
});
break;
case "驻青单位":
distict = getDistict("山东省");
lists.forEach(l->{
l.put("district",distict);
l.put("type",1);
});
break;
default:
distict = getDistict(mName);
lists.forEach(l->{
l.put("district",distict);
String name = l.get("name").toString();
if(name.contains("企业") || name.contains("集团") || name.contains("公司")){
l.put("type",4);
}else{
l.put("type",3);
}
});
}
lists.forEach(list->{//如果有该ID和name目前暂不处理否则插入
SysDeptEntity dept = sysDeptDao.getById(Long.valueOf(list.get("id").toString()));
SysDeptEntity deptNew = new SysDeptEntity();
deptNew.setName(list.get("name").toString());
deptNew.setId(Long.valueOf(list.get("id").toString()));
deptNew.setPid(Long.valueOf(list.get("pid").toString()));
deptNew.setPids(list.get("pids").toString());
deptNew.setDistrict(Long.valueOf(list.get("district").toString()));
deptNew.setType(Integer.parseInt(list.get("type").toString()));
if(dept == null){
System.out.println("deptname->"+deptNew.getName());
sysDeptDao.insert(deptNew);
}
});
}
}
}
}
});
return new Result().ok("保存成功");
}catch (Exception e){
e.printStackTrace();
return new Result().error("保存失败");
}
}
@Override
public Result getUserInfoFromJH(){
List<Map> deptList = JhDeptsEnum.getAllToList();
int size = deptList.size();
try {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
for (int i = 1; i <= size; i++) {
LdapContext ldapContext = jhlDAPTool.LDAP_connect(deptList.get(i - 1).get(String.valueOf(i)).toString());
List<Map> maps = jhlDAPTool.readLdap(ldapContext);
if (maps.size() > 0) {
maps.forEach(m-> {
//根据username判断
if(m.get(("username")) != null){
String userName = m.get("username").toString();
SysUserEntity user = sysUserDao.getUserByName(userName);
if(user == null){//用户表中没有该用户插入
SysUserEntity newUser = new SysUserEntity();
newUser.setUsername(userName);
newUser.setSuperAdmin(0);
newUser.setGuid(m.get("guid") == null ? "":m.get("guid").toString());
newUser.setId(Long.valueOf(m.get("id") == null ? "0":m.get("id").toString()));
newUser.setRealName(m.get("real_name") == null ?"":m.get("real_name").toString());
newUser.setEmail(m.get("email") == null ?"":m.get("email").toString());
newUser.setMobile(m.get("mobile") == null ?"":m.get("mobile").toString());
newUser.setStatus(1);//账号状态 1正常 0停用
//给dept_id赋值
String deptNames = m.get("distinguishedName") == null ? "":m.get("distinguishedName").toString();
if(deptNames == null){
newUser.setDeptId(0L);
}else{
String[] deptArray = deptNames.split(",");
String dept,deptFather;
dept = deptArray[1];
deptFather = deptArray[2];
long id = getDeptId(dept.substring(3,dept.length()),deptFather.substring(3,deptFather.length()));
newUser.setDeptId(id);
sysUserDao.insert(newUser);
}
}
}
});
}
}
}
});
return new Result().ok("保存成功");
} catch (Exception e) {
e.printStackTrace();
return new Result().error("保存失败");
}
}
public SysRegionEntity getRegion(String name){
QueryWrapper<SysRegionEntity> regionWrapper = new QueryWrapper<>();
regionWrapper.eq("name",name);
SysRegionEntity region = regionDao.selectOne(regionWrapper);
return region;
}
public long getDeptId(String deptName,String fatherDeptName){
QueryWrapper<SysDeptEntity> deptWrapper = new QueryWrapper<>();
deptWrapper.eq("name",deptName);
List<SysDeptEntity> deptList = sysDeptDao.selectList(deptWrapper);
if(deptList.size() == 0){
return 0;
}else if(deptList.size() == 1){
return deptList.get(0).getId();
}else{//出现多个相同的deptname,根据他们的父级来确定
AtomicLong newId = new AtomicLong();
deptList.forEach(dept->{
long fatherId = dept.getPid();//获取其中一个的父级ID
SysDeptEntity fatherEntity = sysDeptDao.getById(fatherId);//根据父级ID查询管理部门
if(fatherEntity != null && fatherEntity.getName().equals(fatherDeptName)){//如果该管理部门的名称等于传进来的父级名称那么这条dept就是我们需要的
if(fatherEntity.getId() == fatherId){//如果父级ID等于
newId.set(dept.getId());
}
}
});
return newId.get();
}
}
public Long getDistict(String deptName){
QueryWrapper<SysRegionEntity> regionWrapper = new QueryWrapper<>();
regionWrapper.eq("name",deptName);
SysRegionEntity entity = regionDao.selectOne(regionWrapper);
if (entity == null) {
return 0L;
}else{
return entity.getId();
}
}
}

View File

@ -36,7 +36,7 @@ public class WorkDynamicsDTO implements Serializable {
private Long updater;
@ApiModelProperty(value = "修改时间")
private Date updateDate;
@ApiModelProperty(value = "备用字段1")
@ApiModelProperty(value = "摘要")
private String note1;
@ApiModelProperty(value = "备用字段2")
private String note2;

View File

@ -59,7 +59,7 @@ public class WorkDynamicsEntity {
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
/**
* 备用字段1
* 摘要
*/
private String note1;
/**

View File

@ -36,7 +36,7 @@ public class WorkDynamicsExcel {
private Long updater;
@ExcelProperty(value = "修改时间", index = 8)
private Date updateDate;
@ExcelProperty(value = "备用字段1", index = 9)
@ExcelProperty(value = "摘要", index = 9)
private String note1;
@ExcelProperty(value = "备用字段2", index = 10)
private String note2;

View File

@ -0,0 +1,55 @@
server:
port: 8888
spring:
datasource:
druid:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.10.30.10:3306/nlpt?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: nlpt
password: Nlpt@2022
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 10
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
#上传的静态资源配置
resource:
root_url: 10.10.30.9
pic-host: http://${resource.root_url}:${server.port}${server.servlet.context-path}
path: /data1/services/nengli/files/
devModelFilePath: /data1/services/nengli/files/devModelFile
# 大数据部门相关配置
big_date:
name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人
hisense:
gateway:
url: http://devtest-security-app.hismarttv.com:8080
#调用青岛应急局-查询青岛地区天气信息接口
qdyjj:
ipAndPort: 15.2.21.238:9015

View File

@ -0,0 +1,55 @@
server:
port: 8888
spring:
datasource:
druid:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.10.30.10:3306/nlpt?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: nlpt
password: Nlpt@2022
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 10
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
#上传的静态资源配置
resource:
root_url: 10.10.30.9
pic-host: http://${resource.root_url}:${server.port}${server.servlet.context-path}
path: /data1/services/nengli/files/
devModelFilePath: /data1/services/nengli/files/devModelFile
# 大数据部门相关配置
big_date:
name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人
hisense:
gateway:
url: http://devtest-security-app.hismarttv.com:8080
#调用青岛应急局-查询青岛地区天气信息接口
qdyjj:
ipAndPort: 15.2.21.238:9015

View File

@ -1,3 +1,6 @@
project:
# 平台部署位置 0青岛市区 1青岛西海岸 2包头
place: 0
# 大数据部门相关配置
big_date:
name: 青岛市大数据发展管理局
@ -52,8 +55,8 @@ spring:
resources:
static-locations: classpath:/static,classpath:/public,file:${resource.path}
flyway:
enable: true
locations: classpath:db
enabled: true
locations: filesystem:config/db
baseline-on-migrate: true
baseline-version: 0
@ -93,7 +96,7 @@ system:
yawei:
enable: true
#知识库
#对接知识库相关配置
zsk:
url:
sign: https://cms.qingdao.gov.cn:9020/api-gateway/jpaas-jags-server/interface/createsign.do

View File

@ -52,6 +52,9 @@
<include>*.json</include>
<include>db/*.sql</include>
</includes>
<excludes>
<exclude>application-prod.yml</exclude>
</excludes>
<filtered>true</filtered>
<outputDirectory>${file.separator}config</outputDirectory>
</fileSet>

View File

@ -0,0 +1,3 @@
UPDATE sys_notice SET `from` = '评论' WHERE title LIKE '需求%';
UPDATE sys_notice SET `from` = '通知' WHERE title LIKE '流程%';
UPDATE sys_notice SET `from` = '其他' WHERE title IS NULL;

View File

@ -1 +1,2 @@
ALTER TABLE `share_platform`.`t_resource_mount_apply` ADD COLUMN `resource_dto` json NULL COMMENT '挂载资源对象' AFTER `resource_id`;
ALTER TABLE `share_platform`.`t_resource_mount_apply` ADD COLUMN `resource_dto` json NULL COMMENT '挂载资源对象';
UPDATE `share_platform`.`t_resource_mount_apply` SET resource_dto = parameter_content;

View File

@ -0,0 +1,3 @@
ALTER TABLE `share_platform`.`tb_data_attr`
ADD INDEX `resource_id`(`data_resource_id`),
ADD FULLTEXT INDEX `attr_value`(`attr_type`, `attr_value`);

View File

@ -0,0 +1 @@
ALTER TABLE `share_platform`.`tb_data_resource` ADD COLUMN `info_list` json NULL COMMENT '属性信息';

View File

@ -0,0 +1,2 @@
ALTER TABLE `share_platform`.`tb_work_dynamics`
MODIFY COLUMN `note1` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '摘要';

View File

@ -0,0 +1 @@
ALTER TABLE `sys_user` ADD COLUMN `guid` varchar(100) NULL;

View File

@ -0,0 +1 @@
ALTER TABLE `sys_notice` ADD COLUMN `from` varchar(255) NULL COMMENT '通知来源';

View File

@ -0,0 +1 @@
baotou.hlsurl=http://10.110.205.1:18088/server/device/hisdeviceapplylist/url/%s

View File

@ -0,0 +1,6 @@
tsingtao-xha.cloudhls=http://10.10.30.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls
tsingtao-xha.localhls=http://10.134.135.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls
tsingtao-xha.cloudcam=http://10.10.30.9:8001/hx-weather-warning/camera/getCameraListByName?name=%s&pageNo=%d&pageSize=%d
tsingtao-xha.localcam=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraListByName?name=%s&pageNo=%d&pageSize=%d
tsingtao-xha.resourcecount=http://10.16.3.224:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=&type=&orderField=requestNum&orderType=desc&pageNum=1&pageSize=10&serviceType=data&rq=1655106309671.43
tsingtao-xha.resourceapplyinfo=http://10.134.135.24:30058/shareportal/platform/index/abilityMarket/count

View File

@ -33,6 +33,8 @@
<result property="enclosure" column="enclosure"/>
<result property="undercarriageReason" column="undercarriage_reason"/>
<result property="undercarriageUserName" column="undercarriage_user_name"/>
<result property="infoList" column="info_list"
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
</resultMap>
<resultMap id="resourceDTO" type="io.renren.modules.resource.dto.ResourceDTO">
@ -103,7 +105,7 @@
<select id="selectWithAttrs" resultMap="resourceDTO">
SELECT
tdr.*,
DISTINCT tdr.*,
IFNULL(taa2.approve_status, '未申请') AS "applyState",
IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount",
@ -179,6 +181,9 @@
FROM tb_data_resource
WHERE 1 = 1
AND del_flag = 0
<if test="type != null and type != ''">
AND type = #{type}
</if>
GROUP BY type
ORDER BY type
</select>
@ -249,7 +254,7 @@
sd.NAME AS "deptName",
IFNULL( trc2.isCollect, 'false' ) AS "isCollect",
IF
( taa2.approve_status &lt; 1, '未申请', "已申请" ) AS "applyState"
( taa2.approve_status &lt; 1, '未申请', '已申请' ) AS "applyState"
FROM
tb_data_resource tdr
LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0
@ -564,7 +569,8 @@
tdav.data_resource_id AS resourceId
FROM
tb_data_attr tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
1 = 1
AND tdav.attr_type = '应用领域'
@ -827,7 +833,8 @@
COUNT( tdav.data_resource_id ) AS "count"
FROM
tb_data_attr tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
1 = 1
AND tdav.attr_type = '应用领域'
@ -847,7 +854,8 @@
COUNT( tdav.data_resource_id ) AS "count"
FROM
tb_data_attr tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
1 = 1
AND tdav.attr_type = '应用领域'
@ -880,7 +888,8 @@
COUNT( tdav.data_resource_id ) AS "total"
FROM
tb_data_attr tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
1 = 1
AND tdav.attr_type = '应用领域'
@ -890,4 +899,43 @@
type
</select>
<select id="selectTopFiveComponentServiceApplications" resultType="java.util.Map">
SELECT
tdr.id AS "resourceId",
tdr.NAME AS "name",
IFNULL(COUNT( taa.id ), 0) AS "count"
FROM
tb_data_resource tdr
LEFT JOIN t_ability_application taa ON tdr.id = taa.resource_id AND taa.del_flag = 0
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.type = '组件服务'
GROUP BY
tdr.id
ORDER BY
count DESC
LIMIT 5
</select>
<select id="selectTopFiveComponentServiceScore" resultType="java.util.Map">
SELECT
tdr.id AS "resourceId",
tdr.NAME AS "name",
IFNULL( SUM( trs.score ), 0 ) AS "score"
FROM
tb_data_resource tdr
LEFT JOIN tb_resource_score trs ON tdr.id = trs.resource_id
AND trs.del_flag = 0
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.type = '组件服务'
GROUP BY
tdr.id
ORDER BY
score DESC
LIMIT 5
</select>
</mapper>

View File

@ -73,5 +73,18 @@
WHERE
`status` = 1
</select>
<insert id="batchSaveUser" parameterType="java.util.List">
INSERT INTO user_bak (displayName,distinguishedName,userPrincipalName,telephoneNumber,objectGUID,sAMAccountName,primaryGroupID)
values
<foreach collection="list" item="item" separator="," >
(
#{item.displayName},#{item.distinguishedName},#{item.userPrincipalName},#{item.telephoneNumber},
#{item.objectGUID},#{item.sAMAccountName},#{item.primaryGroupID}
)
</foreach>
</insert>
<select id="getUserByName" parameterType="java.lang.String" resultType="io.renren.modules.sys.entity.SysUserEntity">
SELECT id,username FROM sys_user WHERE username = #{username} limit 1
</select>
</mapper>

View File

@ -1,5 +1,7 @@
package io.renren.common.constant;
import java.util.Arrays;
/**
* 常量
*/
@ -212,4 +214,40 @@ public interface Constant {
return value;
}
}
/**
* 项目运行地点
*/
enum ProjectPlace {
/**
* 青岛市区
*/
TSINGTAO(0),
/**
* 青岛西海岸
*/
TSINGTAO_XHA(1),
/**
* 包头
*/
BAOTOU(2),
/**
* 未知
*/
UNKNOWN(Integer.MAX_VALUE);
private int value;
ProjectPlace(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static ProjectPlace getByFlag(int flag) {
ProjectPlace[] index = ProjectPlace.values();
return Arrays.asList(index).stream().filter(index_ -> index_.value == flag).findAny().orElse(ProjectPlace.UNKNOWN);
}
}
}

View File

@ -0,0 +1,292 @@
package io.renren.common.utils;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.*;
import java.util.*;
/**
* 通过该类完成金宏系统中 部门和用户名信息的提取
*/
@Component
public class JhlDAPTool {
private String URL = "ldap://15.72.158.50:389/";
private String BASEDN = "DC=qd,DC=gov,DC=cn";//指定从哪里开始搜索从上往下推
private String username = "CN=智慧发改项目认证接入,OU=管理开发用户,DC=qd,DC=gov,DC=cn";//要登录的账号所在位置从下往上推
private String password = "QD@zhfg2019";
private String FACTORY = "com.sun.jndi.ldap.LdapCtxFactory";
LdapContext ctx = null;
Control[] connCtls = null;
//登录LDAP服务器
public LdapContext LDAP_connect(String OU) {
//1. 设置初始LDAP上下文的属性并初始化LDAP上下文
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
if(StringUtils.isEmpty(OU)){
env.put(Context.PROVIDER_URL, URL +BASEDN);//路径
}else{
env.put(Context.PROVIDER_URL, URL + "OU="+OU+","+BASEDN);//路径
}
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, username); // 管理员
env.put(Context.SECURITY_CREDENTIALS, password); // 管理员密码
// **解决 乱码 的关键一句
env.put("java.naming.ldap.attributes.binary","objectGUID");
try {
ctx = new InitialLdapContext(env, connCtls);
System.out.println( "连接成功" );
return ctx;
} catch (javax.naming.AuthenticationException e) {
System.out.println("连接失败:");
e.printStackTrace();
} catch (Exception e) {
System.out.println("连接出错:"+e.getMessage());
e.printStackTrace();
}
return null;
}
private void closeContext(){
if (ctx != null) {
try {
ctx.close();
}
catch (NamingException e) {
e.printStackTrace();
}
}
}
/**
* 根据区名获取用户信息
* @param
* @param
* @return
*/
public List<Map> readLdap(LdapContext ctx){//OU=即墨区,
List<Map> lm=new ArrayList<Map>(1000);
byte[] cookie = null;
try {
if(ctx!=null) {
//2. 设置查询的属性
SearchControls searchControls = new SearchControls();//搜索控件
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);//搜索范围,1只搜索指定命名对象的一个级别这是缺省值2以指定命名对象为根结点的整棵树
//分页
ctx.setRequestControls(new Control[]{new PagedResultsControl(2, Control.CRITICAL)});
do {
NamingEnumeration<SearchResult> answer = ctx.search("", "sAMAccountType=805306368", searchControls);
//NamingEnumeration<SearchResult> answer = ctx.search("", "objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=gov,DC=cn", searchControls);
while (answer.hasMore()) {
SearchResult result = (SearchResult) answer.next();
NamingEnumeration<? extends Attribute> attrs = result.getAttributes().getAll();
//System.out.println("getNameInNamespace-》"+result.getNameInNamespace());//CN=李平先,OU=抬三,OU=即墨普东中心社区,OU=即墨中心社区,OU=即墨区,DC=qd,DC=gov,DC=cn
Map<String,Object> user = new HashMap<>();
while (attrs.hasMore()) {
Attribute next = attrs.next();
//System.out.println(next);
if ("displayName".equals(next.getID())) {
user.put("real_name",next.get().toString());
//user.setDisplayName(next.get().toString());
}else if("sAMAccountName".equals(next.getID())){
user.put("username",next.get().toString());
//user.setSamaccountName(next.get().toString());
}else if("userPrincipalName".equals(next.getID())){
user.put("email",next.get().toString());
//user.setUserPrincipalName(next.get().toString());
}else if("telephoneNumber".equals(next.getID())){
user.put("mobile",next.get().toString());
//user.setTelephoneNumber(next.get().toString());
}else if("distinguishedName".equals(next.getID())){
//CN=葛琳,OU=城阳区疾病预防控制中心,OU=城阳区卫生健康局,OU=区属机关,OU=城阳区,DC=qd,DC=gov,DC=cn
// String distinguishedName = next.get().toString();
// String[] distinguishedNames = distinguishedName.split(",");
// String deptName = distinguishedNames[1].split("=")[1];
user.put("distinguishedName",next.get().toString());
}else if("objectGUID".equals(next.getID())){
String guidStr = next.getID().toString();
user.put("id",SingleID.getSingleID(guidStr));
String guid = guidStr.substring(1,guidStr.length()-1);
user.put("guid",guid);
}
}
lm.add(user);
}
cookie = parseControls(ctx.getResponseControls());
ctx.setRequestControls(new Control[]{new PagedResultsControl(2, cookie, Control.CRITICAL)});
} while (cookie != null && (cookie.length != 0));
}
}catch (Exception e) {
System.out.println("获取用户信息异常:");
e.printStackTrace();
}finally {
closeContext();
}
System.out.println(lm.size());
return lm;
}
/**
* 获取管理部门信息
* @param ctx
* @param filter
* @return
*/
public List<Map<String,Object>> readLdap(LdapContext ctx,String filter){
List<Map<String,Object>> lm=new ArrayList<>(1000);
byte[] cookie = null;
try {
if(ctx!=null) {
//过滤条件
//String filter = "(&(objectClass=*)(uid=*))";
//String filter = "(&(userAccountControl=66048)(sAMAccountType=805306368))";
//String[] attrPersonArray = {"sAMAccountName", "distinguishedName", "displayName"};
//String[] attrPersonArray = { "uid", "userPassword", "displayName", "cn", "sn", "mail", "description","uidNumber","gidNumber" };
//2. 设置查询的属性
SearchControls searchControls = new SearchControls();//搜索控件
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);//搜索范围,1只搜索指定命名对象的一个级别这是缺省值2以指定命名对象为根结点的整棵树 SearchControls.SUBTREE_SCOPE
//searchControls.setReturningAttributes(attrPersonArray);
//分页
ctx.setRequestControls(new Control[]{new PagedResultsControl(2, Control.CRITICAL)});
//IdentifierGenerator identifierGenerator=new DefaultIdentifierGenerator();
do {
//3.(1)要搜索的上下文或对象的名称(2).过滤条件可为null默认搜索所有信息(3).搜索控件可为null使用默认的搜索控件
//objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=gov,DC=cn
//sAMAccountType=805306368
NamingEnumeration<SearchResult> answer = ctx.search("", filter, searchControls);
//NamingEnumeration<SearchResult> answer = ctx.search("", "objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=gov,DC=cn", searchControls);
//<SearchResult> answer = ctx.search("",filter.toString(),searchControls);
while (answer.hasMore()) {
SearchResult result = (SearchResult) answer.next();
NamingEnumeration<? extends Attribute> attrs = result.getAttributes().getAll();
//System.out.println(result.getName());//CN=李平先,OU=抬三,OU=即墨普东中心社区,OU=即墨中心社区
//System.out.println(result.getClass());
System.out.println("getNameInNamespace-》"+result.getNameInNamespace());//CN=李平先,OU=抬三,OU=即墨普东中心社区,OU=即墨中心社区,OU=即墨区,DC=qd,DC=gov,DC=cn
Map<String,Object> dept = new HashMap<>();
while (attrs.hasMore()) {
Attribute next = attrs.next();
//System.out.println(next);
if ("name".equals(next.getID())) {
String name = next.get().toString();
dept.put("name",name);
//dept.put("id",SingleID.getSingleID(name));
}else if("distinguishedName".equals(next.getID())){
//OU=事业发展中心,OU=办公厅,OU=人大常委会,DC=qd,DC=gov,DC=cn
dept.put("namespace",next.get());
}else if("instanceType".equals(next.getID())){
dept.put("instancetype",next.get());
}
else if("objectGUID".equals(next.getID())){
//{49D369CC-9DD3-407D-B618-01B00496039B}
byte[] GUID = (byte[])next.get();
String guid = getGUID(GUID);
String id = SingleID.getSingleID(guid);
dept.put("id",String.valueOf(id));
}
}
dept.put("pid",0);
dept.put("pids","");
if(!dept.get("name").toString().contains("停用") && !dept.get("name").toString().contains("删除") && !dept.get("name").toString().contains("人员") && !dept.get("name").toString().contains("临时")){
lm.add(dept);
}
//System.out.println("-----------------------------------------------");
}
cookie = parseControls(ctx.getResponseControls());
ctx.setRequestControls(new Control[]{new PagedResultsControl(2, cookie, Control.CRITICAL)});
} while (cookie != null && (cookie.length != 0));
}
}catch (Exception e) {
System.out.println("获取区域信息异常:");
e.printStackTrace();
}finally {
closeContext();
}
System.out.println(lm.size());
return lm;
}
//解决objectGUID乱码的具体方法
private static String getGUID(byte[] GUID) {
String strGUID = "";
String byteGUID = "";
//Convert the GUID into string using the byte format
for (int c=0;c<GUID.length;c++) {
byteGUID = byteGUID + "\\" + AddLeadingZero((int)GUID[c] & 0xFF);
}
strGUID = "{";
strGUID = strGUID + AddLeadingZero((int)GUID[3] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[2] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[1] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[0] & 0xFF);
strGUID = strGUID + "-";
strGUID = strGUID + AddLeadingZero((int)GUID[5] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[4] & 0xFF);
strGUID = strGUID + "-";
strGUID = strGUID + AddLeadingZero((int)GUID[7] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[6] & 0xFF);
strGUID = strGUID + "-";
strGUID = strGUID + AddLeadingZero((int)GUID[8] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[9] & 0xFF);
strGUID = strGUID + "-";
strGUID = strGUID + AddLeadingZero((int)GUID[10] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[11] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[12] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[13] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[14] & 0xFF);
strGUID = strGUID + AddLeadingZero((int)GUID[15] & 0xFF);
strGUID = strGUID + "}";
return strGUID;
}
static String AddLeadingZero(int k) {
return (k <= 0xF) ? "0" + Integer.toHexString(k) : Integer
.toHexString(k);
}
//分页查询时下次查询要用的cookie
private static byte[] parseControls(Control[] controls)
throws NamingException {
byte[] cookie = null;
if (controls != null) {
for (int i = 0; i < controls.length; i++) {
if (controls[i] instanceof PagedResultsResponseControl) {
PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls[i];
cookie = prrc.getCookie();
System.out.println(">>Next Page \n");
}
}
}
return (cookie == null) ? new byte[0] : cookie;
}
}

View File

@ -0,0 +1,25 @@
package io.renren.common.utils;
import java.math.BigInteger;
import java.security.MessageDigest;
/**
* 字符串根据MD5计算出定长的唯一数字符合mysql bigint的取值范围
*/
public class SingleID {
public static String getSingleID(String s) throws Exception{
// 第一步获取MessageDigest对象参数为MD5字符串表示这是一个MD5算法
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(s.getBytes());
//计算MD5值
byte[] bytes = md5.digest();
byte[] newBytes = new byte[8];
//因为转化的数字太长了所以截取部分进行转化
System.arraycopy(bytes,6,newBytes,0,8);
BigInteger bigInt = new BigInteger(1, newBytes);
String resultStr = bigInt.toString(10);
return resultStr.substring(0,resultStr.length()-1);
}
}