提交 dba7f4fd 作者: 925993793@qq.com

专题创建逻辑完善、接口补充以及bug修改

上级 2975571f
...@@ -128,8 +128,6 @@ public class SubjectManageController { ...@@ -128,8 +128,6 @@ public class SubjectManageController {
public Result<?> researchCenterPageList(SubjectCondition subjectCondition, public Result<?> researchCenterPageList(SubjectCondition subjectCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
UserVo loginUser = AuthUtil.getLoginUser();
subjectCondition.setUsername(loginUser.getUsername());
Page<SubjectPage> pageList = subjectService.researchCenterPageList(subjectCondition, pageNo, pageSize); Page<SubjectPage> pageList = subjectService.researchCenterPageList(subjectCondition, pageNo, pageSize);
return Result.OK(pageList); return Result.OK(pageList);
} }
......
package com.zzsn.event.controller; package com.zzsn.event.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Result; import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Subject; import com.zzsn.event.entity.Subject;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.SubjectService; import com.zzsn.event.service.SubjectService;
import com.zzsn.event.service.SubjectSimpleService; import com.zzsn.event.service.SubjectSimpleService;
import com.zzsn.event.vo.SearchWordVO; import com.zzsn.event.vo.InfoDataSearchCondition;
import com.zzsn.event.vo.SubjectDetailVO; import com.zzsn.event.vo.SubjectDetailVO;
import com.zzsn.event.vo.SubjectSimpleVO; import com.zzsn.event.vo.SubjectSimpleVO;
import com.zzsn.event.vo.es.SpecialInformation;
import com.zzsn.event.xxljob.service.IXxlJobInfoService; import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/** /**
* 专题管理流程简化版 * 专题管理流程简化版
...@@ -30,6 +38,8 @@ public class SubjectSimpleController { ...@@ -30,6 +38,8 @@ public class SubjectSimpleController {
private SubjectService subjectService; private SubjectService subjectService;
@Autowired @Autowired
private IXxlJobInfoService xxlJobInfoService; private IXxlJobInfoService xxlJobInfoService;
@Autowired
private EsService esService;
/** /**
* 创建专题 * 创建专题
...@@ -68,9 +78,66 @@ public class SubjectSimpleController { ...@@ -68,9 +78,66 @@ public class SubjectSimpleController {
*/ */
@GetMapping("/queryInfo") @GetMapping("/queryInfo")
public Result<?> queryInfo(@RequestParam String subjectId){ public Result<?> queryInfo(@RequestParam String subjectId){
SubjectDetailVO subjectDetailVO = subjectService.queryInfo(subjectId); SubjectDetailVO subjectDetailVO = subjectSimpleService.queryInfo(subjectId);
List<SearchWordVO> list = subjectSimpleService.subjectBindWordInfo(subjectId);
subjectDetailVO.setKeywords(list);
return Result.OK(subjectDetailVO); return Result.OK(subjectDetailVO);
} }
/**
* 删除专题
*
* @param subjectId 专题id
* @return
*/
@GetMapping(value = "/removeSubject")
public Result<?> removeSubject(@RequestParam String subjectId) {
subjectSimpleService.removeSubject(subjectId);
CompletableFuture.runAsync(() -> {
//删除xxljob里面的信息
LambdaQueryWrapper<Subject> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Subject::getId, subjectId);
Subject subject = subjectService.getOne(queryWrapper);
xxlJobInfoService.deleteByInfosourceCode(subject.getSubjectCode());
});
return Result.OK();
}
/**
* 批量添加至精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
@PostMapping("/selected")
public Result<?> selected(@RequestBody InfoDataSearchCondition searchCondition) {
subjectSimpleService.selected(searchCondition);
return Result.OK();
}
/**
* 批量移除精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
@PostMapping("/removeSelected")
public Result<?> removeSelected(@RequestBody InfoDataSearchCondition searchCondition) {
subjectSimpleService.removeSelected(searchCondition);
return Result.OK();
}
/**
* 批量删除
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
@PostMapping("/batchRemove")
public Result<?> batchRemove(@RequestBody InfoDataSearchCondition searchCondition) {
subjectSimpleService.batchRemove(searchCondition);
return Result.OK();
}
} }
...@@ -77,7 +77,7 @@ public class InformationController { ...@@ -77,7 +77,7 @@ public class InformationController {
* @date 2024/12/24 * @date 2024/12/24
*/ */
@GetMapping("/listBeInStorage") @GetMapping("/listBeInStorage")
public Result<?> listBeInStorage(@RequestParam() String subjectId, @RequestParam() String ids) { public Result<?> listBeInStorage(@RequestParam String subjectId, @RequestParam String ids) {
List<String> list = esService.listBeInStorage(subjectId, ids); List<String> list = esService.listBeInStorage(subjectId, ids);
return Result.OK(list); return Result.OK(list);
} }
...@@ -146,7 +146,7 @@ public class InformationController { ...@@ -146,7 +146,7 @@ public class InformationController {
/** /**
* 专题下模型绑定的标签信息 * 专题下模型绑定的标签信息-筛选条件
* *
* @param subjectId 专题id * @param subjectId 专题id
* @author lkg * @author lkg
...@@ -199,6 +199,9 @@ public class InformationController { ...@@ -199,6 +199,9 @@ public class InformationController {
*/ */
@PostMapping("/subjectPageList") @PostMapping("/subjectPageList")
public Result<?> subjectPageList(@RequestBody InfoDataSearchCondition searchCondition) { public Result<?> subjectPageList(@RequestBody InfoDataSearchCondition searchCondition) {
if (StringUtils.isEmpty(searchCondition.getSubjectId())) {
return Result.FAIL("专题id不能为空");
}
UserVo userVo = AuthUtil.getLoginUser(); UserVo userVo = AuthUtil.getLoginUser();
IPage<DisplayInfo> pageList = informationService.subjectPageList(userVo, searchCondition); IPage<DisplayInfo> pageList = informationService.subjectPageList(userVo, searchCondition);
return Result.OK(pageList); return Result.OK(pageList);
......
...@@ -767,7 +767,7 @@ public class EsService { ...@@ -767,7 +767,7 @@ public class EsService {
for (SearchHit hit : searchHits) { for (SearchHit hit : searchHits) {
String queryInfo = hit.getSourceAsString(); String queryInfo = hit.getSourceAsString();
SpecialInformation info = JSONUtil.toBean(queryInfo, SpecialInformation.class); SpecialInformation info = JSONUtil.toBean(queryInfo, SpecialInformation.class);
info.setIndex(hit.getIndex()); info.setDbIndex(hit.getIndex());
list.add(info); list.add(info);
} }
IPage<SpecialInformation> pageData = new Page<>(pageNo, pageSize, searchResponse.getHits().getTotalHits().value); IPage<SpecialInformation> pageData = new Page<>(pageNo, pageSize, searchResponse.getHits().getTotalHits().value);
...@@ -1174,7 +1174,7 @@ public class EsService { ...@@ -1174,7 +1174,7 @@ public class EsService {
String queryInfo = hit.getSourceAsString(); String queryInfo = hit.getSourceAsString();
SpecialInformation info = JSON.parseObject(queryInfo, SpecialInformation.class); SpecialInformation info = JSON.parseObject(queryInfo, SpecialInformation.class);
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate())); info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
info.setIndex(hit.getIndex()); info.setDbIndex(hit.getIndex());
dataList.add(info); dataList.add(info);
} }
} catch (IOException e) { } catch (IOException e) {
......
...@@ -29,7 +29,7 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -29,7 +29,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
Page<SubjectPage> pageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page); Page<SubjectPage> pageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page);
/** /**
* 专题分页列表-研究中心 * 专题分页列表(个人)-研究中心
* *
* @param subjectCondition 查询条件 * @param subjectCondition 查询条件
* @param page 分页参数 * @param page 分页参数
...@@ -37,6 +37,15 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -37,6 +37,15 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @date 2024/12/18 * @date 2024/12/18
*/ */
Page<SubjectPage> researchCenterPageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page); Page<SubjectPage> researchCenterPageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page);
/**
* 专题分页列表(公开)-研究中心
*
* @param subjectCondition 查询条件
* @param page 分页参数
* @author lkg
* @date 2025/1/14
*/
Page<SubjectPage> researchCenterFacePageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page);
/** /**
* 获取专题详情(包含样例文章信息) * 获取专题详情(包含样例文章信息)
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
select id,name_cn as name,pid,top_id,'region_out' as labelMark,'region_label' as labelType from sys_base_region select id,name_cn as name,pid,top_id,'region_out' as labelMark,'region_label' as labelType from sys_base_region
</select> </select>
<select id="industryList" resultType="com.zzsn.event.vo.LabelTypeVO"> <select id="industryList" resultType="com.zzsn.event.vo.LabelTypeVO">
select id,name_cn as name,pid,top_id,'standard-industry' as labelMark,'industry_label' as labelType from sys_base_industry select id,name_cn as name,pid,'standard-industry' as labelMark,'industry_label' as labelType from sys_base_industry
</select> </select>
<select id="queryCustomLabel" resultType="com.zzsn.event.vo.SysLabelVo"> <select id="queryCustomLabel" resultType="com.zzsn.event.vo.SysLabelVo">
......
...@@ -112,9 +112,38 @@ ...@@ -112,9 +112,38 @@
</if> </if>
order by d.create_time desc order by d.create_time desc
</select> </select>
<select id="researchCenterFacePageList" resultType="com.zzsn.event.vo.SubjectPage">
SELECT d.id,
d.subject_name,
d.remark,
d.create_time,
d.status,
c.type_name as subjectTypeName
from subject d
LEFT JOIN subject_type_map b ON b.subject_id = d.id
LEFT JOIN subject_type c ON b.type_id = c.id
where face_public = 1
<if test="subjectCondition.id !=null and subjectCondition.id !=''">
and d.id =#{subjectCondition.id}
</if>
<if test="subjectCondition.subjectName!=null and subjectCondition.subjectName != ''">
and d.subject_name like CONCAT('%',#{subjectCondition.subjectName},'%')
</if>
<if test="subjectCondition.startTime != null and subjectCondition.startTime != ''">
and d.create_time >= #{subjectCondition.startTime}
</if>
<if test="subjectCondition.endTime != null and subjectCondition.endTime != ''">
and d.create_time <![CDATA[ <= ]]> #{subjectCondition.endTime}
</if>
<if test="subjectCondition.status!=null">
and d.status = #{subjectCondition.status}
</if>
order by d.create_time desc
</select>
<resultMap id="SubjectDetailVOMap" type="com.zzsn.event.vo.SubjectDetailVO"> <resultMap id="SubjectDetailVOMap" type="com.zzsn.event.vo.SubjectDetailVO">
<result column="subject_name" property="subjectName"/> <result column="subject_name" property="subjectName"/>
<result column="subjectTypeId" property="subjectTypeId"/>
<result column="subjectTypeName" property="subjectTypeName"/> <result column="subjectTypeName" property="subjectTypeName"/>
<result column="remark" property="remark"/> <result column="remark" property="remark"/>
<result column="data_source" property="dataSource"/> <result column="data_source" property="dataSource"/>
...@@ -138,6 +167,7 @@ ...@@ -138,6 +167,7 @@
s.data_source, s.data_source,
s.face_public, s.face_public,
s.library, s.library,
c.id as subjectTypeId,
c.type_name as subjectTypeName, c.type_name as subjectTypeName,
f.id, f.id,
f.file_name, f.file_name,
......
package com.zzsn.event.service; package com.zzsn.event.service;
import com.zzsn.event.entity.Subject; import com.zzsn.event.entity.Subject;
import com.zzsn.event.vo.InfoDataSearchCondition;
import com.zzsn.event.vo.SearchWordVO; import com.zzsn.event.vo.SearchWordVO;
import com.zzsn.event.vo.SubjectDetailVO;
import com.zzsn.event.vo.SubjectSimpleVO; import com.zzsn.event.vo.SubjectSimpleVO;
import java.util.List; import java.util.List;
...@@ -14,9 +16,75 @@ import java.util.List; ...@@ -14,9 +16,75 @@ import java.util.List;
*/ */
public interface SubjectSimpleService { public interface SubjectSimpleService {
/**
* 新增专题
*
* @param subjectSimpleVO 参数
* @author lkg
* @date 2025/1/14
*/
Subject createSubject(SubjectSimpleVO subjectSimpleVO); Subject createSubject(SubjectSimpleVO subjectSimpleVO);
/**
* 编辑专题
*
* @param subjectSimpleVO 参数
* @author lkg
* @date 2025/1/14
*/
void editSubject(SubjectSimpleVO subjectSimpleVO); void editSubject(SubjectSimpleVO subjectSimpleVO);
/**
* 专题绑定关键词信息
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/14
*/
List<SearchWordVO> subjectBindWordInfo(String subjectId); List<SearchWordVO> subjectBindWordInfo(String subjectId);
/**
* 专题详情(包含样例文章以及关键词)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/14
*/
SubjectDetailVO queryInfo(String subjectId);
/**
* 删除专题
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/14
*/
void removeSubject(String subjectId);
/**
* 批量添加至精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
void selected(InfoDataSearchCondition searchCondition);
/**
* 批量移除精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
void removeSelected(InfoDataSearchCondition searchCondition);
/**
* 批量删除
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
void batchRemove(InfoDataSearchCondition searchCondition);
} }
...@@ -174,8 +174,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -174,8 +174,7 @@ public class InformationServiceImpl implements InformationService {
Label dataSet = new Label(); Label dataSet = new Label();
String dataSetId = searchCondition.getDataSetId(); String dataSetId = searchCondition.getDataSetId();
dataSet.setRelationId(dataSetId); dataSet.setRelationId(dataSetId);
//totalMap结构 index >> id >> updateField Map<String,List<SpecialInformation>> map = new HashMap<>();
Map<String,Map<String, Map<String, Object>>> totalMap = new HashMap<>();
for (int i = 1; ; i++) { for (int i = 1; ; i++) {
searchCondition.setPageNo(i); searchCondition.setPageNo(i);
List<SpecialInformation> informationList = esService.informationList(searchCondition); List<SpecialInformation> informationList = esService.informationList(searchCondition);
...@@ -184,8 +183,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -184,8 +183,7 @@ public class InformationServiceImpl implements InformationService {
break; break;
} }
for (SpecialInformation information : informationList) { for (SpecialInformation information : informationList) {
String id = information.getId(); String index = information.getDbIndex();
String index = information.getIndex();
List<Label> labels = information.getLabels(); List<Label> labels = information.getLabels();
if (CollectionUtils.isNotEmpty(labels)) { if (CollectionUtils.isNotEmpty(labels)) {
boolean present = labels.stream().anyMatch(label -> label.getRelationId().equals(dataSetId)); boolean present = labels.stream().anyMatch(label -> label.getRelationId().equals(dataSetId));
...@@ -195,23 +193,17 @@ public class InformationServiceImpl implements InformationService { ...@@ -195,23 +193,17 @@ public class InformationServiceImpl implements InformationService {
} else { } else {
labels.add(dataSet); labels.add(dataSet);
} }
Map<String,Object> updateField = new HashMap<>(); information.setLabels(labels);
updateField.put("labels", labels); if (map.containsKey(index)) {
if (totalMap.containsKey(index)) { map.get(index).add(information);
totalMap.get(index).put(id, updateField);
} else { } else {
//updateFields结构 id >> updateField List<SpecialInformation> list = new ArrayList<>();
Map<String, Map<String, Object>> updateFields = new HashMap<>(); list.add(information);
updateFields.put(id, updateField); map.put(index, list);
totalMap.put(index, updateFields);
} }
} }
} }
for (Map.Entry<String, Map<String, Map<String, Object>>> entry : totalMap.entrySet()) { map.forEach((k, v) -> esOpUtil.docUpdateBulk(k, v));
String index = entry.getKey();
Map<String, Map<String, Object>> value = entry.getValue();
esOpUtil.bulkUpdateFields(index, value);
}
} }
@Override @Override
...@@ -372,7 +364,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -372,7 +364,7 @@ public class InformationServiceImpl implements InformationService {
public void updateInfo(JSONObject jsonObject,UserVo userVo) { public void updateInfo(JSONObject jsonObject,UserVo userVo) {
SpecialInformation specialInformation = JSON.parseObject(JSON.toJSONString(jsonObject.get("data")), SpecialInformation.class); SpecialInformation specialInformation = JSON.parseObject(JSON.toJSONString(jsonObject.get("data")), SpecialInformation.class);
Integer category = (Integer) jsonObject.get("category"); Integer category = (Integer) jsonObject.get("category");
String index = specialInformation.getIndex(); String index = specialInformation.getDbIndex();
specialInformation.setIndex(null); specialInformation.setIndex(null);
//更新content字段 //更新content字段
if (StringUtils.isNotBlank(specialInformation.getContentWithTag())) { if (StringUtils.isNotBlank(specialInformation.getContentWithTag())) {
......
...@@ -25,6 +25,8 @@ import com.zzsn.event.util.CodeGenerateUtil; ...@@ -25,6 +25,8 @@ import com.zzsn.event.util.CodeGenerateUtil;
import com.zzsn.event.util.CronUtil; import com.zzsn.event.util.CronUtil;
import com.zzsn.event.util.HttpUtil; import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.RedisUtil; import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -127,6 +129,11 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -127,6 +129,11 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
@Override @Override
public Page<SubjectPage> researchCenterPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize) { public Page<SubjectPage> researchCenterPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize) {
Integer facePublic = subjectCondition.getFacePublic();
Page<SubjectPage> page = new Page<>(pageNo, pageSize);
if (facePublic == 1) {
page = baseMapper.researchCenterFacePageList(subjectCondition, page);
} else {
//查询类别id的所有明细id //查询类别id的所有明细id
List<String> typeIds = new ArrayList<>(); List<String> typeIds = new ArrayList<>();
String subjectTypeId = subjectCondition.getSubjectTypeId(); String subjectTypeId = subjectCondition.getSubjectTypeId();
...@@ -134,8 +141,11 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -134,8 +141,11 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
typeIds = subjectTypeService.researchCenterBelowIdList(subjectTypeId, 1); typeIds = subjectTypeService.researchCenterBelowIdList(subjectTypeId, 1);
} }
subjectCondition.setTypeIds(typeIds); subjectCondition.setTypeIds(typeIds);
Page<SubjectPage> page = new Page<>(pageNo, pageSize); UserVo loginUser = AuthUtil.getLoginUser();
return baseMapper.researchCenterPageList(subjectCondition, page); subjectCondition.setUsername(loginUser.getUsername());
page = baseMapper.researchCenterPageList(subjectCondition, page);
}
return page;
} }
@Override @Override
...@@ -187,8 +197,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -187,8 +197,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
}*/ }*/
//判断开始时间和结束时间是否发生变动 //判断开始时间和结束时间是否发生变动 todo 还需要吗
Date newTimeEnable = subjectPage.getTimeEnable(); /*Date newTimeEnable = subjectPage.getTimeEnable();
Date oldTimeEnable = oldSubject.getTimeEnable(); Date oldTimeEnable = oldSubject.getTimeEnable();
if (!((newTimeEnable == null && oldTimeEnable == null) || if (!((newTimeEnable == null && oldTimeEnable == null) ||
(newTimeEnable != null && oldTimeEnable != null && oldTimeEnable.compareTo(newTimeEnable) == 0))) { (newTimeEnable != null && oldTimeEnable != null && oldTimeEnable.compareTo(newTimeEnable) == 0))) {
...@@ -200,7 +210,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -200,7 +210,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
//更新redis中关键词时间 //更新redis中关键词时间
updateRedisKeyWordsDate(subjectPage.getId(), keyWordIds); updateRedisKeyWordsDate(subjectPage.getId(), keyWordIds);
} }*/
} }
@Override @Override
......
...@@ -6,21 +6,22 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -6,21 +6,22 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.entity.*; import com.zzsn.event.entity.*;
import com.zzsn.event.enums.CodePrefixEnum; import com.zzsn.event.enums.CodePrefixEnum;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.util.CodeGenerateUtil; import com.zzsn.event.util.CodeGenerateUtil;
import com.zzsn.event.vo.SearchWordVO; import com.zzsn.event.util.EsOpUtil;
import com.zzsn.event.vo.SubjectKeywordsMap; import com.zzsn.event.vo.*;
import com.zzsn.event.vo.SubjectPage; import com.zzsn.event.vo.es.SpecialInformation;
import com.zzsn.event.vo.SubjectSimpleVO;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* 简化专题创建流程 * 简化专题创建流程
...@@ -43,8 +44,22 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -43,8 +44,22 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
private ISubjectKeywordsMapService subjectKeywordsMapService; private ISubjectKeywordsMapService subjectKeywordsMapService;
@Autowired @Autowired
private ClbModelArrangeSubjectMapService clbModelArrangeSubjectMapService; private ClbModelArrangeSubjectMapService clbModelArrangeSubjectMapService;
@Autowired
private ISubjectTypeMapService subjectTypeMapService;
@Autowired
private IProjectSubjectMapService projectSubjectMapService;
@Autowired
private ISubjectSearchEnginesMapService subjectSearchEnginesMapService;
@Autowired
private ISubjectInfoSourceMapService subjectInfoSourceMapService;
@Autowired
private ISubjectModelMapService subjectModelMapService;
@Autowired @Autowired
private EsService esService;
@Autowired
private EsOpUtil esOpUtil;
@Autowired
private CodeGenerateUtil codeGenerateUtil; private CodeGenerateUtil codeGenerateUtil;
private final static String KEYWORDS_TYPE_ID = "1476498704680194050"; private final static String KEYWORDS_TYPE_ID = "1476498704680194050";
...@@ -124,6 +139,110 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -124,6 +139,110 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
return wordList; return wordList;
} }
@Override
public SubjectDetailVO queryInfo(String subjectId) {
SubjectDetailVO subjectDetailVO = subjectService.queryInfo(subjectId);
if (subjectDetailVO != null) {
List<SearchWordVO> list = this.subjectBindWordInfo(subjectId);
subjectDetailVO.setKeywords(list);
}
return subjectDetailVO;
}
@Override
public void removeSubject(String subjectId) {
subjectService.removeById(subjectId);
CompletableFuture.runAsync(()->{
//删除与类别的映射
subjectTypeMapService.deleteBySubjectId(subjectId);
//删除与信息源的关联关系
subjectInfoSourceMapService.delete(subjectId);
//获取绑定的关键词
LambdaQueryWrapper<SubjectKeywordsMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectKeywordsMap::getSubjectId, subjectId);
List<SubjectKeywordsMap> list = subjectKeywordsMapService.list(queryWrapper);
if (CollectionUtils.isNotEmpty(list)) {
List<String> keywordIds = list.stream().map(SubjectKeywordsMap::getKeywordsId).collect(Collectors.toList());
//删除关键词
keywordWordsService.removeByIds(keywordIds);
//删除与关键词组的关联关系
subjectKeywordsMapService.delete(subjectId);
//删除关键词组关联关系
subjectKeywordsGroupRelationService.remove(Wrappers.<SubjectKeywordsGroupRelation>lambdaQuery().eq(SubjectKeywordsGroupRelation::getSubjectId, subjectId));
}
//删除专题-项目的绑定关系
projectSubjectMapService.deleteBySubjectId(subjectId);
//删除事件-模型关系
subjectModelMapService.remove(Wrappers.<SubjectModelMap>lambdaQuery().eq(SubjectModelMap::getSubjectId, subjectId));
//删除事件-搜索引擎关系
subjectSearchEnginesMapService.remove(Wrappers.<SubjectSearchEnginesMap>lambdaQuery().eq(SubjectSearchEnginesMap::getSubjectId, subjectId));
//删除专题/事件-tpu流程关系
clbModelArrangeSubjectMapService.remove(Wrappers.<ClbModelArrangeSubjectMap>lambdaQuery().eq(ClbModelArrangeSubjectMap::getSubjectId, subjectId));
//向python发送消息结束
subjectService.send(subjectId, "-1");
});
}
@Override
public void selected(InfoDataSearchCondition searchCondition) {
String[] fetchFields = new String[]{"id", "checkStatus"};
searchCondition.setFetchFields(fetchFields);
Map<String,List<SpecialInformation>> updateMap = new HashMap<>();
List<SpecialInformation> informationList = esService.informationList(searchCondition);
for (SpecialInformation information : informationList) {
String index = information.getDbIndex();
information.setCheckStatus(1);
if (updateMap.containsKey(index)) {
updateMap.get(index).add(information);
} else {
List<SpecialInformation> list = new ArrayList<>();
list.add(information);
updateMap.put(index, list);
}
}
updateMap.forEach((k,v)->esOpUtil.docUpdateBulk(k,v));
}
@Override
public void removeSelected(InfoDataSearchCondition searchCondition) {
String[] fetchFields = new String[]{"id", "checkStatus"};
searchCondition.setFetchFields(fetchFields);
Map<String,List<SpecialInformation>> updateMap = new HashMap<>();
List<SpecialInformation> informationList = esService.informationList(searchCondition);
for (SpecialInformation information : informationList) {
String index = information.getDbIndex();
information.setCheckStatus(0);
if (updateMap.containsKey(index)) {
updateMap.get(index).add(information);
} else {
List<SpecialInformation> list = new ArrayList<>();
list.add(information);
updateMap.put(index, list);
}
}
updateMap.forEach((k,v)->esOpUtil.docUpdateBulk(k,v));
}
@Override
public void batchRemove(InfoDataSearchCondition searchCondition) {
String[] fetchFields = new String[]{"id", "deleteFlag"};
searchCondition.setFetchFields(fetchFields);
Map<String,List<SpecialInformation>> updateMap = new HashMap<>();
List<SpecialInformation> informationList = esService.informationList(searchCondition);
for (SpecialInformation information : informationList) {
String index = information.getDbIndex();
information.setDeleteFlag(1);
if (updateMap.containsKey(index)) {
updateMap.get(index).add(information);
} else {
List<SpecialInformation> list = new ArrayList<>();
list.add(information);
updateMap.put(index, list);
}
}
updateMap.forEach((k,v)->esOpUtil.docUpdateBulk(k,v));
}
//目标集合按照另一个集合的顺序排序 //目标集合按照另一个集合的顺序排序
private void sortByAnotherList(List<SearchWordVO> list, List<String> anotherList) { private void sortByAnotherList(List<SearchWordVO> list, List<String> anotherList) {
list.sort((o1, o2) -> { list.sort((o1, o2) -> {
......
...@@ -7,6 +7,8 @@ import com.alibaba.fastjson2.JSON; ...@@ -7,6 +7,8 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter; import com.alibaba.fastjson2.JSONWriter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.vo.es.Label;
import com.zzsn.event.vo.es.SpecialInformation;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
...@@ -496,6 +498,35 @@ public class EsOpUtil<T> { ...@@ -496,6 +498,35 @@ public class EsOpUtil<T> {
return false; return false;
} }
public void docUpdateBulk(String index, List<SpecialInformation> dataList){
BulkRequest bulkRequest = new BulkRequest();
for (SpecialInformation information : dataList) {
UpdateRequest request = new UpdateRequest(index, information.getId());
request.doc(JSON.toJSONString(information), XContentType.JSON);
bulkRequest.add(request);
}
// 执行更新请求
client.bulkAsync(bulkRequest, RequestOptions.DEFAULT, new ActionListener<BulkResponse>() {
@Override
public void onResponse(BulkResponse bulkItemResponses) {
BulkItemResponse[] bulkItems = bulkItemResponses.getItems();
for (BulkItemResponse response : bulkItems) {
if (response.isFailed()) {//查看所有请求失败结果
log.info("批量更新[{}]过程中,id为[{}]的更新失败,失败原因[{}]", response.getIndex(), response.getId(), response.getFailureMessage());
} else {//请求成功的
log.info("批量更新[{}]过程中,id为[{}]的更新成功,状态[{}],version[{}]", response.getIndex(), response.getId(), response.status(), response.getVersion());
}
}
}
@Override
public void onFailure(Exception e) {
log.warn("批量[{}]更新失败,失败原因[{}]", index, e.getMessage());
}
});
}
/** /**
* 批量删除 * 批量删除
* *
...@@ -745,6 +776,8 @@ public class EsOpUtil<T> { ...@@ -745,6 +776,8 @@ public class EsOpUtil<T> {
for (BulkItemResponse response : bulkItemResponses) { for (BulkItemResponse response : bulkItemResponses) {
if (response.isFailed()) { if (response.isFailed()) {
log.info("批量更新字段[{}]过程中,id为[{}]的更新失败,失败原因[{}]", response.getIndex(), response.getId(), response.getFailureMessage()); log.info("批量更新字段[{}]过程中,id为[{}]的更新失败,失败原因[{}]", response.getIndex(), response.getId(), response.getFailureMessage());
} else {
log.info("批量保存[{}]过程中,id为[{}]的保存成功,状态[{}],version[{}]", response.getIndex(), response.getId(), response.status(), response.getVersion());
} }
} }
} catch (IOException e) { } catch (IOException e) {
......
...@@ -36,6 +36,8 @@ public class SubjectDetailVO { ...@@ -36,6 +36,8 @@ public class SubjectDetailVO {
/**划分专题库*/ /**划分专题库*/
private String library; private String library;
/**专题分类id*/
private String subjectTypeId;
/**专题分类名称*/ /**专题分类名称*/
private String subjectTypeName; private String subjectTypeName;
/**专题下的样例文章*/ /**专题下的样例文章*/
......
...@@ -123,7 +123,7 @@ public class SpecialInformation { ...@@ -123,7 +123,7 @@ public class SpecialInformation {
*/ */
private Integer ismain; private Integer ismain;
//数据所在的索引名称 //数据所在的索引名称
private String index; private Long index;
//关键词 //关键词
private List<String> keyWordsList; private List<String> keyWordsList;
//命中词 //命中词
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论