提交 667c3375 作者: 925993793@qq.com

智库绑定信息源功能迭代

上级 fc5fc0ab
......@@ -45,6 +45,12 @@
<artifactId>mysql-connector-java</artifactId>
<version>8.0.21</version>
</dependency>
<!-- 动态数据源 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
<!-- excel工具包 -->
<dependency>
......
package com.zzsn.thinktank.config;
import com.baomidou.mybatisplus.extension.incrementer.OracleKeyGenerator;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author
* @description: mybatis-plus配置
* @date
*/
@Configuration
public class MybatisPlusConfig {
/**
* mybatis-plus分页配置
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
}
}
......@@ -176,8 +176,8 @@ public class ThinktankBasicInfoController {
for (ThinkTankFileVO thinkTankImportVO : thinkTankImportVOList) {
if (StringUtils.isEmpty(thinkTankImportVO.getChineseWhole()) || StringUtils.isEmpty(thinkTankImportVO.getBelongCountry())) {
requiredFlag = false;
break;
}
break;
}
if (!requiredFlag) {
return Result.error("必填项【中文全称和所属国家】有缺失,请核对后再导入。");
......@@ -207,9 +207,9 @@ public class ThinktankBasicInfoController {
List<ThinktankBasicInfo> thinkTankBasicInfos = thinktankBasicInfoService.exportListByCondition(one.getId(), one.getCodeId(),
one.getTypeId(), one.getThinktankName(), one.getTagId(), one.getKeyword());
if (CollectionUtils.isNotEmpty(thinkTankBasicInfos)) {
String[] arr = new String[]{"智库机构id", "智库机构编码", "中文全称", "中文简称", "英文全称", "英文简称", "官网", "所属国家", "语言", "经营状态","营利性质",
"智库性质", "研究领域", "影响力和地位", "人员规模","智库规模", "成果类型", "资金来源", "原文全称", "原文简称", "简介", "成立时间", "是否收费(1-是;0-否)",
"地址", "创办单位/所属单位","是否展示(1-是;0-否)"};
String[] arr = new String[]{"智库机构id", "智库机构编码", "中文全称", "中文简称", "英文全称", "英文简称", "官网", "所属国家", "语言", "经营状态", "营利性质",
"智库性质", "研究领域", "影响力和地位", "人员规模", "智库规模", "成果类型", "资金来源", "原文全称", "原文简称", "简介", "成立时间", "是否收费(1-是;0-否)",
"地址", "创办单位/所属单位", "是否展示(1-是;0-否)"};
XSSFWorkbook workbook = new XSSFWorkbook();
//基本信息
List<List<String>> rows = new ArrayList<>();
......@@ -218,7 +218,7 @@ public class ThinktankBasicInfoController {
//智库栏目采集统计信息
String[] header = new String[]{"智库机构id", "智库机构编码", "中文全称", "关联信息源数量", "信息采集总量", "关联信息源编码",
"关联信息源名称", "栏目名称", "网址", "启用状态(1-启用;0-禁用)","信息源采集数量", "信息源近一月采集量","采集状态"};
"关联信息源名称", "栏目名称", "网址", "启用状态(1-启用;0-禁用)", "信息源采集数量", "信息源近一月采集量", "采集状态"};
List<ThinkTankSourceVO> thinkTankSourceVOS = thinktankBasicInfoService.thinkTankCollectCount(thinkTankBasicInfos);
//补充信息源采集状态
List<String> allIds = thinkTankSourceVOS.stream().map(ThinkTankSourceVO::getSourceId).distinct().collect(Collectors.toList());
......@@ -229,16 +229,16 @@ public class ThinktankBasicInfoController {
JSONArray result = JSONObject.parseObject(res).getJSONArray("result");
for (int i = 0; i < result.size(); i++) {
JSONObject record = result.getJSONObject(i);
infoMap.put(record.getString("id"),record);
infoMap.put(record.getString("id"), record);
}
}
for (ThinkTankSourceVO thinkTankSourceVO : thinkTankSourceVOS) {
JSONObject record = infoMap.get(thinkTankSourceVO.getSourceId());
if(record==null){
if (record == null) {
continue;
}
//采集状态
switch (record.getString("abnormalCode")){
switch (record.getString("abnormalCode")) {
case "1":
thinkTankSourceVO.setAbnormalName("正常采集");
break;
......@@ -268,12 +268,12 @@ public class ThinktankBasicInfoController {
}
}
List<List<String>> rowList = new ArrayList<>();
thinkTankSourceVOS.forEach(e->rowList.add(e.toList()));
thinkTankSourceVOS.forEach(e -> rowList.add(e.toList()));
ExcelExportUtil.exportExcelData(workbook, 1, Arrays.asList(header), rowList, "智库栏目采集统计信息");
//智库机构采集统计信息
List<String> tIds = thinkTankBasicInfos.stream().map(ThinktankBasicInfo::getId).collect(Collectors.toList());
exportBindCount(workbook, 2, "智库机构采集统计信息",infoMap,thinkTankBasicInfos,tIds);
exportBindCount(workbook, 2, "智库机构采集统计信息", infoMap, thinkTankBasicInfos, tIds);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
workbook.write(outStream);
// 将字节流转换为InputStream
......@@ -285,17 +285,21 @@ public class ThinktankBasicInfoController {
return bytes;
}
/**
* 智库成果列表
*
* @param id 智库id
* @param pageNo 页码
* @param pageSize 每页返回条数
* @author lkg
* @date 2025/8/4
*/
@GetMapping("/listBaseData")
public Result<?> getListBaseData(@RequestParam(name = "id", required = true) String id,
@RequestParam(name = "pageNo", required = true) Integer pageNo,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
public Result<?> getListBaseData(@RequestParam String id,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
log.info("智库成果分页查询:{}", id);
if (pageNo < 1)
pageNo = 1;
if (pageSize < 0)
pageSize = 10;
Integer office = pageSize * (pageNo - 1);
return thinktankBasicInfoService.getListBaseData(id, pageNo, pageSize, office);
return thinktankBasicInfoService.getListBaseData(id, pageNo, pageSize);
}
private boolean checkExcel(MultipartFile multipartFile) {
......@@ -340,7 +344,7 @@ public class ThinktankBasicInfoController {
* @param thinkTankBasicInfos
* @param tIds 智库id列表
*/
public void exportBindCount(XSSFWorkbook workbook, int sheetNum, String sheetName, Map<String, JSONObject> infoMap, List<ThinktankBasicInfo> thinkTankBasicInfos, List<String> tIds){
public void exportBindCount(XSSFWorkbook workbook, int sheetNum, String sheetName, Map<String, JSONObject> infoMap, List<ThinktankBasicInfo> thinkTankBasicInfos, List<String> tIds) {
//查询所有的
List<CountVo> bindAll = thinktankBasicInfoService.bindInfoSource(tIds);
List<String> headers = new ArrayList<>();
......@@ -355,38 +359,38 @@ public class ThinktankBasicInfoController {
headers.add("是否展示");
headers.add("栏目数");
Map<String,Integer> columnNum = new HashMap<>();
Map<String, Integer> columnNum = new HashMap<>();
headers.add("启用数");
Map<String,Integer> enableNum = new HashMap<>();
Map<String, Integer> enableNum = new HashMap<>();
headers.add("未启用数");
Map<String,Integer> disableNum = new HashMap<>();
Map<String, Integer> disableNum = new HashMap<>();
headers.add("正常采集");
Map<String,Integer> normalNum = new HashMap<>();
Map<String, Integer> normalNum = new HashMap<>();
headers.add("访问异常");
Map<String,Integer> errorNum = new HashMap<>();
Map<String, Integer> errorNum = new HashMap<>();
headers.add("列表页解析异常");
Map<String,Integer> listParseErrorNum = new HashMap<>();
Map<String, Integer> listParseErrorNum = new HashMap<>();
headers.add("详情页配置异常");
Map<String,Integer> detailParseErrorNum = new HashMap<>();
Map<String, Integer> detailParseErrorNum = new HashMap<>();
headers.add("详情规则有差异");
Map<String,Integer> detailParseDiffNum = new HashMap<>();
Map<String, Integer> detailParseDiffNum = new HashMap<>();
headers.add("信息源漏采");
Map<String,Integer> missNum = new HashMap<>();
Map<String, Integer> missNum = new HashMap<>();
headers.add("账号异常");
Map<String,Integer> accountErrorNum = new HashMap<>();
Map<String, Integer> accountErrorNum = new HashMap<>();
headers.add("微信公众号异堂");
Map<String,Integer> wechatErrorNum = new HashMap<>();
Map<String, Integer> wechatErrorNum = new HashMap<>();
headers.add("待配置");
Map<String,Integer> configNum = new HashMap<>();
Map<String, Integer> configNum = new HashMap<>();
headers.add("待验证");
Map<String,Integer> verifyNum = new HashMap<>();
Map<String, Integer> verifyNum = new HashMap<>();
headers.add("验证通过");
Map<String,Integer> verifyPassNum = new HashMap<>();
Map<String, Integer> verifyPassNum = new HashMap<>();
headers.add("验证不通过");
Map<String,Integer> verifyFailNum = new HashMap<>();
Map<String, Integer> verifyFailNum = new HashMap<>();
//查询智库列表
List<String> hasInfoIds = bindAll.stream().map(CountVo::getId).distinct().collect(Collectors.toList());
List<ThinktankBasicInfo> basicInfos = thinkTankBasicInfos.stream().filter(item -> hasInfoIds.contains(item.getId())).collect(Collectors.toList());
......@@ -396,56 +400,56 @@ public class ThinktankBasicInfoController {
List<String> sourceList = bindAll.stream().filter(item -> tid.equals(item.getId())).map(CountVo::getCode).collect(Collectors.toList());
for (String sourceId : sourceList) {
JSONObject record = infoMap.get(sourceId);
if(record==null){
if (record == null) {
continue;
}
countAdd(columnNum,tid);
countAdd(columnNum, tid);
//是否启用
if("1".equals(record.getString("enable"))){
countAdd(enableNum,tid);
}else{
countAdd(disableNum,tid);
if ("1".equals(record.getString("enable"))) {
countAdd(enableNum, tid);
} else {
countAdd(disableNum, tid);
}
//采集状态
switch (record.getString("abnormalCode")){
switch (record.getString("abnormalCode")) {
case "1":
countAdd(normalNum,tid);
countAdd(normalNum, tid);
break;
case "101":
countAdd(errorNum,tid);
countAdd(errorNum, tid);
break;
case "201":
countAdd(listParseErrorNum,tid);
countAdd(listParseErrorNum, tid);
break;
case "202":
countAdd(detailParseErrorNum,tid);
countAdd(detailParseErrorNum, tid);
break;
case "203":
countAdd(detailParseDiffNum,tid);
countAdd(detailParseDiffNum, tid);
break;
case "301":
countAdd(missNum,tid);
countAdd(missNum, tid);
break;
case "503":
countAdd(accountErrorNum,tid);
countAdd(accountErrorNum, tid);
break;
case "601":
countAdd(wechatErrorNum,tid);
countAdd(wechatErrorNum, tid);
break;
}
//状态
switch (record.getString("status")){
switch (record.getString("status")) {
case "1":
countAdd(configNum,tid);
countAdd(configNum, tid);
break;
case "2":
countAdd(verifyNum,tid);
countAdd(verifyNum, tid);
break;
case "3":
countAdd(verifyPassNum,tid);
countAdd(verifyPassNum, tid);
break;
case "4":
countAdd(verifyFailNum,tid);
countAdd(verifyFailNum, tid);
break;
}
}
......@@ -474,38 +478,38 @@ public class ThinktankBasicInfoController {
//是否展示
dataItem.add(String.valueOf(basicInfo.getYnDisplay()));
//栏目数
dataItem.add(getMapStr(columnNum,id));
dataItem.add(getMapStr(columnNum, id));
//是否启用
dataItem.add(getMapStr(enableNum,id));
dataItem.add(getMapStr(disableNum,id));
dataItem.add(getMapStr(enableNum, id));
dataItem.add(getMapStr(disableNum, id));
//采集状态
dataItem.add(getMapStr(normalNum,id));
dataItem.add(getMapStr(errorNum,id));
dataItem.add(getMapStr(listParseErrorNum,id));
dataItem.add(getMapStr(detailParseErrorNum,id));
dataItem.add(getMapStr(detailParseDiffNum,id));
dataItem.add(getMapStr(missNum,id));
dataItem.add(getMapStr(accountErrorNum,id));
dataItem.add(getMapStr(wechatErrorNum,id));
dataItem.add(getMapStr(normalNum, id));
dataItem.add(getMapStr(errorNum, id));
dataItem.add(getMapStr(listParseErrorNum, id));
dataItem.add(getMapStr(detailParseErrorNum, id));
dataItem.add(getMapStr(detailParseDiffNum, id));
dataItem.add(getMapStr(missNum, id));
dataItem.add(getMapStr(accountErrorNum, id));
dataItem.add(getMapStr(wechatErrorNum, id));
//状态
dataItem.add(getMapStr(configNum,id));
dataItem.add(getMapStr(verifyNum,id));
dataItem.add(getMapStr(verifyPassNum,id));
dataItem.add(getMapStr(verifyFailNum,id));
dataItem.add(getMapStr(configNum, id));
dataItem.add(getMapStr(verifyNum, id));
dataItem.add(getMapStr(verifyPassNum, id));
dataItem.add(getMapStr(verifyFailNum, id));
rows.add(dataItem);
}
ExcelExportUtil.exportExcelData(workbook,sheetNum, headers, rows, sheetName);
ExcelExportUtil.exportExcelData(workbook, sheetNum, headers, rows, sheetName);
}
private String getMapStr(Map<String, Integer> map, String id) {
if(map.containsKey(id)){
if (map.containsKey(id)) {
return map.get(id) + "";
}
return "0";
}
private String getSumMapStr(Map<String, Integer> map) {
if(map.isEmpty()){
if (map.isEmpty()) {
return "0";
}
return map.values().stream().mapToInt(Integer::intValue).sum() + "";
......
package com.zzsn.thinktank.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.math.MathUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.thinktank.entity.InfoSource;
import com.zzsn.thinktank.service.InfoSourceGroupMapService;
import com.zzsn.thinktank.service.InfoSourceService;
import com.zzsn.thinktank.vo.InfoSourceGroupPage;
import com.zzsn.thinktank.vo.InfoSourceVo;
import com.zzsn.thinktank.vo.Result;
import com.zzsn.thinktank.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.security.auth.Subject;
import java.util.List;
/**
......@@ -34,6 +38,7 @@ public class ThinktankBindController {
/**
* 查询信息源组的绑定列表
*
* @param infoSourceVo
* @param ynBind
* @param groupId
......@@ -41,14 +46,14 @@ public class ThinktankBindController {
* @param pageSize
* @return
*/
@GetMapping(value = "/bindList")
//@GetMapping(value = "/bindList")
public Result<?> bindList(InfoSourceVo infoSourceVo,
@RequestParam(name="ynBind", required=true) Integer ynBind,
@RequestParam(name="groupId", required=true) String groupId,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
@RequestParam(name = "ynBind", required = true) Integer ynBind,
@RequestParam(name = "groupId", required = true) String groupId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
log.info("查询信息源组的绑定列表:{}", infoSourceVo);
log.info("信息源组id:{}---{}",groupId,pageNo);
log.info("信息源组id:{}---{}", groupId, pageNo);
IPage<InfoSourceVo> pageList = infoSourceService.pageListByGroupId(infoSourceVo, ynBind, groupId, pageNo, pageSize);
List<InfoSourceVo> list = pageList.getRecords();
return Result.OK(pageList);
......@@ -56,29 +61,198 @@ public class ThinktankBindController {
/**
* 智库绑定信息源分页列表
*
* @param thinkTankId 智库id
* @param infoSearchCondition 检索条件
* @param pageNo 页码
* @param pageSize 每页条数
* @author lkg
* @date 2025/8/2
*/
@GetMapping(value = "/bindInfoSourcePageList")
public Result<?> bindInfoSourcePageList(InfoSearchCondition infoSearchCondition,
@RequestParam String thinkTankId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
IPage<BindInfoSourceVO> pageList = infoSourceService.bindInfoSourcePageList(thinkTankId, infoSearchCondition, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 智库绑定信息源栏目分页列表
*
* @param thinkTankId 智库id
* @param infoSearchCondition 检索条件
* @param pageNo 页码
* @param pageSize 每页条数
* @author lkg
* @date 2025/8/2
*/
@GetMapping(value = "/bindInfoSourceColumnPageList")
public Result<?> bindInfoSourceColumnPageList(InfoSearchCondition infoSearchCondition,
@RequestParam String thinkTankId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
IPage<BindInfoSourceColumnVO> pageList = infoSourceService.bindInfoSourceColumnPageList(thinkTankId, infoSearchCondition, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 智库绑定信息源组列表
*
* @param thinkTankId 智库id
* @author lkg
* @date 2025/8/2
*/
@GetMapping(value = "/bindInfoSourceGroupList")
public Result<?> bindInfoSourceMainGroupList(@RequestParam String thinkTankId) {
JSONObject infoSourceGroupPages = infoSourceService.bindInfoSourceGroupList(thinkTankId);
return Result.OK(infoSourceGroupPages);
}
/**
* 智库绑定的信息源列表
*
* @param thinkTankId 智库id
* @author lkg
* @date 2025/8/2
*/
@GetMapping(value = "/bindInfoSourceList")
public Result<?> bindInfoSourceList(@RequestParam String thinkTankId) {
JSONObject infoSourcePages = infoSourceService.bindInfoSourceList(thinkTankId);
return Result.OK(infoSourcePages);
}
/**
* 智库绑定信息源栏目组列表
*
* @param thinkTankId 智库id
* @author lkg
* @date 2025/8/2
*/
@GetMapping(value = "/bindInfoSourceColumnGroupList")
public Result<?> bindInfoSourceColumnGroupList(@RequestParam String thinkTankId) {
JSONObject infoSourceGroupPages = infoSourceService.bindInfoSourceColumnGroupList(thinkTankId);
return Result.OK(infoSourceGroupPages);
}
/**
* 智库绑定的信息源栏目列表
*
* @param thinkTankId 智库id
* @author lkg
* @date 2025/8/2
*/
@GetMapping(value = "/bindInfoSourceColumnList")
public Result<?> bindInfoSourceColumnList(@RequestParam String thinkTankId) {
JSONObject infoSourceGroupPages = infoSourceService.bindInfoSourceColumnList(thinkTankId);
return Result.OK(infoSourceGroupPages);
}
/**
* 智库绑定的信息源/信息源栏目标签列表
*
* @param thinkTankId 智库id
* @param category 类型(1-信息源栏目;2-信息源)
* @author lkg
* @date 2025/8/2
*/
@GetMapping(value = "/bindInfoSourceLabelList")
public Result<?> bindInfoSourceLabelList(@RequestParam String thinkTankId, @RequestParam Integer category) {
if (category != 1 && category != 2) {
return Result.error("参数错误");
}
JSONObject infoSourceGroupPages = infoSourceService.bindInfoSourceLabelList(thinkTankId, category);
return Result.OK(infoSourceGroupPages);
}
/**
* 信息源分页列表查询
*
* @param infoSourceVo
* @param pageNo
* @param pageSize
* @param infoSourceTypeId
* @return
*/
@GetMapping(value = "/listByTypeId")
//@GetMapping(value = "/listByTypeId")
public Result<?> queryPageListByTypeId(InfoSourceVo infoSourceVo,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(name = "infoSourceTypeId", defaultValue = "") String infoSourceTypeId) {
log.info("信息源分页列表查询:{}",infoSourceVo);
IPage<InfoSourceVo> pageList = infoSourceService.pageListByTypeId(null,null,infoSourceVo, pageNo, pageSize, infoSourceTypeId);
log.info("信息源分页列表查询:{}", infoSourceVo);
IPage<InfoSourceVo> pageList = infoSourceService.pageListByTypeId(null, null, infoSourceVo, pageNo, pageSize, infoSourceTypeId);
return Result.OK(pageList);
}
/**
* 绑定信息源
*
* @param bindVO 绑定信息
* @author lkg
* @date 2025/8/2
*/
@PostMapping(value = "/bind")
public Result<?> bind(@RequestBody BindVO bindVO) {
List<String> bindIds = bindVO.getBindIds();
if (StringUtils.isEmpty(bindVO.getThinkTankId())) {
return Result.error("智库id不能为空");
}
if (bindVO.getSourceBindType() == null) {
return Result.error("绑定类型不能为空");
}
if (bindVO.getSourceType() == null) {
return Result.error("信息源类型不能为空");
}
if (CollectionUtil.isEmpty(bindIds) && (bindVO.getSourceType() == 1 || bindVO.getSourceType() == 2)) {
return Result.error("绑定id不能为空");
}
if (CollectionUtil.isEmpty(bindVO.getBindLabels()) && bindVO.getSourceType() == 3) {
return Result.error("绑定标签不能为空");
}
infoSourceGroupMapService.bind(bindVO);
return Result.OK();
}
/**
* 绑定信息源
*
* @param bindVO 绑定信息
* @author lkg
* @date 2025/8/2
*/
@PostMapping(value = "/unBind")
public Result<?> unBind(@RequestBody BindVO bindVO) {
List<String> bindIds = bindVO.getBindIds();
if (StringUtils.isEmpty(bindVO.getThinkTankId())) {
return Result.error("智库id不能为空");
}
if (bindVO.getSourceBindType() == null) {
return Result.error("解绑类型不能为空");
}
if (bindVO.getSourceType() == null) {
return Result.error("信息源类型不能为空");
}
if (CollectionUtil.isEmpty(bindIds) && (bindVO.getSourceType() == 1 || bindVO.getSourceType() == 2)) {
return Result.error("解绑绑定id不能为空");
}
if (CollectionUtil.isEmpty(bindVO.getBindLabels()) && bindVO.getSourceType() == 3) {
return Result.error("解绑标签不能为空");
}
infoSourceGroupMapService.unBind(bindVO);
return Result.OK();
}
/**
* 绑定信息源
*/
//@PostMapping(value = "/bind")
public Result<?> bind(@RequestBody InfoSourceGroupPage infoSourceGroupPage) {
log.info("绑定信息源:{}", infoSourceGroupPage);
String message = infoSourceGroupMapService.bind(infoSourceGroupPage.getId(), infoSourceGroupPage.getInfoSourceIds());
......@@ -98,22 +272,17 @@ public class ThinktankBindController {
/**
* 提升信息源优先等级
* 批量紧急
*
* @param groupId 信息源组id
* @author
* @date
*/
/**
* 提升信息源优先等级
* 批量紧急
* @param groupId 信息源组id
* @return
*/
@GetMapping("/upLevel")
public Result<?> upLevel(@RequestParam("groupId") String groupId){
public Result<?> upLevel(@RequestParam("groupId") String groupId) {
log.info("批量紧急:{}", groupId);
List<String> sourceIdList = infoSourceService.listByGroupId(groupId);
LambdaUpdateWrapper<InfoSource> update = Wrappers.lambdaUpdate();
update.set(InfoSource::getSiteLevel,1).in(InfoSource::getId,sourceIdList);
update.set(InfoSource::getSiteLevel, 1).in(InfoSource::getId, sourceIdList);
infoSourceService.update(update);
return Result.OK();
}
......
......@@ -35,6 +35,10 @@ public class InfoSourceGroupMap implements Serializable {
/**信息源id*/
@Excel(name = "信息源id", width = 15)
private String sourceId;
/**标签值编码(专题绑定信息源标签时特有的字段)*/
private String sourceItemId;
/**绑定的信息源类型*/
private Integer type;
/**创建人*/
private String createBy;
/**创建日期*/
......
package com.zzsn.thinktank.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
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
@TableName("sys_dict_item")
@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;
/**
* 字典id
*/
private String pid;
/**
* 字典id
*/
private String hasChild;
/**
* 字典id
*/
private String pathIds;
private String names;
/**
* 字典id
*/
private String dictItemCode;
/**
* 层级
*/
private Integer level;
/**
* 字典编码
*/
@TableField(exist = false)
private String dictCode;
}
package com.zzsn.thinktank.enums;
import java.util.ArrayList;
import java.util.List;
/**
* @author zs
* @Description 信息源/信息源组 枚举
* @since 2021/12/9
*/
public enum BindTypeEnum {
INFO_SOURCE(1,"绑定的通用信息源栏目"),
INFO_SOURCE_GROUP(2,"绑定的通用信息源栏目组"),
EXCLUDE_INFO_SOURCE(3,"排除的信息源栏目"),
EXCLUDE_INFO_SOURCE_GROUP(4,"排除的信息源栏目组"),
DIRECTIONA_INFO_SOURCE_GROUP(5,"定向的信息源栏目组"),
DIRECTIONA_INFO_SOURCE(6,"定向的信息源栏目"),
INFO_SOURCE_LABEL(12,"通用信息源栏目标签"),
EXCLUDE_INFO_SOURCE_LABEL(14,"排除信息源栏目标签"),
DIRECTIONA_INFO_SOURCE_LABEL(15,"定向信息源栏目标签"),
INFO_MAIN_SOURCE(31,"绑定的通用信息源"),
INFO_MAIN_SOURCE_GROUP(32,"绑定的通用信息源组"),
EXCLUDE_MAIN_INFO_SOURCE(33,"排除的信息源"),
EXCLUDE_MAIN_INFO_SOURCE_GROUP(34,"排除的信息源组"),
DIRECTIONA_MAIN_INFO_SOURCE_GROUP(35,"定向的信息源组"),
DIRECTIONA_MAIN_INFO_SOURCE(36,"定向的信息源"),
INFO_SOURCE_MAIN_LABEL(312,"通用信息源标签"),
EXCLUDE_INFO_MAIN_SOURCE_LABEL(314,"排除信息源标签"),
DIRECTIONA_INFO_MAIN_SOURCE_LABEL(315,"定向信息源标签")
;
private Integer value;
private String des;
BindTypeEnum(int value, String des) {
this.value = value;
this.des = des;
}
public Integer getvalue() {
return value;
}
public String getDes() {
return des;
}
//定向、通用、屏蔽信息源栏目组类型返回
public static List<Integer> getInfoSourceGroupType() {
List<Integer> values = new ArrayList<>();
values.add(BindTypeEnum.INFO_SOURCE_GROUP.getvalue());
values.add(BindTypeEnum.EXCLUDE_INFO_SOURCE_GROUP.getvalue());
values.add(BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue());
return values;
}
//定向、通用、屏蔽信息源类栏目型返回
public static List<Integer> getInfoSourceType() {
List<Integer> values = new ArrayList<>();
values.add(BindTypeEnum.INFO_SOURCE.getvalue());
values.add(BindTypeEnum.EXCLUDE_INFO_SOURCE.getvalue());
values.add(BindTypeEnum.DIRECTIONA_INFO_SOURCE.getvalue());
return values;
}
//定向、通用、屏蔽 信息源栏目标签类型返回
public static List<Integer> getInfoSourceLabelType() {
List<Integer> values = new ArrayList<>();
values.add(BindTypeEnum.INFO_SOURCE_LABEL.getvalue());
values.add(BindTypeEnum.EXCLUDE_INFO_SOURCE_LABEL.getvalue());
values.add(BindTypeEnum.DIRECTIONA_INFO_SOURCE_LABEL.getvalue());
return values;
}
//定向、通用、屏蔽信息源组类型返回
public static List<Integer> getInfoSourceMainGroupType() {
List<Integer> values = new ArrayList<>();
values.add(BindTypeEnum.INFO_MAIN_SOURCE_GROUP.getvalue());
values.add(BindTypeEnum.EXCLUDE_MAIN_INFO_SOURCE_GROUP.getvalue());
values.add(BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE_GROUP.getvalue());
return values;
}
//定向、通用、屏蔽信息源类型返回
public static List<Integer> getInfoSourceMainType() {
List<Integer> values = new ArrayList<>();
values.add(BindTypeEnum.INFO_MAIN_SOURCE.getvalue());
values.add(BindTypeEnum.EXCLUDE_MAIN_INFO_SOURCE.getvalue());
values.add(BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE.getvalue());
return values;
}
//定向、通用、屏蔽 信息源标签类型返回
public static List<Integer> getInfoSourceMainLabelType() {
List<Integer> values = new ArrayList<>();
values.add(BindTypeEnum.INFO_SOURCE_MAIN_LABEL.getvalue());
values.add(BindTypeEnum.EXCLUDE_INFO_MAIN_SOURCE_LABEL.getvalue());
values.add(BindTypeEnum.DIRECTIONA_INFO_MAIN_SOURCE_LABEL.getvalue());
return values;
}
public static BindTypeEnum getEnumByValue(Integer value) {
for (BindTypeEnum bindTypeEnum : BindTypeEnum.values()) {
if (bindTypeEnum.getvalue().equals(value)) {
return bindTypeEnum;
}
}
return null;
}
}
package com.zzsn.thinktank.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.thinktank.entity.InfoSource;
import com.zzsn.thinktank.vo.InfoSourceVo;
import com.zzsn.thinktank.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -21,11 +23,103 @@ public interface InfoSourceMapper extends BaseMapper<InfoSource> {
Integer totalCountByGroupId(@Param("infoSourceVo") InfoSourceVo infoSourceVo, @Param("ynBind") Integer ynBind, @Param("groupId") String groupId);
List<InfoSourceVo> pageList(@Param("customerId") String customerId,@Param("userId") String userId,@Param("infoSourceVo") InfoSourceVo infoSourceVo, @Param("typeIds") List<String> typeIds, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
List<InfoSourceVo> pageList(@Param("customerId") String customerId, @Param("userId") String userId, @Param("infoSourceVo") InfoSourceVo infoSourceVo, @Param("typeIds") List<String> typeIds, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
List<InfoSourceVo> listBySidList(@Param("customerId") String customerId,@Param("userId") String userId,List<String> collect);
List<InfoSourceVo> listBySidList(@Param("customerId") String customerId, @Param("userId") String userId, List<String> collect);
Integer totalCount(@Param("customerId") String customerId,@Param("userId") String userId,@Param("infoSourceVo") InfoSourceVo infoSourceVo, @Param("typeIds") List<String> typeIds);
Integer totalCount(@Param("customerId") String customerId, @Param("userId") String userId, @Param("infoSourceVo") InfoSourceVo infoSourceVo, @Param("typeIds") List<String> typeIds);
List<String> listByGroupId(@Param("groupId") String groupId);
/**
* 智库绑定信息源分页列表
*
* @param thinkTankId 智库id
* @param infoSearchCondition 检索条件
* @param page 分页信息
* @author lkg
* @date 2025/8/2
*/
IPage<BindInfoSourceVO> bindInfoSourcePageList(@Param("thinkTankId") String thinkTankId, @Param("infoSearchCondition") InfoSearchCondition infoSearchCondition, Page<BindInfoSourceVO> page);
/**
* 智库绑定信息源栏目分页列表
*
* @param thinkTankId 智库id
* @param infoSearchCondition 检索条件
* @param page 分页信息
* @author lkg
* @date 2025/8/2
*/
IPage<BindInfoSourceColumnVO> bindInfoSourceColumnPageList(@Param("thinkTankId") String thinkTankId, @Param("infoSearchCondition") InfoSearchCondition infoSearchCondition, Page<BindInfoSourceColumnVO> page);
/**
* 智库绑定信息源栏目列表
*
* @param thinkTankId 智库id
* @param infoSearchCondition 检索条件
* @author lkg
* @date 2025/8/2
*/
List<BindInfoSourceColumnVO> bindInfoSourceColumnPageList(@Param("thinkTankId") String thinkTankId, @Param("infoSearchCondition") InfoSearchCondition infoSearchCondition);
/**
* 智库绑定信息源组列表
*
* @param thinkTankId 智库id
* @param types 信息源类型
* @author lkg
* @date 2025/8/2
*/
List<InfoSourceGroupVO> bindInfoSourceGroupList(@Param("thinkTankId") String thinkTankId, @Param("types") List<Integer> types);
/**
* 智库绑定信息源列表
*
* @param thinkTankId 智库id
* @param types 信息源类型
* @author lkg
* @date 2025/8/2
*/
List<BindInfoSourceVO> bindInfoSourceList(@Param("thinkTankId") String thinkTankId, @Param("types") List<Integer> types);
/**
* 智库绑定信息源/信息源栏目标签列表
*
* @param thinkTankId 智库id
* @param types 信息源类型
* @author lkg
* @date 2025/8/2
*/
List<InfoSourceLabelVO> bindInfoSourceLabelList(@Param("thinkTankId") String thinkTankId, @Param("types") List<Integer> types);
/**
* 智库绑定信息源栏目组列表
*
* @param thinkTankId 智库id
* @param types 信息源类型
* @author lkg
* @date 2025/8/2
*/
List<InfoSourceGroupVO> bindInfoSourceColumnGroupList(@Param("thinkTankId") String thinkTankId, @Param("types") List<Integer> types);
/**
* 智库绑定信息源栏目列表
*
* @param thinkTankId 智库id
* @param types 信息源类型
* @author lkg
* @date 2025/8/2
*/
List<BindInfoSourceColumnVO> bindInfoSourceColumnList(@Param("thinkTankId") String thinkTankId, @Param("types") List<Integer> types);
/**
* 获取智库绑定信息源的数量
*
* @param thinkTankIds 智库id集合
* @author lkg
* @date 2025/8/5
*/
List<BindSourceDetailVO> bindSourceCount(@Param("thinkTankIds") List<String> thinkTankIds);
}
package com.zzsn.thinktank.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.thinktank.entity.SysDictItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
@Mapper
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
List<SysDictItem> listByDictCode(@Param("dictCode") String dictCode);
}
......@@ -2,6 +2,7 @@ package com.zzsn.thinktank.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.thinktank.entity.InfoSourceGroupMap;
import com.zzsn.thinktank.vo.BindVO;
import com.zzsn.thinktank.vo.ThinkTankSourceVO;
import java.util.List;
......@@ -30,4 +31,22 @@ public interface InfoSourceGroupMapService extends IService<InfoSourceGroupMap>
* @date 2024/8/23
*/
List<ThinkTankSourceVO> listOfThinkTank(List<String> groupIds);
/**
* 绑定信息源
*
* @param bindVO 绑定信息
* @author lkg
* @date 2025/8/2
*/
void bind(BindVO bindVO);
/**
* 解绑信息源
*
* @param bindVO 绑定信息
* @author lkg
* @date 2025/8/5
*/
void unBind(BindVO bindVO);
}
package com.zzsn.thinktank.service;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.thinktank.entity.InfoSource;
import com.zzsn.thinktank.vo.InfoSourceVo;
import com.zzsn.thinktank.vo.*;
import java.util.List;
......@@ -17,15 +18,104 @@ public interface InfoSourceService extends IService<InfoSource> {
/**
* 根据分类id获取信息源列表(ynBind=0 :查询没有绑定该组的信息源列表 ynBind=1 :查询绑定该组的信息源列表 )
*/
IPage<InfoSourceVo> pageListByGroupId (InfoSourceVo infoSourceVo, Integer ynBind, String groupId, Integer pageNo, Integer pageSize);
IPage<InfoSourceVo> pageListByGroupId(InfoSourceVo infoSourceVo, Integer ynBind, String groupId, Integer pageNo, Integer pageSize);
/**
* 根据分类id获取信息源列表
*/
IPage<InfoSourceVo> pageListByTypeId (String customerId, String userId, InfoSourceVo infoSourceVo, Integer pageNo, Integer pageSize, String infoSourceTypeId);
IPage<InfoSourceVo> pageListByTypeId(String customerId, String userId, InfoSourceVo infoSourceVo, Integer pageNo, Integer pageSize, String infoSourceTypeId);
/**
* 获取信息源组下的信息源id集合
*/
List<String> listByGroupId(String groupId);
/**
* 智库绑定信息源分页列表
*
* @param thinkTankId 智库id
* @param infoSearchCondition 检索条件
* @param pageNo 页码
* @param pageSize 每页条数
* @author lkg
* @date 2025/8/2
*/
IPage<BindInfoSourceVO> bindInfoSourcePageList(String thinkTankId, InfoSearchCondition infoSearchCondition, Integer pageNo, Integer pageSize);
/**
* 智库绑定信息源栏目分页列表
*
* @param thinkTankId 智库id
* @param infoSearchCondition 检索条件
* @param pageNo 页码
* @param pageSize 每页条数
* @author lkg
* @date 2025/8/2
*/
IPage<BindInfoSourceColumnVO> bindInfoSourceColumnPageList(String thinkTankId, InfoSearchCondition infoSearchCondition, Integer pageNo, Integer pageSize);
/**
* 智库绑定信息源栏目列表
*
* @param thinkTankId 智库id
* @param infoSearchCondition 检索条件
* @author lkg
* @date 2025/8/4
*/
List<BindInfoSourceColumnVO> bindInfoSourceColumnPageList(String thinkTankId, InfoSearchCondition infoSearchCondition);
/**
* 智库绑定信息源组列表
*
* @param thinkTankId 智库id
* @author lkg
* @date 2025/8/2
*/
JSONObject bindInfoSourceGroupList(String thinkTankId);
/**
* 智库绑定信息源列表
*
* @param thinkTankId 智库id
* @author lkg
* @date 2025/8/2
*/
JSONObject bindInfoSourceList(String thinkTankId);
/**
* 智库绑定信息源标签列表
*
* @param thinkTankId 智库id
* @param category 类型(1-信息源栏目;2-信息源)
* @author lkg
* @date 2025/8/2
*/
JSONObject bindInfoSourceLabelList(String thinkTankId, Integer category);
/**
* 智库绑定信息源栏目组列表
*
* @param thinkTankId 智库id
* @author lkg
* @date 2025/8/2
*/
JSONObject bindInfoSourceColumnGroupList(String thinkTankId);
/**
* 智库绑定信息源栏目列表
*
* @param thinkTankId 智库id
* @author lkg
* @date 2025/8/2
*/
JSONObject bindInfoSourceColumnList(String thinkTankId);
/**
* 获取智库绑定信息源的数量
*
* @param thinkTankIds 智库id集合
* @author lkg
* @date 2025/8/5
*/
List<BindSourceDetailVO> bindSourceCount(List<String> thinkTankIds);
}
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 SysDictItemService extends IService<SysDictItem> {
List<SysDictItem> listByDictCode(String dictCode);
}
......@@ -27,7 +27,7 @@ public interface ThinktankBasicInfoService extends IService<ThinktankBasicInfo>
void downloadTemplate(HttpServletResponse response);
Result<?> getListBaseData(String id, Integer pageNo, Integer pageSize, Integer office);
Result<?> getListBaseData(String id, Integer pageNo, Integer pageSize);
/**
* 批量导入智库信息
......
package com.zzsn.thinktank.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.thinktank.entity.InfoSourceGroupMap;
import com.zzsn.thinktank.entity.ThinktankBasicInfo;
import com.zzsn.thinktank.enums.BindTypeEnum;
import com.zzsn.thinktank.mapper.InfoSourceGroupMapMapper;
import com.zzsn.thinktank.service.InfoSourceGroupMapService;
import com.zzsn.thinktank.vo.BindLabelVo;
import com.zzsn.thinktank.vo.BindVO;
import com.zzsn.thinktank.vo.InfoSourceGroupPage;
import com.zzsn.thinktank.vo.ThinkTankSourceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.*;
/**
* @Description: 信息源组和信息源关联表
......@@ -25,26 +33,23 @@ import java.util.List;
@Service
public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMapMapper, InfoSourceGroupMap> implements InfoSourceGroupMapService {
@Autowired
private InfoSourceGroupMapMapper infoSourceGroupMapMapper;
@Override
@Transactional //抛出异常回滚
public String bind (String groupId, List<String> sourceIds){
public String bind(String groupId, List<String> sourceIds) {
String message = "绑定成功!";
if(!StringUtils.isEmpty(groupId) && sourceIds != null && sourceIds.size() > 0){
for(String sourceId : sourceIds){
if (!StringUtils.isEmpty(groupId) && sourceIds != null && sourceIds.size() > 0) {
for (String sourceId : sourceIds) {
//判断是否绑定过
QueryWrapper<InfoSourceGroupMap> queryWrapper = new QueryWrapper<InfoSourceGroupMap>();
queryWrapper.eq("group_id", groupId);
queryWrapper.eq("source_id", sourceId);
//todo:query in loop
List<InfoSourceGroupMap> list = infoSourceGroupMapMapper.selectList(queryWrapper);
List<InfoSourceGroupMap> list = baseMapper.selectList(queryWrapper);
if (list.size() <= 0) {
InfoSourceGroupMap infoSourceGroupMap = new InfoSourceGroupMap();
infoSourceGroupMap.setGroupId(groupId);
infoSourceGroupMap.setSourceId(sourceId);
infoSourceGroupMapMapper.insert(infoSourceGroupMap);
baseMapper.insert(infoSourceGroupMap);
} else {
message = "部分已经绑定信息源成功过滤,未绑定的信息源已经绑定!";
}
......@@ -54,9 +59,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
}
@Override
public void unBind(String groupId, List<String> sourceIds){
if(!StringUtils.isEmpty(groupId) && sourceIds != null && sourceIds.size() > 0){
infoSourceGroupMapMapper.deleteBySourceIds(groupId, sourceIds);
public void unBind(String groupId, List<String> sourceIds) {
if (!StringUtils.isEmpty(groupId) && sourceIds != null && sourceIds.size() > 0) {
baseMapper.deleteBySourceIds(groupId, sourceIds);
}
}
......@@ -64,7 +69,7 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
public List<InfoSourceGroupMap> getSourceGroupMap(List groupIds) {
LambdaQueryWrapper<InfoSourceGroupMap> lambdaQuery = Wrappers.lambdaQuery();
lambdaQuery.in(InfoSourceGroupMap::getGroupId,groupIds);
lambdaQuery.in(InfoSourceGroupMap::getGroupId, groupIds);
List<InfoSourceGroupMap> list = baseMapper.selectList(lambdaQuery);
return list;
}
......@@ -74,4 +79,303 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return baseMapper.listOfThinkTank(groupIds);
}
@Override
public void bind(BindVO bindVO) {
//绑定信息源栏目组
if (bindVO.getSourceType() == 1) {
bindInfoSourceColumnGroup(bindVO);
}
//绑定信息源栏目
if (bindVO.getSourceType() == 2) {
bindInfoSourceColumn(bindVO);
}
//绑定栏目标签
if (bindVO.getSourceType() == 3) {
bindInfoSourceColumnLabels(bindVO);
}
//绑定信息源组
if (bindVO.getSourceType() == 4) {
bindInfoSourceGroup(bindVO);
}
//绑定信息源
if (bindVO.getSourceType() == 5) {
bindInfoSource(bindVO);
}
//绑定信息源标签
if (bindVO.getSourceType() == 6) {
bindInfoSourceLabels(bindVO);
}
}
@Override
public void unBind(BindVO bindVO) {
//解绑信息源栏目组
if (bindVO.getSourceType() == 1) {
unBindInfoSourceColumnGroup(bindVO);
}
//解绑信息源栏目
if (bindVO.getSourceType() == 2) {
unBindInfoSourceColumn(bindVO);
}
//解绑信息源栏目标签
if (bindVO.getSourceType() == 3) {
unBindInfoSourceColumnLabels(bindVO);
}
//解绑信息源组
if (bindVO.getSourceType() == 4) {
unBindInfoSourceGroup(bindVO);
}
//解绑信息源
if (bindVO.getSourceType() == 5) {
unBindInfoSource(bindVO);
}
//解绑信息源标签
if (bindVO.getSourceType() == 6) {
unBindInfoSourceLabels(bindVO);
}
}
private void unBindInfoSourceColumnGroup(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<String> idList = bindVO.getBindIds();
if(CollectionUtil.isEmpty(idList)){
return ;
}
if (sourceBindType == 1) {
//解绑通用信息源组
unBindInfoSource(bindVO, BindTypeEnum.INFO_SOURCE_GROUP.getvalue());
}
if (sourceBindType == 2) {
//解绑定向信息源组
unBindInfoSource(bindVO,BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue());
}
}
private void unBindInfoSourceColumn(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<String> idList = bindVO.getBindIds();
if(CollectionUtil.isEmpty(idList)){
return ;
}
if (sourceBindType == 1) {
//解绑通用信息源组
unBindInfoSource(bindVO, BindTypeEnum.INFO_SOURCE.getvalue());
}
if (sourceBindType == 2) {
//解绑定向信息源组
unBindInfoSource(bindVO,BindTypeEnum.DIRECTIONA_INFO_SOURCE.getvalue());
}
}
private void unBindInfoSourceGroup(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<String> idList = bindVO.getBindIds();
if(CollectionUtil.isEmpty(idList)){
return ;
}
if (sourceBindType == 1) {
//解绑通用信息源组
unBindInfoSource(bindVO, BindTypeEnum.INFO_MAIN_SOURCE_GROUP.getvalue());
}
if (sourceBindType == 2) {
//解绑定向信息源组
unBindInfoSource(bindVO,BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE_GROUP.getvalue());
}
}
private void unBindInfoSource(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<String> idList = bindVO.getBindIds();
if(CollectionUtil.isEmpty(idList)){
return ;
}
if (sourceBindType == 1) {
//解绑通用信息源
unBindInfoSource(bindVO, BindTypeEnum.INFO_MAIN_SOURCE.getvalue());
}
if (sourceBindType == 2) {
//解绑定向信息源
unBindInfoSource(bindVO,BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE.getvalue());
}
}
private void unBindInfoSourceColumnLabels(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<BindLabelVo> bindLabels = bindVO.getBindLabels();
if(CollectionUtil.isEmpty(bindLabels)){
return ;
}
if (sourceBindType == 1) {
//解绑通用标签
unBindLabel(bindVO, BindTypeEnum.INFO_SOURCE_LABEL.getvalue());
}
if (sourceBindType == 2) {
//解绑定向标签
unBindLabel(bindVO, BindTypeEnum.DIRECTIONA_INFO_SOURCE_LABEL.getvalue());
}
}
private void unBindInfoSourceLabels(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<BindLabelVo> bindLabels = bindVO.getBindLabels();
if(CollectionUtil.isEmpty(bindLabels)){
return ;
}
if (sourceBindType == 1) {
//解绑通用标签
unBindLabel(bindVO, BindTypeEnum.INFO_SOURCE_MAIN_LABEL.getvalue());
}
if (sourceBindType == 2) {
//解绑定向标签
unBindLabel(bindVO, BindTypeEnum.DIRECTIONA_INFO_MAIN_SOURCE_LABEL.getvalue());
}
}
private void bindInfoSourceColumnGroup(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<String> idList = bindVO.getBindIds();
if (CollectionUtil.isEmpty(idList)) {
return;
}
if (sourceBindType == 1) {
//绑定通用信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.INFO_SOURCE_GROUP.getvalue());
}
if (sourceBindType == 2) {
//绑定定向信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue());
}
}
private void bindInfoSourceColumn(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<String> idList = bindVO.getBindIds();
if (CollectionUtil.isEmpty(idList)) {
return;
}
if (sourceBindType == 1) {
//绑定通用信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.INFO_SOURCE.getvalue());
}
if (sourceBindType == 2) {
//绑定定向信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.DIRECTIONA_INFO_SOURCE.getvalue());
}
}
private void bindInfoSourceColumnLabels(BindVO bindVO) {
String thinkTankId = bindVO.getThinkTankId();
Integer sourceBindType = bindVO.getSourceBindType();
List<BindLabelVo> bindLabels = bindVO.getBindLabels();
if (CollectionUtil.isEmpty(bindLabels)) {
return;
}
if (sourceBindType == 1) {
//绑定通用标签信息源
bindLabels(thinkTankId, bindLabels, BindTypeEnum.INFO_SOURCE_LABEL.getvalue());
}
if (sourceBindType == 2) {
//绑定定向标签信息源
bindLabels(thinkTankId, bindLabels, BindTypeEnum.DIRECTIONA_INFO_SOURCE_LABEL.getvalue());
}
}
private void bindInfoSourceLabels(BindVO bindVO) {
String thinkTankId = bindVO.getThinkTankId();
Integer sourceBindType = bindVO.getSourceBindType();
List<BindLabelVo> bindLabels = bindVO.getBindLabels();
if (CollectionUtil.isEmpty(bindLabels)) {
return;
}
if (sourceBindType == 1) {
//绑定通用标签信息源
bindLabels(thinkTankId, bindLabels, BindTypeEnum.INFO_SOURCE_MAIN_LABEL.getvalue());
}
if (sourceBindType == 2) {
//绑定定向标签信息源
bindLabels(thinkTankId, bindLabels, BindTypeEnum.DIRECTIONA_INFO_MAIN_SOURCE_LABEL.getvalue());
}
}
private void bindInfoSourceGroup(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<String> idList = bindVO.getBindIds();
if (CollectionUtil.isEmpty(idList)) {
return;
}
if (sourceBindType == 1) {
//绑定通用信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.INFO_MAIN_SOURCE_GROUP.getvalue());
}
if (sourceBindType == 2) {
//绑定定向信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE_GROUP.getvalue());
}
}
private void bindInfoSource(BindVO bindVO) {
Integer sourceBindType = bindVO.getSourceBindType();
List<String> idList = bindVO.getBindIds();
if (CollectionUtil.isEmpty(idList)) {
return;
}
if (sourceBindType == 1) {
//绑定通用信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.INFO_MAIN_SOURCE.getvalue());
}
if (sourceBindType == 2) {
//绑定定向信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE.getvalue());
}
}
private void bindInfoSource(BindVO bindVO, List<String> idList, Integer type) {
List<InfoSourceGroupMap> mapList = new ArrayList<>();
String thinkTankId = bindVO.getThinkTankId();
for (String infoSourceId : idList) {
InfoSourceGroupMap infoSourceGroupMap = new InfoSourceGroupMap();
infoSourceGroupMap.setSourceId(infoSourceId);
infoSourceGroupMap.setGroupId(thinkTankId);
infoSourceGroupMap.setType(type);
mapList.add(infoSourceGroupMap);
}
this.saveBatch(mapList);
}
private void unBindInfoSource(BindVO bindVO, Integer bindType) {
LambdaQueryWrapper<InfoSourceGroupMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(InfoSourceGroupMap::getGroupId, bindVO.getThinkTankId())
.eq(InfoSourceGroupMap::getType, bindType)
.in(InfoSourceGroupMap::getSourceId, bindVO.getBindIds());
this.remove(queryWrapper);
}
private void bindLabels(String thinkTankId, List<BindLabelVo> bindLabels, Integer bindType) {
List<InfoSourceGroupMap> mapList = new ArrayList<>();
for (BindLabelVo infoSourceId : bindLabels) {
InfoSourceGroupMap infoSourceGroupMap = new InfoSourceGroupMap();
infoSourceGroupMap.setSourceId(infoSourceId.getLabelCode());
infoSourceGroupMap.setSourceItemId(infoSourceId.getLabelItemCode());
infoSourceGroupMap.setGroupId(thinkTankId);
infoSourceGroupMap.setType(bindType);
mapList.add(infoSourceGroupMap);
}
this.saveBatch(mapList);
}
private void unBindLabel(BindVO bindVO, Integer type) {
List<BindLabelVo> bindLabels = bindVO.getBindLabels();
if(CollectionUtil.isEmpty(bindLabels)){
return ;
}
Set<String> labelCode = new HashSet<>();
Set<String> labelItemCode = new HashSet<>();
for (BindLabelVo bindLabelVo : bindLabels) {
labelCode.add(bindLabelVo.getLabelCode());
labelItemCode.add(bindLabelVo.getLabelItemCode());
}
this.remove(Wrappers.<InfoSourceGroupMap>lambdaQuery()
.in(InfoSourceGroupMap::getSourceId,labelCode)
.in(InfoSourceGroupMap::getSourceItemId,labelItemCode)
.eq(InfoSourceGroupMap::getGroupId,bindVO.getThinkTankId())
.eq(InfoSourceGroupMap::getType,type));
}
}
package com.zzsn.thinktank.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.thinktank.entity.InfoSource;
import com.zzsn.thinktank.entity.SysDictItem;
import com.zzsn.thinktank.enums.BindTypeEnum;
import com.zzsn.thinktank.mapper.InfoSourceMapper;
import com.zzsn.thinktank.service.InfoSourceService;
import com.zzsn.thinktank.service.SysDictItemService;
import com.zzsn.thinktank.util.PageBuilderParser;
import com.zzsn.thinktank.vo.InfoSourceVo;
import com.zzsn.thinktank.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.w3c.dom.Document;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -28,6 +32,8 @@ import java.util.stream.Collectors;
@Service
public class InfoSourceServiceImpl extends ServiceImpl<InfoSourceMapper, InfoSource> implements InfoSourceService {
@Autowired
private SysDictItemService sysDictItemService;
/**
* 根据分类id获取信息源列表(ynBind=0 :查询没有绑定该组的信息源列表 ynBind=1 :查询绑定该组的信息源列表 )
......@@ -192,4 +198,152 @@ public class InfoSourceServiceImpl extends ServiceImpl<InfoSourceMapper, InfoSou
public List<String> listByGroupId(String groupId) {
return baseMapper.listByGroupId(groupId);
}
@Override
public IPage<BindInfoSourceVO> bindInfoSourcePageList(String thinkTankId, InfoSearchCondition infoSearchCondition, Integer pageNo, Integer pageSize) {
Page<BindInfoSourceVO> page = new Page<>(pageNo, pageSize);
return baseMapper.bindInfoSourcePageList(thinkTankId, infoSearchCondition, page);
}
@Override
public IPage<BindInfoSourceColumnVO> bindInfoSourceColumnPageList(String thinkTankId, InfoSearchCondition infoSearchCondition, Integer pageNo, Integer pageSize) {
Page<BindInfoSourceColumnVO> page = new Page<>(pageNo, pageSize);
return baseMapper.bindInfoSourceColumnPageList(thinkTankId, infoSearchCondition, page);
}
@Override
public List<BindInfoSourceColumnVO> bindInfoSourceColumnPageList(String thinkTankId, InfoSearchCondition infoSearchCondition) {
return baseMapper.bindInfoSourceColumnPageList(thinkTankId, infoSearchCondition);
}
@Override
public JSONObject bindInfoSourceGroupList(String thinkTankId) {
JSONObject jsonObject = new JSONObject();
List<InfoSourceGroupVO> groupList = baseMapper.bindInfoSourceGroupList(thinkTankId, BindTypeEnum.getInfoSourceMainGroupType());
Map<Integer, List<InfoSourceGroupVO>> collect = groupList.stream().collect(Collectors.groupingBy(InfoSourceGroupVO::getSourceType));
collect.forEach((k,v)-> {
BindTypeEnum enumByValue = BindTypeEnum.getEnumByValue(k);
if (ObjectUtil.isNotNull(enumByValue)) {
//合并相同信息源组
List<InfoSourceGroupVO> list = new ArrayList<>();
for (InfoSourceGroupVO groupPage : v) {
Optional<InfoSourceGroupVO> first = list.stream().filter(f -> StrUtil.equals(f.getId(), groupPage.getId())).findFirst();
if(first.isPresent()){
InfoSourceGroupVO infoSourceGroupVO = first.get();
infoSourceGroupVO.setGroupTypeName(infoSourceGroupVO.getGroupTypeName()+"、"+groupPage.getGroupTypeName());
}else {
list.add(groupPage);
}
}
jsonObject.put(enumByValue.toString(), list);
}
});
return jsonObject;
}
@Override
public JSONObject bindInfoSourceList(String thinkTankId) {
JSONObject jsonObject = new JSONObject();
List<BindInfoSourceVO> infoSourceVos = baseMapper.bindInfoSourceList(thinkTankId, BindTypeEnum.getInfoSourceMainType());
if (CollectionUtil.isEmpty(infoSourceVos)) {
return jsonObject;
}
Map<Integer, List<BindInfoSourceVO>> collect = infoSourceVos.stream().collect(Collectors.groupingBy(BindInfoSourceVO::getSourceType));
collect.forEach((k,v)-> {
BindTypeEnum enumByValue = BindTypeEnum.getEnumByValue(k);
if (ObjectUtil.isNotNull(enumByValue)) {
jsonObject.put(enumByValue.toString(), v);
}
});
return jsonObject;
}
@Override
public JSONObject bindInfoSourceLabelList(String thinkTankId,Integer category) {
JSONObject jsonObject = new JSONObject();
List<Integer> typeList = null;
if (category == 1) {
typeList = BindTypeEnum.getInfoSourceLabelType();
} else if (category == 2) {
typeList = BindTypeEnum.getInfoSourceMainLabelType();
}
List<InfoSourceLabelVO> infoSourceLabelVOS = baseMapper.bindInfoSourceLabelList(thinkTankId, typeList);
if (CollectionUtil.isEmpty(infoSourceLabelVOS)) {
return jsonObject;
}
//字典类的标签处理层级关系
List<String> dictCodes = infoSourceLabelVOS.stream().filter(f -> "3".equals(f.getBusinessCaliber())).map(InfoSourceLabelVO::getDictCode).collect(Collectors.toList());
dictCodes.forEach(e -> {
List<SysDictItem> dictList = sysDictItemService.listByDictCode(e);
infoSourceLabelVOS.forEach(ee -> {
if ("3".equals(ee.getBusinessCaliber())){
//标签使用的字典
Optional<SysDictItem> first = dictList.stream().filter(f -> f.getItemValue().equals(ee.getLabelItemCode())).findFirst();
if (first.isPresent()) {
SysDictItem dictItem = first.get();
if (StrUtil.isNotBlank(dictItem.getNames())) {
ee.setLabelItemName(dictItem.getNames());
}else{
ee.setLabelItemName(dictItem.getItemText());
}
}
}
});
});
Map<Integer, List<InfoSourceLabelVO>> collect = infoSourceLabelVOS.stream().collect(Collectors.groupingBy(InfoSourceLabelVO::getSourceType));
collect.forEach((k,v)-> {
BindTypeEnum enumByValue = BindTypeEnum.getEnumByValue(k);
if (ObjectUtil.isNotNull(enumByValue)) {
jsonObject.put(enumByValue.toString(), v);
}
});
return jsonObject;
}
@Override
public JSONObject bindInfoSourceColumnGroupList(String thinkTankId) {
JSONObject jsonObject = new JSONObject();
List<InfoSourceGroupVO> groupList = baseMapper.bindInfoSourceColumnGroupList(thinkTankId, BindTypeEnum.getInfoSourceGroupType());
Map<Integer, List<InfoSourceGroupVO>> collect = groupList.stream().collect(Collectors.groupingBy(InfoSourceGroupVO::getSourceType));
collect.forEach((k,v)-> {
BindTypeEnum enumByValue = BindTypeEnum.getEnumByValue(k);
if (ObjectUtil.isNotNull(enumByValue)) {
//合并相同信息源组
List<InfoSourceGroupVO> list = new ArrayList<>();
for (InfoSourceGroupVO groupPage : v) {
Optional<InfoSourceGroupVO> first = list.stream().filter(f -> StrUtil.equals(f.getId(), groupPage.getId())).findFirst();
if(first.isPresent()){
InfoSourceGroupVO infoSourceGroupVO = first.get();
infoSourceGroupVO.setGroupTypeName(infoSourceGroupVO.getGroupTypeName()+"、"+groupPage.getGroupTypeName());
}else {
list.add(groupPage);
}
}
jsonObject.put(enumByValue.toString(), list);
}
});
return jsonObject;
}
@Override
public JSONObject bindInfoSourceColumnList(String thinkTankId) {
List<BindInfoSourceColumnVO> infoSourceVos = baseMapper.bindInfoSourceColumnList(thinkTankId,BindTypeEnum.getInfoSourceType());
JSONObject jsonObject = new JSONObject();
if (CollectionUtil.isEmpty(infoSourceVos)) {
return jsonObject;
}
Map<Integer, List<BindInfoSourceColumnVO>> collect = infoSourceVos.stream().collect(Collectors.groupingBy(BindInfoSourceColumnVO::getSourceType));
collect.forEach((k,v)-> {
BindTypeEnum enumByValue = BindTypeEnum.getEnumByValue(k);
if (ObjectUtil.isNotNull(enumByValue)) {
jsonObject.put(enumByValue.toString(), v);
}
});
return jsonObject;
}
@Override
public List<BindSourceDetailVO> bindSourceCount(List<String> thinkTankIds) {
return baseMapper.bindSourceCount(thinkTankIds);
}
}
package com.zzsn.thinktank.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.thinktank.mapper.SysDictItemMapper;
import com.zzsn.thinktank.service.SysDictItemService;
import com.zzsn.thinktank.entity.SysDictItem;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @Author zhangweijian
* @since 2018-12-28
*/
@Service
@DS("slave")
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
@Override
public List<SysDictItem> listByDictCode(String dictCode) {
return this.baseMapper.listByDictCode(dictCode);
}
}
......@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -68,6 +69,9 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
InfoSourceGroupMapService infoSourceGroupMapService;
@Autowired
private InfoSourceService infoSourceService;
@Autowired
EsUtil esUtil;
@Resource
......@@ -265,6 +269,78 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
@Override
public Result<?> getList(ThinktankBasicInfoListVo thinktankBasicInfoListVo) {
IPage page = new Page();
thinktankBasicInfoListVo.setColumn(StringUtil.humpToLine(thinktankBasicInfoListVo.getColumn()));
//查询列表
List<ThinktankBasicInfoVo> list = thinktankBasicInfoMapper.getList(thinktankBasicInfoListVo);
page.setRecords(list);
//查询总数
Integer total = thinktankBasicInfoMapper.getCount(thinktankBasicInfoListVo);
page.setTotal(total);
Integer pageNo = thinktankBasicInfoListVo.getPageNo();
Integer pageSize = thinktankBasicInfoListVo.getPageSize();
page.setCurrent(pageNo);
page.setSize(pageSize);
if (list.size() == 0) {
return Result.OK(page);
}
//智库id集合
List<String> groupIds = list.stream().map(ThinktankBasicInfoVo::getId).collect(Collectors.toList());
//智库绑定信息源栏目详细情况
List<BindSourceDetailVO> bindSourceDetailList = infoSourceService.bindSourceCount(groupIds);
//按智库分组
Map<String, List<BindSourceDetailVO>> collect = bindSourceDetailList.stream().collect(Collectors.groupingBy(BindSourceDetailVO::getThinkTankId));
//所有绑定的信息源栏目id集合
List<String> sidList = bindSourceDetailList.stream().map(BindSourceDetailVO::getSourceId).collect(Collectors.toList());
//智库绑定信息源栏目采集资讯的数量
Map<String, Integer> groupCount = new HashMap<>();
//查询es
BoolQueryBuilder boolQuerylist = QueryBuilders.boolQuery();
boolQuerylist.must(QueryBuilders.termsQuery("sid", sidList));
try {
Map<String, Long> mapGroup = esUtil.groupBy("basedata", "sid", boolQuerylist, sidList.size());
for (Map.Entry<String, List<BindSourceDetailVO>> entry : collect.entrySet()) {
String thinkTankId = entry.getKey();
List<String> bindSidList = entry.getValue().stream().map(BindSourceDetailVO::getSourceId).collect(Collectors.toList());
long count = 0;
for (Map.Entry<String, Long> longEntry : mapGroup.entrySet()) {
if (bindSidList.contains(longEntry.getKey())) {
count += longEntry.getValue();
}
}
groupCount.put(thinkTankId, Math.toIntExact(count));
}
} catch (IOException e) {
log.error("ES查询失败");
e.printStackTrace();
}
for (ThinktankBasicInfoVo thinktankBasicInfoVo : list) {
String id = thinktankBasicInfoVo.getId();
List<BindSourceDetailVO> bindSourceDetailVOS = collect.get(id);
if (CollectionUtils.isEmpty(bindSourceDetailVOS)) {
continue;
}
thinktankBasicInfoVo.setInfoSourceCount(bindSourceDetailVOS.size());
Integer count = groupCount.get(id);
if (count == null) {
continue;
}
thinktankBasicInfoVo.setCollectionCount(count);
}
CompletableFuture.runAsync(()->{
//记录热门标签
String tagId = thinktankBasicInfoListVo.getTagId();
if (tagId != null && tagId.length() > 0) {
String[] tagIdArr = tagId.split(",");
for (String s : tagIdArr) {
thinktankTagService.addTagTop(s);
}
}
});
return Result.OK(page);
}
public Result<?> getList_old(ThinktankBasicInfoListVo thinktankBasicInfoListVo) {
IPage page = new Page();
thinktankBasicInfoListVo.setColumn(StringUtil.humpToLine(thinktankBasicInfoListVo.getColumn()));
//查询列表
......@@ -386,39 +462,30 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
}
@Override
public Result<?> getListBaseData(String id, Integer pageNo, Integer pageSize, Integer office) {
List<InfoSourceGroupMap> infoSourceGroupMapList = infoSourceGroupMapService.getSourceGroupMap(Arrays.asList(id));
List<String> sidList = new ArrayList<>();
for (InfoSourceGroupMap infoSourceGroupMap : infoSourceGroupMapList) {
sidList.add(infoSourceGroupMap.getSourceId());
}
public Result<?> getListBaseData(String id, Integer pageNo, Integer pageSize) {
List<BindInfoSourceColumnVO> sourceColumnList = infoSourceService.bindInfoSourceColumnPageList(id, null);
List<String> sidList = sourceColumnList.stream().map(BindInfoSourceColumnVO::getId).collect(Collectors.toList());
//设置分页参数
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
// searchSourceBuilder.size(pageSize);
// searchSourceBuilder.from(office);
searchSourceBuilder.trackTotalHits(true);
//排序
searchSourceBuilder.sort("createDate", SortOrder.ASC);
//查询es
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termsQuery("sid", sidList));
//查询数据
searchSourceBuilder.query(boolQuery);
Page<TransferData> page = null;
Page<TransferData> page = new Page<>(pageNo, pageSize);
try {
page = esUtil.queryPage("basedata", searchSourceBuilder, TransferData.class, pageNo, pageSize);
} catch (IOException e) {
e.printStackTrace();
}
for (TransferData transferData : page.getRecords()) {
transferData.setCreateDate(EsDateUtil.esFieldDateMapping(transferData.getCreateDate()));
transferData.setPublishDate(EsDateUtil.esFieldDateMapping(transferData.getPublishDate()));
}
} catch (IOException e) {
e.printStackTrace();
}
return Result.OK(page);
}
......@@ -649,7 +716,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
Map<String, Long> monthlyCountMap = new HashMap<>();
try {
//所有
totalCountMap = esUtil.groupBy("basedata", "sid", boolQuerylist, 100);
totalCountMap = esUtil.groupBy("basedata", "sid", boolQuerylist, sourceIds.size());
//近一个月
DateTime yesterday = cn.hutool.core.date.DateUtil.yesterday();
DateTime startTime = cn.hutool.core.date.DateUtil.offsetDay(yesterday, -30);
......
package com.zzsn.thinktank.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
/**
* <p>
* 信息源表
* </p>
*
* @author obcy
* @since 2025-06-19
*/
@Data
public class BindInfoSourceColumnVO {
/**
* 信息源栏目id
*/
private String id;
/**
* 信息源栏目编码
*/
private String infoSourceCode;
/**
* 信息源栏目名称
*/
private String siteName;
/**
* 信息源栏目地址
*/
private String siteUri;
/**
* 信息源名称
*/
private String webSiteName;
/**
* 信息源栏目状态
*/
private Integer status;
/**
* 绑定的信息源类型
*/
private Integer sourceType;
}
package com.zzsn.thinktank.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
/**
* <p>
* 信息源表
* </p>
*
* @author obcy
* @since 2025-06-19
*/
@Data
public class BindInfoSourceVO {
/**
* 信息源id
*/
private String id;
/**
* 信息源编码
*/
private String code;
/**
* 信息源名称
*/
private String infoName;
/**
* 地址
*/
private String infoAddress;
/**
* 绑定的信息源类型
*/
private Integer sourceType;
}
package com.zzsn.thinktank.vo;
import lombok.Data;
import java.util.List;
@Data
public class BindLabelVo {
private String labelCode ;
private String labelItemCode ;
private List<BindLabelVo> labelItems;
}
package com.zzsn.thinktank.vo;
import lombok.Data;
/**
* 智库绑定信息源数量对象
*
* @author lkg
* @date 2025/8/5
*/
@Data
public class BindSourceDetailVO {
private String thinkTankId;
private String sourceId;
}
package com.zzsn.thinktank.vo;
import lombok.Data;
import java.util.List;
/**
* 绑定信息源对象
*
* @author lkg
* @date 2025/8/2
*/
@Data
public class BindVO {
//智库id
private String thinkTankId;
//id(可以是信息源/信息源栏目组id集合,可以是信息源/信息源栏目id集合)
private List<String> bindIds;
//信息源标签
private List<BindLabelVo> bindLabels;
//绑定类型类型(1:通用 2:定向)
private Integer sourceBindType;
//信息源类型(1:信息源栏目组 2:信息源栏目 3:信息源栏目标签 4:信息源组 5:信息源 6:信息源标签)
private Integer sourceType;
}
package com.zzsn.thinktank.vo;
import lombok.Data;
/**
* 绑定信息源的检索条件
*
* @author lkg
* @date 2025/8/2
*/
@Data
public class InfoSearchCondition {
/**
* 信息源编码
*/
private String code;
/**
* 信息源名称
*/
private String infoName;
/**
* 信息源URL
*/
private String infoAddress;
/**
* 信息源栏目名称
*/
private String siteName;
/**
* 信息源栏目URL
*/
private String siteUri;
/**
* 信息源栏目状态
*/
private String status;
/**
* 爬虫类别
*/
private Integer crawlType;
}
package com.zzsn.thinktank.vo;
import lombok.Data;
/**
* 信息源组信息
*
* @author lkg
* @date 2025/8/2
*/
@Data
public class InfoSourceGroupVO {
/**
* 信息源组id
*/
private String id;
/**
* 信息源组编码
*/
private String groupCode;
/**
* 信息源组名称
*/
private String groupName;
/**
* 信息源组名称
*/
private Integer sourceType;
/**
* 信息源组分类名称
*/
private String groupTypeName;
}
package com.zzsn.thinktank.vo;
import lombok.Data;
/**
* 信息源标签信息
*
* @author lkg
* @date 2025/8/2
*/
@Data
public class InfoSourceLabelVO {
/**
* 标签值id
*/
private String id;
/**
* 标签编码
*/
private String labelCode;
/**
* 标签名称
*/
private String labelName;
/**
* 业务口径(1自定义,2实体表引用,3字典引用)
*/
private String businessCaliber;
/**
* 引用数据字典的编码
*/
private String dictCode;
/**
* 标签值编码
*/
private String labelItemCode;
/**
* 标签值名称
*/
private String labelItemName;
/**
* 绑定的信息源类型
*/
private Integer sourceType;
}
......@@ -78,9 +78,9 @@ public class ThinktankBasicInfoVo extends Model<ThinktankBasicInfoVo> {
private Date updateTime;
//采集信息总量
private Integer collectionCount;
private Integer collectionCount = 0;
//绑定信息源个数
private Integer infoSourceCount;
private Integer infoSourceCount = 0;
//语言
private String lang;
......
......@@ -10,9 +10,48 @@ spring:
max-file-size: 100MB
#总上传文件大小
max-request-size: 1000MB
datasource:
url: jdbc:mysql://1.95.14.228:3306/clb_project?useUnicode=true&characterEncoding=utf-8&AllowPublicKeyRetrieval=True&serverTimezone=Asia/Shanghai&autoReconnect=true&rewriteBatchedStatements=true
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456667
allow:
web-stat-filter:
enabled: true
dynamic:
druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
# 连接池的配置信息
# 初始化大小,最小,最大
initial-size: 5
min-idle: 10
maxActive: 100
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 600000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
filters: stat,wall,slf4j
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://1.95.14.228:3306/clb_project?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
username: ciglobal
password: _PSuWVQ4CLpX
slave:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://1.95.14.228:3306/clb_system?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
username: ciglobal
password: _PSuWVQ4CLpX
redis:
......
......@@ -210,9 +210,263 @@
</select>
<select id="listByGroupId" resultType="String">
SELECT a.id from info_source a
SELECT a.id
from info_source a
INNER JOIN thinktank_info_source_group_map b ON b.source_id = a.id
where b.group_id = #{groupId}
</select>
<select id="bindInfoSourcePageList" resultType="com.zzsn.thinktank.vo.BindInfoSourceVO">
SELECT
a.id,a.code,a.info_name,a.info_address
FROM
info_source_main a
LEFT JOIN (
SELECT DISTINCT
bind.id
FROM
(
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
WHERE
sm.type IN ( 31, 36 )
AND sm.group_id = #{thinkTankId} UNION
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source_main_group_map m ON m.group_id = sm.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
WHERE
sm.type IN ( 32, 35 )
AND sm.group_id = #{thinkTankId} UNION
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN clb_label_main_source_map lam ON sm.source_id = lam.label_code
AND sm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
WHERE
sm.type IN ( 312, 315 )
AND sm.group_id = #{thinkTankId}
) bind
) b ON a.id = b.id
WHERE
b.id IS NOT NULL
<if test="infoSearchCondition.infoAddress!=null and infoSearchCondition.infoAddress != ''">
and a.info_address like CONCAT('%',#{infoSearchCondition.infoAddress},'%')
</if>
<if test="infoSearchCondition.infoName!=null and infoSearchCondition.infoName != ''">
and a.info_name like CONCAT('%',#{infoSearchCondition.infoName},'%')
</if>
<if test="infoSearchCondition.code!=null and infoSearchCondition.code != ''">
and a.code like CONCAT('%',#{infoSearchCondition.code},'%')
</if>
</select>
<select id="bindInfoSourceColumnPageList" resultType="com.zzsn.thinktank.vo.BindInfoSourceColumnVO">
SELECT
a.id,a.info_source_code,a.site_name,a.site_uri,a.web_site_name,a.status
FROM
info_source a
LEFT JOIN (
SELECT DISTINCT
bind.id
FROM
(
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source im ON im.id = sm.source_id
WHERE
sm.type IN ( 1, 6 )
AND sm.group_id = #{thinkTankId} UNION
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source_group_map m ON m.group_id = sm.source_id
INNER JOIN info_source im ON im.id = m.source_id
WHERE
sm.type IN ( 2, 5 )
AND sm.group_id = #{thinkTankId} UNION
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN clb_label_info_source_map lam ON sm.source_id = lam.label_code AND sm.source_item_id = lam.label_item_code
INNER JOIN info_source im ON lam.entity_code = im.id
WHERE
sm.type IN ( 12, 15 )
AND sm.group_id = #{thinkTankId}
) bind
) b ON a.id = b.id
WHERE
b.id IS NOT NULL
<if test="infoSearchCondition.infoName!=null and infoSearchCondition.infoName != ''">
and a.web_site_name like CONCAT('%',#{infoSearchCondition.infoName},'%')
</if>
<if test="infoSearchCondition.siteName!=null and infoSearchCondition.siteName != ''">
and a.site_name like CONCAT('%',#{infoSearchCondition.siteName},'%')
</if>
<if test="infoSearchCondition.siteUri!=null and infoSearchCondition.siteUri != ''">
and a.site_uri like CONCAT('%',#{infoSearchCondition.siteUri},'%')
</if>
<if test="infoSearchCondition.status!=null">
and a.status = #{infoSearchCondition.status}
</if>
<if test="infoSearchCondition.crawlType!=null">
and a.crawl_type = #{infoSearchCondition.crawlType}
</if>
</select>
<select id="bindInfoSourceGroupList" resultType="com.zzsn.thinktank.vo.InfoSourceGroupVO">
SELECT b.id,b.group_code,b.group_name, d.type_name as groupTypeName,a.type as sourceType
FROM thinktank_info_source_group_map a
LEFT JOIN info_source_main_group b on a.source_id = b.id
LEFT JOIN group_main_type_map c on b.id = c.group_id
LEFT JOIN group_main_type d on d.id = c.type_id
where a.group_id = #{thinkTankId}
<if test="types != null and types.size() > 0">
and a.type in
<foreach collection="types" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="bindInfoSourceList" resultType="com.zzsn.thinktank.vo.BindInfoSourceVO">
SELECT b.id,b.code,b.info_name,b.info_address, a.type as sourceType
FROM thinktank_info_source_group_map a
LEFT JOIN info_source_main b on a.source_id = b.id
WHERE a.group_id = #{thinkTankId}
<if test="types != null and types.size() > 0">
and a.type in
<foreach collection="types" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="bindInfoSourceLabelList" resultType="com.zzsn.thinktank.vo.InfoSourceLabelVO">
SELECT item.id, m.source_id label_code, label.label_name, label.business_caliber,label.dict_code,
m.source_item_id label_item_code, item.label_item_name,m.type as sourceType
FROM thinktank_info_source_group_map m
left join clb_label_item item on m.source_item_id = item.label_item_code
left join clb_label label on m.source_id = label.label_code
where m.group_id = #{thinkTankId}
<if test="types != null and types.size() > 0">
and m.type in
<foreach collection="types" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="bindInfoSourceColumnGroupList" resultType="com.zzsn.thinktank.vo.InfoSourceGroupVO">
SELECT b.id,b.group_code,b.group_name, a.type as sourceType, d.type_name as groupTypeName
FROM thinktank_info_source_group_map a
LEFT JOIN info_source_group b on a.source_id = b.id
LEFT JOIN group_type_map c on b.id = c.group_id
LEFT JOIN group_type d on d.id = c.type_id
where a.group_id = #{thinkTankId}
<if test="types != null and types.size() > 0">
and a.type in
<foreach collection="types" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="bindInfoSourceColumnList" resultType="com.zzsn.thinktank.vo.BindInfoSourceColumnVO">
SELECT b.id,b.info_source_code,b.site_name,b.web_site_name,a.type as sourceType
FROM thinktank_info_source_group_map a
LEFT JOIN info_source b on a.source_id = b.id
WHERE a.group_id = #{thinkTankId}
<if test="types != null and types.size() > 0">
and a.type in
<foreach collection="types" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="bindSourceCount" resultType="com.zzsn.thinktank.vo.BindSourceDetailVO">
select distinct x.source_id,x.group_id from (
select m.source_id,n.group_id from thinktank_info_source_group_map n
inner join info_source_group_map m on n.source_id = m.group_id
where n.type in(2,5)
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and n.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select iso.id as source_id,sim.group_id from
thinktank_info_source_group_map sim
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
where sim.type IN ( 32, 35 )
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sim.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select sm.source_id,sm.group_id from thinktank_info_source_group_map sm where sm.type in(1,6)
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select iso.id as source_id ,sm.group_id FROM
thinktank_info_source_group_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sm.type IN ( 31, 36 )
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select m.entity_code as source_id,n.group_id from thinktank_info_source_group_map n
inner join clb_label_info_source_map m on n.source_id = m.label_code and n.source_item_id = m.label_item_code
where n.type in(12,15)
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and n.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select isoo.id as source_id,smm.group_id
FROM
thinktank_info_source_group_map smm
INNER JOIN clb_label_main_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE
smm.type IN ( 312, 315 )
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and smm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
) x
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.thinktank.mapper.SysDictItemMapper">
<select id="listByDictCode" resultType="com.zzsn.thinktank.entity.SysDictItem">
select * from sys_dict_item item inner join sys_dict dict on item.dict_id = dict.id
where dict.dict_code = #{dictCode} and item.status = 1
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论