Compare commits

...

24 Commits

Author SHA1 Message Date
wangliwen edda52f387 jenkins 打包会替换 user.dir 2022-06-19 14:49:57 +08:00
wangliwen 633a131619 组件服务、知识库 统计接口 2022-06-19 14:36:21 +08:00
wangliwen 04a4be0294 cv一下 2022-06-19 13:12:06 +08:00
wangliwen 7d0760eb68 。。。 2022-06-19 13:02:14 +08:00
wangliwen 593516266a 区市、委办局 两类应用资源排名接口 2022-06-19 12:52:07 +08:00
wangliwen 46de17be45 。。。 2022-06-19 12:17:17 +08:00
wangliwen 8138361207 新加一个统计控制器 2022-06-19 11:46:04 +08:00
wangliwen 089e507426 处理falyway使用的sql文件被打包忽略外置时的问题 2022-06-19 10:03:17 +08:00
wangliwen 2c99eb5590 ... 2022-06-19 09:56:16 +08:00
wangliwen 802a5b83ec 打更新包时忽略prod环境配置文件;一些sql文件调整 2022-06-19 09:31:12 +08:00
wangliwen da765470e0 ... 2022-06-17 18:33:27 +08:00
wangliwen fb33764365 Merge remote-tracking branch 'origin/master' 2022-06-17 18:26:58 +08:00
wangliwen b780d1bdc3 打包排除生产环境 2022-06-17 18:26:23 +08:00
huangweixiong 508047c9a4 资源目录列表增加分页总数 2022-06-17 18:09:05 +08:00
huangweixiong 593aa55e24 Merge branch 'master' of http://221.0.232.152:9393/ability-center/share-platform
* 'master' of http://221.0.232.152:9393/ability-center/share-platform:
  能力导入采用全异步;所属部门不存在时默认deptId 为1

# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java
2022-06-17 15:04:25 +08:00
huangweixiong 7fa6cb05e5 Merge branch 'master' of http://221.0.232.152:9393/ability-center/share-platform
* 'master' of http://221.0.232.152:9393/ability-center/share-platform:
  导入表头升序处理
  ...
  web导入能力实现
  能力数据导入
  屮

# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java
2022-06-17 14:58:38 +08:00
wangliwen e1c7d34edc 能力导入采用全异步;所属部门不存在时默认deptId 为1 2022-06-17 14:18:25 +08:00
huangweixiong c01f7c913d 目录资源转发对接 2022-06-17 11:31:11 +08:00
wangliwen 64b44da859 导入表头升序处理 2022-06-16 15:53:19 +08:00
wangliwen e034129167 ... 2022-06-16 15:47:28 +08:00
wangliwen 4b7bb257ba web导入能力实现 2022-06-16 15:24:35 +08:00
wangliwen 6b5f35e283 能力数据导入 2022-06-16 14:54:12 +08:00
wangliwen e13ea7939e 2022-06-16 11:45:44 +08:00
wangliwen 84014eb3fa 。。。 2022-06-15 17:07:59 +08:00
16 changed files with 2838 additions and 163 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

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

View File

@ -0,0 +1,292 @@
package io.renren.common.controller;
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.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 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.stream.Collectors;
/**
* 2022.6.19 版本
*/
@Api(tags = "全局统计中心v2")
@RestController
@RequestMapping("/census/center/v2")
public class CensusControllerV2 {
private static 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;
@Value("${census.type}")
private String[] censusTypes; // 需要进行统计的资源类型
@GetMapping(value = "/whole_amount")
@ApiOperation("平台概览")
public Result<List<Map<String, Object>>> wholeAmount() {
List<Map<String, Object>> result = Collections.synchronizedList(new ArrayList<>());
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 = Collections.synchronizedList(new ArrayList<>());
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 = Collections.synchronizedList(new ArrayList<>());
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 = Collections.synchronizedList(new ArrayList<>());
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 = Collections.synchronizedList(new ArrayList<>());
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);
}
}

View File

@ -1,5 +1,6 @@
package io.renren.modules.resource.controller; package io.renren.modules.resource.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.renren.common.annotation.LogOperation; import io.renren.common.annotation.LogOperation;
@ -10,6 +11,7 @@ import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.DefaultGroup;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.excel.ResourceExcelImportListener;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -19,17 +21,26 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.util.HashMap; import javax.servlet.http.HttpServletRequest;
import java.util.Map; import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import java.util.concurrent.CompletableFuture;
/** /**
* 资源表 * 资源表
@ -72,12 +83,21 @@ public class ResourceController {
@Value("${zsk.catalogIds}") @Value("${zsk.catalogIds}")
private String[] catalogIds; private String[] catalogIds;
@Value("${resource.path}")
private String uploadPath;
@Autowired @Autowired
private ResourceService resourceService; private ResourceService resourceService;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Lazy
@Autowired
private JdbcTemplate jdbcTemplate;
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/");
private static final Logger logger = LoggerFactory.getLogger(ResourceController.class); private static final Logger logger = LoggerFactory.getLogger(ResourceController.class);
@GetMapping("/page") @GetMapping("/page")
@ -186,6 +206,48 @@ public class ResourceController {
return new Result().ok(dto.getId() == null ? "" : dto.getId()); return new Result().ok(dto.getId() == null ? "" : dto.getId());
} }
@PostMapping("/importResource")
@ApiOperation("导入")
@LogOperation("导入")
@ApiImplicitParams({
@ApiImplicitParam(name = "source", value = "请求来源", paramType = "string", dataType = "string")
})
public Result importResource(@RequestParam("file") MultipartFile uploadFile, HttpServletRequest request) {
List<Map<String, Object>> dept =
jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept");
logger.info("上传文件:" + uploadFile.getOriginalFilename());
String format = sdf.format(new Date());
File folder = new File(uploadPath + "upload" + File.separator + format);
logger.info(folder.getPath());
if (!folder.isDirectory()) {
folder.mkdirs();
}
// 对上传的文件重命名避免文件重名
String oldName = uploadFile.getOriginalFilename();
String newName = UUID.randomUUID().toString()
+ oldName.substring(oldName.lastIndexOf("."));
try {
// 文件保存
File file = new File(folder, newName);
uploadFile.transferTo(file);
CompletableFuture.runAsync(() -> {
EasyExcel.read(file, new ResourceExcelImportListener(0, dept, resourceService)).sheet(0).headRowNumber(1).doReadSync();
});
CompletableFuture.runAsync(() -> {
EasyExcel.read(file, new ResourceExcelImportListener(1, dept, resourceService)).sheet(1).headRowNumber(1).doReadSync();
});
CompletableFuture.runAsync(() -> {
EasyExcel.read(file, new ResourceExcelImportListener(2, dept, resourceService)).sheet(2).headRowNumber(1).doReadSync();
});
CompletableFuture.runAsync(() -> {
EasyExcel.read(file, new ResourceExcelImportListener(3, dept, resourceService)).sheet(3).headRowNumber(1).doReadSync();
});
} catch (IOException e) {
return new Result<String>().error(e.getMessage());
}
return new Result().ok(LocalDateTime.now().toString());
}
@PutMapping("/update") @PutMapping("/update")
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
@ -236,6 +298,45 @@ public class ResourceController {
} }
} }
@GetMapping("ZywMessage/list")
@ApiOperation("资源列表转发")
public Result ZywMessageList(Integer page, Integer size) {
String url = "http://15.72.158.81/zyjk/ZywMessage.asmx";
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" +
" <ZWCJ_mainPort xmlns=\"http://tempuri.org/\">\n" +
String.format("<pagenum>%d</pagenum>\n <pagesize>%d</pagesize>\n", page, size) +
" </ZWCJ_mainPort>\n" +
" </soap:Body>\n" +
"</soap:Envelope>";
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("SOAPAction", "http://tempuri.org/ZWCJ_mainPort");
requestHeaders.setContentType(MediaType.TEXT_XML);
HttpEntity<String> requestEntity = new HttpEntity(parame, requestHeaders);
try {
String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody();
String startTag = "<ZWCJ_mainPortResult>";
String endTag = "</ZWCJ_mainPortResult>";
String json = body.substring(body.indexOf(startTag) + startTag.length(), body.indexOf(endTag));
HashMap result = JSONObject.parseObject(json, HashMap.class);
List<Map> rows = (List<Map>) result.get("data");
List<Object> objects = rows.stream()
.filter(item -> item.get("main") != null)
.map(item -> item.get("main"))
.collect(Collectors.toList());
result.put("data", objects);
return new Result().ok(result);
} catch (Exception e) {
e.printStackTrace();
return new Result().ok(new ArrayList(0));
}
}
@GetMapping("qdyjjWeather") @GetMapping("qdyjjWeather")
@ApiOperation("青岛应急局-查询青岛市地区天气信息") @ApiOperation("青岛应急局-查询青岛市地区天气信息")
public Result qdyjjWeather(String cityName) { public Result qdyjjWeather(String cityName) {

View File

@ -63,6 +63,10 @@ public class AttrEntity implements Serializable{
private String note4; private String note4;
private String note5; private String note5;
public AttrEntity() {
this.delFlag = 0;
}
public Long getId() { public Long getId() {
return id; return id;
} }

View File

@ -0,0 +1,374 @@
package io.renren.modules.resource.excel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSON;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.service.ResourceService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* 导入资源
*/
public class ResourceExcelImportListener extends AnalysisEventListener<Map<Integer, String>> {
private static final Logger logger = LoggerFactory.getLogger(ResourceExcelImportListener.class);
private int BATCH_COUNT = Runtime.getRuntime().availableProcessors() * 10;
private int sheet = 1; // 读取excel sheet
private List<Map<String, Object>> deptList; // 部门信息
private ResourceService resourceService;
private List<Map<Integer, String>> list = new ArrayList<>();
Map<Integer, String> headMap = null;
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public ResourceExcelImportListener(int sheet, List<Map<String, Object>> deptList, ResourceService resourceService) {
this.sheet = sheet;
this.deptList = deptList;
this.resourceService = resourceService;
}
/**
* When analysis one row trigger invoke function.
*
* @param data one row value. Is is same as {@link AnalysisContext#readRowHolder()}
* @param context analysis context
*/
@Override
public void invoke(Map<Integer, String> data, AnalysisContext context) {
list.add(data);
if (list.size() > BATCH_COUNT) {
dealDate();
list.clear();
}
}
/**
* if have something to do after all analysis
*
* @param context
*/
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
dealDate();
}
@Override
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
if (this.headMap == null) {
this.headMap = headMap;
}
logger.info("sheet:" + sheet + "解析到一条头数据:{}", JSON.toJSONString(headMap));
}
/**
* 处理数据
*/
private void dealDate() {
list.stream().map(index -> {
Optional<Map<String, Object>> deptOptional =
deptList.stream().filter(dept -> index.values().contains(dept.getOrDefault("name", "").toString())).findAny();
if (!deptOptional.isPresent()) {
logger.info("找不到部门:{}", index.toString());
deptOptional = Optional.of(new LinkedHashMap<String, Object>() {
{
put("id", 1516728214814113793L); // 包头市行政审批和政务服务服务局
}
});
}
ResourceDTO resourceDTO = new ResourceDTO();
switch (sheet) {
case 0: // 需要跳过前6行
resourceDTO = getResourceDTO(resourceDTO, index, 0, Long.valueOf(deptOptional.get().get("id").toString()));
break;
case 1:
resourceDTO = getResourceDTO(resourceDTO, index, 1, Long.valueOf(deptOptional.get().get("id").toString()));
break;
case 2:
resourceDTO = getResourceDTO(resourceDTO, index, 2, Long.valueOf(deptOptional.get().get("id").toString()));
break;
case 3:
resourceDTO = getResourceDTO(resourceDTO, index, 3, Long.valueOf(deptOptional.get().get("id").toString()));
break;
default:
logger.error("不支持该sheet");
}
return resourceDTO;
}).filter(index -> index != null).forEach(index -> {
try {
logger.info("准备插入:" + JSON.toJSONString(index));
resourceService.insertWithAttrs(index);
logger.info("完成导入:{}", index.getName());
} catch (Exception exception) {
logger.error("导入异常", exception);
}
});
}
/**
* @param resourceDTO
* @return 获取导入对应参数
*/
private ResourceDTO getResourceDTO(ResourceDTO resourceDTO, Map<Integer, String> date, int sheet, Long deptId) {
List<AttrEntity> infoList = new ArrayList<>();
resourceDTO.setCreateDate(new Date());
switch (sheet) {
case 0: {
resourceDTO.setType("应用资源");
resourceDTO.setName(date.get(0));
AttrEntity attrEntity1 = new AttrEntity();
attrEntity1.setAttrType("应用状态");
attrEntity1.setAttrValue(date.get(1));
infoList.add(attrEntity1); // 应用状态
AttrEntity attrEntity2 = new AttrEntity();
attrEntity2.setAttrType("应用类型");
attrEntity2.setAttrValue(date.get(2));
infoList.add(attrEntity2); // 应用类型
AttrEntity attrEntity3 = new AttrEntity();
attrEntity3.setAttrType("应用领域");
attrEntity3.setAttrValue(date.get(3).replaceAll("\\s*", ""));
infoList.add(attrEntity3); // 应用领域
resourceDTO.setDescription(date.get(4)); // 描述
AttrEntity attrEntity4 = new AttrEntity();
attrEntity4.setAttrType("发布端");
attrEntity4.setAttrValue(date.get(5));
infoList.add(attrEntity4); // 发布端
resourceDTO.setDeptName(date.get(6));
resourceDTO.setDeptContacts(date.get(7)); // 部门联系人
resourceDTO.setDeptPhone(date.get(8)); // 部门联系人电话
AttrEntity attrEntity5 = new AttrEntity();
attrEntity5.setAttrType("应用展示视频");
attrEntity5.setAttrValue(date.get(9));
infoList.add(attrEntity5); // 应用展示视频
AttrEntity attrEntity6 = new AttrEntity();
attrEntity6.setAttrType("应用图片");
attrEntity6.setAttrValue(date.get(10));
infoList.add(attrEntity6); // 应用图片
AttrEntity attrEntity7 = new AttrEntity();
attrEntity7.setAttrType("功能介绍");
attrEntity7.setAttrValue(date.get(11));
infoList.add(attrEntity7); // 功能介绍
AttrEntity attrEntity8 = new AttrEntity();
attrEntity8.setAttrType("部署区域");
attrEntity8.setAttrValue(date.get(12));
infoList.add(attrEntity8); // 部署区域
AttrEntity attrEntity9 = new AttrEntity();
attrEntity9.setAttrType("是否统一登录");
attrEntity9.setAttrValue(date.get(13));
infoList.add(attrEntity9); // 是否统一登录
resourceDTO.setLink(date.get(14)); // 访问地址
resourceDTO.setShareCondition(date.get(15)); // 共享条件
resourceDTO.setShareMode(date.get(16)); // 共享类型
resourceDTO.setShareType(null);
AttrEntity attrEntity10 = new AttrEntity();
attrEntity10.setAttrType("等保定级");
attrEntity10.setAttrValue(date.get(17));
infoList.add(attrEntity10); // 等保定级
AttrEntity attrEntity11 = new AttrEntity();
attrEntity11.setAttrType("是否等保备案");
attrEntity11.setAttrValue(date.get(18));
infoList.add(attrEntity11); // 是否等保备案
AttrEntity attrEntity12 = new AttrEntity();
attrEntity12.setAttrType("服务商");
attrEntity12.setAttrValue(date.get(19));
infoList.add(attrEntity12); // 服务商
AttrEntity attrEntity13 = new AttrEntity();
attrEntity13.setAttrType("服务商联系人");
attrEntity13.setAttrValue(date.get(20));
infoList.add(attrEntity13); // 服务商联系人
AttrEntity attrEntity14 = new AttrEntity();
attrEntity14.setAttrType("服务商联系电话");
attrEntity14.setAttrValue(date.get(21));
infoList.add(attrEntity14); // 服务商联系人
AttrEntity attrEntity15 = new AttrEntity();
attrEntity15.setAttrType("常见问题");
attrEntity15.setAttrValue(date.get(22));
infoList.add(attrEntity15); // 常见问题
}
break;
case 1: {
resourceDTO.setType("组件服务");
resourceDTO.setName(date.get(0));
AttrEntity attrEntity = new AttrEntity();
attrEntity.setAttrType("组件类型");
attrEntity.setAttrValue("智能算法");
infoList.add(attrEntity); // 组件类型
AttrEntity attrEntity1 = new AttrEntity();
attrEntity1.setAttrType("算法类别");
attrEntity1.setAttrValue(date.get(1));
infoList.add(attrEntity1); // 算法类别
AttrEntity attrEntity2 = new AttrEntity();
attrEntity2.setAttrType("是否免批");
attrEntity2.setAttrValue(date.get(2));
infoList.add(attrEntity2); // 算法类别
AttrEntity attrEntity3 = new AttrEntity();
attrEntity3.setAttrType("使用方式");
attrEntity3.setAttrValue(date.get(3));
infoList.add(attrEntity3); // 使用方式
AttrEntity attrEntity4 = new AttrEntity();
attrEntity4.setAttrType("部署位置");
attrEntity4.setAttrValue(date.get(4));
infoList.add(attrEntity4); // 部署位置
AttrEntity attrEntity5 = new AttrEntity();
attrEntity5.setAttrType("应用领域");
attrEntity5.setAttrValue(date.get(5).replaceAll("\\s*", ""));
infoList.add(attrEntity5); // 应用领域
resourceDTO.setShareCondition(date.get(6)); // 共享条件
resourceDTO.setShareMode(date.get(7)); // 共享类型
resourceDTO.setShareType(null);
resourceDTO.setDescription(date.get(8));
AttrEntity attrEntity6 = new AttrEntity();
attrEntity6.setAttrType("算法介绍视频");
attrEntity6.setAttrValue(date.get(9));
infoList.add(attrEntity5); // 算法介绍视频
AttrEntity attrEntity7 = new AttrEntity();
attrEntity7.setAttrType("服务商");
attrEntity7.setAttrValue(date.get(10));
infoList.add(attrEntity7); // 服务商
AttrEntity attrEntity8 = new AttrEntity();
attrEntity8.setAttrType("服务商联系人");
attrEntity8.setAttrValue(date.get(11));
infoList.add(attrEntity8); // 服务商联系人
AttrEntity attrEntity9 = new AttrEntity();
attrEntity9.setAttrType("服务商联系电话");
attrEntity9.setAttrValue(date.get(12));
infoList.add(attrEntity9); // 服务商联系人
AttrEntity attrEntity10 = new AttrEntity();
attrEntity10.setAttrType("关联应用");
attrEntity10.setAttrValue(date.get(13));
infoList.add(attrEntity10); // 关联应用
AttrEntity attrEntity11 = new AttrEntity();
attrEntity11.setAttrType("算法优势");
attrEntity11.setAttrValue(date.get(14));
infoList.add(attrEntity11); // 算法优势
AttrEntity attrEntity12 = new AttrEntity();
attrEntity12.setAttrType("应用场景");
attrEntity12.setAttrValue(date.get(15));
infoList.add(attrEntity12); // 应用场景
resourceDTO.setLink(date.get(16));
resourceDTO.setApiMethodType(date.get(17));
AttrEntity attrEntity13 = new AttrEntity();
attrEntity13.setAttrType("技术文档");
attrEntity13.setAttrValue(date.get(18));
infoList.add(attrEntity13); // 技术文档
AttrEntity attrEntity14 = new AttrEntity();
attrEntity14.setAttrType("试用地址");
attrEntity14.setAttrValue(date.get(19));
infoList.add(attrEntity14); // 试用地址
AttrEntity attrEntity15 = new AttrEntity();
attrEntity15.setAttrType("是否收费");
attrEntity15.setAttrValue(date.get(20));
infoList.add(attrEntity15); // 是否收费
AttrEntity attrEntity16 = new AttrEntity();
attrEntity16.setAttrType("计费标准信息");
attrEntity16.setAttrValue(date.get(21));
infoList.add(attrEntity16); // 计费标准信息
AttrEntity attrEntity17 = new AttrEntity();
attrEntity17.setAttrType("常见问题");
attrEntity17.setAttrValue(date.get(22));
infoList.add(attrEntity17); // 常见问题
}
break;
case 2: {
resourceDTO.setType("知识库");
resourceDTO.setName(date.get(0));
resourceDTO.setLink(date.get(1));
resourceDTO.setDescription(date.get(2));
try {
Date createDate = sdf.parse(date.get(4).trim());
resourceDTO.setCreateDate(createDate);
} catch (Exception exception) {
logger.error("时间异常", exception);
}
AttrEntity attrEntity = new AttrEntity();
attrEntity.setAttrType("文件类型");
attrEntity.setAttrValue(date.get(6));
infoList.add(attrEntity);
this.headMap.keySet().stream().sorted().skip(6).forEach(key -> { // 表头后6个
AttrEntity attrEntity_ = new AttrEntity();
attrEntity_.setAttrType(this.headMap.get(key));
attrEntity_.setAttrValue(date.get(key));
infoList.add(attrEntity_);
});
}
break;
case 3: {
resourceDTO.setType("基础设施");
resourceDTO.setName(date.get(0));
this.headMap.keySet().stream().sorted().skip(1).forEach(key -> { // 表头后1个
AttrEntity attrEntity_ = new AttrEntity();
attrEntity_.setAttrType(this.headMap.get(key));
attrEntity_.setAttrValue(date.get(key));
infoList.add(attrEntity_);
});
}
break;
}
resourceDTO.setInfoList(infoList.stream().distinct().filter(info -> StringUtils.isNotEmpty(info.getAttrValue())).collect(Collectors.toList())); // infoList内空属性不导入
resourceDTO.setDelFlag(0);
resourceDTO.setDeptId(deptId); // 所属部门
return resourceDTO;
}
}

View File

@ -66,6 +66,6 @@ public class TResourceMountApplyEntity extends BaseEntity {
*/ */
private Long resourceId; private Long resourceId;
@TableField(typeHandler = FastjsonTypeHandler.class) @TableField(value = "resource_dto", typeHandler = FastjsonTypeHandler.class)
private ResourceDTO resourceDTO; private ResourceDTO resourceDTO;
} }

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

View File

@ -36,7 +36,7 @@ spring:
multi-statement-allow: true multi-statement-allow: true
# 生产环境默认关掉flyway # 生产环境默认关掉flyway
flyway: flyway:
enable: false enabled: false
#上传的静态资源配置 #上传的静态资源配置
resource: resource:
root_url: 15.72.183.90 root_url: 15.72.183.90

View File

@ -53,7 +53,7 @@ spring:
static-locations: classpath:/static,classpath:/public,file:${resource.path} static-locations: classpath:/static,classpath:/public,file:${resource.path}
flyway: flyway:
enable: true enable: true
locations: classpath:db locations: filesystem:config/db
baseline-on-migrate: true baseline-on-migrate: true
baseline-version: 0 baseline-version: 0

View File

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

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`);