提交 0bbacb7c 作者: chenshiqiang

compute

上级 3bf36b9c
...@@ -15,6 +15,11 @@ public class Constants { ...@@ -15,6 +15,11 @@ public class Constants {
* 关键词数据入缓存 key前缀 * 关键词数据入缓存 key前缀
*/ */
public static final String KEY_WORDS_TO_REDIS_PREFIX = "KEY_WORDS_TO_REDIS::"; public static final String KEY_WORDS_TO_REDIS_PREFIX = "KEY_WORDS_TO_REDIS::";
public static final String MAX_TOTAL_HOT_SCORE = "MAX_TOTAL_HOT_SCORE";
public static final String MAX_MEDIA_HOT_SCORE = "MAX_MEDIA_HOT_SCORE";
public static final String MAX_WECHAT_HOT_SCORE = "MAX_WECHAT_HOT_SCORE";
public static final String MAX_OTHER_HOT_SCORE = "MAX_OTHER_HOT_SCORE";
public static String[] FETCH_FIELDS_STATISTIC = {"id", "subjectId","title","origin", "publishDate", "sourceAddress", "masterEntryId","infoSourceType"}; public static String[] FETCH_FIELDS_STATISTIC = {"id", "subjectId","title","origin", "publishDate", "sourceAddress", "masterEntryId","infoSourceType"};
public static String[] FETCH_FIELDS_DATA = {"id", "subjectId", "title", "content", "publishDate", "origin", "sourceAddress", "masterEntryId","infoSourceType"}; public static String[] FETCH_FIELDS_DATA = {"id", "subjectId", "title", "content", "publishDate", "origin", "sourceAddress", "masterEntryId","infoSourceType"};
//es 专题库索引 //es 专题库索引
......
...@@ -20,9 +20,13 @@ import org.apache.commons.lang3.ObjectUtils; ...@@ -20,9 +20,13 @@ import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; 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.HttpServletRequest;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
/** /**
* 事件 * 事件
...@@ -72,7 +76,7 @@ public class EventController { ...@@ -72,7 +76,7 @@ public class EventController {
/** /**
* 添加 * 添加
* *
* @param event * @param eventParam
* @return * @return
*/ */
@ApiOperation(value="事件-添加", notes="事件-添加") @ApiOperation(value="事件-添加", notes="事件-添加")
...@@ -125,7 +129,9 @@ public class EventController { ...@@ -125,7 +129,9 @@ public class EventController {
@ApiOperation(value="事件-通过id删除", notes="事件-通过id删除") @ApiOperation(value="事件-通过id删除", notes="事件-通过id删除")
@DeleteMapping(value = "/delete") @DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) { public Result<?> delete(@RequestParam(name="id",required=true) String id) {
eventService.removeById(id); Event event = eventService.getById(id);
iXxlJobInfoService.deleteByInfosourceCode(event.getEventCode());
eventService.deleteMain(id);
return Result.OK("删除成功!"); return Result.OK("删除成功!");
} }
...@@ -163,7 +169,7 @@ public class EventController { ...@@ -163,7 +169,7 @@ public class EventController {
public Object infoSourceBind(@RequestBody SubjectPage subjectPage) { public Object infoSourceBind(@RequestBody SubjectPage subjectPage) {
try { try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectPage);; JSONObject params = ObjectUtil.objectToJSONObject(subjectPage);;
String url = SERVICE_PROJECT_URL + "enterpriseData/getYearReportList"; String url = SERVICE_PROJECT_URL + "event/infoSource/infoSourceBind";
return RestUtil.post(url, null, params); return RestUtil.post(url, null, params);
} catch (Exception e) { } catch (Exception e) {
return null; return null;
...@@ -273,4 +279,19 @@ public class EventController { ...@@ -273,4 +279,19 @@ public class EventController {
List<SubjectAnalysis> cacheList = analysisService.eventContext(subjectId, fakeNum); List<SubjectAnalysis> cacheList = analysisService.eventContext(subjectId, fakeNum);
return Result.OK(cacheList); return Result.OK(cacheList);
} }
/**
* 添上传
*
* @return
*/
@PostMapping(value = "/upload")
@ResponseBody
public Result<?> uploadKnowledge(HttpServletRequest request) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
String orgName = file.getOriginalFilename();// 获取文件名
String url=eventService.upload(file);
return Result.OK(url);
}
} }
...@@ -119,4 +119,8 @@ public class Event { ...@@ -119,4 +119,8 @@ public class Event {
/**事件专题时间间隔分析规则(天)*/ /**事件专题时间间隔分析规则(天)*/
@ApiModelProperty(value = "事件专题时间间隔分析规则(天)") @ApiModelProperty(value = "事件专题时间间隔分析规则(天)")
private Integer timeAnaRule; private Integer timeAnaRule;
private Integer totalHot;
private Integer mediaHot;
private Integer wechatHot;
private Integer otherHot;
} }
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 专题与信息源关联表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
@Data
@TableName("subject_info_source_map")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="subject_info_source_map对象", description="专题与信息源关联表")
public class SubjectInfoSourceMap implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**专题id*/
@Excel(name = "专题id", width = 15)
@ApiModelProperty(value = "专题id")
private String subjectId;
/**信息源id或信息源组id*/
@Excel(name = "信息源id或信息源组id", width = 15)
@ApiModelProperty(value = "信息源id或信息源组id")
private String sourceId;
/**种类(1:信息源id 2:信息源组id)*/
@Excel(name = "种类(1:信息源id 2:信息源组id)", width = 15)
@ApiModelProperty(value = "种类(1:信息源id 2:信息源组id)")
private Integer type;
@ApiModelProperty(value = "信息源组权重")
private String weight;
}
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.Event; import com.zzsn.event.entity.Event;
import com.zzsn.event.vo.SubjectKafkaVo; import com.zzsn.event.vo.SubjectKafkaVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -19,9 +20,9 @@ public interface EventMapper extends BaseMapper<Event> { ...@@ -19,9 +20,9 @@ public interface EventMapper extends BaseMapper<Event> {
List<SubjectKafkaVo> eventSubjectList(int i); List<SubjectKafkaVo> eventSubjectList(int i);
List<Event> pageList(Event event, Integer offset, Integer pageSize); List<Event> pageList(@Param("event")Event event, Integer offset, Integer pageSize);
Integer totalCount(Event event); Integer totalCount(@Param("event") Event event);
List<SubjectKafkaVo> prosessList(Date disableDate); List<SubjectKafkaVo> prosessList(Date disableDate);
} }
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.SubjectInfoSourceMap;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description: 专题与信息源关联表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
@Mapper
public interface SubjectInfoSourceMapMapper extends BaseMapper<SubjectInfoSourceMap> {
void deleteBySubjectId (@Param("subjectId") String subjectId);
void deleteBySubjectIds (@Param("subjectIds") List<String> subjectIds);
void deleteInfoSourceIds(@Param("subjectId") String subjectId, @Param("infoSourceIds") List<String> infoSourceIds, @Param("type")Integer type);
List<String> selectInfoSourceBySubject(@Param("subjectIds") List<String> subjectIds, @Param("type")Integer type);
List<String> selectInfoSourceBySubjectAndTypes(@Param("subjectIds") List<String> subjectIds, @Param("types") List<Integer> types);
void deleteInfoSourceMapByInfoSourceIds(@Param("infoSourceIds") List<String> infoSourceIds);
void infoSourceWeight(String subjectId, String infoSourceGroupId, String weight);
List<String> selectSubjectIdsByGroupId(@Param("infoSourceGroupId") String infoSourceGroupId);
}
...@@ -22,4 +22,6 @@ public interface SubjectKeywordsMapMapper extends BaseMapper<SubjectKeywordsMap> ...@@ -22,4 +22,6 @@ public interface SubjectKeywordsMapMapper extends BaseMapper<SubjectKeywordsMap>
int selectCountByKeyWordsId(@Param("keyWordsId") String keyWordsId); int selectCountByKeyWordsId(@Param("keyWordsId") String keyWordsId);
KeyWordsDTO selectMaxByKeyWordsId(@Param("keyWordsId") String keyWordsId); KeyWordsDTO selectMaxByKeyWordsId(@Param("keyWordsId") String keyWordsId);
void deleteBySubjectId (@Param("subjectId") String subjectId);
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
and t1.event_name like CONCAT('%',#{event.eventName},'%') and t1.event_name like CONCAT('%',#{event.eventName},'%')
</if> </if>
<if test="event.eventType!=null and event.eventType != ''"> <if test="event.eventType!=null and event.eventType != ''">
and dt1.event_type = #{event.eventType} and t1.event_type = #{event.eventType}
</if> </if>
limit #{offset}, #{pageSize} limit #{offset}, #{pageSize}
</select> </select>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
and t1.event_name like CONCAT('%',#{event.eventName},'%') and t1.event_name like CONCAT('%',#{event.eventName},'%')
</if> </if>
<if test="event.eventType!=null and event.eventType != ''"> <if test="event.eventType!=null and event.eventType != ''">
and dt1.event_type = #{event.eventType} and t1.event_type = #{event.eventType}
</if> </if>
</select> </select>
......
<?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.event.mapper.SubjectInfoSourceMapMapper">
<select id="selectInfoSourceBySubject" resultType="String">
select distinct e.source_id from subject_info_source_map d
inner join info_source_group_map e on d.source_id = e.group_id
where 1 = 1
<if test="subjectIds!=null and subjectIds.size > 0">
and d.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="type!=null">
and d.type = #{type}
</if>
</select>
<select id="selectInfoSourceBySubjectAndTypes" resultType="java.lang.String">
select distinct e.source_id from subject_info_source_map d
inner join info_source_group_map e on d.source_id = e.group_id
where 1 = 1
<if test="subjectIds!=null and subjectIds.size > 0">
and d.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="types!=null and types.size > 0">
and d.type in
<foreach collection="types" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="selectSubjectIdsByGroupId" resultType="String">
select distinct subject_id from subject_info_source_map
where source_id = #{infoSourceGroupId} and type = 2
</select>
<delete id="deleteBySubjectId" >
delete from subject_info_source_map
WHERE subject_id = #{subjectId}
</delete>
<delete id="deleteBySubjectIds" >
delete from subject_info_source_map
WHERE subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
<delete id="deleteInfoSourceIds" >
delete from subject_info_source_map
WHERE type = #{type}
<if test="infoSourceIds!=null and infoSourceIds.size > 0">
and source_id in
<foreach collection="infoSourceIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="subjectId!=null and subjectId != ''">
and subject_id = #{subjectId}
</if>
</delete>
<delete id="deleteInfoSourceMapByInfoSourceIds">
delete from subject_info_source_map
where source_id in
<foreach collection="infoSourceIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
<update id="infoSourceWeight">
update subject_info_source_map set weight = #{weight}
where type = 1 and subject_id = #{subjectId} and source_id in (select source_id from info_source_group_map where group_id = #{infoSourceGroupId})
</update>
</mapper>
...@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.vo.AddEventParam; import com.zzsn.event.vo.AddEventParam;
import com.zzsn.event.vo.KeyWordsPage; import com.zzsn.event.vo.KeyWordsPage;
import com.zzsn.event.vo.SubjectKafkaVo; import com.zzsn.event.vo.SubjectKafkaVo;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Description: 事件 * @Description: 事件
...@@ -37,4 +39,8 @@ public interface IEventService extends IService<Event> { ...@@ -37,4 +39,8 @@ public interface IEventService extends IService<Event> {
* 获取专题绑定的关键词组列表 * 获取专题绑定的关键词组列表
*/ */
List<KeyWordsPage> bindKeyWordsList(String id); List<KeyWordsPage> bindKeyWordsList(String id);
void deleteMain(String id);
String upload(MultipartFile file);
} }
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.SubjectInfoSourceMap;
import java.util.List;
/**
* @Description: 专题与信息源关联表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
public interface ISubjectInfoSourceMapService extends IService<SubjectInfoSourceMap> {
/**
* 根据专题id删除关联数据
*/
void delete(String subjectId);
/**
* 根据专题ids批量删除
*/
void deleteBySubjectIds(List<String> subjectIds);
/**
* 根据批量删除
*/
void deleteInfoSourceIds(String subjectId, List<String> infoSourceIds, Integer type);
/**
* 根据专题查看绑定的信息源id
*/
List<String> selectInfoSourceBySubject(List<String> subjectIds, Integer... type);
/**
* 根据信息源ids删除相应的映射关系
* @param infoSourceIds
*/
void deleteInfoSourceMapByInfoSourceIds(List<String> infoSourceIds);
/**
* 更新数据
* @param subjectInfoSourceMap
*/
void updateMain(SubjectInfoSourceMap subjectInfoSourceMap);
/**
* 根据信息源组id,查询出关联的专题id
* @param infoSourceGroupId
* @return
*/
List<String> querySubjectIdsByGroupId(String infoSourceGroupId);
}
...@@ -13,6 +13,10 @@ import java.util.List; ...@@ -13,6 +13,10 @@ import java.util.List;
* @Version: V1.0 * @Version: V1.0
*/ */
public interface ISubjectKeywordsMapService extends IService<SubjectKeywordsMap> { public interface ISubjectKeywordsMapService extends IService<SubjectKeywordsMap> {
/**
* 根据专题id删除关联数据
*/
void delete(String subjectId);
/** /**
* 查询这个词组绑定的专题的最小时间 * 查询这个词组绑定的专题的最小时间
...@@ -35,4 +39,5 @@ public interface ISubjectKeywordsMapService extends IService<SubjectKeywordsMap> ...@@ -35,4 +39,5 @@ public interface ISubjectKeywordsMapService extends IService<SubjectKeywordsMap>
*/ */
KeyWordsDTO selectMaxByKeyWordsId(String keyWordsId); KeyWordsDTO selectMaxByKeyWordsId(String keyWordsId);
} }
...@@ -2,24 +2,20 @@ package com.zzsn.event.service.impl; ...@@ -2,24 +2,20 @@ package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.constant.Constants; import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.Event; import com.zzsn.event.entity.Event;
import com.zzsn.event.enums.CodePrefixEnum; import com.zzsn.event.enums.CodePrefixEnum;
import com.zzsn.event.mapper.EventMapper; import com.zzsn.event.mapper.EventMapper;
import com.zzsn.event.producer.ProduceInfo; import com.zzsn.event.producer.ProduceInfo;
import com.zzsn.event.service.IEventService; import com.zzsn.event.service.*;
import com.zzsn.event.service.IKeyWordsService; import com.zzsn.event.util.*;
import com.zzsn.event.service.ISubjectKeywordsMapService;
import com.zzsn.event.service.ISubjectSearchEnginesMapService;
import com.zzsn.event.util.CodeGenerateUtil;
import com.zzsn.event.util.CronUtil;
import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.vo.AddEventParam; import com.zzsn.event.vo.AddEventParam;
import com.zzsn.event.vo.KeyWordsDTO; import com.zzsn.event.vo.KeyWordsDTO;
import com.zzsn.event.vo.KeyWordsPage; import com.zzsn.event.vo.KeyWordsPage;
import com.zzsn.event.vo.SubjectKafkaVo; import com.zzsn.event.vo.SubjectKafkaVo;
import lombok.extern.slf4j.Slf4j;
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.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -27,8 +23,16 @@ import org.springframework.context.annotation.Primary; ...@@ -27,8 +23,16 @@ import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.util.*; import java.util.*;
/** /**
...@@ -38,6 +42,7 @@ import java.util.*; ...@@ -38,6 +42,7 @@ import java.util.*;
* @Version: V1.0 * @Version: V1.0
*/ */
@Service @Service
@Slf4j
public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements IEventService { public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements IEventService {
@Value("${hotWords.extractUrl}") @Value("${hotWords.extractUrl}")
private String extractHotWordsUrl; private String extractHotWordsUrl;
...@@ -47,25 +52,84 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -47,25 +52,84 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
private IKeyWordsService iKeyWordsService; private IKeyWordsService iKeyWordsService;
@Autowired @Autowired
private ISubjectSearchEnginesMapService iSubjectSearchEnginesMapService; private ISubjectSearchEnginesMapService iSubjectSearchEnginesMapService;
@Autowired
private ISubjectInfoSourceMapService iSubjectInfoSourceMapService;
@Autowired @Autowired
private ISubjectKeywordsMapService iSubjectKeywordsMapService; private ISubjectKeywordsMapService iSubjectKeywordsMapService;
@Autowired @Autowired
private ProduceInfo produceInfo; private ProduceInfo produceInfo;
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Value("${files.storage}")
String filesStorage;
@Value("${scoreRule.weekScore}")
Integer weekScore;
@Value("${scoreRule.monthScore}")
Integer monthScore;
@Value("${scoreRule.yearScore}")
Integer yearScore;
@Value("${scoreRule.beforeYearScore}")
Integer beforeYearScore;
@Override @Override
public void compute() { public void compute() {
//get the events need to compute //get the events need to compute
List<Event> list = this.list(new LambdaQueryWrapper<Event>().eq(Event::getStatus, 1)); List<Event> list = this.list(new LambdaQueryWrapper<Event>().eq(Event::getStatus, 1));
for (Event event : list) { for (Event event : list) {
// latest week data //total
Integer totalScore = 0;
Integer totalHot = getHot(Constants.MAX_TOTAL_HOT_SCORE, totalScore);
//media
Integer mediaScore = 0;
Integer mediaHot = getHot(Constants.MAX_MEDIA_HOT_SCORE, mediaScore);
//wechat
Integer wechatScore = 0;
Integer wechatHot = getHot(Constants.MAX_WECHAT_HOT_SCORE, wechatScore);
//others
Integer otherScore = 0;
Integer otherHot = getHot(Constants.MAX_OTHER_HOT_SCORE, otherScore);
event.setTotalHot(totalHot);
event.setMediaHot(mediaHot);
event.setWechatHot(wechatHot);
event.setOtherHot(otherHot);
this.updateById(event);
// latest month data
// latest year data
// data before a year
} }
}
private Integer getHot(String key, Integer Score) {
Object total = redisUtil.get(Constants.MAX_TOTAL_HOT_SCORE);
if (null != total) {
Integer maxTotalScore = (Integer) total;
if (Score > maxTotalScore) {
redisUtil.set(Constants.MAX_TOTAL_HOT_SCORE, Score);
return 100;
} else {
return Score / maxTotalScore * 100;
}
} else {
redisUtil.set(Constants.MAX_TOTAL_HOT_SCORE, Score);
return 100;
}
}
/**
* 计算热度
*
* @param weekTimes 周内次数
* @param monthTimes 月内次数
* @param yearTimes 年内次数
* @param beforeYearTimes 年外次数
*/
private Integer computeScore(Integer weekTimes, Integer monthTimes, Integer yearTimes, Integer beforeYearTimes) {
// latest week data
// latest month data
// latest year data
// data before a year
return weekTimes * weekScore + monthTimes * monthScore + yearTimes * yearScore + beforeYearTimes * beforeYearScore;
} }
@Override @Override
...@@ -89,7 +153,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -89,7 +153,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
Integer count = baseMapper.totalCount(event); Integer count = baseMapper.totalCount(event);
IPage<Event> pageData = new Page<>(pageNo, pageSize, count); IPage<Event> pageData = new Page<>(pageNo, pageSize, count);
pageData.setRecords(pageList); pageData.setRecords(pageList);
return null; return pageData;
} }
@Override @Override
...@@ -144,10 +208,64 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -144,10 +208,64 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
updateRedisKeyWordsDate(addEventParam.getId(), keyWordIds); updateRedisKeyWordsDate(addEventParam.getId(), keyWordIds);
} }
} }
@Override @Override
public List<KeyWordsPage> bindKeyWordsList(String subjectId) { public List<KeyWordsPage> bindKeyWordsList(String subjectId) {
return iKeyWordsService.bindKeyWordsList(subjectId); return iKeyWordsService.bindKeyWordsList(subjectId);
} }
@Override
public void deleteMain(String id) {
//删除与信息源的关联关系
iSubjectInfoSourceMapService.delete(id);
//删除与关键词组的关联关系
iSubjectKeywordsMapService.delete(id);
baseMapper.deleteById(id);
}
@Override
public String upload(MultipartFile file) {
try {
String fileName = file.getOriginalFilename(); // 获取文件名称
long fileSize = file.getSize(); // get file size
log.info("文件上传:" + fileName);
String filePath = getFilePath() + fileName;
//byte[] bytes = file.getBytes(); // get file in bytes
//Files.write(Paths.get(filePath), bytes);
String path = ClassUtils.getDefaultClassLoader().getResource("").getPath();
file.transferTo(new File(filesStorage + filePath));
log.info("文件上传成功:" + fileName + "---" + filePath);
return filePath;
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
// if the operation of file uploading is unsuccessful, an error occurs
log.info("上传文件时出现问题!");
return null;
}
//生成文件夹路径
private String getFilePath() {
LocalDate currentDate = LocalDate.now();
String current = currentDate.toString().replace("-", "");
String filePath = current + "/";
//判断文件夹是否存在,不存在创建
Path directory = Paths.get(filesStorage + filePath);
if (!Files.exists(directory)) {
try {
Files.createDirectories(directory);
log.info("文件夹创建成功:" + filePath);
} catch (IOException e) {
log.error("文件夹创建失败:" + filePath);
e.printStackTrace();
}
}
return filePath;
}
//更新专题绑定的关键词组的缓存信息 //更新专题绑定的关键词组的缓存信息
private void updateRedisKeyWordsDate(String subjectId, List<String> keyWordsIds) { private void updateRedisKeyWordsDate(String subjectId, List<String> keyWordsIds) {
for (String keyWordsId : keyWordsIds) { for (String keyWordsId : keyWordsIds) {
......
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SubjectInfoSourceMap;
import com.zzsn.event.mapper.SubjectInfoSourceMapMapper;
import com.zzsn.event.service.ISubjectInfoSourceMapService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @Description: 专题与信息源关联表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
@Service
public class SubjectInfoSourceMapServiceImpl extends ServiceImpl<SubjectInfoSourceMapMapper, SubjectInfoSourceMap> implements ISubjectInfoSourceMapService {
@Override
@Transactional
public void delete(String subjectId){
baseMapper.deleteBySubjectId(subjectId);
}
@Override
@Transactional
public void deleteBySubjectIds(List<String> subjectIds){
baseMapper.deleteBySubjectIds(subjectIds);
}
@Override
public void deleteInfoSourceIds(String subjectId, List<String> infoSourceIds, Integer type){
baseMapper.deleteInfoSourceIds(subjectId, infoSourceIds, type);
}
@Override
public List<String> selectInfoSourceBySubject(List<String> subjectIds, Integer... type ){
List<String> list = new ArrayList<>();
if(subjectIds != null && subjectIds.size() > 0) {
list = baseMapper.selectInfoSourceBySubjectAndTypes(subjectIds, Arrays.asList(type));
}
return list;
}
@Override
public void deleteInfoSourceMapByInfoSourceIds(List<String> infoSourceIds){
baseMapper.deleteInfoSourceMapByInfoSourceIds(infoSourceIds);
}
@Override
public void updateMain(SubjectInfoSourceMap subjectInfoSourceMap){
//更新信息源组信息权重
baseMapper.updateById(subjectInfoSourceMap);
//更新绑定的信息源权重(根据绑定的信息源组实现)
baseMapper.infoSourceWeight(subjectInfoSourceMap.getSubjectId(), subjectInfoSourceMap.getSourceId(), subjectInfoSourceMap.getWeight());
}
@Override
public List<String> querySubjectIdsByGroupId(String infoSourceGroupId){
return baseMapper.selectSubjectIdsByGroupId(infoSourceGroupId);
}
}
...@@ -7,6 +7,7 @@ import com.zzsn.event.service.ISubjectKeywordsMapService; ...@@ -7,6 +7,7 @@ import com.zzsn.event.service.ISubjectKeywordsMapService;
import com.zzsn.event.vo.KeyWordsDTO; import com.zzsn.event.vo.KeyWordsDTO;
import com.zzsn.event.vo.SubjectKeywordsMap; import com.zzsn.event.vo.SubjectKeywordsMap;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/** /**
* @Description: 专题关键词关联表 * @Description: 专题关键词关联表
...@@ -17,7 +18,11 @@ import org.springframework.stereotype.Service; ...@@ -17,7 +18,11 @@ import org.springframework.stereotype.Service;
@Service @Service
public class SubjectKeywordsMapServiceImpl extends ServiceImpl<SubjectKeywordsMapMapper, SubjectKeywordsMap> implements ISubjectKeywordsMapService { public class SubjectKeywordsMapServiceImpl extends ServiceImpl<SubjectKeywordsMapMapper, SubjectKeywordsMap> implements ISubjectKeywordsMapService {
@Override
@Transactional
public void delete(String subjectId){
baseMapper.deleteBySubjectId(subjectId);
}
@Override @Override
public KeyWordsDTO selectMinByKeyWordsId(String keyWordsId){ public KeyWordsDTO selectMinByKeyWordsId(String keyWordsId){
return baseMapper.selectMinByKeyWordsId(keyWordsId); return baseMapper.selectMinByKeyWordsId(keyWordsId);
......
...@@ -191,8 +191,8 @@ public class AnalysisTask { ...@@ -191,8 +191,8 @@ public class AnalysisTask {
* 定时生成传播路径 * 定时生成传播路径
* 每天凌晨0点10分执行一次 * 每天凌晨0点10分执行一次
*/ */
// @Scheduled(cron = "0 0 0 * * ?") @Scheduled(cron = "0 0 0 * * ?")
@Scheduled(cron = "0 * * * * ?") // @Scheduled(cron = "0 * * * * ?")
public void propagationPath() { public void propagationPath() {
Date today = new Date(); Date today = new Date();
Date deadlineDate = DateUtil.addDate(today, -1); Date deadlineDate = DateUtil.addDate(today, -1);
......
...@@ -6,6 +6,8 @@ spring: ...@@ -6,6 +6,8 @@ spring:
multipart: multipart:
max-request-size: 1024MB max-request-size: 1024MB
max-file-size: 100MB max-file-size: 100MB
resources:
static-locations: file:D:/event/
datasource: datasource:
druid: druid:
stat-view-servlet: stat-view-servlet:
...@@ -113,4 +115,6 @@ serviceProject: ...@@ -113,4 +115,6 @@ serviceProject:
url: https://clb.ciglobal.cn/clb-api/ url: https://clb.ciglobal.cn/clb-api/
#热词抽取地址 #热词抽取地址
hotWords: hotWords:
extractUrl: http://114.116.99.6:8055/task/dispose/extractKeyword extractUrl: http://114.116.99.6:8055/task/dispose/extractKeyword
\ No newline at end of file files:
storage: D:/event/
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论