提交 fa55849d 作者: zgz

智库标签

上级 9006de1a
......@@ -64,7 +64,17 @@
</exclusion>
</exclusions>
</dependency>
<!-- 动态数据源 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>2.5.7</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.17</version>
</dependency>
<!-- hutool工具类-->
<dependency>
<groupId>cn.hutool</groupId>
......
package com.zzsn.thinktank.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.thinktank.entity.SysDictItem;
import com.zzsn.thinktank.service.ISysDictItemService;
import com.zzsn.thinktank.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Date;
/**
* <p>
* 前端控制器
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
@RestController
@RequestMapping("/sys/dictItem")
@Slf4j
public class SysDictItemController {
@Autowired
private ISysDictItemService sysDictItemService;
/**
* @功能:查询字典数据
* @param sysDictItem
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@PostMapping(value = "/remoteList")
public Result<IPage<SysDictItem>> remoteList(@RequestBody SysDictItem sysDictItem,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
Result<IPage<SysDictItem>> result = new Result<IPage<SysDictItem>>();
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<SysDictItem>()
.eq(null != sysDictItem.getStatus(), SysDictItem::getStatus, sysDictItem.getStatus())
.eq(null != sysDictItem.getDictId(), SysDictItem::getDictId, sysDictItem.getDictId())
.like(null != sysDictItem.getItemText(), SysDictItem::getItemText, sysDictItem.getItemText());
Page<SysDictItem> page = new Page<SysDictItem>(pageNo, pageSize);
IPage<SysDictItem> pageList = sysDictItemService.page(page, queryWrapper);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
}
......@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
......
package com.zzsn.thinktank.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysDictItem implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 字典id
*/
private String dictId;
/**
* 字典项文本
*/
@Excel(name = "字典项文本", width = 20)
private String itemText;
/**
* 字典项值
*/
@Excel(name = "字典项值", width = 30)
private String itemValue;
/**
* 描述
*/
@Excel(name = "描述", width = 40)
private String description;
/**
* 排序
*/
@Excel(name = "排序", width = 15,type=4)
private Integer sortOrder;
/**
* 状态(1启用 0不启用)
*/
private Integer status;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
}
......@@ -107,7 +107,8 @@ public class ThinktankBasicInfo extends Model<ThinktankBasicInfo> {
private String achievementType;
//资金来源
private String fundsSource;
//语言中文名称
private String langName;
public List<String> toList(){
List<String> list = new ArrayList<>();
list.add(getValue(id));
......
package com.zzsn.thinktank.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.thinktank.entity.SysDictItem;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
}
package com.zzsn.thinktank.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.thinktank.entity.SysDictItem;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
public interface ISysDictItemService extends IService<SysDictItem> {
}
......@@ -11,6 +11,7 @@ import com.zzsn.thinktank.vo.ThinktankInfoVo;
import org.springframework.web.multipart.MultipartFile;
import com.zzsn.thinktank.vo.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
......
package com.zzsn.thinktank.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.thinktank.entity.SysDictItem;
import com.zzsn.thinktank.mapper.SysDictItemMapper;
import com.zzsn.thinktank.service.ISysDictItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.dynamic.datasource.annotation.DS;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
@DS("slave")
@Service
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements ISysDictItemService {
@Autowired
private SysDictItemMapper sysDictItemMapper;
}
......@@ -16,6 +16,7 @@ import com.zzsn.thinktank.mapper.ThinktankOttInfoMapper;
import com.zzsn.thinktank.service.*;
import com.zzsn.thinktank.util.EsDateUtil;
import com.zzsn.thinktank.util.EsUtil;
import com.zzsn.thinktank.util.SimRedisUtil;
import com.zzsn.thinktank.util.StringUtil;
import com.zzsn.thinktank.vo.*;
import lombok.extern.slf4j.Slf4j;
......@@ -46,6 +47,7 @@ import java.util.*;
import java.util.function.Function;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Version 1.0
......@@ -643,8 +645,14 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
public IPage<ThinktankBasicInfo> pageList(Integer pageNo,Integer pageSize,ThinktankBasicInfoListVo vo, HttpServletRequest req) throws Exception {
QueryWrapper<ThinktankBasicInfo> queryWrapper = new QueryWrapper<>();
if(vo!=null){
List<String> fieldTypeId = vo.getFieldTypeId();
List<String> regionalCountriesTypeId = vo.getRegionalCountriesTypeId();
List<String> fieldTypeId = vo.getFieldTypeId();//领域标签id
List<String> regionalCountriesTypeId = vo.getRegionalCountriesTypeId();//区域国家标签id
List<String> langList = vo.getLangList();//语言
List<String> natureList = vo.getNatureList();//智库性质
List<String> influencePositionList = vo.getInfluencePositionList();//影响力和地位
List<String> scaleList = vo.getScaleList();//智库规模
List<String> staffSizeList = vo.getStaffSizeList();//人员规模
List<String> operateStatusList = vo.getOperateStatusList();//运营状态
List<String> regionalCountriesTypeIds = new ArrayList<>();
queryWrapper.eq("status",1);
if(StringUtils.isNotBlank(vo.getKeyword())){
......@@ -696,6 +704,66 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
}
});
}
if(langList!=null && langList.size()>0 && StringUtils.isNotBlank(langList.get(0))){
queryWrapper.and(wreapper->{
for(int i=0;i<langList.size();i++){
wreapper.like("lang",langList.get(i));
if(i != langList.size()-1){
wreapper.or();
}
}
});
}
if(natureList!=null && natureList.size()>0 && StringUtils.isNotBlank(natureList.get(0))){
queryWrapper.and(wreapper->{
for(int i=0;i<natureList.size();i++){
wreapper.like("nature",natureList.get(i));
if(i != natureList.size()-1){
wreapper.or();
}
}
});
}
if(influencePositionList!=null && influencePositionList.size()>0 && StringUtils.isNotBlank(influencePositionList.get(0))){
queryWrapper.and(wreapper->{
for(int i=0;i<influencePositionList.size();i++){
wreapper.like("influence_position",influencePositionList.get(i));
if(i != influencePositionList.size()-1){
wreapper.or();
}
}
});
}
if(scaleList!=null && scaleList.size()>0 && StringUtils.isNotBlank(scaleList.get(0))){
queryWrapper.and(wreapper->{
for(int i=0;i<scaleList.size();i++){
wreapper.like("scale",scaleList.get(i));
if(i != scaleList.size()-1){
wreapper.or();
}
}
});
}
if(staffSizeList!=null && staffSizeList.size()>0 && StringUtils.isNotBlank(staffSizeList.get(0))){
queryWrapper.and(wreapper->{
for(int i=0;i<staffSizeList.size();i++){
wreapper.like("staff_size",staffSizeList.get(i));
if(i != staffSizeList.size()-1){
wreapper.or();
}
}
});
}
if(operateStatusList!=null && operateStatusList.size()>0 && StringUtils.isNotBlank(operateStatusList.get(0))){
queryWrapper.and(wreapper->{
for(int i=0;i<operateStatusList.size();i++){
wreapper.like("operate_status",operateStatusList.get(i));
if(i != operateStatusList.size()-1){
wreapper.or();
}
}
});
}
}
queryWrapper.orderByDesc("update_time");
Integer total = this.getBaseMapper().selectCount(queryWrapper);
......@@ -717,66 +785,118 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
List<Map<String,Object>> mapList = new ArrayList<>();
QueryWrapper<ThinktankBasicInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.select("id","code_id","chinese_whole","belong_country_id","belong_country","tag_id","tag_name",
"lang","profit_nature","nature","influence_position","scale","achievement_type","funds_source","operate_status","staff_size",
"(SELECT name_cn from brpa_base_region where id = (SELECT pid from brpa_base_region where id=belong_country_id) ) as continentName",
"(SELECT pid from brpa_base_region where id=belong_country_id) as continentId");
List<ThinktankBasicInfo> list = this.getBaseMapper().selectPage(page,queryWrapper).getRecords();
// switch (type) {
// case "continent":
// mapList = list.stream()
// .collect(Collectors.groupingBy(
// ThinktankBasicInfo::getContinentName,
// Collectors.counting() // 计算每个组的数量
// ))
// .entrySet()
// .stream()
// .map(entry -> {
// Map<String, Object> map = new HashMap<>();
// map.put("data", entry.getKey()); // 使用entry.getKey()获取洲ID
// map.put("num", entry.getValue()); // 使用entry.getValue()获取数量
// return map;
// })
// .collect(Collectors.toList()); // 收集结果列表
// break;
// case "country":
// mapList = list.stream()
// .collect(Collectors.groupingBy(
// ThinktankBasicInfo::getBelongCountry,
// Collectors.counting() // 计算每个组的数量
// ))
// .entrySet()
// .stream()
// .map(entry -> {
// Map<String, Object> map = new HashMap<>();
// map.put("data", entry.getKey()); // 使用entry.getKey()获取洲ID
// map.put("num", entry.getValue()); // 使用entry.getValue()获取数量
// return map;
// })
// .collect(Collectors.toList()); // 收集结果列表
// break;
// case "tag":
// mapList = list.stream()
// .filter(info -> StringUtils.isNotBlank(info.getTagName())) // 确保info.getTagName()不为null
// .flatMap(info -> Arrays.stream(info.getTagName().split(","))) // 拆分每个tagName字段
// .map(String::trim) // 去除多余的空格
// .collect(Collectors.groupingBy(
// tag -> tag,
// Collectors.counting() // 计算每个组的数量
// ))
// .entrySet()
// .stream()
// .map(entry -> {
// Map<String, Object> map = new HashMap<>();
// map.put("data", entry.getKey()); // 使用entry.getKey()获取洲名称
// map.put("num", entry.getValue()); // 使用entry.getValue()获取数量
// return map;
// })
// .collect(Collectors.toList()); // 收集结果列表
// break;
// }
switch (type) {
case "continent":
mapList = list.stream()
.collect(Collectors.groupingBy(
ThinktankBasicInfo::getContinentName,
Collectors.counting() // 计算每个组的数量
))
.entrySet()
.stream()
.map(entry -> {
Map<String, Object> map = new HashMap<>();
map.put("data", entry.getKey()); // 使用entry.getKey()获取洲ID
map.put("num", entry.getValue()); // 使用entry.getValue()获取数量
return map;
})
.collect(Collectors.toList()); // 收集结果列表
mapList = processGrouping(list, ThinktankBasicInfo::getContinentName,false,null);//洲
break;
case "country":
mapList = list.stream()
.collect(Collectors.groupingBy(
ThinktankBasicInfo::getBelongCountry,
Collectors.counting() // 计算每个组的数量
))
.entrySet()
.stream()
.map(entry -> {
Map<String, Object> map = new HashMap<>();
map.put("data", entry.getKey()); // 使用entry.getKey()获取洲ID
map.put("num", entry.getValue()); // 使用entry.getValue()获取数量
return map;
})
.collect(Collectors.toList()); // 收集结果列表
mapList = processGrouping(list, ThinktankBasicInfo::getBelongCountry,false,null);//国家
break;
case "tag":
mapList = list.stream()
.filter(info -> StringUtils.isNotBlank(info.getTagName())) // 确保info.getTagName()不为null
.flatMap(info -> Arrays.stream(info.getTagName().split(","))) // 拆分每个tagName字段
.map(String::trim) // 去除多余的空格
.collect(Collectors.groupingBy(
tag -> tag,
Collectors.counting() // 计算每个组的数量
))
.entrySet()
.stream()
.map(entry -> {
Map<String, Object> map = new HashMap<>();
map.put("data", entry.getKey()); // 使用entry.getKey()获取洲名称
map.put("num", entry.getValue()); // 使用entry.getValue()获取数量
return map;
})
.collect(Collectors.toList()); // 收集结果列表
mapList = processGrouping(list, ThinktankBasicInfo::getTagName, true,",");//领域标签
break;
case "lang":
mapList = processGrouping(list, ThinktankBasicInfo::getLang, true,",");//语言
break;
case "nature":
mapList = processGrouping(list, ThinktankBasicInfo::getNature, false,null);//性质
break;
case "influencePosition":
mapList = processGrouping(list, ThinktankBasicInfo::getInfluencePosition, true,"、");//影响力和地位
break;
case "scale":
mapList = processGrouping(list, ThinktankBasicInfo::getScale, false,null);//智库规模
break;
case "staffSize":
mapList = processGrouping(list, ThinktankBasicInfo::getStaffSize, false,null);//人员规模
break;
case "operateStatus":
mapList = processGrouping(list, ThinktankBasicInfo::getOperateStatus, false,null);//运营状态
break;
}
return mapList;
}
// 提取的分组和计数方法,添加了两个参数来处理是否需要拆分标签、以及用什么符号拆分
private List<Map<String, Object>> processGrouping(List<ThinktankBasicInfo> list, Function<ThinktankBasicInfo, String> classifier, boolean splitTags,String split) {
Stream<String> stream = list.stream().map(classifier)
.filter(item -> item != null && !item.isEmpty()); // 过滤掉null和空字符串
if (splitTags) {
stream = stream.flatMap(info -> Arrays.stream(info.split(split)))
.map(String::trim)
.filter(Objects::nonNull); // 过滤掉null元素;
}
return stream.collect(Collectors.groupingBy(
Function.identity(),
Collectors.counting()
)).entrySet().stream()
.map(entry -> createMap(entry.getKey(), entry.getValue()))
.collect(Collectors.toList());
}
// 创建Map的方法
private Map<String, Object> createMap(String key, Long value) {
Map<String, Object> map = new HashMap<>();
map.put("data", key);
map.put("num", value);
return map;
}
/**
* 智库维护
*
......
......@@ -49,4 +49,16 @@ public class ThinktankBasicInfoListVo {
private List<String> regionalCountriesTypeId;
//领域标签id
private List<String> fieldTypeId;
//语言
private List<String> langList;
//智库性质
private List<String> natureList;
//影响力和地位
private List<String> influencePositionList;
//智库规模
private List<String> scaleList;
//人员规模
private List<String> staffSizeList;
//运营状态
private List<String> operateStatusList;
}
......@@ -9,11 +9,43 @@ spring:
max-file-size: 100MB
#总上传文件大小
max-request-size: 1000MB
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource:
url: jdbc:mysql://114.116.44.11:3306/clb_project?useUnicode=true&characterEncoding=utf-8&AllowPublicKeyRetrieval=True&serverTimezone=Asia/Shanghai&autoReconnect=true&rewriteBatchedStatements=true
username: ciglobal
password: qwer@9988&zzsn
dynamic:
druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
# 连接池的配置信息
# 初始化大小,最小,最大
initial-size: 10
min-idle: 5
maxActive: 30
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
filters: stat
primary: master
datasource:
master:
url: jdbc:mysql://114.116.44.11:3306/clb_project?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false&allowMultiQueries=true
username: ciglobal
password: qwer@9988&zzsn
driver-class-name: com.mysql.jdbc.Driver
slave:
url: jdbc:mysql://114.116.44.11:3306/clb_system?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false
username: ciglobal
password: qwer@9988&zzsn
driver-class-name: com.mysql.jdbc.Driver
redis:
database: 0
host: 114.116.90.53
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论