提交 74dfeb42 作者: 925993793@qq.com

导入导出逻辑优化调整

上级 75e8e756
package com.zzsn.thinktank.controller;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.zzsn.thinktank.entity.ThinktankBasicInfo;
import com.zzsn.thinktank.service.LeaderCategoryService;
import com.zzsn.thinktank.service.ThinktankBasicInfoService;
import com.zzsn.thinktank.vo.Result;
import com.zzsn.thinktank.vo.ThinktankBasicInfoListVo;
import com.zzsn.thinktank.vo.ThinktankBasicInfoVo;
import com.zzsn.thinktank.util.ExcelExportUtil;
import com.zzsn.thinktank.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.util.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Map;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.*;
/**
* @Version 1.0
......@@ -32,63 +35,69 @@ public class ThinktankBasicInfoController {
@Autowired
ThinktankBasicInfoService thinktankBasicInfoService;
@Autowired
LeaderCategoryService leaderCategoryService;
/**
* 新增
*
* @param thinktankBasicInfo
* @return
*/
@PostMapping("/add")
public Result<?> add(@RequestBody ThinktankBasicInfo thinktankBasicInfo){
log.info("新增信息:{}",thinktankBasicInfo);
public Result<?> add(@RequestBody ThinktankBasicInfo thinktankBasicInfo) {
log.info("新增信息:{}", thinktankBasicInfo);
return thinktankBasicInfoService.add(thinktankBasicInfo);
}
/**
* 根据id主键删除
*
* @param id
* @return
*/
@GetMapping("/del")
public Result<?> del(@RequestParam(name="id",required=true) String id){
public Result<?> del(@RequestParam(name = "id", required = true) String id) {
log.info("根据id删除:{}", id);
return thinktankBasicInfoService.del(id);
}
/**
* 根据id修改信息
*
* @param thinktankBasicInfo
* @return
*/
@PostMapping("/edit")
public Result<?> edit(@RequestBody ThinktankBasicInfo thinktankBasicInfo){
log.info("根据id修改信息:{}",thinktankBasicInfo);
if(thinktankBasicInfo.getId() == null)
public Result<?> edit(@RequestBody ThinktankBasicInfo thinktankBasicInfo) {
log.info("根据id修改信息:{}", thinktankBasicInfo);
if (thinktankBasicInfo.getId() == null)
return Result.error(400, "id不能为空");
return thinktankBasicInfoService.edit(thinktankBasicInfo);
}
/**
* 根据id主键查询
*
* @param id
* @return
*/
@GetMapping("getById")
public Result<?> getById(@RequestParam(name="id",required=true) String id){
log.info("根据id主键查询:{}",id);
public Result<?> getById(@RequestParam(name = "id", required = true) String id) {
log.info("根据id主键查询:{}", id);
ThinktankBasicInfoVo thinktankBasicInfo = thinktankBasicInfoService.getInfoById(id);
return Result.OK(thinktankBasicInfo);
}
@PostMapping("/list")
public Result<?> getList(@RequestBody ThinktankBasicInfoListVo thinktankBasicInfoListVo){
public Result<?> getList(@RequestBody ThinktankBasicInfoListVo thinktankBasicInfoListVo) {
log.info("智库信息条件分页查询:{}", thinktankBasicInfoListVo);
Integer pageNo = thinktankBasicInfoListVo.getPageNo();
Integer pageSize= thinktankBasicInfoListVo.getPageSize();
if(pageNo < 1)
Integer pageSize = thinktankBasicInfoListVo.getPageSize();
if (pageNo < 1)
pageNo = 1;
if(pageSize < 0)
if (pageSize < 0)
pageSize = 10;
Integer office = pageSize * (pageNo - 1);
thinktankBasicInfoListVo.setOffset(office);
......@@ -97,6 +106,7 @@ public class ThinktankBasicInfoController {
/**
* 模板下载
*
* @param response
*/
@GetMapping("/downloadTemplate")
......@@ -104,39 +114,109 @@ public class ThinktankBasicInfoController {
thinktankBasicInfoService.downloadTemplate(response);
}
/**
* 批量导入数据
* @param
* @return
*
* @param file excel文件
* @author lkg
* @date 2024/8/22
*/
//@Transactional
@PostMapping("/batchImport")
public Result<?> batchImport( HttpServletRequest request) {
log.info("批量导入数据");
// log.info("批量导入数据:{}",file.getOriginalFilename());
// log.info("file:{}",file.getName());
MultipartHttpServletRequest multipartRequest = WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class);
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
log.info(fileMap.size() + "");
// MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
// Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
// log.info("file size:{}",fileMap.size());
// if (fileMap.size() < 1) {
// return Result.error("请上传文件!");
// }
MultipartFile multipartFile = fileMap.get(new ArrayList<>(fileMap.keySet()).get(0));
Result result = thinktankBasicInfoService.batchImport(multipartFile);
// Result result = thinktankBasicInfoService.batchImport(file);
return result;
public Result<?> batchImport(@RequestParam("file") MultipartFile file) {
int index = Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf(".");
String fileSuffix = file.getOriginalFilename().substring(index + 1);
if ("xls".equals(fileSuffix) || "xlsx".equals(fileSuffix)) {
boolean flag = checkExcel(file);
if (!flag) {
return Result.error("模版有误,请使用正确的模板!");
}
} else {
return Result.error("不支持的文件类型!");
}
try {
ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
Map<String, String> header = new HashMap<>();
header.put("智库机构编码", "codeId");
header.put("* 中文全称", "chineseWhole");
header.put("中文简称", "chineseSimple");
header.put("英文全称", "englishWhole");
header.put("英文简称", "englishSimple");
header.put("官网", "officialWebsite");
header.put("* 所属国家", "belongCountry");
header.put("语言", "lang");
header.put("营利性质", "profitNature");
header.put("智库性质", "nature");
header.put("研究领域", "tagName");
header.put("影响力和地位", "influencePosition");
header.put("智库规模", "scale");
header.put("成果类型", "achievementType");
header.put("资金来源", "fundsSource");
header.put("原文全称", "originalWhole");
header.put("原文简称", "originalSimple");
header.put("简介", "biographicalNotes");
header.put("成立时间", "establishTime");
header.put("是否收费(1-是;0-否)", "charge");
header.put("地址", "address");
header.put("创办单位/所属单位", "belongUnit");
reader.setHeaderAlias(header);
List<ThinkTankFileVO> thinkTankImportVOList = reader.read(1, 2, ThinkTankFileVO.class);
if (CollectionUtils.isNotEmpty(thinkTankImportVOList)) {
boolean requiredFlag = true;
for (ThinkTankFileVO thinkTankImportVO : thinkTankImportVOList) {
if (StringUtils.isEmpty(thinkTankImportVO.getChineseWhole()) || StringUtils.isEmpty(thinkTankImportVO.getBelongCountry())) {
requiredFlag = false;
break;
}
}
if (!requiredFlag) {
return Result.error("必填项【中文全称和所属国家】有缺失,请核对后再导入。");
}
String msg = thinktankBasicInfoService.batchImport(thinkTankImportVOList);
return Result.OK(msg);
} else {
return Result.error("文件数据为空。");
}
} catch (IOException e) {
e.printStackTrace();
}
return Result.OK();
}
@PostMapping("/batchExport")
public byte[] batchExport(@RequestBody ThinktankBasicInfoListVo one) {
byte[] bytes = null;
try {
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-否)",
"地址", "创办单位/所属单位"};
XSSFWorkbook workbook = new XSSFWorkbook();
//基本信息
List<List<String>> rows = new ArrayList<>();
thinkTankBasicInfos.forEach(each -> rows.add(each.toList()));
ExcelExportUtil.exportExcelData(workbook, 0, Arrays.asList(arr), rows, "智库基本信息");
//统计信息
String[] header = new String[]{"智库机构id", "智库机构编码", "中文全称", "关联信息源数量", "信息采集总量", "关联信息源编码",
"关联信息源名称", "栏目名称", "网址", "启用状态(1-启用;0-禁用)","信息源采集数量", "信息源近一月采集量"};
List<ThinkTankSourceVO> thinkTankSourceVOS = thinktankBasicInfoService.thinkTankCollectCount(thinkTankBasicInfos);
List<List<String>> rowList = new ArrayList<>();
thinkTankSourceVOS.forEach(e->rowList.add(e.toList()));
ExcelExportUtil.exportExcelData(workbook, 1, Arrays.asList(header), rowList, "智库采集统计信息");
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
workbook.write(outStream);
// 将字节流转换为InputStream
bytes = outStream.toByteArray();
}
} catch (Exception e) {
e.printStackTrace();
}
return bytes;
}
/* @PostMapping("/batchExport")
public byte[] batchExport(@RequestBody ThinktankBasicInfoListVo thinktankBasicInfoListVo,HttpServletRequest request, HttpServletResponse response){
log.info("导出:{}", thinktankBasicInfoListVo);
// Integer pageNo = thinktankBasicInfoListVo.getPageNo();
......@@ -148,20 +228,49 @@ public class ThinktankBasicInfoController {
// Integer office = pageSize * (pageNo - 1);
// thinktankBasicInfoListVo.setOffset(office);
return thinktankBasicInfoService.batchExport(thinktankBasicInfoListVo,request,response);
}
}*/
@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(name = "id", required = true) String id,
@RequestParam(name = "pageNo", required = true) Integer pageNo,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
log.info("智库成果分页查询:{}", id);
if(pageNo < 1)
if (pageNo < 1)
pageNo = 1;
if(pageSize < 0)
if (pageSize < 0)
pageSize = 10;
Integer office = pageSize * (pageNo - 1);
return thinktankBasicInfoService.getListBaseData(id,pageNo,pageSize,office);
return thinktankBasicInfoService.getListBaseData(id, pageNo, pageSize, office);
}
private boolean checkExcel(MultipartFile multipartFile) {
Workbook workbook = ExcelExportUtil.getWorkbook(multipartFile);
if (workbook != null) {
List<String> list = ExcelExportUtil.getSheetTitles(workbook);
return list != null
&& list.contains("智库机构编码")
&& list.contains("* 中文全称")
&& list.contains("中文简称")
&& list.contains("英文全称")
&& list.contains("英文简称")
&& list.contains("官网")
&& list.contains("* 所属国家")
&& list.contains("语言")
&& list.contains("营利性质")
&& list.contains("智库性质")
&& list.contains("研究领域")
&& list.contains("影响力和地位")
&& list.contains("智库规模")
&& list.contains("成果类型")
&& list.contains("资金来源")
&& list.contains("原文全称")
&& list.contains("原文简称")
&& list.contains("简介")
&& list.contains("成立时间")
&& list.contains("是否收费(1-是;0-否)")
&& list.contains("地址")
&& list.contains("创办单位/所属单位");
}
return false;
}
}
......@@ -5,9 +5,12 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
......@@ -78,4 +81,58 @@ public class ThinktankBasicInfo extends Model<ThinktankBasicInfo> {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
//语言
private String lang;
//营利性质
private String profitNature;
//智库性质
private String nature;
//影响力和地位
private String influencePosition;
//智库规模
private String scale;
//成果类型
private String achievementType;
//资金来源
private String fundsSource;
public List<String> toList(){
List<String> list = new ArrayList<>();
list.add(getValue(id));
list.add(getValue(codeId));
list.add(getValue(chineseWhole));
list.add(getValue(chineseSimple));
list.add(getValue(englishWhole));
list.add(getValue(englishSimple));
list.add(getValue(officialWebsite));
list.add(getValue(belongCountry));
list.add(getValue(lang));
list.add(getValue(profitNature));
list.add(getValue(nature));
list.add(getValue(tagName));
list.add(getValue(influencePosition));
list.add(getValue(scale));
list.add(getValue(achievementType));
list.add(getValue(fundsSource));
list.add(getValue(originalWhole));
list.add(getValue(originalSimple));
list.add(getValue(biographicalNotes));
list.add(getValue(establishTime));
if (charge != null) {
list.add(String.valueOf(charge));
} else {
list.add(" ");
}
list.add(getValue(address));
list.add(getValue(belongUnit));
return list;
}
private String getValue(String value){
if (StringUtils.isEmpty(value)) {
value = " ";
}
return value;
}
}
package com.zzsn.thinktank.mapper;
import com.zzsn.thinktank.vo.DataChangeVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 批量导入数据
*
* @author lkg
* @date 2024/8/22
*/
public interface DataImportMapper {
/**
* 获取字典值列表
*
* @param dictCode 字段编码
* @author lkg
* @date 2024/8/23
*/
List<DataChangeVO> dictItemList(@Param("dictCode") String dictCode);
/**
* 获取标签实体列表
*
* @param labelId 标签id
* @author lkg
* @date 2024/8/23
*/
List<DataChangeVO> labelEntityList(@Param("labelId") String labelId);
}
......@@ -2,6 +2,7 @@ package com.zzsn.thinktank.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.thinktank.entity.InfoSourceGroupMap;
import com.zzsn.thinktank.vo.ThinkTankSourceVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -19,4 +20,13 @@ public interface InfoSourceGroupMapMapper extends BaseMapper<InfoSourceGroupMap>
void deleteBySourceId(@Param("sourceId") String sourceId);
void deleteBySourceIds(@Param("groupId") String groupId, @Param("sourceIds") List<String> sourceIds);
/**
* 获取智库关联的信息源集合
*
* @param groupIds 智库id集合
* @author lkg
* @date 2024/8/23
*/
List<ThinkTankSourceVO> listOfThinkTank(@Param("groupIds") List<String> groupIds);
}
......@@ -6,6 +6,7 @@ import com.zzsn.thinktank.vo.ThinktankBasicInfoExportVo;
import com.zzsn.thinktank.vo.ThinktankBasicInfoListVo;
import com.zzsn.thinktank.vo.ThinktankBasicInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -22,4 +23,19 @@ public interface ThinktankBasicInfoMapper extends BaseMapper<ThinktankBasicInfo>
Integer getCount(ThinktankBasicInfoListVo thinktankBasicInfoListVo);
List<ThinktankBasicInfoExportVo> getExportList(ThinktankBasicInfoListVo thinktankBasicInfoListVo);
/**
* 根据搜索条件获取导出列表
*
* @param ids 智库id集合
* @param codeId 主库编码
* @param typeId 国家id
* @param thinktankName 智库名称
* @param tagId 研究领域id
* @param keyword 关键词
* @author lkg
* @date 2024/8/23
*/
List<ThinktankBasicInfo> exportListByCondition(@Param("ids") List<String> ids, @Param("codeId") String codeId, @Param("typeId") String typeId,
@Param("thinktankName") String thinktankName, @Param("tagId") String tagId, @Param("keyword") String keyword);
}
package com.zzsn.thinktank.service;
import com.zzsn.thinktank.vo.DataChangeVO;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/8/23
*/
public interface DataImportService {
/**
* 获取字典值列表
*
* @param dictCode 字段编码
* @author lkg
* @date 2024/8/23
*/
List<DataChangeVO> dictItemList(String dictCode);
/**
* 获取标签实体列表
*
* @param labelId 标签id
* @author lkg
* @date 2024/8/23
*/
List<DataChangeVO> labelEntityList(String labelId);
}
package com.zzsn.thinktank.service;
import com.zzsn.thinktank.mapper.DataImportMapper;
import com.zzsn.thinktank.vo.DataChangeVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/8/23
*/
@Service
public class DataImportServiceImpl implements DataImportService{
@Resource
private DataImportMapper dataImportMapper;
@Override
public List<DataChangeVO> dictItemList(String dictCode) {
return dataImportMapper.dictItemList(dictCode);
}
@Override
public List<DataChangeVO> labelEntityList(String labelId) {
return dataImportMapper.labelEntityList(labelId);
}
}
......@@ -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.ThinkTankSourceVO;
import java.util.List;
......@@ -20,4 +21,13 @@ public interface InfoSourceGroupMapService extends IService<InfoSourceGroupMap>
void unBind(String groupId, List<String> sourceIds);
List<InfoSourceGroupMap> getSourceGroupMap(List groupIds);
/**
* 获取智库关联的信息源集合
*
* @param groupIds 智库id集合
* @author lkg
* @date 2024/8/23
*/
List<ThinkTankSourceVO> listOfThinkTank(List<String> groupIds);
}
......@@ -2,13 +2,12 @@ package com.zzsn.thinktank.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.thinktank.entity.ThinktankBasicInfo;
import com.zzsn.thinktank.vo.Result;
import com.zzsn.thinktank.vo.ThinktankBasicInfoListVo;
import com.zzsn.thinktank.vo.ThinktankBasicInfoVo;
import com.zzsn.thinktank.vo.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @Version 1.0
......@@ -35,4 +34,37 @@ public interface ThinktankBasicInfoService extends IService<ThinktankBasicInfo>
byte[] batchExport(ThinktankBasicInfoListVo thinktankBasicInfoListVo, HttpServletRequest request, HttpServletResponse response);
Result<?> getListBaseData(String id, Integer pageNo, Integer pageSize, Integer office);
/**
* 批量导入智库信息
*
* @param thinkTankImportVOList 智库信息列表
* @author lkg
* @date 2024/8/23
*/
String batchImport(List<ThinkTankFileVO> thinkTankImportVOList);
/**
* 根据搜索条件获取导出列表
*
* @param id 智库id集合,多个逗号隔开
* @param codeId 主库编码
* @param typeId 国家id
* @param thinktankName 智库名称
* @param tagId 研究领域id
* @param keyword 关键词
* @author lkg
* @date 2024/8/23
*/
List<ThinktankBasicInfo> exportListByCondition(String id, String codeId, String typeId,
String thinktankName, String tagId, String keyword);
/**
* 智库采集量统计
*
* @param dataList 智库列表
* @author lkg
* @date 2024/8/23
*/
List<ThinkTankSourceVO> thinkTankCollectCount(List<ThinktankBasicInfo> dataList);
}
......@@ -8,6 +8,7 @@ import com.zzsn.thinktank.entity.InfoSourceGroupMap;
import com.zzsn.thinktank.entity.ThinktankBasicInfo;
import com.zzsn.thinktank.mapper.InfoSourceGroupMapMapper;
import com.zzsn.thinktank.service.InfoSourceGroupMapService;
import com.zzsn.thinktank.vo.ThinkTankSourceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -68,4 +69,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return list;
}
@Override
public List<ThinkTankSourceVO> listOfThinkTank(List<String> groupIds) {
return baseMapper.listOfThinkTank(groupIds);
}
}
package com.zzsn.thinktank.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -13,6 +14,8 @@ import com.zzsn.thinktank.service.*;
import com.zzsn.thinktank.util.*;
import com.zzsn.thinktank.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.Functions;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.elasticsearch.index.query.BoolQueryBuilder;
......@@ -22,16 +25,17 @@ import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -70,6 +74,22 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
@Autowired
EsUtil esUtil;
@Resource
private DataImportService dataImportService;
//语种字典吗
@Value("${dict.language:}")
private String LANGUAGE;
//营利性质字典吗
@Value("${dict.think_tank_profit_nature:}")
private String THINK_TANK_PROFIT_NATURE;
//智库性质字典吗
@Value("${dict.think_tank_nature:}")
private String THINK_TANK_NATURE;
//研究领域标签id
@Value("${sys_base_label_type}")
private String SYS_BASE_LABEL_TYPE;
@Value("${files.storage}")
String filesStorage;
......@@ -88,7 +108,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//标签
String tagId = thinktankBasicInfo.getTagId();
if(tagId != null && tagId.length() > 0){
if (tagId != null && tagId.length() > 0) {
String[] ids = tagId.split(",");
List<LabelEntity> list = thinktankTagService.getListByIds(ids);
List<String> nameList = new ArrayList<>();
......@@ -103,7 +123,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//类别
String belongCountryId = thinktankBasicInfo.getBelongCountryId();
ThinktankCategoryStructure tcs = leaderCategoryService.getById(belongCountryId);
if(tcs != null){
if (tcs != null) {
String typeName = tcs.getTypeName();
thinktankBasicInfo.setBelongCountry(typeName);
}
......@@ -113,7 +133,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
boolean b = this.save(thinktankBasicInfo);
Result result = Result.OK();
if(!b){
if (!b) {
result.error500("保存失败!");
}
//同步新增智库数据到标签管理
......@@ -127,7 +147,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
List<String> ids = Arrays.asList(idArr);
boolean b = this.removeByIds(ids);
Result result = Result.OK();
if(!b){
if (!b) {
result.error500("删除失败!");
}
thinktankTagService.delLabel(ids);
......@@ -139,7 +159,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//标签
String tagId = thinktankBasicInfo.getTagId();
if(tagId != null && tagId.length() > 0){
if (tagId != null && tagId.length() > 0) {
String[] ids = tagId.split(",");
List<LabelEntity> list = thinktankTagService.getListByIds(ids);
List<String> nameList = new ArrayList<>();
......@@ -161,7 +181,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
boolean b = this.updateById(thinktankBasicInfo);
Result result = Result.OK();
if(!b){
if (!b) {
result.error500("修改失败!");
}
thinktankTagService.editLabel(thinktankBasicInfo);
......@@ -172,7 +192,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
public ThinktankBasicInfoVo getInfoById(String id) {
ThinktankBasicInfo info = this.getById(id);
if(info == null){
if (info == null) {
return null;
}
......@@ -198,7 +218,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//查询es
BoolQueryBuilder boolQuerylist = QueryBuilders.boolQuery();
boolQuerylist.must(QueryBuilders.termsQuery("sid",sidList));
boolQuerylist.must(QueryBuilders.termsQuery("sid", sidList));
Map<String, Long> mapGroup = null;
try {
mapGroup = esUtil.groupBy("basedata", "sid", boolQuerylist, 100);
......@@ -206,11 +226,11 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
log.error("ES查询失败");
e.printStackTrace();
}
if(mapGroup != null && mapGroup.size() > 0){
if (mapGroup != null && mapGroup.size() > 0) {
for (InfoSourceGroupCountVo infoSourceGroupCountVo : countVoList) {
String sourceId = infoSourceGroupCountVo.getSourceId();
Long countInfo = mapGroup.get(sourceId);
if(countInfo == null){
if (countInfo == null) {
countInfo = 0L;
}
infoSourceGroupCountVo.setInfoCount(Math.toIntExact(countInfo));
......@@ -224,7 +244,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
for (ThinktankBasicInfoVo thinktankBasicInfoVo : list) {
// String id = thinktankBasicInfoVo.getId();
List<InfoSourceGroupCountVo> listVo = studentsByGrade.get(thinktankBasicInfoVo.getId());
if(listVo == null){
if (listVo == null) {
thinktankBasicInfoVo.setCollectionCount(0);
thinktankBasicInfoVo.setInfoSourceCount(0);
} else {
......@@ -252,11 +272,11 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
Integer total = thinktankBasicInfoMapper.getCount(thinktankBasicInfoListVo);
page.setTotal(total);
Integer pageNo = thinktankBasicInfoListVo.getPageNo();
Integer pageSize= thinktankBasicInfoListVo.getPageSize();
Integer pageSize = thinktankBasicInfoListVo.getPageSize();
page.setCurrent(pageNo);
page.setSize(pageSize);
if(list.size() == 0){
if (list.size() == 0) {
return Result.OK(page);
}
......@@ -278,7 +298,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//查询es
BoolQueryBuilder boolQuerylist = QueryBuilders.boolQuery();
boolQuerylist.must(QueryBuilders.termsQuery("sid",sidList));
boolQuerylist.must(QueryBuilders.termsQuery("sid", sidList));
Map<String, Long> mapGroup = null;
try {
mapGroup = esUtil.groupBy("basedata", "sid", boolQuerylist, 100);
......@@ -286,11 +306,11 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
log.error("ES查询失败");
e.printStackTrace();
}
if(mapGroup != null && mapGroup.size() > 0){
if (mapGroup != null && mapGroup.size() > 0) {
for (InfoSourceGroupCountVo infoSourceGroupCountVo : countVoList) {
String sourceId = infoSourceGroupCountVo.getSourceId();
Long countInfo = mapGroup.get(sourceId);
if(countInfo == null){
if (countInfo == null) {
countInfo = 0L;
}
infoSourceGroupCountVo.setInfoCount(Math.toIntExact(countInfo));
......@@ -304,7 +324,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
for (ThinktankBasicInfoVo thinktankBasicInfoVo : list) {
String id = thinktankBasicInfoVo.getId();
List<InfoSourceGroupCountVo> listVo = studentsByGrade.get(id);
if(listVo == null){
if (listVo == null) {
thinktankBasicInfoVo.setCollectionCount(0);
thinktankBasicInfoVo.setInfoSourceCount(0);
} else {
......@@ -312,7 +332,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
int count = 0;
for (InfoSourceGroupCountVo infoSourceGroupCountVo : listVo) {
Integer infoCount = infoSourceGroupCountVo.getInfoCount();
if(infoCount != null){
if (infoCount != null) {
count += infoCount;
}
}
......@@ -322,7 +342,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//记录热门标签
String tagId = thinktankBasicInfoListVo.getTagId();
if(tagId != null && tagId.length() >0){
if (tagId != null && tagId.length() > 0) {
String[] tagIdArr = tagId.split(",");
for (String s : tagIdArr) {
thinktankTagService.addTagTop(s);
......@@ -373,12 +393,13 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
log.error("excel格式不对");
return Result.error("模版有误,请使用正确的模板!");
}
String msg = doExcel(multipartFile,fileSuffix);
String msg = doExcel(multipartFile, fileSuffix);
return Result.OK(msg);
} else {
return Result.error("不支持的文件类型!");
}
}
private boolean checkExcel(MultipartFile multipartFile) {
Workbook workbook = ExcelExportUtil.getWorkbook(multipartFile);
if (workbook != null) {
......@@ -406,7 +427,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
return false;
}
private String doExcel(MultipartFile multipartFile,String fileSuffix){
private String doExcel(MultipartFile multipartFile, String fileSuffix) {
List<List<String>> excelLists = null;
try {
byte[] fileData = multipartFile.getBytes();
......@@ -419,39 +440,39 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
String msg = "";
int i = 0;//记录成功数量
int j = 0;//记录失败数量
if(excelLists != null && excelLists.size() > 0){
if (excelLists != null && excelLists.size() > 0) {
//处理数据
List<ThinktankBasicInfo> infoList = new ArrayList<>();
for (List<String> list : excelLists) {
ThinktankBasicInfo thinktankBasicInfo = new ThinktankBasicInfo();
if(StringUtils.isNotEmpty(list.get(0))) thinktankBasicInfo.setId(list.get(0));
if(StringUtils.isNotEmpty(list.get(1))) thinktankBasicInfo.setCodeId(list.get(1));
if(StringUtils.isNotEmpty(list.get(2))) thinktankBasicInfo.setChineseWhole(list.get(2));
if(StringUtils.isNotEmpty(list.get(3))) thinktankBasicInfo.setChineseSimple(list.get(3));
if(StringUtils.isNotEmpty(list.get(4))) thinktankBasicInfo.setEnglishWhole(list.get(4));
if(StringUtils.isNotEmpty(list.get(5))) thinktankBasicInfo.setEnglishSimple(list.get(5));
if(StringUtils.isNotEmpty(list.get(6))) thinktankBasicInfo.setOriginalWhole(list.get(6));
if(StringUtils.isNotEmpty(list.get(7))) thinktankBasicInfo.setOriginalSimple(list.get(7));
if(StringUtils.isNotEmpty(list.get(8))) thinktankBasicInfo.setOfficialWebsite(list.get(8));
if(StringUtils.isNotEmpty(list.get(9))) thinktankBasicInfo.setBelongCountry(list.get(9));
if(StringUtils.isNotEmpty(list.get(10))) thinktankBasicInfo.setTagName(list.get(10));
if(StringUtils.isNotEmpty(list.get(11))) thinktankBasicInfo.setBiographicalNotes(list.get(11));
if(StringUtils.isNotEmpty(list.get(12))) thinktankBasicInfo.setEstablishTime(list.get(12));
if (StringUtils.isNotEmpty(list.get(0))) thinktankBasicInfo.setId(list.get(0));
if (StringUtils.isNotEmpty(list.get(1))) thinktankBasicInfo.setCodeId(list.get(1));
if (StringUtils.isNotEmpty(list.get(2))) thinktankBasicInfo.setChineseWhole(list.get(2));
if (StringUtils.isNotEmpty(list.get(3))) thinktankBasicInfo.setChineseSimple(list.get(3));
if (StringUtils.isNotEmpty(list.get(4))) thinktankBasicInfo.setEnglishWhole(list.get(4));
if (StringUtils.isNotEmpty(list.get(5))) thinktankBasicInfo.setEnglishSimple(list.get(5));
if (StringUtils.isNotEmpty(list.get(6))) thinktankBasicInfo.setOriginalWhole(list.get(6));
if (StringUtils.isNotEmpty(list.get(7))) thinktankBasicInfo.setOriginalSimple(list.get(7));
if (StringUtils.isNotEmpty(list.get(8))) thinktankBasicInfo.setOfficialWebsite(list.get(8));
if (StringUtils.isNotEmpty(list.get(9))) thinktankBasicInfo.setBelongCountry(list.get(9));
if (StringUtils.isNotEmpty(list.get(10))) thinktankBasicInfo.setTagName(list.get(10));
if (StringUtils.isNotEmpty(list.get(11))) thinktankBasicInfo.setBiographicalNotes(list.get(11));
if (StringUtils.isNotEmpty(list.get(12))) thinktankBasicInfo.setEstablishTime(list.get(12));
//是否收费
if(StringUtils.isNotEmpty(list.get(13))){
if (StringUtils.isNotEmpty(list.get(13))) {
String chargeStr = list.get(13);
try {
Integer charge = Integer.valueOf(chargeStr);
thinktankBasicInfo.setCharge(charge);
} catch (Exception e) {
thinktankBasicInfo.setCharge(-1);
log.error("是否收费转换失败:{},{}",list.get(1),list.get(13));
log.error("是否收费转换失败:{},{}", list.get(1), list.get(13));
}
}
if(StringUtils.isNotEmpty(list.get(14))) thinktankBasicInfo.setAddress(list.get(14));
if(StringUtils.isNotEmpty(list.get(15))) thinktankBasicInfo.setBelongUnit(list.get(15));
if(StringUtils.isNotEmpty(list.get(15))) thinktankBasicInfo.setAttribute(list.get(16));
if (StringUtils.isNotEmpty(list.get(14))) thinktankBasicInfo.setAddress(list.get(14));
if (StringUtils.isNotEmpty(list.get(15))) thinktankBasicInfo.setBelongUnit(list.get(15));
if (StringUtils.isNotEmpty(list.get(15))) thinktankBasicInfo.setAttribute(list.get(16));
infoList.add(thinktankBasicInfo);
}
......@@ -459,14 +480,14 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
List<ThinktankCategoryStructure> listCategoryStructure = leaderCategoryService.list();
Map<String, String> mapCategoryStructure = new HashMap<>();
for (ThinktankCategoryStructure thinktankCategoryStructure : listCategoryStructure) {
mapCategoryStructure.put(thinktankCategoryStructure.getTypeName(),thinktankCategoryStructure.getId());
mapCategoryStructure.put(thinktankCategoryStructure.getTypeName(), thinktankCategoryStructure.getId());
}
//标签列表
Map<String, String> mapTag = new HashMap<>();//标签名称列表
Result result = thinktankTagService.getTagList(null,null);
Result result = thinktankTagService.getTagList(null, null);
List<SysLabelVo> list = (List<SysLabelVo>) result.getResult();
for (SysLabelVo labelVo : list) {
mapTag.put(labelVo.getName(),labelVo.getId());
mapTag.put(labelVo.getName(), labelVo.getId());
}
StringBuffer sb = new StringBuffer();
......@@ -475,16 +496,16 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//序号
String number = thinktankBasicInfo.getId();
String codeId = thinktankBasicInfo.getCodeId();
if(codeId == null || codeId.length() ==0){
if (codeId == null || codeId.length() == 0) {
thinktankBasicInfo.setCodeId(generatorIdService.getIdNo());
thinktankBasicInfo.setId(Long.toString(generatorIdService.getOrderId()));
thinktankBasicInfo.setCreateTime(new Date());
thinktankBasicInfo.setUpdateTime(new Date());
} else {
LambdaQueryWrapper<ThinktankBasicInfo> lambdaQuery = Wrappers.lambdaQuery();
lambdaQuery.eq(ThinktankBasicInfo::getCodeId,codeId);
lambdaQuery.eq(ThinktankBasicInfo::getCodeId, codeId);
List<ThinktankBasicInfo> listBasicInfo = thinktankBasicInfoMapper.selectList(lambdaQuery);
if(listBasicInfo.size() > 0){
if (listBasicInfo.size() > 0) {
thinktankBasicInfo.setId(listBasicInfo.get(0).getId());
thinktankBasicInfo.setUpdateTime(new Date());
} else {
......@@ -497,23 +518,23 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//国家
String belongCountry = thinktankBasicInfo.getBelongCountry();
String belongCountryId = mapCategoryStructure.get(belongCountry);
if(StringUtils.isEmpty(belongCountryId)){
if (StringUtils.isEmpty(belongCountryId)) {
b = false;
sb.append("序号为'" + number + "'的国家’" + belongCountry +"‘数据库没有,导入失败;\n");
sb.append("序号为'" + number + "'的国家’" + belongCountry + "‘数据库没有,导入失败;\n");
} else {
thinktankBasicInfo.setBelongCountryId(belongCountryId);
}
//标签
String tagName = thinktankBasicInfo.getTagName();
if(tagName != null && tagName.length() > 0){
if (tagName != null && tagName.length() > 0) {
String[] tagNameArr = tagName.split(",");
List<String> tagIdList = new ArrayList<>();
for (String s : tagNameArr) {
String tagId = mapTag.get(s);
if(StringUtils.isEmpty(tagId)){
if (StringUtils.isEmpty(tagId)) {
b = false;
sb.append("序号为'" + number + "'的标签'" + s +"'数据库没有,导入失败;\n");
sb.append("序号为'" + number + "'的标签'" + s + "'数据库没有,导入失败;\n");
} else {
tagIdList.add(tagId);
}
......@@ -524,25 +545,25 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//所属单位
String belongUnit = thinktankBasicInfo.getBelongUnit();
if(belongUnit != null && belongUnit.length() > 0){
if (belongUnit != null && belongUnit.length() > 0) {
List<SysBaseEnterprise> listEnter = enterpriseService.getListByName(belongUnit);
if(listEnter.size() > 0){
if (listEnter.size() > 0) {
SysBaseEnterprise enter = listEnter.get(0);
String belongUnitCode = enter.getSocialCreditCode();
thinktankBasicInfo.setBelongUnitCode(belongUnitCode);
} else {
b = false;
sb.append("序号为'" + number + "'的创办单位/所属单位'" + belongUnit +"'数据库没有,导入失败;\n");
sb.append("序号为'" + number + "'的创办单位/所属单位'" + belongUnit + "'数据库没有,导入失败;\n");
}
}
//成立时间
String establishTime = thinktankBasicInfo.getEstablishTime();
if(!DateUtil.isDate(establishTime)){
if (!DateUtil.isDate(establishTime)) {
b = false;
sb.append("序号为'" + number + "'的成立时间'" + belongUnit +"'格式错误,导入失败;\n");
sb.append("序号为'" + number + "'的成立时间'" + belongUnit + "'格式错误,导入失败;\n");
}
if(b){
if (b) {
this.saveOrUpdate(thinktankBasicInfo);
thinktankTagService.addLabel(thinktankBasicInfo);
i++;
......@@ -556,9 +577,9 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
+ "导入成功数量:" + i + "\n"
+ "导入失败数量:" + j + "\n"
+ "其中:\n"
+sb.toString();
+ sb.toString();
}
if(j > 0){
if (j > 0) {
return msg;
}
return "true";
......@@ -567,7 +588,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
@Override
public byte[] batchExport(ThinktankBasicInfoListVo thinktankBasicInfoListVo, HttpServletRequest request, HttpServletResponse response) {
List<ThinktankBasicInfoExportVo> list = this.getExportList(thinktankBasicInfoListVo);
log.info("{}",list.size());
log.info("{}", list.size());
int i = 1;
for (ThinktankBasicInfoExportVo thinktankBasicInfoVo : list) {
......@@ -625,7 +646,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//查询列表
List<ThinktankBasicInfoExportVo> list = thinktankBasicInfoMapper.getExportList(thinktankBasicInfoListVo);
if(list.size() == 0){
if (list.size() == 0) {
return list;
}
......@@ -647,7 +668,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//查询es
BoolQueryBuilder boolQuerylist = QueryBuilders.boolQuery();
boolQuerylist.must(QueryBuilders.termsQuery("sid",sidList));
boolQuerylist.must(QueryBuilders.termsQuery("sid", sidList));
//boolQuerylist.filter(QueryBuilders.rangeQuery("publishDate").gte("2024-05-18T00:00:01"));
......@@ -658,11 +679,11 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
log.error("ES查询失败");
e.printStackTrace();
}
if(mapGroup != null && mapGroup.size() > 0){
if (mapGroup != null && mapGroup.size() > 0) {
for (InfoSourceGroupCountVo infoSourceGroupCountVo : countVoList) {
String sourceId = infoSourceGroupCountVo.getSourceId();
Long countInfo = mapGroup.get(sourceId);
if(countInfo == null){
if (countInfo == null) {
countInfo = 0L;
}
infoSourceGroupCountVo.setInfoCount(Math.toIntExact(countInfo));
......@@ -677,7 +698,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
String infoSourceId = thinktankBasicInfoVo.getInfoSourceId();
Long count = mapGroup.get(infoSourceId);
if(count == null){
if (count == null) {
thinktankBasicInfoVo.setCount(0);
} else {
thinktankBasicInfoVo.setCount(Math.toIntExact(count));
......@@ -685,7 +706,7 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
String id = thinktankBasicInfoVo.getId();
List<InfoSourceGroupCountVo> listVo = studentsByGrade.get(id);
if(listVo == null){
if (listVo == null) {
thinktankBasicInfoVo.setCollectionCount(0);
thinktankBasicInfoVo.setInfoSourceCount(0);
} else {
......@@ -720,14 +741,14 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
//查询es
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termsQuery("sid",sidList));
boolQuery.must(QueryBuilders.termsQuery("sid", sidList));
//查询数据
searchSourceBuilder.query(boolQuery);
Page<TransferData> page = null;
try {
page = esUtil.queryPage("basedata", searchSourceBuilder, TransferData.class, pageNo,pageSize);
page = esUtil.queryPage("basedata", searchSourceBuilder, TransferData.class, pageNo, pageSize);
} catch (IOException e) {
e.printStackTrace();
}
......@@ -738,5 +759,251 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
return Result.OK(page);
}
@Override
@Transactional
public String batchImport(List<ThinkTankFileVO> thinkTankImportVOList) {
//国家列表
List<ThinktankCategoryStructure> listCategoryStructure = leaderCategoryService.list();
Map<String, String> mapCategoryStructure = listCategoryStructure.stream().collect(Collectors.toMap(ThinktankCategoryStructure::getTypeName, ThinktankCategoryStructure::getId, (value1, value2) -> value1));
//语种
List<DataChangeVO> languageList = dataImportService.dictItemList(LANGUAGE);
Map<String, String> languageMap = languageList.stream().collect(Collectors.toMap(DataChangeVO::getDescription, DataChangeVO::getValue, (value1, value2) -> value1));
//营利性质
List<DataChangeVO> profitNatureList = dataImportService.dictItemList(THINK_TANK_PROFIT_NATURE);
Map<String, String> profitNatureMap = profitNatureList.stream().collect(Collectors.toMap(DataChangeVO::getDescription, DataChangeVO::getValue, (value1, value2) -> value1));
//智库性质
List<DataChangeVO> natureList = dataImportService.dictItemList(THINK_TANK_NATURE);
Map<String, String> natureMap = natureList.stream().collect(Collectors.toMap(DataChangeVO::getDescription, DataChangeVO::getValue, (value1, value2) -> value1));
//研究领域
List<DataChangeVO> researchFieldList = dataImportService.labelEntityList(SYS_BASE_LABEL_TYPE);
Map<String, String> researchFieldMap = researchFieldList.stream().collect(Collectors.toMap(DataChangeVO::getDescription, DataChangeVO::getValue, (value1, value2) -> value1));
StringBuilder stringBuilder = new StringBuilder();
for (ThinkTankFileVO thinkTankImportVO : thinkTankImportVOList) {
ThinktankBasicInfo thinktankBasicInfo = new ThinktankBasicInfo();
BeanUtils.copyProperties(thinkTankImportVO, thinktankBasicInfo);
String codeId = thinkTankImportVO.getCodeId();
if (StringUtils.isEmpty(codeId)) {
codeId = generatorIdService.getIdNo();
}
thinktankBasicInfo.setCodeId(codeId);
String belongCountry = thinkTankImportVO.getBelongCountry();
String belongCountryId = mapCategoryStructure.get(belongCountry);
if (StringUtils.isEmpty(belongCountryId)) {
stringBuilder.append("智库【").append(thinktankBasicInfo.getChineseWhole()).append("】的国家【").append(belongCountry).append("】,数据库中没有,导入失败;\n");
continue;
} else {
thinktankBasicInfo.setBelongCountryId(belongCountryId);
}
String lang = thinkTankImportVO.getLang();
if (StringUtils.isNotEmpty(lang)) {
StringBuilder noExist = new StringBuilder();
StringBuilder langCode = new StringBuilder();
for (String value : lang.split(",")) {
String langValue = languageMap.get(value);
if (StringUtils.isEmpty(langValue)) {
noExist.append(",").append(value);
} else {
langCode.append(",").append(langValue);
}
}
if (StringUtils.isNotEmpty(noExist)) {
stringBuilder.append("智库【").append(thinktankBasicInfo.getChineseWhole()).append("】的语言【").append(noExist.substring(1)).append("】,数据库中没有,导入失败;\n");
continue;
} else {
thinktankBasicInfo.setLang(langCode.substring(1));
}
}
String profitNature = thinkTankImportVO.getProfitNature();
if (StringUtils.isNotEmpty(profitNature)) {
String profitNatureValue = profitNatureMap.get(profitNature);
if (StringUtils.isEmpty(profitNatureValue)) {
stringBuilder.append("智库【").append(thinktankBasicInfo.getChineseWhole()).append("】的营利性质【").append(profitNature).append("】,数据库中没有,导入失败;\n");
continue;
} else {
thinktankBasicInfo.setProfitNature(profitNatureValue);
}
}
String nature = thinkTankImportVO.getNature();
if (StringUtils.isNotEmpty(nature)) {
String natureValue = natureMap.get(nature);
if (StringUtils.isEmpty(natureValue)) {
stringBuilder.append("智库【").append(thinktankBasicInfo.getChineseWhole()).append("】的智库性质【").append(nature).append("】,数据库中没有,导入失败;\n");
continue;
} else {
thinktankBasicInfo.setNature(natureValue);
}
}
String tagName = thinkTankImportVO.getTagName();
if (StringUtils.isNotEmpty(tagName)) {
StringBuilder noExist = new StringBuilder();
StringBuilder tagId = new StringBuilder();
for (String name : tagName.split(",")) {
String value = researchFieldMap.get(name);
if (StringUtils.isEmpty(value)) {
noExist.append(",").append(name);
} else {
tagId.append(",").append(value);
}
}
if (StringUtils.isNotEmpty(noExist)) {
stringBuilder.append("智库【").append(thinktankBasicInfo.getChineseWhole()).append("】的研究领域【").append(noExist.substring(1)).append("】,数据库中没有,导入失败;\n");
continue;
} else {
thinktankBasicInfo.setTagId(tagId.substring(1));
}
}
String belongUnit = thinkTankImportVO.getBelongUnit();
if (StringUtils.isNotEmpty(belongUnit)) {
List<SysBaseEnterprise> listEnter = enterpriseService.getListByName(belongUnit);
if (CollectionUtils.isEmpty(listEnter)) {
stringBuilder.append("智库【").append(thinktankBasicInfo.getChineseWhole()).append("】的创办单位/所属单位【").append(belongUnit).append("】,数据库中没有,导入失败;\n");
continue;
} else {
SysBaseEnterprise enter = listEnter.get(0);
thinktankBasicInfo.setBelongUnitCode(enter.getSocialCreditCode());
}
}
LambdaQueryWrapper<ThinktankBasicInfo> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(ThinktankBasicInfo::getCodeId, codeId);
ThinktankBasicInfo one = thinktankBasicInfoMapper.selectOne(queryWrapper);
if (one != null) {
thinktankBasicInfo.setId(one.getId());
thinktankBasicInfoMapper.updateById(thinktankBasicInfo);
//编辑标签数据
thinktankTagService.editLabel(thinktankBasicInfo);
} else {
thinktankBasicInfo.setId(Long.toString(generatorIdService.getOrderId()));
thinktankBasicInfoMapper.insert(thinktankBasicInfo);
//增加标签数据
thinktankTagService.addLabel(thinktankBasicInfo);
}
}
return stringBuilder.length() > 0 ? stringBuilder.toString() : null;
}
@Override
public List<ThinktankBasicInfo> exportListByCondition(String id, String codeId, String typeId, String thinktankName, String tagId, String keyword) {
List<String> ids = new ArrayList<>();
if (StringUtils.isNotEmpty(id)) {
ids = Arrays.asList(id.split(","));
}
List<ThinktankBasicInfo> thinkTankBasicInfos = thinktankBasicInfoMapper.exportListByCondition(ids, codeId, typeId, thinktankName, tagId, keyword);
if (CollectionUtils.isNotEmpty(thinkTankBasicInfos)) {
//国家列表
List<ThinktankCategoryStructure> listCategoryStructure = leaderCategoryService.list();
Map<String, String> mapCategoryStructure = listCategoryStructure.stream().collect(Collectors.toMap(ThinktankCategoryStructure::getId, ThinktankCategoryStructure::getTypeName, (value1, value2) -> value1));
//语种
List<DataChangeVO> languageList = dataImportService.dictItemList(LANGUAGE);
Map<String, String> languageMap = languageList.stream().collect(Collectors.toMap(DataChangeVO::getValue, DataChangeVO::getDescription, (value1, value2) -> value1));
//营利性质
List<DataChangeVO> profitNatureList = dataImportService.dictItemList(THINK_TANK_PROFIT_NATURE);
Map<String, String> profitNatureMap = profitNatureList.stream().collect(Collectors.toMap(DataChangeVO::getValue, DataChangeVO::getDescription, (value1, value2) -> value1));
//智库性质
List<DataChangeVO> natureList = dataImportService.dictItemList(THINK_TANK_NATURE);
Map<String, String> natureMap = natureList.stream().collect(Collectors.toMap(DataChangeVO::getValue, DataChangeVO::getDescription, (value1, value2) -> value1));
//研究领域
List<DataChangeVO> researchFieldList = dataImportService.labelEntityList(SYS_BASE_LABEL_TYPE);
Map<String, String> researchFieldMap = researchFieldList.stream().collect(Collectors.toMap(DataChangeVO::getValue, DataChangeVO::getDescription, (value1, value2) -> value1));
for (ThinktankBasicInfo thinkTankBasicInfo : thinkTankBasicInfos) {
thinkTankBasicInfo.setBelongCountry(mapCategoryStructure.get(thinkTankBasicInfo.getBelongCountryId()));
String lang = thinkTankBasicInfo.getLang();
if (StringUtils.isNotEmpty(lang)) {
StringBuilder sb = new StringBuilder();
for (String s : lang.split(",")) {
String value = languageMap.get(s);
sb.append(",").append(value);
}
thinkTankBasicInfo.setLang(sb.substring(1));
}
String profitNature = thinkTankBasicInfo.getProfitNature();
if (StringUtils.isNotEmpty(profitNature)) {
thinkTankBasicInfo.setProfitNature(profitNatureMap.get(profitNature));
}
String nature = thinkTankBasicInfo.getNature();
if (StringUtils.isNotEmpty(nature)) {
thinkTankBasicInfo.setNature(natureMap.get(nature));
}
String tagIds = thinkTankBasicInfo.getTagId();
if (StringUtils.isNotEmpty(tagIds)) {
StringBuilder sb = new StringBuilder();
for (String s : tagIds.split(",")) {
String value = researchFieldMap.get(s);
sb.append(",").append(value);
}
thinkTankBasicInfo.setTagName(sb.substring(1));
}
String belongUnitCode = thinkTankBasicInfo.getBelongUnitCode();
if (StringUtils.isNotEmpty(belongUnitCode)) {
LambdaQueryWrapper<SysBaseEnterprise> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(SysBaseEnterprise::getName).eq(SysBaseEnterprise::getSocialCreditCode, belongUnitCode);
SysBaseEnterprise one = enterpriseService.getOne(queryWrapper);
if (one != null) {
thinkTankBasicInfo.setBelongUnit(one.getName());
}
}
}
}
return thinkTankBasicInfos;
}
@Override
public List<ThinkTankSourceVO> thinkTankCollectCount(List<ThinktankBasicInfo> dataList) {
Map<String, ThinktankBasicInfo> map = dataList.stream().collect(Collectors.toMap(ThinktankBasicInfo::getId, Function.identity()));
List<String> idList = new ArrayList<>();
dataList.forEach(e -> idList.add(e.getId()));
List<ThinkTankSourceVO> thinkTankSourceVOS = infoSourceGroupMapService.listOfThinkTank(idList);
List<String> sourceIds = new ArrayList<>();
for (ThinkTankSourceVO thinkTankSourceVO : thinkTankSourceVOS) {
ThinktankBasicInfo thinktankBasicInfo = map.get(thinkTankSourceVO.getGroupId());
thinkTankSourceVO.setCodeId(thinktankBasicInfo.getCodeId());
thinkTankSourceVO.setChineseWhole(thinktankBasicInfo.getChineseWhole());
//信息源id集合
sourceIds.add(thinkTankSourceVO.getSourceId());
}
//查询es
BoolQueryBuilder boolQuerylist = QueryBuilders.boolQuery();
boolQuerylist.must(QueryBuilders.termsQuery("sid", sourceIds));
Map<String, Long> totalCountMap = new HashMap<>();
Map<String, Long> monthlyCountMap = new HashMap<>();
try {
//所有
totalCountMap = esUtil.groupBy("basedata", "sid", boolQuerylist, 100);
//近一个月
DateTime yesterday = cn.hutool.core.date.DateUtil.yesterday();
DateTime startTime = cn.hutool.core.date.DateUtil.offsetDay(yesterday, -30);
boolQuerylist.filter(QueryBuilders.rangeQuery("createDate")
.gte(EsDateUtil.esFieldDateFormat(cn.hutool.core.date.DateUtil.format(startTime, "yyyy-MM-dd 00:00:00")))
.lte(EsDateUtil.esFieldDateFormat(cn.hutool.core.date.DateUtil.format(yesterday, "yyyy-MM-dd 23:59:59"))));
monthlyCountMap = esUtil.groupBy("basedata", "sid", boolQuerylist, 100);
} catch (IOException e) {
log.error("ES查询失败");
e.printStackTrace();
}
//采集量统计
for (ThinkTankSourceVO thinkTankSourceVO : thinkTankSourceVOS) {
String sourceId = thinkTankSourceVO.getSourceId();
Long infoCount = totalCountMap.get(sourceId);
if (infoCount == null) {
infoCount = 0L;
}
thinkTankSourceVO.setInfoCount(infoCount.intValue());
Long infoMonthlyCount = monthlyCountMap.get(sourceId);
if (infoMonthlyCount == null) {
infoMonthlyCount = 0L;
}
thinkTankSourceVO.setInfoMonthlyCount(infoMonthlyCount.intValue());
}
//数据合并
List<ThinkTankSourceVO> list = new ArrayList<>();
Map<String, List<ThinkTankSourceVO>> groupCountMap = thinkTankSourceVOS.stream().collect(Collectors.groupingBy(ThinkTankSourceVO::getGroupId));
for (Map.Entry<String, List<ThinkTankSourceVO>> entry : groupCountMap.entrySet()) {
List<ThinkTankSourceVO> value = entry.getValue();
int groupCount = value.stream().mapToInt(ThinkTankSourceVO::getInfoCount).sum();
ThinkTankSourceVO thinkTankSourceVO = value.get(0);
thinkTankSourceVO.setGroupCount(groupCount);
thinkTankSourceVO.setInfoSourceCount(value.size());
list.addAll(value);
}
return list;
}
}
......@@ -47,12 +47,14 @@ public class ThinktankTagServiceImpl extends ServiceImpl<ThinktankTagMapper, Lab
@Value("${sys_base_label_type_id}")
private String sys_base_label_type_id;
@Value("${sys_base_label_type}")
private String sys_base_label_type;
@Override
public Result<?> getTagList(String id, String name) {
if(id == null || id.length() == 0){
id = sys_base_label_type_id;
id = sys_base_label_type;
}
List<SysBaseLabelType> endNodes = getEndNodes(id);
List<String> ids = new ArrayList<>();
......
......@@ -9,6 +9,7 @@ import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
......@@ -209,13 +210,15 @@ public class ExcelExportUtil {
return null;
}
// 获取第一行数据(假如第一行就是列名)
Row sheetTitleRow = sheet.getRow(sheet.getFirstRowNum());
Row sheetTitleRow = sheet.getRow(1);
// 取出最后一列
short lastCellNum = sheetTitleRow.getLastCellNum();
List<String> sheetTitleList = new LinkedList<>();
for (int i = 0; i < lastCellNum; i++) {
// 取出每一列的名
String cellValue = sheetTitleRow.getCell(i).getStringCellValue();
Cell cell = sheetTitleRow.getCell(i);
HSSFDataFormatter dataFormatter = new HSSFDataFormatter();
String cellValue = dataFormatter.formatCellValue(cell);
sheetTitleList.add(cellValue);
}
return sheetTitleList;
......
package com.zzsn.thinktank.vo;
import lombok.Getter;
import lombok.Setter;
/**
* 批量导入时,数据转换实体
*
* @author lkg
* @date 2024/8/22
*/
@Setter
@Getter
public class DataChangeVO {
private String description;
private String value;
}
package com.zzsn.thinktank.vo;
import lombok.Getter;
import lombok.Setter;
/**
* 智库导入模板对应实体
*
* @author lkg
* @date 2024/8/22
*/
@Setter
@Getter
public class ThinkTankFileVO {
//智库机构编码
private String codeId;
//中文全称
private String chineseWhole;
//中文简称
private String chineseSimple;
//英文全称
private String englishWhole;
//英文简称
private String englishSimple;
//官网
private String officialWebsite;
//所属国家/地区
private String belongCountry;
//语言
private String lang;
//营利性质
private String profitNature;
//智库性质
private String nature;
//研究领域
private String tagName;
//影响力和地位
private String influencePosition;
//智库规模
private String scale;
//成果类型
private String achievementType;
//资金来源
private String fundsSource;
//原文全称
private String originalWhole;
//原文简称
private String originalSimple;
//简介
private String biographicalNotes;
//成立时间
private String establishTime;
//是否收费 1是 0否 默认为空值
private Integer charge;
//地址
private String address;
//创办单位/所属单位
private String belongUnit;
}
package com.zzsn.thinktank.vo;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/8/23
*/
@Setter
@Getter
public class ThinkTankSourceVO {
/**信息源组id*/
private String groupId;
//智库机构编码
private String codeId;
//中文全称
private String chineseWhole;
//关联信息源数量
private Integer infoSourceCount;
/**信息源id*/
private String sourceId;
//关联信息源编码
private String infoSourceCode;
//关联信息源名称
private String webSiteName;
//栏目名称
private String siteName;
//网址
private String siteUri;
//启用状态 1启用 0禁用
private String status;
/**信息源采集资讯数量**/
private Integer infoCount;
/**信息源进一个月的采集资讯数量**/
private Integer infoMonthlyCount;
/**智库下的资讯数量**/
private Integer groupCount;
public List<String> toList(){
List<String> list = new ArrayList<>();
list.add(getValue(groupId));
list.add(getValue(codeId));
list.add(getValue(chineseWhole));
if (infoSourceCount == null) {
list.add(" ");
} else {
list.add(String.valueOf(infoSourceCount));
}
if (groupCount == null) {
list.add(" ");
} else {
list.add(String.valueOf(groupCount));
}
list.add(getValue(infoSourceCode));
list.add(getValue(webSiteName));
list.add(getValue(siteName));
list.add(getValue(siteUri));
list.add(getValue(status));
if (infoCount == null) {
list.add(" ");
} else {
list.add(String.valueOf(infoCount));
}
if (infoMonthlyCount == null) {
list.add(" ");
} else {
list.add(String.valueOf(infoMonthlyCount));
}
return list;
}
private String getValue(String value){
if (StringUtils.isEmpty(value)) {
value = " ";
}
return value;
}
}
......@@ -39,4 +39,6 @@ public class ThinktankBasicInfoListVo {
//标签
private String tagId;
//智库id,多个逗号隔开
private String id;
}
......@@ -82,4 +82,19 @@ public class ThinktankBasicInfoVo extends Model<ThinktankBasicInfoVo> {
//绑定信息源个数
private Integer infoSourceCount;
//语言
private String lang;
//营利性质
private String profitNature;
//智库性质
private String nature;
//影响力和地位
private String influencePosition;
//智库规模
private String scale;
//成果类型
private String achievementType;
//资金来源
private String fundsSource;
}
......@@ -20,14 +20,6 @@ spring:
host: 114.116.90.53
password: clbzzsn
port: 6380
kafka:
bootstrap-servers: 114.115.159.144:9092
consumer:
group-id: groupName
auto-offset-reset: earliest
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
mybatis-plus:
mapper-locations: mapper/*.xml
configuration:
......@@ -46,6 +38,11 @@ es1:
password: zzsn9988
sys_base_label_type_id: 1783029731298439170
sys_base_label_type: 1792195735429595138
dict:
language: clb_language
think_tank_nature: think_tank_nature
think_tank_profit_nature: think_tank_profit_nature
files:
#storage: D:\\thinktank\\
......
<?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.DataImportMapper">
<select id="dictItemList" resultType="com.zzsn.thinktank.vo.DataChangeVO">
select item.item_text as description,item.item_value as value
from clb_system.sys_dict_item item inner join clb_system.sys_dict dict on item.dict_id = dict.id
where dict.dict_code = #{dictCode}
</select>
<select id="labelEntityList" resultType="com.zzsn.thinktank.vo.DataChangeVO">
select entity.name as description,entity.id as value
from label_entity entity inner join sys_base_label_type_map map on map.relation_id = entity.id
where map.label_id = #{labelId}
</select>
</mapper>
......@@ -30,9 +30,7 @@
<select id="getListByName" resultType="com.zzsn.thinktank.entity.SysBaseEnterprise">
select * from sys_base_enterprise
where 1=1
and name = #{name}
select id,social_credit_code,name from sys_base_enterprise where name = #{name}
</select>
</mapper>
......
......@@ -20,4 +20,16 @@
</foreach>
</if>
</delete>
<select id="listOfThinkTank" resultType="com.zzsn.thinktank.vo.ThinkTankSourceVO">
select b.group_id,b.source_id,a.info_source_code,a.web_site_name,a.site_name,a.site_uri,a.status
from info_source a inner join thinktank_info_source_group_map b on a.id = b.source_id
where 1=1
<if test="groupIds != null and groupIds.size() > 0">
and b.group_id in
<foreach collection="groupIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -6,7 +6,11 @@
<select id="getList" resultType="com.zzsn.thinktank.vo.ThinktankBasicInfoVo">
select
id,code_id,chinese_whole,chinese_simple,english_whole,english_simple,original_whole,original_simple,official_website,tag_id,tag_name,establish_time,charge,country_within_external,belong_country_id,belong_country,region,address,belong_unit_code,belong_unit,head_sculpture,biographical_notes,attribute,status,create_by,create_time,update_by,update_time
id,code_id,chinese_whole,chinese_simple,english_whole,english_simple,
original_whole,original_simple,official_website,tag_id,tag_name,establish_time,charge,
country_within_external,belong_country_id,belong_country,region,address,
belong_unit_code,belong_unit,head_sculpture,biographical_notes,status,
lang,profit_nature,nature,influence_position,scale,achievement_type,funds_source
from thinktank_basic_info a
where 1 = 1
<if test="codeId != null and codeId != ''">
......@@ -25,7 +29,8 @@
</if>
<if test="keyword != null and keyword != ''">
AND CONCAT_WS(',',code_id,chinese_whole,chinese_simple,english_whole,english_simple,original_whole,original_simple,official_website,tag_name,country_within_external,belong_country,region,address,belong_unit_code,belong_unit,biographical_notes,attribute)
AND
CONCAT_WS(',',code_id,chinese_whole,chinese_simple,english_whole,english_simple,original_whole,original_simple,official_website,tag_name,country_within_external,belong_country,region,address,belong_unit_code,belong_unit,biographical_notes,attribute)
like '%${keyword}%'
</if>
<if test="order != null and order != ''">
......@@ -54,7 +59,8 @@
</foreach>
</if>
<if test="keyword != null and keyword != ''">
AND CONCAT_WS(',',code_id,chinese_whole,chinese_simple,english_whole,english_simple,original_whole,original_simple,official_website,tag_name,country_within_external,belong_country,region,address,belong_unit_code,belong_unit,biographical_notes,attribute)
AND
CONCAT_WS(',',code_id,chinese_whole,chinese_simple,english_whole,english_simple,original_whole,original_simple,official_website,tag_name,country_within_external,belong_country,region,address,belong_unit_code,belong_unit,biographical_notes,attribute)
like '%${keyword}%'
</if>
......@@ -63,7 +69,9 @@
<select id="getExportList" resultType="com.zzsn.thinktank.vo.ThinktankBasicInfoExportVo">
select
a.id, a.code_id, a.chinese_whole, a.chinese_simple, a.english_whole, a.english_simple, a.original_whole, a.original_simple, a.official_website, a.belong_country, a.tag_name, a.biographical_notes, a.establish_time, a.charge, a.address, a.belong_unit,
a.id, a.code_id, a.chinese_whole, a.chinese_simple, a.english_whole, a.english_simple, a.original_whole,
a.original_simple, a.official_website, a.belong_country, a.tag_name, a.biographical_notes, a.establish_time,
a.charge, a.address, a.belong_unit,
c.id as infoSourceId, c.info_source_code, c.web_site_name, c.site_name, c.site_uri, c.status
from thinktank_basic_info a
LEFT JOIN thinktank_info_source_group_map b
......@@ -87,7 +95,8 @@
</if>
<if test="keyword != null and keyword != ''">
AND CONCAT_WS(',',code_id,chinese_whole,chinese_simple,english_whole,english_simple,original_whole,original_simple,official_website,tag_name,country_within_external,belong_country,region,address,belong_unit_code,belong_unit,biographical_notes,attribute)
AND
CONCAT_WS(',',code_id,chinese_whole,chinese_simple,english_whole,english_simple,original_whole,original_simple,official_website,tag_name,country_within_external,belong_country,region,address,belong_unit_code,belong_unit,biographical_notes,attribute)
like '%${keyword}%'
</if>
<if test="order != null and order != ''">
......@@ -96,8 +105,41 @@
</select>
<select id="exportListByCondition" resultType="com.zzsn.thinktank.entity.ThinktankBasicInfo">
select
a.id, a.code_id, a.chinese_whole, a.chinese_simple, a.english_whole, a.english_simple, a.original_whole,
a.original_simple, a.official_website, a.belong_country_id, a.tag_id, a.biographical_notes, a.establish_time,
a.charge, a.address, a.belong_unit_code,lang,profit_nature,nature,influence_position,scale,achievement_type,funds_source
from thinktank_basic_info a
where 1 = 1
<if test="ids != null and ids.size() > 0">
AND a.id in
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="codeId != null and codeId != ''">
AND a.code_id = #{codeId}
</if>
<if test="typeId != null and typeId != ''">
AND a.belong_country_id = #{typeId}
</if>
<if test="thinktankName != null and thinktankName != ''">
AND a.chinese_whole like '%${thinktankName}%'
</if>
<if test="tagId != null and tagId != ''">
<foreach item="item" index="index" collection="tagId.split(',')">
AND a.tag_id like '%${item}%'
</foreach>
</if>
<if test="keyword != null and keyword != ''">
AND
CONCAT_WS(',',code_id,chinese_whole,chinese_simple,english_whole,english_simple,original_whole,original_simple,official_website,tag_name,country_within_external,belong_country,region,address,belong_unit_code,belong_unit,biographical_notes,attribute)
like '%${keyword}%'
</if>
order by create_time desc
</select>
</mapper>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论