提交 14f24f28 作者: 925993793@qq.com

事件服务功能开发

上级 c5743224
......@@ -227,7 +227,7 @@
<repository>
<id>zzsn</id>
<name>zzsn Repository</name>
<url>http://114.115.159.144:8065/repository/maven-public</url>
<url>https://maven.ciglobal.cn/repository/maven-public</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
......
package com.zzsn.event;
import com.zzsn.event.config.TaskExecutor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class EventAnalysisApplication {
......@@ -12,9 +9,5 @@ public class EventAnalysisApplication {
public static void main(String[] args) {
SpringApplication.run(EventAnalysisApplication.class, args);
}
@Bean
public TaskExecutor schedulerRunner() {
return new TaskExecutor();
}
}
package com.zzsn.event.config;
import com.zzsn.event.service.IEventService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class TaskExecutor implements CommandLineRunner {
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
private final Integer PERIOD=10000;
@Autowired
private IEventService eventService;
@Override
public void run(String... args)throws Exception {
scheduledExecutorService.scheduleAtFixedRate(()->{
eventService.compute();
},5,PERIOD, TimeUnit.SECONDS);
log.info("简易版定时任务启动成功!{}{}执行一次",PERIOD,TimeUnit.HOURS);
}
}
package com.zzsn.event.config.scheduler;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
import org.springframework.scheduling.config.TaskManagementConfigUtils;
/**
*
* @author lkg
* @date 2023/7/15
*/
@Configuration
public class Scheduler {
@Conditional(SchedulerCondition.class)
@Bean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor(){
return new ScheduledAnnotationBeanPostProcessor();
}
}
package com.zzsn.event.config.scheduler;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
*
* @author lkg
* @date 2023/7/15
*/
public class SchedulerCondition implements Condition {
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata){
return Boolean.parseBoolean(context.getEnvironment().getProperty("scheduling.enable"));
}
}
package com.zzsn.event.constant;
import java.util.Arrays;
import java.util.List;
/**
* Description:
* Author: EDY
* Date: 2023/10/9
*/
public enum DirEnum {
QYYearReport("QYYearReport/","企业年报","1"),
QYQuarterReport("QYQuarterReport/","企业季报","2"),
QYMonthReport("QYMonthReport/","企业月报","3"),
QYResearchReport("QYResearchReport/","企业研报","4"),
HYResearchReport("HYResearchReport/","行业研报","5"),
SubjectAtt("SubjectAtt/","专题上的附件","6"),
PolicyDocuments("PolicyDocuments/","政策文件附件","7"),
QYNotice("QYNotice/","企业公告","8"),
GZNotice3("GZNotice-3/","股转公告 新三版","9"),
GPSH3("GPSH-3/","挂牌审核 新三版","10"),
ZLJGCS3("ZLJGCS-3/","自律监管措施 新三版","11"),
WXH3("WXH-3/","问询函 新三版","12"),
JLCF3("JLCF-3/","纪律处分 新三版","13"),
MXYL("MXYL/","模型语料","14"),
SubjectUp("SubjectUp/","专题上传","15"),
KLBImage("KLBImage/","克虏宝企业log图片","16"),
REPORT("report/","生成的报告","17"),
REPORT_TEMPLATE("report/template/","生成的报告模板","18"),
SCIENCE_FILE("report/reportScience/","智能写作_期刊/论文/图书/研报","19"),
;
public static List<DirEnum> getAll(){
DirEnum[] values = DirEnum.values();
return Arrays.asList(values);
}
public static DirEnum getByPath(String path) {
for (DirEnum enumValue : DirEnum.values()) {
if (enumValue.getPath().equals(path)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + path);
}
public static DirEnum getByDes(String des) {
for (DirEnum enumValue : DirEnum.values()) {
if (enumValue.getDes().equals(des)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + des);
}
public static DirEnum getByType(String type) {
for (DirEnum enumValue : DirEnum.values()) {
if (enumValue.getType().equals(type)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + type);
}
/**路径名称*/
private final String path;
/**路径描述*/
private final String des;
/**路径描述*/
private final String type;
public String getType() {
return type;
}
public String getPath() {
return path;
}
public String getDes() {
return des;
}
DirEnum(String path, String des , String type) {
this.path = path;
this.des = des;
this.type = type;
}
}
package com.zzsn.event.constant;
import java.time.Duration;
/**
* @author: zhangcx
* @date: 2019/8/7 17:23
*/
public class DocumentConstants {
public static final String HTTP_SCHEME = "http";
/**
* 支持的文档类型
*/
public static final String[] FILE_TYPE_SUPPORT_VIEW = {"doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "pdf"};
/**
* 不支持编辑的类型
*/
public static final String[] FILE_TYPE_UNSUPPORT_EDIT = {"pdf"};
/**
* 文档文件下载接口地址
*/
public static final String OFFICE_API_DOC_FILE = "%s/api/file/download%s";
/**
* 文档信息获取地址
*/
public static final String OFFICE_API_DOC = "%s/api/doc/%s";
/**
* 编辑回调地址
*/
public static final String OFFICE_API_CALLBACK = "%s/api/file/callback";
/**
* 预览地址
*/
public static final String OFFICE_VIEWER = "%s/viewer/%s";
/**
* 编辑地址
*/
public static final String OFFICE_EDITOR = "%s/editor/%s";
/**
* 文档redis缓存前缀 格式化
*/
public static final String DOCUMENT_REDIS_KEY_PREFIX_FORMAT = "onlyoffice:document:%s";
/**
* 缓存过期时间: 1天
*/
public static final Duration CACHE_DURATION = Duration.ofDays(1);
public static final String HASH_KEY = "lezhixing";
}
/**
*
* (c) Copyright Ascensio System SIA 2023
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.zzsn.event.constant;
public enum DocumentType {
word,
cell,
slide
}
package com.zzsn.event.constant;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
/**
* 错误码枚举
* 约定 code 为 0 表示操作成功,
* 1 或 2 等正数表示软件错误,
* -1, -2 等负数表示系统错误.
* @author: zhangcx
* @date: 2019/8/12 13:18
*/
public enum ErrorCodeEnum {
SUCCESS("0", "success"),
DOC_FILE_NOT_EXISTS("1001", "目标文档不存在"),
DOC_FILE_EMPTY("1002", "目标文档是目录或空文件"),
DOC_FILE_UNREADABLE("1003", "目标文档不可读"),
DOC_FILE_OVERSIZE("1004", "目标文档大小超过限制"),
DOC_FILE_TYPE_UNSUPPORTED("1005", "目标文档格式不正确"),
DOC_FILE_MD5_ERROR("1006", "目标文档md5校验失败"),
DOC_FILE_MIME_ERROR("1007", "目标文档MIME检查失败"),
DOC_FILE_NO_EXTENSION("1008", "文件路径不包含扩展名"),
DOC_FILE_EXTENSION_NOT_MATCH("1009", "文件路径和名称后缀不匹配"),
DOC_FILE_KEY_ERROR("1010", "目标文档key计算失败"),
DOC_CACHE_ERROR("1101", "文档信息缓存失败"),
DOC_CACHE_NOT_EXISTS("1102", "从缓存中获取文档信息失败"),
UNSUPPORTED_REQUEST_METHOD("1201", "不支持的请求类型"),
SYSTEM_UNKNOWN_ERROR("-1", "系统繁忙,请稍后再试...");
private String code;
private String msg;
ErrorCodeEnum(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public String getMsg() {
return msg;
}
@Override
public String toString() {
return "ErrorCodeEnum{" +
"code='" + code + '\'' +
", msg='" + msg + '\'' +
'}';
}
public boolean isSuccessful() {
return this.code == ErrorCodeEnum.SUCCESS.getCode();
}
public boolean isFailed() {
return !isSuccessful();
}
public static void main(String[] args) {
System.out.println("| 代码 | 描述 |");
System.out.println("| ---- | ---- |");
Arrays.stream(ErrorCodeEnum.values()).forEach((ce) -> {
System.out.println("| " + StringUtils.rightPad(ce.getCode(), 4) + " | " + ce.getMsg() + " |");
});
}
}
package com.zzsn.event.vo;
package com.zzsn.event.constant;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zzsn.event.constant.CommonConstant;
import lombok.Data;
import java.io.Serializable;
......@@ -42,68 +40,14 @@ public class Result<T> implements Serializable {
*/
private long timestamp = System.currentTimeMillis();
/**
* python接口返回
*/
private String handleMsg;
/**
* python接口返回状态
*/
private boolean isHandleSuccess;
/**
* python接口返回状态
*/
private String logs;
/**
* 返回数据对象 data
*/
private T resultData;
public Result() {
}
public Result<T> success(String message) {
this.message = message;
this.code = CommonConstant.SC_OK_200;
this.success = true;
return this;
}
@Deprecated
public static Result<Object> ok() {
Result<Object> r = new Result<Object>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage("成功");
return r;
}
@Deprecated
public static Result<Object> ok(String msg) {
Result<Object> r = new Result<Object>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage(msg);
return r;
}
public Result() {}
@Deprecated
public static Result<Object> ok(Object data) {
Result<Object> r = new Result<Object>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setResult(data);
return r;
}
public static<T> Result<T> OK() {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setCode(200);
r.setMessage("成功");
return r;
}
......@@ -111,46 +55,24 @@ public class Result<T> implements Serializable {
public static<T> Result<T> OK(T data) {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setCode(200);
r.setResult(data);
return r;
}
public static<T> Result<T> OK(String msg, T data) {
public static<T> Result<T> FAIL() {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage(msg);
r.setResult(data);
r.setCode(500);
r.setMessage("失败");
return r;
}
public static Result<Object> error(String msg) {
return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
}
public static Result<Object> error(int code, String msg) {
Result<Object> r = new Result<Object>();
public static<T> Result<T> FAIL(Integer code,String message) {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(code);
r.setMessage(msg);
r.setSuccess(false);
r.setMessage(message);
return r;
}
public Result<T> error500(String message) {
this.message = message;
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
this.success = false;
return this;
}
/**
* 无权限访问返回结果
*/
public static Result<Object> noauth(String msg) {
return error(CommonConstant.SC_JEECG_NO_AUTHZ, msg);
}
@JsonIgnore
private String onlTable;
}
\ No newline at end of file
package com.zzsn.event.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.entity.EventCategory;
import com.zzsn.event.service.IEventCategoryService;
import com.zzsn.event.vo.Result;
import com.zzsn.event.constant.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -28,42 +24,11 @@ import java.util.stream.Collectors;
@Slf4j
@Api(tags="事件分类")
@RestController
@RequestMapping("/event/eventCategory")
@RequestMapping("/eventCategory")
public class EventCategoryController {
@Autowired
private IEventCategoryService eventCategoryService;
/**
* 分页列表查询
*
* @param eventCategory
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@ApiOperation(value="事件分类-分页列表查询", notes="事件分类-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(EventCategory eventCategory,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<EventCategory> queryWrapper = new QueryWrapper<>();
Page<EventCategory> page = new Page<EventCategory>(pageNo, pageSize);
IPage<EventCategory> pageList = eventCategoryService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 通过父级id查询列表
*
* @return
*/
@ApiOperation(value="通过父级id查询列表", notes="通过父级id查询列表")
@GetMapping(value = "/getByParentId")
public Result<?> getByParentId(String pid) {
return Result.OK(eventCategoryService.list(new LambdaQueryWrapper<EventCategory>().eq(EventCategory::getPid,pid)));
}
/**
* 获取树状数据
*
......@@ -88,72 +53,4 @@ public class EventCategoryController {
}
}
/**
* 添加
*
* @param eventCategory
* @return
*/
@ApiOperation(value="事件分类-添加", notes="事件分类-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody EventCategory eventCategory) {
eventCategoryService.save(eventCategory);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param eventCategory
* @return
*/
@ApiOperation(value="事件分类-编辑", notes="事件分类-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody EventCategory eventCategory) {
eventCategoryService.updateById(eventCategory);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@ApiOperation(value="事件分类-通过id删除", notes="事件分类-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
eventCategoryService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@ApiOperation(value="事件分类-批量删除", notes="事件分类-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.eventCategoryService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@ApiOperation(value="事件分类-通过id查询", notes="事件分类-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
EventCategory eventCategory = eventCategoryService.getById(id);
return Result.OK(eventCategory);
}
}
package com.zzsn.event.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zzsn.event.constant.Result;
import com.zzsn.event.service.EsService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.vo.EventExcelVO;
import com.zzsn.event.vo.EventFrontVO;
import com.zzsn.event.vo.StatisticsKeyWordVo;
import com.zzsn.event.vo.SubjectDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* 事件
*
* @Author: jeecg-boot
* @Date: 2024-03-14
* @Version: V1.0
*/
@Slf4j
@Api(tags = "事件")
@RestController
@RequestMapping("/data")
public class EventDataController {
@Autowired
private IEventService eventService;
@Autowired
private EsService esService;
/**
* 分页列表-门户
*
* @param eventName 事件名称
* @param eventType 事件分类id
* @param labelField 搜索字段
* @param labelName 搜索词
* @param order 排序字段
* @param orderType 排序方式
* @param pageNo 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/8
*/
@ApiOperation(value = "事件-分页列表查询", notes = "事件-分页列表查询")
@GetMapping(value = "/pageList")
public Result<?> pageList(@RequestParam(name = "eventName", required = false) String eventName,
@RequestParam(name = "eventType", required = false) Integer eventType,
@RequestParam(name = "labelField", required = false) String labelField,
@RequestParam(name = "labelName", required = false) String labelName,
@RequestParam(name = "order", required = false) String order,
@RequestParam(name = "orderType", required = false) String orderType,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
IPage<EventFrontVO> pageList = eventService.frontPageList(eventName, eventType, labelField,labelName,order,orderType,pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 事件资讯分页列表
*
* @param subjectId 事件id
* @param searchWord 搜索词
* @param position 搜索位置(title-标题;content-内容)
* @param category 匹配度(1-模糊;2-精确)
* @param column 排序字段
* @param order 排序方式(asc-正序;desc-倒序)
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/10
*/
@ApiOperation(value = "专题信息列表-分页列表查询", notes = "专题信息列表-分页列表查询")
@GetMapping(value = "/listArticle")
public Result<?> queryPageList(@RequestParam(name = "subjectId", required = false) String subjectId,
@RequestParam(name = "searchWord", required = false) String searchWord,
@RequestParam(name = "position", required = false) String position,
@RequestParam(name = "category", required = false) Integer category,
@RequestParam(name = "column", defaultValue = "publishDate") String column,
@RequestParam(name = "order", defaultValue = "desc") String order,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
List<String> subjectIdList = new ArrayList<>();
if (StringUtils.isNotEmpty(subjectId)) {
subjectIdList.add(subjectId);
} else {
List<EventExcelVO> frontList = eventService.frontList(null, null);
frontList.forEach(e -> subjectIdList.add(e.getId()));
}
//获取数据
IPage<SubjectDataVo> pageList = esService.frontListByPage(subjectIdList, searchWord, position, category, column, order, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 资讯详情
*
* @return
*/
@GetMapping(value = "/articleDetail")
public Result<?> articleDetail(@RequestParam String index, @RequestParam String id) {
SubjectDataVo subjectDataVo = esService.queryInfo(index, id);
return Result.OK(subjectDataVo);
}
/**
* 单篇文章热词
*
* @param index 索引名称
* @param id 资讯id
* @param number 热词数量
* @author lkg
* @date 2024/4/10
*/
@ApiOperation(value = "单篇文章热词", notes = "单篇文章热词")
@GetMapping(value = "/hotWords")
public Result<?> articleList(@RequestParam("index") String index, @RequestParam("id") String id,
@RequestParam(name = "number", defaultValue = "200") Integer number) {
List<StatisticsKeyWordVo> words = eventService.hotWords(index, id, number);
return Result.OK(words);
}
/**
* 相关推荐
*
* @param id 资讯id
* @param title 标题
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/10
*/
@GetMapping(value = "/recommendList")
public Result<?> recommendList(@RequestParam(name = "id") String id,
@RequestParam(name = "title") String title,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
List<SubjectDataVo> recommendList = esService.queryRecommendList(id, title, pageNo, pageSize);
return Result.OK(recommendList);
}
}
package com.zzsn.event.controller;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.util.ExcelExportUtil;
import com.zzsn.event.vo.EventExcelVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 导出功能
*
* @author lkg
* @date 2024/4/10
*/
@RestController
@RequestMapping("/export")
public class EventExportController {
@Autowired
private IEventService eventService;
/**
* 导出事件列表
*
* @param eventIdList 事件id集合
* @param size 导出数量
* @author lkg
* @date 2024/4/10
*/
@GetMapping("/eventList")
public void exportEventList(@RequestParam(required = false) List<String> eventIdList,
@RequestParam(required = false) Integer size,
HttpServletResponse response) {
String[] headers = new String[]{"id", "事件名称", "事件描述", "发布时间", "热度"};
List<EventExcelVO> eventList = eventService.frontList(eventIdList, size);
if (CollectionUtils.isNotEmpty(eventList)) {
String name = "event.xlsx";
List<List<String>> dataList = new ArrayList<>();
eventList.forEach(e -> dataList.add(e.toList()));
XSSFWorkbook workbook = ExcelExportUtil.exportExcelData(Arrays.asList(headers), dataList, "事件");
try {
setResponseHeader(response, name);
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void setResponseHeader(HttpServletResponse response, String name) {
try {
try {
name = new String(name.getBytes(), "ISO8859-1");
} catch (Exception e) {
e.printStackTrace();
}
response.setContentType("application/octet-stream;charset=ISO8859-1");
response.setHeader("Content-Disposition", "attachment;filename=" + name);
response.setHeader("Pargam", "no-cache");
response.setHeader("Cache-Control", "no-cache");
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.zzsn.event.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zzsn.event.entity.Event;
import com.zzsn.event.service.EsStatisticsService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.vo.EventRegionVO;
import com.zzsn.event.vo.EventTopVO;
import com.zzsn.event.constant.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 事件首页
*
* @author lkg
* @date 2024/4/8
*/
@RestController
@RequestMapping("/home")
public class EventHomeController {
@Autowired
private EsStatisticsService esStatisticsService;
@Autowired
private IEventService eventService;
/**
* 事件数据统计-首页
*
* @author lkg
* @date 2024/1/12
*/
@GetMapping(value = "/eventData")
public Result<?> eventData() {
Map<String, Integer> map = new HashMap<>();
List<Event> list = eventService.list(new LambdaQueryWrapper<Event>()
.eq(Event::getFacePublic,1)
.eq(Event::getPublishStatus,1));
map.put("eventCount", list.size());
List<String> eventIdList = list.stream().map(Event::getId).collect(Collectors.toList());
long total = esStatisticsService.totalCount(eventIdList, null, null);
map.put("total", (int) total);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
LocalDateTime previousHour = now.minus(1, ChronoUnit.DAYS);
long totalAdd = esStatisticsService.totalCount(eventIdList, previousHour.format(formatter), now.format(formatter));
map.put("totalAdd", (int) totalAdd);
return Result.OK(map);
}
/**
* 热点事件-前10
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param type 分类(1-按发布时间;2.按热度)
* @param size 返回个数
* @author lkg
* @date 2024/4/8
*/
@GetMapping("/hotEventFlow")
public Result<?> hotEventFlow(@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime,
@RequestParam Integer type,
@RequestParam(defaultValue = "10") Integer size) {
List<EventTopVO> list = eventService.topEventList(startTime, endTime, type, size);
return Result.OK(list);
}
/**
* 事件按地域分析
*
* @param type 地域类型(1-国际;2-国内)
* @param regionName 地域名称
* @author lkg
* @date 2024/4/10
*/
@GetMapping("/region")
public Result<?> region(@RequestParam Integer type, @RequestParam(required = false) String regionName) {
List<Map<String, Object>> dataList = new ArrayList<>();
List<EventRegionVO> eventRegionVOList = eventService.listByRegion(type, regionName);
Map<String, List<EventRegionVO>> map = eventRegionVOList.stream().collect(Collectors.groupingBy(EventRegionVO::getRegionName));
for (Map.Entry<String, List<EventRegionVO>> entry : map.entrySet()) {
Map<String, Object> regionMap = new HashMap<>();
regionMap.put("region", entry.getKey());
regionMap.put("events", entry.getValue());
regionMap.put("count", entry.getValue().size());
dataList.add(regionMap);
}
return Result.OK(dataList);
}
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description: 专家
* @Author: jeecg-boot
* @Date: 2024-03-14
* @Version: V1.0
*/
@Data
@TableName("cms_expert")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CmsExpert {
/**id*/
private String expertId;
private String headPic;
}
package com.zzsn.event.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* @Description: 事件
......
package com.zzsn.event.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* @Description: 事件分类
......
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 事件地域关系表
*
* @author lkg
* @date 2024/4/9
*/
@Data
@TableName("event_region_map")
@ApiModel(value="event_region_map对象")
public class EventRegionMap implements Serializable {
/**主键id*/
@TableId(value = "id",type = IdType.ASSIGN_ID)
private String id;
/**事件id*/
@TableField("event_id")
private String eventId;
/**地域id*/
@TableField("region_id")
private String regionId;
/**地域名称*/
@TableField("top_region_id")
private String topRegionId;
/**地域类型(1-国际;2-国内)*/
@TableField("type")
private Integer type;
/**创建时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("create_time")
private Date createTime;
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* @Description: EventTag
......
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzsn.event.vo.ReportExtendVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 报告表
*
* @author lkg
* @date 2023/3/16
*/
@Data
@TableName("clb_report")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "clb_report", description = "报告表")
public class Report implements Serializable {
/**
* 主键id
*/
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
/**
* 报告名称
*/
@ApiModelProperty(value = "报告名称")
@TableField("report_name")
private String reportName;
/**
* 报告刊期
*/
@ApiModelProperty(value = "报告刊期")
@TableField("report_issue")
private String reportIssue;
/**
* 报告内容
*/
@ApiModelProperty(value = "报告内容")
@TableField("content")
private String content;
/**
* 开始时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "开始时间")
@TableField("start_time")
private Date startTime;
/**
* 结束时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "结束时间")
@TableField("end_time")
private Date endTime;
/**
* 文件地址
*/
@ApiModelProperty(value = "文件地址")
@TableField("file_path")
private String filePath;
/**
* 预览地址
*/
@ApiModelProperty(value = "预览地址")
@TableField("preview")
private String preview;
/**
* 模板id
*/
@ApiModelProperty(value = "模板id")
@TableField("template_id")
private String templateId;
/**
* 报告类型id
*/
@ApiModelProperty(value = "报告类型id")
@TableField("type_id")
private String typeId;
/**
* 描述
*/
@ApiModelProperty(value = "描述")
@TableField("description")
private String description;
/**
* 专题id
*/
@ApiModelProperty(value = "专题id")
@TableField("subject_id")
private String subjectId;
/**
* 项目id
*/
@ApiModelProperty(value = "项目id")
@TableField("project_id")
private String projectId;
/**
* 项目下的栏目id
*/
@ApiModelProperty(value = "项目下的栏目id")
@TableField("column_id")
private String columnId;
/**
* 发布状态(0-不发布;1-发布)
*/
@ApiModelProperty(value = "发布状态(0-不发布;1-发布)")
@TableField("publish")
private Integer publish;
/**
* 生成方式(1-自动;2-手动)
*/
@ApiModelProperty(value = "生成方式(1-自动;2-手动)")
@TableField("create_way")
private Integer createWay;
/**
* 报告状态(0-禁用;1-正常)
*/
@ApiModelProperty(value = "报告状态(0-禁用;1-正常)")
@TableField("status")
private Integer status;
/**
* 报告任务id
*/
@ApiModelProperty(value = "报告任务id")
@TableField("task_id")
private String taskId;
/**
* 任务执行时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "任务执行时间")
@TableField("task_execution_time")
private Date taskExecutionTime;
/**
* 是否删除(0-否;1-是)
*/
@ApiModelProperty(value = "是否删除(0-否;1-是)")
@TableField("delete_status")
private Integer deleteStatus;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
@TableField("create_by")
private String createBy;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
/**报告所属栏目信息*/
@TableField(exist = false)
private List<ReportExtendVo> reportExtendVoList;
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @author : wp
* @title : Subject
* @description: 专题
* @date : Created in 2022/7/7 10:04
* @modified By:
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "subject",autoResultMap = true)
public class Subject implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
private String subjectCode;
/**
* 专题名称
*/
private String subjectName;
/**
* 专题图片名称
*/
private String picturePolicy;
/**
* 启用时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date timeEnable;
/**
* 停用时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date timeDisable;
/**
* 专题增量分析规则
*/
private Integer increAnaRule;
/**
* 专题总量分析规则
*/
private Integer totalAnaRule;
/**
* 专题时间间隔分析规则
*/
private Integer timeAnaRule;
/**
* 专题最近一次分析时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date analysisTime;
/**
* 分析事件脉络-最新资讯的时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date eventTime;
/**
* 外事办映射id
*/
private Integer wsbMapId;
/**
* 创建人
*/
private String createBy;
/**
* 创建日期
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新日期
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 所属部门
*/
private String sysOrgCode;
/**
* 所属客户
*/
private String customerId;
private Integer status;
/**
* 专题类别(1:通用专题 2:事件专题)
*/
public Integer subjectType;
}
......@@ -19,9 +19,9 @@ public enum CodePrefixEnum {
LABEL_CODE_DEFAULT("LABEL", "标签编码默认前缀");
// 前缀
private String value;
private final String value;
// 描述信息
private String des;
private final String des;
CodePrefixEnum(String value, String des) {
this.value = value;
......
package com.zzsn.event.enums;
/**
* 影响力字段枚举
*
* @author lkg
* @date 2024/1/24
*/
public enum InfluenceEnum {
LIKE("likeNum", "点赞数"),
COMMENT("commentNum", "评论数"),
COLLECT("collectNum", "收藏数"),
SHARE("shareNum", "分享数");
/**值*/
private final String field;
/**描述*/
private final String description;
public String getField() {
return field;
}
public String getDescription() {
return description;
}
InfluenceEnum(String field, String description) {
this.field = field;
this.description = description;
}
}
package com.zzsn.event.enums;
/**
* Description:
*
* @author: EDY
* @since: 2024/1/9
*/
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Description:
* Author: EDY
* Date: 2023/10/9
*/
public enum KnowTypeEnum {
Notice("公告","1"),
LeadershipSpeech("领导讲话","2"),
YearReport("年报","3"),
JournalArticle("期刊论文","3"),
Book("图书","4"),
ResearchReport("研报","5"),
Policies("政策法规","6"),
Message("资讯","7"),
;
public static List<KnowTypeEnum> getAll(){
KnowTypeEnum[] values = KnowTypeEnum.values();
return Arrays.asList(values);
}
public static Map<String,String> getAllAsMap(){
Map<String , String> res = new HashMap<>();
KnowTypeEnum[] values = KnowTypeEnum.values();
for (KnowTypeEnum value : values) {
res.put(value.des,value.type);
}
return res;
}
public static KnowTypeEnum getByDes(String des) {
for (KnowTypeEnum enumValue : KnowTypeEnum.values()) {
if (enumValue.getDes().equals(des)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + des);
}
public static KnowTypeEnum getByType(String type) {
for (KnowTypeEnum enumValue : KnowTypeEnum.values()) {
if (enumValue.getType().equals(type)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + type);
}
/**路径描述*/
private final String des;
/**路径描述*/
private final String type;
public String getType() {
return type;
}
public String getDes() {
return des;
}
KnowTypeEnum( String des ,String type) {
this.des = des;
this.type = type;
}
}
package com.zzsn.event.enums;
import lombok.Getter;
/**
* 货币计量单位枚举
*
* @author lkg
* @date 2023/8/25
*/
@Getter
public enum SourceEnum {
OTHER("0", "其他"),
WEBSITE("1", "网站"),
WEIBO("2", "微博"),
WECHAT("3", "微信公众号"),
DOUYIN("4", "抖音"),
TIEBA("5", "贴吧");
/**值*/
private final String value;
/**描述*/
private final String description;
SourceEnum(String value, String description) {
this.value = value;
this.description = description;
}
public static String getDescription(String value){
String description = null;
SourceEnum[] values = SourceEnum.values();
for (SourceEnum sourceEnum : values) {
if (sourceEnum.value.equals(value)) {
description = sourceEnum.description;
break;
}
}
return description;
}
}
package com.zzsn.event.consumer;
package com.zzsn.event.kafka.consumer;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.SubjectAnalysis;
import com.zzsn.event.service.EsService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.SubjectAnalysisService;
import com.zzsn.event.vo.SubjectDataVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
......@@ -30,9 +27,6 @@ import java.util.List;
@Slf4j
@Component
public class KafkaConsumer {
@Autowired
private EsService esService;
@Autowired
private SubjectAnalysisService subjectAnalysisService;
@Autowired
......@@ -51,22 +45,7 @@ public class KafkaConsumer {
String subjectId = null;
try {
List<SubjectAnalysis> subjectAnalyses = JSON.parseArray(value, SubjectAnalysis.class);
subjectAnalyses.forEach(e -> {
SubjectDataVo subjectDataVo = esService.queryInfo(e.getDataId());
Integer repeatNum = e.getRepeatNum();
if (repeatNum == 0) {
String repeatId = subjectDataVo.getRepeatId();
if (StringUtils.isNotEmpty(repeatId)) {
repeatNum = esService.getRepeatNum(repeatId);
}
}
if (repeatNum == 0) {
e.setRepeatNum(1);
} else {
e.setRepeatNum(repeatNum);
}
e.setTitle(removeNonBmpUniCodes(e.getTitle()));
});
subjectAnalyses.forEach(e -> e.setTitle(removeNonBmpUniCodes(e.getTitle())));
Integer category = subjectAnalyses.get(0).getCategory();
subjectId = subjectAnalyses.get(0).getSubjectId();
Date analysisDate = subjectAnalyses.get(0).getAnalysisDate();
......
package com.zzsn.event.producer;
package com.zzsn.event.kafka.producer;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel;
import javax.sound.midi.Receiver;
/**
* @author zs
* @Description 信息通道
......
package com.zzsn.event.producer;
package com.zzsn.event.kafka.producer;
import com.alibaba.fastjson.JSON;
......@@ -10,8 +10,6 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Slf4j
@EnableBinding(IInfosourceSource.class)
......@@ -20,18 +18,6 @@ public class ProduceInfo {
@Autowired
private IInfosourceSource source;
/*
* 专题拉取数据
* @param info 专题编码
* */
public void sendSubjectMsg(String subjectCode) {
Message<String> message = MessageBuilder.withPayload(subjectCode).build();
source.subjectModel().send(message);
log.info("专题投递到kafka成功,topic:subjectModel, subjectCode=[{}]", subjectCode);
}
/**
* 关键词执行
* @param keyWordsDTO 关键词信息源
......@@ -42,6 +28,7 @@ public class ProduceInfo {
Message<String> message = MessageBuilder.withPayload(msg).build();
source.keyWordsCrawl().send(message);
}catch (Exception e){
e.printStackTrace();
log.error("关键词:"+ keyWordsDTO.getWordsCode() + "推送kafka失败");
}
}
......
......@@ -2,8 +2,7 @@ package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.LabelEntity;
import com.zzsn.event.vo.SubjectKafkaVo;
import com.zzsn.event.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -13,19 +12,115 @@ import java.util.List;
/**
* @Description: 事件
* @Author: jeecg-boot
* @Date: 2024-03-14
* @Date: 2024-03-14
* @Version: V1.0
*/
@Mapper
public interface EventMapper extends BaseMapper<Event> {
List<SubjectKafkaVo> eventSubjectList(int i);
List<SubjectKafkaVo> eventSubjectList();
List<Event> pageList(@Param("event")Event event, Integer offset, Integer pageSize,String order,String orderType);
/**
* 分页列表-后台管理
*
* @param eventName 事件名称
* @param eventType 事件分类id
* @param startTime 开始时间
* @param endTime 结束时间
* @param order 排序字段
* @param orderType 排序方式
* @param offset 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/8
*/
List<EventManageVO> pageList(@Param("eventName") String eventName, @Param("eventType") Integer eventType,
@Param("startTime") String startTime, @Param("endTime") String endTime,
@Param("order") String order, @Param("orderType") String orderType,
@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
Integer totalCount(@Param("event") Event event);
/**
* 总数量-后台管理
*
* @param eventName 事件名称
* @param eventType 事件分类id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2024/4/8
*/
Integer totalCount(@Param("eventName") String eventName, @Param("eventType") Integer eventType,
@Param("startTime") String startTime, @Param("endTime") String endTime);
List<SubjectKafkaVo> prosessList(Date disableDate);
/**
* 分页列表-后台管理
*
* @param eventName 事件名称
* @param eventType 事件分类id
* @param labelField 搜索字段
* @param labelName 搜索词
* @param type 类别(1-自定义标签;2-抽取标签)
* @param order 排序字段
* @param orderType 排序方式
* @param offset 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/8
*/
List<EventFrontVO> frontPageList(@Param("eventName") String eventName, @Param("eventType") Integer eventType,
@Param("labelField") String labelField, @Param("labelName") String labelName,
@Param("type") Integer type,
@Param("order") String order, @Param("orderType") String orderType,
@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
List<LabelEntity> listByType(String labelTypeId);
/**
* 总数量-后台管理
*
* @param eventName 事件名称
* @param eventType 事件分类id
* @param labelField 搜索字段
* @param labelName 搜索词
* @param type 类别(1-自定义标签;2-抽取标签)
* @author lkg
* @date 2024/4/8
*/
Integer frontTotalCount(@Param("eventName") String eventName, @Param("eventType") Integer eventType,
@Param("labelField") String labelField, @Param("labelName") String labelName,
@Param("type") Integer type);
/**
* 热点事件列表-前10
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param type 分类(1-按发布时间;2.按热度)
* @param offset 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/8
*/
List<EventTopVO> topEventList(@Param("startTime") String startTime, @Param("endTime") String endTime,
@Param("type") Integer type,
@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
List<SubjectKafkaVo> processList(@Param("disableDate") Date disableDate);
/**
* 根据地域获取事件信息列表
*
* @param name 地域名称
* @author lkg
* @date 2024/4/10
*/
List<EventRegionVO> listByRegion(@Param("type") Integer type, @Param("name") String name);
/**
* 公开且发布的事件信息集合
*
* @param eventIdList 事件id集合
* @param size 数量
* @author lkg
* @date 2024/4/10
*/
List<EventExcelVO> frontList(@Param("eventIdList") List<String> eventIdList, @Param("size") Integer size);
}
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.EventRegionMap;
import com.zzsn.event.vo.RegionVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/4/9
*/
@Mapper
public interface EventRegionMapMapper extends BaseMapper<EventRegionMap> {
/**
* 事件关联地域信息
*
* @param eventId 事件id
* @author lkg
* @date 2024/4/9
*/
List<RegionVO> regionList(@Param("eventId") String eventId);
}
......@@ -2,6 +2,7 @@ package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.LabelEntity;
import com.zzsn.event.util.tree.Node;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -26,6 +27,21 @@ public interface LabelEntityMapper extends BaseMapper<LabelEntity> {
* @date 2024/1/22
*/
List<LabelEntity> listByType(@Param("labelTypeId") String labelTypeId);
/**
* 国际地域信息列表
*
* @author lkg
* @date 2024/4/9
*/
List<Node> regionInList();
/**
* 国际地域信息列表
*
* @author lkg
* @date 2024/4/9
*/
List<Node> regionOutList();
}
......
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.Report;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 报告表
*
* @author lkg
* @date 2023/3/16
*/
@Mapper
public interface ReportMapper extends BaseMapper<Report> {
// /**
// * 报告表-分页列表
// *
// * @param typeId 报告分类id
// * @param offset 偏移量
// * @param pageSize 返回条数
// * @author lkg
// * @date 2023/3/24
// */
// List<ReportVO> pageList(@Param("typeId") String typeId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
//
// /**
// * 报告表-总数量
// *
// * @param typeId 报告分类id
// * @author lkg
// * @date 2023/3/24
// */
// Integer count(@Param("typeId") String typeId);
//
//
// /**
// * 报告表-分页列表(客户)
// *
// * @param typeIds 报告分类id集合
// * @param projectIds 项目id集合
// * @param reportName 报告名称
// * @param startTime 开始时间
// * @param endTime 结束时间
// * @param offset 偏移量
// * @param pageSize 返回条数
// * @author lkg
// * @date 2023/3/24
// */
// List<UserReportVO> userPageList(@Param("typeIds") List<String> typeIds, @Param("projectIds") List<String> projectIds,
// @Param("reportName") String reportName,
// @Param("startTime") String startTime, @Param("endTime") String endTime,
// @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
//
// /**
// * 报告表-总数量(客户)
// *
// * @param typeIds 报告分类id集合
// * @param projectIds 项目id集合
// * @param reportName 报告名称
// * @param startTime 开始时间
// * @param endTime 结束时间
// * @author lkg
// * @date 2023/3/24
// */
// Integer total(@Param("typeIds") List<String> typeIds, @Param("projectIds") List<String> projectIds,
// @Param("reportName") String reportName,
// @Param("startTime") String startTime, @Param("endTime") String endTime);
}
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.Subject;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* @author : wp
* @title : subjectMapper
* @description:专题mapper接口
* @date : Created in 2022/7/7 10:25
* @modified By:
*/
@Mapper
public interface SubjectMapper extends BaseMapper<Subject> {
// /**
// * 获取用户授权得事件专题列表
// *
// * @param userId: 用户id
// * @param subjectType: 专题类别(1:通用专题 2:事件专题)
// * @param title: 专题标题
// * @author lkg
// * @date 2023/2/22
// */
// List<Subject> searchSubjectList(@Param("userId") String userId, @Param("subjectType") Integer subjectType, @Param("title") String title);
//
// /**
// * 获取进行中(未结束)的事件专题列表
// *
// * @param subjectType 专题类别(1:通用专题 2:事件专题)
// * @param endDate 结束时间
// * @return java.util.List<com.zzsn.subjectAnalysis.vo.SubjectKafkaVo>
// * @author lkg
// */
// List<SubjectKafkaVo> progressList(@Param("subjectType") Integer subjectType, @Param("endDate") Date endDate);
//
// /**
// * 获取所有的事件专题列表
// *
// * @param subjectType 专题类别(1:通用专题 2:事件专题)
// * @return java.util.List<com.zzsn.subjectAnalysis.vo.SubjectKafkaVo>
// * @author lkg
// */
// List<SubjectKafkaVo> eventSubjectList(@Param("subjectType") Integer subjectType);
//
// /**
// * 获取最大外事办映射id
// *
// * @return java.lang.Integer
// * @author lkg
// */
// Integer getMaxWsbMapId();
}
......@@ -3,68 +3,188 @@
<mapper namespace="com.zzsn.event.mapper.EventMapper">
<select id="eventSubjectList" resultType="com.zzsn.event.vo.SubjectKafkaVo">
select s.id,s.event_name as subject_name,s.start_time as time_enable,s.end_time as time_disable,s.incre_ana_rule,
s.total_ana_rule,s.time_ana_rule,s.analysis_time,s.event_time
from event s
select s.id,
s.event_name as subject_name,
s.start_time as time_enable,
s.end_time as time_disable,
s.incre_ana_rule,
s.total_ana_rule,
s.time_ana_rule,
s.analysis_time,
s.event_time
from event s
</select>
</select>
<select id="pageList" resultType="com.zzsn.event.entity.Event">
select t2.type_name,t1.*,t3.* from event t1
left join event_category t2 on t1.event_type =t2.id
left join event_tag t3 on t1.id=t3.event_id
where 1=1
<if test="event.eventName!=null and event.eventName != ''">
and t1.event_name like CONCAT('%',#{event.eventName},'%')
<select id="pageList" resultType="com.zzsn.event.vo.EventManageVO">
select t2.type_name,t1.id,t1.event_icon,t1.event_name,t1.event_label,
t1.face_public,t1.publish_status,t1.create_time,t1.publish_date,t1.start_time,t1.end_time
from event t1
inner join event_category t2 on t1.event_type =t2.id
where 1=1
<if test="eventName!=null and eventName != ''">
and t1.event_name like CONCAT('%',#{eventName},'%')
</if>
<if test="event.eventType!=null and event.eventType != ''">
and t1.event_type = #{event.eventType}
<if test="eventType!=null and eventType != ''">
and t1.event_type = #{eventType}
</if>
<if test="event.startDate!=null and event.startDate != ''">
and t1.create_time >= #{event.startDate}
<if test="startTime!=null and startTime != ''">
and t1.create_time >= #{startTime}
</if>
<if test="event.endDate!=null and event.endDate != ''">
and t1.create_time <![CDATA[ <= ]]> #{event.endDate}
<if test="endTime!=null and endTime != ''">
and t1.create_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="order!=null and order != ''">
order by t1.${order}
<if test="orderType!=null and orderType != ''">
${orderType}
${orderType}
</if>
</if>
limit #{offset}, #{pageSize}
</select>
<select id="totalCount" resultType="java.lang.Integer">
select count(1) from event t1
left join event_category t2 on t1.event_type =t2.id
inner join event_category t2 on t1.event_type =t2.id
where 1=1
<if test="event.eventName!=null and event.eventName != ''">
and t1.event_name like CONCAT('%',#{event.eventName},'%')
<if test="eventName!=null and eventName != ''">
and t1.event_name like CONCAT('%',#{eventName},'%')
</if>
<if test="event.eventType!=null and event.eventType != ''">
and t1.event_type = #{event.eventType}
<if test="eventType!=null and eventType != ''">
and t1.event_type = #{eventType}
</if>
<if test="event.startDate!=null and event.startDate != ''">
and t1.create_time >= #{event.startDate}
<if test="startTime!=null and startTime != ''">
and t1.create_time >= #{startTime}
</if>
<if test="event.endDate!=null and event.endDate != ''">
and t1.create_time <![CDATA[ <= ]]> #{event.endDate}
<if test="endTime!=null and endTime != ''">
and t1.create_time <![CDATA[ <= ]]> #{endTime}
</if>
</select>
<select id="frontPageList" resultType="com.zzsn.event.vo.EventFrontVO">
select
t1.id,t1.event_name,t1.event_icon,t1.start_time,t1.end_time,t1.publish_date,t1.event_describe,t1.event_label,t1.total_hot,
t3.extract_industry_tag,t3.extract_company_tag,t3.extract_person_tag,t3.extract_sentiment_tag,
t3.extract_keywords_tag,t3.extract_time_tag,t3.extract_location_tag
from event t1 inner join event_category t2 on t1.event_type =t2.id
left join event_tag t3 on t1.id=t3.event_id
where t1.publish_status = 1 and t1.face_public = 1
<if test="eventName!=null and eventName != ''">
and t1.event_name like CONCAT('%',#{eventName},'%')
</if>
<if test="eventType!=null and eventType != ''">
and t1.event_type = #{eventType}
</if>
<if test="labelName != null and labelName !=''">
<if test="labelField != null and labelField != ''">
<choose>
<when test="type == 1">
and t1.event_label like concat('%',#{labelName},'%')
</when>
<otherwise>
and t3.${labelField} like concat('%',#{labelName},'%')
</otherwise>
</choose>
</if>
</if>
<choose>
<when test="order != null and order != ''">
order by t1.${order}
<if test="orderType != null and orderType != ''">
${orderType}
</if>
</when>
<otherwise>
order by t1.publish_date desc
</otherwise>
</choose>
limit #{offset}, #{pageSize}
</select>
<select id="prosessList" resultType="com.zzsn.event.vo.SubjectKafkaVo">
select s.id,s.event_name as subject_name,s.start_time as time_enable,s.end_time as time_disable,s.incre_ana_rule,
<select id="frontTotalCount" resultType="java.lang.Integer">
select count(1) from event t1
inner join event_category t2 on t1.event_type =t2.id
left join event_tag t3 on t1.id=t3.event_id
where t1.publish_status = 1 and t1.face_public = 1
<if test="eventName!=null and eventName != ''">
and t1.event_name like CONCAT('%',#{eventName},'%')
</if>
<if test="eventType!=null and eventType != ''">
and t1.event_type = #{eventType}
</if>
<if test="labelName != null and labelName !=''">
<if test="labelField != null and labelField != ''">
<choose>
<when test="type == 1">
and t1.event_label like concat('%',#{labelName},'%')
</when>
<otherwise>
and t3.${labelField} like concat('%',#{labelName},'%')
</otherwise>
</choose>
</if>
</if>
</select>
<select id="topEventList" resultType="com.zzsn.event.vo.EventTopVO">
select t.id,t.event_name,t.publish_date,t.total_hot,ec.type_name from event t
inner join event_category ec on t.event_type = ec.id
where t.publish_status = 1 and t.face_public = 1
<if test="startTime!=null and startTime != ''">
and t.publish_date >= #{startTime}
</if>
<if test="endTime!=null and endTime != ''">
and t.publish_date <![CDATA[ <= ]]> #{endTime}
</if>
order by
<choose>
<when test="type == 1">
t.publish_date
</when>
<otherwise>
t.total_hot
</otherwise>
</choose>
desc
limit #{offset}, #{pageSize}
</select>
<select id="processList" resultType="com.zzsn.event.vo.SubjectKafkaVo">
select s.id,s.event_name as subject_name,s.start_time as time_enable,s.end_time as
time_disable,s.incre_ana_rule,
s.total_ana_rule,s.time_ana_rule,s.analysis_time,s.event_time
from event s
where 1=1
<if test="endDate != null">
and (s.end_time is null or s.end_time <![CDATA[ >= ]]> #{endDate})
<if test="disableDate != null">
and (s.end_time is null or s.end_time <![CDATA[ >= ]]> #{disableDate})
</if>
</select>
<select id="listByRegion" resultType="com.zzsn.event.vo.EventRegionVO">
SELECT
e.id AS eventId,
e.event_name,
r.name_cn AS regionName
FROM
( SELECT id, event_name FROM event WHERE publish_status = 1 AND face_public = 1 ) e
INNER JOIN event_region_map m ON e.id = m.event_id
INNER JOIN sys_base_region r ON m.top_region_id = r.id
WHERE m.type = #{type}
<if test="name != null and name !=''">
and r.name_cn = #{name}
</if>
</select>
<select id="listByType" resultType="com.zzsn.event.entity.LabelEntity">
SELECT e.id, e.name
FROM label_entity e
inner join sys_base_label_type_map m on e.id = m.relation_id
where m.label_id = #{labelTypeId}
<select id="frontList" resultType="com.zzsn.event.vo.EventExcelVO">
select id,event_name,event_describe,publish_date,total_hot from event where publish_status = 1 and face_public =
1
<if test="eventIdList != null and eventIdList.size() > 0">
and id in
<foreach collection="eventIdList" open="(" separator="," close=")" item="item">
#{item}
</foreach>
</if>
<if test="size != null">
order by publish_date desc
limit #{size}
</if>
</select>
</mapper>
\ No newline at end of file
<?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.EventRegionMapMapper">
<select id="regionList" resultType="com.zzsn.event.vo.RegionVO">
select r.id,r.top_id,r.name_cn as regionName,m.type from sys_base_region r
inner join event_region_map m on r.id = m.region_id
where m.event_id = #{eventId}
</select>
</mapper>
\ No newline at end of file
......@@ -30,4 +30,13 @@
inner join sys_base_label_type_map m on e.id = m.relation_id
where m.label_id = #{labelTypeId}
</select>
<select id="regionInList" resultType="com.zzsn.event.util.tree.Node">
select id, name,pid,top_id from sys_base_domestic_region
</select>
<select id="regionOutList" resultType="com.zzsn.event.util.tree.Node">
select id,name_cn as name,pid,top_id from sys_base_region
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.event.mapper.SubjectMapper">
<!-- <select id="searchSubjectList" resultType="com.zzsn.subjectAnalysis.entity.Subject">-->
<!-- select s.id,s.subject_name,s.time_enable,s.time_disable,s.picture_policy,s.wsb_map_id from subject s-->
<!-- <if test="userId !=null and userId != ''">-->
<!-- inner join sys_user_data_permission dp on s.id = dp.permission_id-->
<!-- </if>-->
<!-- where s.subject_type = #{subjectType}-->
<!-- <if test="title !=null and title != ''">-->
<!-- and s.subject_name like concat('%',#{title},'%')-->
<!-- </if>-->
<!-- <if test="userId !=null and userId != ''">-->
<!-- and dp.user_id = #{userId}-->
<!-- </if>-->
<!-- order by s.create_time desc-->
<!-- </select>-->
<!-- <select id="progressList" resultType="com.zzsn.subjectAnalysis.vo.SubjectKafkaVo">-->
<!-- select s.id,s.subject_name,s.time_enable,s.time_disable,s.incre_ana_rule,-->
<!-- s.total_ana_rule,s.time_ana_rule,s.analysis_time,s.event_time-->
<!-- from subject s-->
<!-- where s.subject_type = #{subjectType}-->
<!-- <if test="endDate != null">-->
<!-- and (s.time_disable is null or s.time_disable <![CDATA[ >= ]]> #{endDate})-->
<!-- </if>-->
<!-- </select>-->
<!-- <select id="eventSubjectList" resultType="com.zzsn.subjectAnalysis.vo.SubjectKafkaVo">-->
<!-- &lt;!&ndash;select a.*,w.key_word from (-->
<!-- select s.id,s.subject_name,s.time_enable,s.time_disable,s.incre_ana_rule,-->
<!-- s.total_ana_rule,s.time_ana_rule,s.analysis_time,s.event_time-->
<!-- from subject s-->
<!-- where s.subject_type = #{subjectType}-->
<!-- ) a-->
<!-- INNER JOIN subject_keywords_map k ON a.id=k.subject_id-->
<!-- INNER JOIN key_words w ON k.keywords_id=w.id&ndash;&gt;-->
<!-- select s.id,s.subject_name,s.time_enable,s.time_disable,s.incre_ana_rule,-->
<!-- s.total_ana_rule,s.time_ana_rule,s.analysis_time,s.event_time-->
<!-- from subject s-->
<!-- where s.subject_type = #{subjectType}-->
<!-- </select>-->
<!-- <select id="getMaxWsbMapId" resultType="Integer">-->
<!-- select max(wsb_map_id) from subject-->
<!-- </select>-->
</mapper>
package com.zzsn.event.service;
import com.zzsn.event.entity.SubjectAnalysis;
import com.zzsn.event.vo.PropagationPathVo;
import com.zzsn.event.vo.StatisticAnalysisVo;
import com.zzsn.event.vo.ViewPointAnalysisVo;
import java.util.List;
import java.util.Map;
/**
* @author lkg
......@@ -17,13 +13,6 @@ import java.util.Map;
*/
public interface AnalysisService {
// /**
// * 观点分析
// * @param subjectId 专题id
// * @return java.util.Map<java.lang.String,java.util.List<com.zzsn.subjectAnalysis.vo.ViewPointAnalysisVo>>
// */
// Map<String, List<ViewPointAnalysisVo>> viewPointAnalysis(String subjectId);
//
/**
* 事件脉络
* @param subjectId 专题id
......@@ -38,20 +27,4 @@ public interface AnalysisService {
* @return com.zzsn.subjectAnalysis.vo.PropagationPathVo
*/
PropagationPathVo propagationPath(String subjectId);
// /**
// * 统计分析-所有
// * @param subjectId 专题id
// * @return java.util.Map<java.lang.String,java.lang.Object>
// */
// Map<String, Object> statisticAnalysis(String subjectId);
//
// /**
// * 统计分析-按时间范围
// * @param subjectId 专题id
// * @param startTime 开始时间
// * @param endTime 结束时间
// */
// List<StatisticAnalysisVo> statisticAnalysis(String subjectId, String startTime, String endTime);
}
package com.zzsn.event.service;
import com.zzsn.event.vo.SpecialInformationParam;
import org.elasticsearch.search.builder.SearchSourceBuilder;
/**
* @Description: 门户自定义模型配置
* @Author: jeecg-boot
* @Date: 2023-11-21
* @Version: V1.0
*/
public interface EsDataSearchService {
/**
* 组装es查询条件
*
* @param param 查询参数
* @author lkg
* @date 2024/1/29
*/
SearchSourceBuilder packageSearQuery(SpecialInformationParam param);
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.vo.CountVO;
import com.zzsn.event.vo.MediaVO;
import com.zzsn.event.vo.NegativeDataVO;
import java.util.List;
import java.util.Map;
......@@ -19,17 +15,6 @@ public interface EsStatisticsService {
/**
* 总体信息
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param type 1-按小时;2-按天
* @author lkg
* @date 2024/1/25
*/
CountVO total(String startTime, String endTime, Integer type);
/**
* 总体分析,获取总量和波峰值
*
* @param subjectId 专题id
......@@ -40,18 +25,6 @@ public interface EsStatisticsService {
*/
Map<String, Object> totalAndMax(String subjectId, String startTime, String endTime);
/**
* 时间段内最新或最早的资讯
*
* @param subjectId 专题id
* @param labelId 标签id
* @param type 1-正序;2-倒序
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2024/1/25
*/
Map<String, Object> findOne(String subjectId, String labelId, int type, String startTime, String endTime);
/**
* 情感判断分析
......@@ -67,40 +40,6 @@ public interface EsStatisticsService {
CountVO orientation(String subjectId, String labelId, String startTime, String endTime, Integer type);
/**
* 影响力分析
*
* @param subjectId 专题id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2024/1/25
*/
List<CountVO> influence(String subjectId, String startTime, String endTime);
// /**
// * 媒体分布
// *
// * @param subjectId 专题id
// * @param startTime 开始时间
// * @param endTime 结束时间
// * @author lkg
// * @date 2024/1/24
// */
// List<MediaVO> media(String subjectId, String startTime, String endTime);
/**
* 来源分析
*
* @param subjectId 专题id
* @param startTime 开始时间
* @param endTime 结束时间
* @param type 1-按小时;2-按天
* @author lkg
* @date 2024/1/23
*/
List<CountVO> source(String subjectId, String startTime, String endTime, Integer type);
/**
* 平台活跃度--前十
*
* @param subjectId 专题id
......@@ -111,16 +50,6 @@ public interface EsStatisticsService {
*/
List<CountVO> origin(String subjectId, String startTime, String endTime);
// /**
// * 地域分析
// *
// * @param subjectId 专题id
// * @param startTime 开始时间
// * @param endTime 结束时间
// * @author lkg
// * @date 2024/1/25
// */
// List<CountVO> region(String subjectId, String startTime, String endTime);
/**
* 专题下的主流报道
......@@ -131,21 +60,25 @@ public interface EsStatisticsService {
*/
String mainReport(String subjectId);
/**
* 某标签下资讯分页列表
* 专题信息传播走势
*
* @param labelId 标签id
* @param subjectId 专题id
* @param startTime 开始时间
* @param endTime 结束时间
* @param pageNo 当前页
* @param pageSize 返回条数
* @param endTime 结束时间
* @author lkg
* @date 2024/2/29
* @date 2024/4/10
*/
Page<NegativeDataVO> labelPageList(String labelId, String startTime, String endTime, Integer pageNo, Integer pageSize);
CountVO flowData(String subjectId, String startTime, String endTime, Integer type);
CountVO flowData(String subjectId, String startTime, String endTime);
/**
* 时间段内事件的信息总数
*
* @param eventIdList
* @param startTime
* @param endTime
* @author lkg
* @date 2024/4/10
*/
long totalCount(List<String> eventIdList, String startTime, String endTime);
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.EventRegionMap;
import com.zzsn.event.vo.RegionVO;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/4/9
*/
public interface EventRegionMapService extends IService<EventRegionMap> {
/**
* 事件关联地域信息
*
* @param eventId 事件id
* @author lkg
* @date 2024/4/9
*/
List<RegionVO> regionList(String eventId);
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zzsn.event.entity.Event;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.LabelEntity;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Event;
import com.zzsn.event.vo.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Description: 事件
* @Author: jeecg-boot
* @Date: 2024-03-14
* @Date: 2024-03-14
* @Version: V1.0
*/
public interface IEventService extends IService<Event> {
/**
* 计算热度
*/
void compute();
List<SubjectKafkaVo> progressList(Date disableDate);
List<SubjectKafkaVo> eventSubjectList();
IPage<Event> pageList(Event event, Integer pageNo, Integer pageSize,String order,String orderType);
/**
* 分页列表-后台管理
*
* @param eventName 事件名称
* @param eventType 事件分类id
* @param startTime 开始时间
* @param endTime 结束时间
* @param order 排序字段
* @param orderType 排序方式
* @param pageNo 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/8
*/
IPage<EventManageVO> pageList(String eventName, Integer eventType, String startTime, String endTime,
String order, String orderType, Integer pageNo, Integer pageSize);
/**
* 分页列表-后台管理
*
* @param eventName 事件名称
* @param eventType 事件分类id
* @param labelField 搜索字段
* @param labelName 搜索词
* @param order 排序字段
* @param orderType 排序方式
* @param pageNo 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/8
*/
IPage<EventFrontVO> frontPageList(String eventName, Integer eventType,String labelField, String labelName, String order, String orderType, Integer pageNo, Integer pageSize);
/**
* 热点事件列表-前10
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param type 分类(1-按发布时间;2.按热度)
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/8
*/
List<EventTopVO> topEventList(String startTime, String endTime, Integer type, Integer pageSize);
void extractHotWords(AddEventParam event);
/**
* 根据地域获取事件信息列表
*
* @param type 地域类型(1-国际;2-国内)
* @param name 地域名称
* @author lkg
* @date 2024/4/10
*/
List<EventRegionVO> listByRegion(Integer type, String name);
Event saveMain(AddEventParam addEventParam);
void updateMain(AddEventParam addEventParam);
/**
* 获取专题绑定的关键词组列表
*/
......@@ -43,9 +91,15 @@ public interface IEventService extends IService<Event> {
String upload(MultipartFile file);
List<LabelEntity> listByType(String labelTypeId);
DisplayInfo articleDetail(String articleId);
List<StatisticsKeyWordVo> hotWords(String index, String id, Integer number);
Result<?> hotWords(String id, Integer number);
/**
* 公开且发布的事件信息集合
*
* @param eventIdList 事件id集合
* @param size 数量
* @author lkg
* @date 2024/4/10
*/
List<EventExcelVO> frontList(List<String> eventIdList, Integer size);
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.Subject;
import java.util.Date;
import java.util.List;
/**
* @author : wp
* @title : ISubjectService
* @description: 专题接口
* @date : Created in 2022/7/7 10:21
* @modified By:
*/
public interface ISubjectService extends IService<Subject> {
// /**
// * 获取用户授权得事件专题列表
// *
// * @param userId: 用户id
// * @param title: 专题标题
// * @author lkg
// * @date 2023/2/22
// */
// List<Subject> searchSubjectList(String userId, String title);
//
// IPage<SubjectDataVo> queryInfoListBySid(SubjectVo subjectInfo, Integer pageNo, Integer pageSize) throws Exception;
//
// /**
// * 获取进行中(未结束)的事件专题列表
// *
// * @param endDate 结束时间
// * @return java.util.List<com.zzsn.subjectAnalysis.vo.SubjectKafkaVo>
// * @author lkg
// */
// List<SubjectKafkaVo> progressList(Date endDate);
//
// /**
// * 获取所有的事件专题列表
// *
// * @return java.util.List<com.zzsn.subjectAnalysis.vo.SubjectKafkaVo>
// * @author lkg
// */
// List<SubjectKafkaVo> eventSubjectList();
}
......@@ -2,6 +2,8 @@ package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.LabelEntity;
import com.zzsn.event.util.tree.Node;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -19,4 +21,13 @@ public interface LabelEntityService extends IService<LabelEntity> {
* @date 2024/1/22
*/
List<LabelEntity> listByType(String labelTypeId);
/**
* 地域信息列表
*
* @param type 类别(1-国际;2-国内)
* @author lkg
* @date 2024/4/10
*/
List<Node> regionTree(Integer type);
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.Report;
/**
* 报告表
*
* @author lkg
* @date 2023/3/16
*/
public interface ReportService extends IService<Report> {
//
// /**
// * 报告分页列表
// *
// * @param typeId 分类id
// * @param pageNo 当前页
// * @param pageSize 返回条数
// * @author lkg
// * @date 2024/1/31
// */
// IPage<ReportVO> pageList(String typeId, Integer pageNo, Integer pageSize);
//
//
// /**
// * 报告表-分页列表(客户)
// *
// * @param typeId 报告分类id
// * @param projectId 项目id集合
// * @param reportName 报告名称
// * @param startTime 开始时间
// * @param endTime 结束时间
// * @param pageNo 当前页
// * @param pageSize 返回条数
// * @author lkg
// * @date 2023/3/24
// */
// IPage<UserReportVO> userPageList(String typeId, String projectId, String reportName, String startTime, String endTime, Integer pageNo, Integer pageSize);
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.EventRegionMap;
import com.zzsn.event.mapper.EventRegionMapMapper;
import com.zzsn.event.service.EventRegionMapService;
import com.zzsn.event.vo.RegionVO;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/4/9
*/
@Service
public class EventRegionMapServiceImpl extends ServiceImpl<EventRegionMapMapper, EventRegionMap> implements EventRegionMapService {
@Override
public List<RegionVO> regionList(String eventId) {
return baseMapper.regionList(eventId);
}
}
......@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.LabelEntity;
import com.zzsn.event.mapper.LabelEntityMapper;
import com.zzsn.event.service.LabelEntityService;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.tree.TreeUtil;
import org.springframework.stereotype.Service;
import java.util.List;
......@@ -20,4 +22,15 @@ public class LabelEntityServiceImpl extends ServiceImpl<LabelEntityMapper, Label
public List<LabelEntity> listByType(String labelTypeId) {
return baseMapper.listByType(labelTypeId);
}
@Override
public List<Node> regionTree(Integer type) {
List<Node> nodes;
if (type == 1) {
nodes = baseMapper.regionOutList();
} else {
nodes = baseMapper.regionInList();
}
return TreeUtil.tree(nodes,"0");
}
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.Report;
import com.zzsn.event.mapper.ReportMapper;
import com.zzsn.event.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 报告表
*
* @author lkg
* @date 2023/3/23
*/
@Service
@Slf4j
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
// @Autowired
// private ReportBusinessTypeService reportBusinessTypeService;
// @Autowired
// private IProjectService projectService;
// @Autowired
// private ISubjectService subjectService;
//
// @Override
// public IPage<ReportVO> pageList(String typeId, Integer pageNo, Integer pageSize) {
// int offset = (pageNo - 1) * pageSize;
// List<ReportVO> pageList = baseMapper.pageList(typeId, offset, pageSize);
// Integer count = baseMapper.count(typeId);
// Page<ReportVO> page = new Page<>(pageNo, pageSize, count);
// page.setRecords(pageList);
// return page;
// }
//
// @Override
// public IPage<UserReportVO> userPageList(String typeId, String projectId, String reportName, String startTime, String endTime, Integer pageNo, Integer pageSize) {
// int offset = (pageNo - 1) * pageSize;
// List<String> typeIds = new ArrayList<>();
// List<String> projectIds = new ArrayList<>();
// if (StringUtils.isEmpty(projectId) && StringUtils.isEmpty(typeId)) {
// //获取当前登录用户
// LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// Integer category = currentUser.getCategory();
// if (!category.equals(CommonConstant.SUPER_USER)) {
// String userId = null;
// String customerId = null;
// if (category.equals(CommonConstant.ADMIN_USER)) {
// customerId = currentUser.getRelTenantIds();
// } else if (category.equals(CommonConstant.COMMON_USER)) {
// userId = currentUser.getId();
// }
// List<ProjectVO> projectVOS = projectService.permissionList(customerId, userId);
// projectVOS.forEach(e->projectIds.add(e.getId()));
// }
// } else {
// if (StringUtils.isNotEmpty(typeId)) {
// typeIds = reportBusinessTypeService.getBelowList(typeId);
// }
// if (StringUtils.isNotEmpty(projectId)) {
// projectIds.add(projectId);
// }
// }
// List<UserReportVO> pageList = baseMapper.userPageList(typeIds, projectIds,reportName, startTime, endTime, offset, pageSize);
// for (UserReportVO reportVO : pageList) {
// String subjectId = reportVO.getSubjectId();
// String subjectName = getSubject(subjectId);
// reportVO.setSubjectName(subjectName);
// }
// Integer count = baseMapper.total(typeIds, projectIds,reportName, startTime, endTime);
// Page<UserReportVO> page = new Page<>(pageNo, pageSize, count);
// page.setRecords(pageList);
// return page;
// }
// private String getSubject(String subjectId) {
// String subjectName = null;
// if (StringUtils.isNotEmpty(subjectId)) {
// StringBuilder stringBuilder = new StringBuilder();
// String[] split = subjectId.split(",");
// LambdaQueryWrapper<Subject> query = Wrappers.lambdaQuery();
// query.in(Subject::getId, Arrays.asList(split));
// List<Subject> list = subjectService.list(query);
// list.forEach(e -> stringBuilder.append(",").append(e.getSubjectName()));
// subjectName = stringBuilder.length() == 0 ? null : stringBuilder.substring(1);
// }
// return subjectName;
// }
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.mapper.SubjectMapper;
import com.zzsn.event.service.ISubjectService;
import org.springframework.stereotype.Service;
/**
* @author : wp
* @title : subjectServiceImpl
* @description: 专题实现类
* @date : Created in 2022/7/7 10:23
* @modified By:
*/
@Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> implements ISubjectService {
// @Autowired
// private IKeyWordsService keyWordsService;
// @Autowired
// private EsService esService;
//
// @Override
// public List<Subject> searchSubjectList(String userId, String title) {
// return baseMapper.searchSubjectList(userId, 2,title);
// }
//
// public IPage<SubjectDataVo> queryInfoListBySid(SubjectVo subjectInfo, Integer pageNo, Integer pageSize) {
// IPage<SubjectDataVo> pageData;
// String keyWords = keyWordsService.getBySubjectId(subjectInfo.getId());
// if (StringUtils.isNotEmpty(keyWords)) {
// String keywords = keyWords.replaceAll("\\(","").replaceAll("\\)","")
// .replaceAll("\\+",";").replaceAll("\\|",";");
// pageData = esService.pageList(subjectInfo.getId(), subjectInfo.getTitle(), keywords, subjectInfo.getStartTime(), subjectInfo.getEndTime(), pageNo, pageSize);
// List<SubjectDataVo> records = pageData.getRecords();
// for (SubjectDataVo dataVo :records) {
// String title = dataVo.getTitle();
// String[] keyWordArr = keywords.split(";");
// for (String keyWord :keyWordArr) {
// if (title.contains(keyWord)) {
// title = title.replaceAll(keyWord,"<font style=\"color:red;\">"+keyWord+"</font>");
// }
// }
// dataVo.setTitle(title);
// }
// } else {
// pageData = esService.pageList(subjectInfo.getId(), subjectInfo.getTitle(), null, subjectInfo.getStartTime(), subjectInfo.getEndTime(), pageNo, pageSize);
// }
// return pageData;
// }
//
// @Override
// public List<SubjectKafkaVo> progressList(Date endDate) {
// return baseMapper.progressList(2,endDate);
// }
//
// @Override
// public List<SubjectKafkaVo> eventSubjectList() {
// return baseMapper.eventSubjectList(2);
// }
}
......@@ -11,12 +11,14 @@ import com.zzsn.event.entity.SubjectAnalysis;
import com.zzsn.event.service.AnalysisService;
import com.zzsn.event.service.EsService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.SubjectAnalysisService;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.EsDateUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.KafkaDataVo;
import com.zzsn.event.vo.PropagationPathVo;
import com.zzsn.event.vo.SubjectDataVo;
import com.zzsn.event.vo.SubjectKafkaVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
......@@ -24,7 +26,6 @@ import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -37,7 +38,6 @@ import java.util.*;
*/
@Slf4j
@Component
@EnableScheduling
public class AnalysisTask {
@Autowired
......@@ -61,20 +61,18 @@ public class AnalysisTask {
* 每天凌晨0点执行一次
* 按天发送kafka 获取进行中(未结束)的事件专题列表
*/
// @Scheduled(cron = "0 0 0 * * ?")
// @Scheduled(cron = "0 * * * * ?")
@Scheduled(cron = "0 0 0 * * ?")
public void subjectList() {
List<SubjectKafkaVo> data = new ArrayList<>();
Date today = new Date();
Date disableDate = DateUtil.addDate(today, -1);
String startTime = EsDateUtil.esFieldDateFormat(DateUtil.dateToString(disableDate, "yyyy-MM-dd 00:00:00"));
String endTime = EsDateUtil.esFieldDateFormat(DateUtil.dateToString(disableDate, "yyyy-MM-dd 23:59:59"));
log.info("subjectList");
List<SubjectKafkaVo> subjects = eventService.progressList(disableDate);
subjects.forEach(e -> {
String subjectId = e.getId();
Integer increCount = esService.count(subjectId, startTime, endTime, "0");
Integer totalCount = esService.count(subjectId, null, null, "0");
Integer increCount = esService.count(subjectId, startTime, endTime);
Integer totalCount = esService.count(subjectId, null, null);
Date analysisTime = e.getAnalysisTime();
if (analysisTime == null) {
analysisTime = e.getTimeEnable();
......@@ -95,14 +93,14 @@ public class AnalysisTask {
data.add(e);
}
}catch (Exception exception){
log.error("事件{},报错信息:{}",e,exception.getMessage());
log.error("事件{},报错信息:{}",e.getSubjectName(),exception.getMessage());
}
});
if (CollectionUtils.isNotEmpty(data)) {
kafkaTemplate.send(Constants.EVENT_VIEWPOINT_SEND_DATA, JSON.toJSONString(data));
}
log.info("进行中(未结束)的事件专题列表数据{}发送成功!",data);
log.info("进行中(未结束)的事件专题列表数据发送成功!");
}
/**
......@@ -110,8 +108,7 @@ public class AnalysisTask {
* 按天发送 事件脉络 所需信息到kafka对应的topic
* 保证信息采集的及时性,审核人员审核的及时性
*/
// @Scheduled(cron = "0 5 0 * * ?")
// @Scheduled(cron = "0 * * * * ?")
@Scheduled(cron = "0 5 0 * * ?")
public void eventContext() {
Date today = new Date();
Date disableDate = DateUtil.addDate(today, -1);
......@@ -126,8 +123,10 @@ public class AnalysisTask {
startDate = DateUtil.dateToString(subjectKafkaVo.getTimeEnable(), "yyyy-MM-dd 00:00:00");
}
String endDate = DateUtil.dateToString(disableDate, "yyyy-MM-dd 23:59:59");
List<SubjectDataVo> perDateList = esService.getDataBySubjectId(subjectId, startDate, endDate, "0", Constants.FETCH_FIELDS_DATA, 2, null, null);
List<SubjectDataVo> perDateList = esService.getDataBySubjectId(subjectId, startDate, endDate, Constants.FETCH_FIELDS_DATA);
if (perDateList.size()> 30) {
//按发布时间倒序
perDateList.sort((o1, o2) -> o2.getPublishDate().compareTo(o1.getPublishDate()));
String keyWord = subjectKafkaVo.getKeyWord();
List<KafkaDataVo> list = new ArrayList<>();
format(subjectId, list, perDateList);
......@@ -138,7 +137,7 @@ public class AnalysisTask {
subject.setId(subjectId);
subject.setAnalysisTime(DateUtil.stringToDate(perDateList.get(0).getPublishDate(), "yyyy-MM-dd HH:mm:ss"));
eventService.updateById(subject);
log.info("id为-{}-的专题,此次事件脉络({}~{})数据-共{}条,发送成功!", subjectId, startDate.substring(0, 10), endDate.substring(0, 10), list.size());
log.info("专题-{},此次事件脉络({}~{})数据-共{}条,发送成功!", subjectKafkaVo.getSubjectName(), startDate.substring(0, 10), endDate.substring(0, 10), list.size());
}
}
}
......@@ -147,8 +146,7 @@ public class AnalysisTask {
* 每天凌晨0点20分执行一次
* 发送 伪事件脉络 所需信息到kafka对应的topic
*/
// @Scheduled(cron = "0 20 0 * * ?")
// @Scheduled(cron = "0 * * * * ?")
@Scheduled(cron = "0 20 0 * * ?")
public void eventContext_fake() {
Date today = new Date();
Date disableDate = DateUtil.addDate(today, -1);
......@@ -166,7 +164,7 @@ public class AnalysisTask {
List<KafkaDataVo> kafkaDataVoList = new ArrayList<>();
String subjectId = subjectKafkaVo.getId();
String keyWord = subjectKafkaVo.getKeyWord();
List<SubjectDataVo> dataList = esService.getDataBySubjectId(subjectId, null, null, "0", Constants.FETCH_FIELDS_DATA, 2, null, null);
List<SubjectDataVo> dataList = esService.getDataBySubjectId(subjectId, null, null, Constants.FETCH_FIELDS_DATA);
format(subjectId, kafkaDataVoList, dataList);
splitSend(Constants.FAKE_EVENT_CONTEXT_SEND_TOPIC, subjectId, kafkaDataVoList, keyWord);
}
......@@ -176,8 +174,9 @@ public class AnalysisTask {
dataList.forEach(e -> {
KafkaDataVo kafkaDataVo = new KafkaDataVo();
BeanUtils.copyProperties(e, kafkaDataVo);
List<SubjectDataVo> subjectDataVoList = esService.dataById(subjectId, e.getId());
kafkaDataVo.setRepeatNum(subjectDataVoList.size());
//todo
// List<SubjectDataVo> subjectDataVoList = esService.dataById(subjectId, e.getId());
// kafkaDataVo.setRepeatNum(subjectDataVoList.size());
kafkaDataVoList.add(kafkaDataVo);
});
}
......@@ -197,8 +196,7 @@ public class AnalysisTask {
* 定时生成传播路径
* 每天凌晨0点10分执行一次
*/
// @Scheduled(cron = "0 0 0 * * ?")
// @Scheduled(cron = "0 * * * * ?")
@Scheduled(cron = "0 0 0 * * ?")
public void propagationPath() {
Date today = new Date();
Date deadlineDate = DateUtil.addDate(today, -1);
......@@ -226,43 +224,4 @@ public class AnalysisTask {
log.info("专题id为-{}-的专题-传播路径数据-缓存成功!", subjectId);
}
}
//
// /**
// * 定时生成统计分析数据-最近两周(按最新时间)
// * 每天凌晨1点执行一次
// */
// @Scheduled(cron = "0 0 1 * * ?")
// public void tw_statisticAnalysis() {
// Date today = new Date();
// Date deadlineDate = DateUtil.addDate(today, -1);
// List<SubjectKafkaVo> subjects = eventService.eventSubjectList();
// for (SubjectKafkaVo subject : subjects) {
// String subjectId = subject.getId();
// List<SubjectDataVo> dataVoList = esService.getDataBySubjectId(subjectId, null, null, "0", Constant.FETCH_FIELDS_STATISTIC, 2, null, null);
// if (CollectionUtils.isNotEmpty(dataVoList)) {
// String key = Constants.SUBJECT_ANALYSIS_PRE + Constants.TW_STATISTIC_ANALYSIS_KEY + subjectId;
// Date timeDisable = subject.getTimeDisable();
// String latelyTime = EsDateUtil.esFieldDateMapping(dataVoList.get(0).getPublishDate());
// String twoWeekBeforeTime = DateUtil.getDayBeforeOrAfter(latelyTime, -14);
// //已经结束的事件专题,永久缓存
// if (timeDisable != null && deadlineDate.compareTo(timeDisable) > 0) {
// Object cacheObject = redisUtil.get(key);
// if (cacheObject == null) {
// List<StatisticAnalysisVo> statisticAnalysisVos = analysisService.statisticAnalysis(subjectId, twoWeekBeforeTime, latelyTime);
// if (CollectionUtils.isNotEmpty(statisticAnalysisVos)) {
// redisUtil.set(key, statisticAnalysisVos);
// }
// }
// } else { //已经结束的事件专题,缓存有效期一天
// List<StatisticAnalysisVo> statisticAnalysisVos = analysisService.statisticAnalysis(subjectId, twoWeekBeforeTime, latelyTime);
// if (CollectionUtils.isNotEmpty(statisticAnalysisVos)) {
// redisUtil.set(key, statisticAnalysisVos,3600*24);
// }
// }
// log.info("专题id为-{}-的专题-统计分析数据-最近两周-分析成功!", subjectId);
// }
// }
// }
}
package com.zzsn.event.task;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.Event;
import com.zzsn.event.service.EsStatisticsService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* todo
*
* @author lkg
* @date 2024/4/10
*/
@Slf4j
@Component
public class EventHotTask {
@Autowired
private IEventService eventService;
@Autowired
private EsStatisticsService esStatisticsService;
@Autowired
private RedisUtil redisUtil;
@Value("${scoreRule.weekScore}")
Integer weekScore;
@Value("${scoreRule.monthScore}")
Integer monthScore;
@Value("${scoreRule.yearScore}")
Integer yearScore;
@Value("${scoreRule.beforeYearScore}")
Integer beforeYearScore;
/**
* 专题热度计算
* 每三个小时执行一次
*
* @author lkg
* @date 2024/4/10
*/
@Scheduled(cron = "0 0 0/3 * * ?")
public void hot() {
List<Event> list = eventService.list();
for (Event event : list) {
CompletableFuture.runAsync(() -> {
String id = event.getId();
//total
Integer totalScore = computeScore(id);
Integer totalHot = getHot(Constants.MAX_TOTAL_HOT_SCORE + "::" + id, totalScore);
event.setTotalHot(totalHot);
/*//media
Integer mediaScore = 0;
Integer mediaHot = getHot(Constants.MAX_MEDIA_HOT_SCORE + "::" + id, mediaScore);
//wechat
Integer wechatScore = 0;
Integer wechatHot = getHot(Constants.MAX_WECHAT_HOT_SCORE + "::" + id, wechatScore);
//others
Integer otherScore = 0;
Integer otherHot = getHot(Constants.MAX_OTHER_HOT_SCORE + "::" + id, otherScore);
event.setMediaHot(mediaHot);
event.setWechatHot(wechatHot);
event.setOtherHot(otherHot);*/
eventService.updateById(event);
log.info("专题-{}-热度计算完成", event.getEventName());
});
}
}
private Integer getHot(String key, Integer score) {
Object total = redisUtil.get(key);
if (null != total) {
Integer maxTotalScore = (Integer) total;
if (score > maxTotalScore) {
redisUtil.set(key, score);
return 100;
} else {
return score / maxTotalScore * 100;
}
} else {
redisUtil.set(key, score);
return 100;
}
}
/**
* 计算热度
*
* @param eventId 事件id
*/
private int computeScore(String eventId) {
Date date = new Date();
DateTime beforeWeekDay = DateUtil.offsetWeek(date, -1);
DateTime beforeMonthDay = DateUtil.offsetMonth(date, -1);
DateTime beforeYearDay = DateUtil.offset(date, DateField.YEAR, -1);
List<String> ids = new ArrayList<>();
ids.add(eventId);
// 一周之内
long weekCount = esStatisticsService.totalCount(ids, DateUtil.formatDateTime(beforeWeekDay), DateUtil.formatDateTime(date));
// 一周到一月之内
long monthCount = esStatisticsService.totalCount(ids, DateUtil.formatDateTime(beforeMonthDay), DateUtil.formatDateTime(beforeWeekDay));
// 一月到一年之内
long yearInCount = esStatisticsService.totalCount(ids, DateUtil.formatDateTime(beforeYearDay), DateUtil.formatDateTime(beforeMonthDay));
// 一年之外
long yearOutCount = esStatisticsService.totalCount(ids, null, DateUtil.formatDateTime(beforeYearDay));
return (int) (weekCount * weekScore + monthCount * monthScore + yearInCount * yearScore + yearOutCount * beforeYearScore);
}
}
......@@ -133,6 +133,29 @@ public class CalculateUtil {
}
/**
* 除法-控制精度
* @param param1 参数1
* @param param2 参数2
* @param num 精确到小数点后几位
* @return java.lang.String
*/
public static String divide(String param1,String param2,int num,RoundingMode roundingMode){
if(StringUtils.isNotEmpty(param1)&& StringUtils.isNotEmpty(param2)){
if (!list.contains(param1) && !list.contains(param2) ){
BigDecimal bd2 = new BigDecimal(param2);
if (bd2.compareTo(BigDecimal.ZERO)==0){
return null;
}else {
BigDecimal bd1 = new BigDecimal(param1);
BigDecimal divide = bd1.divide(bd2,num, roundingMode);
return divide.toString();
}
}
}
return null;
}
/**
* 转换百分比
* @param param 参数1
* @return java.lang.String
......
package com.zzsn.event.util;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CommonUtils {
/**
* 判断文件名是否带盘符,重新处理
* @param fileName
* @return
*/
public static String getFileName(String fileName){
//判断是否带有盘符信息
// Check for Unix-style path
int unixSep = fileName.lastIndexOf('/');
// Check for Windows-style path
int winSep = fileName.lastIndexOf('\\');
// Cut off at latest possible point
int pos = (winSep > unixSep ? winSep : unixSep);
if (pos != -1) {
// Any sort of path separator found...
fileName = fileName.substring(pos + 1);
}
//替换上传文件名字的特殊字符
fileName = fileName.replace("=","").replace(",","").replace("&","").replace("#", "");
//替换上传文件名字中的空格
fileName=fileName.replaceAll("\\s","");
return fileName;
}
}
\ No newline at end of file
package com.zzsn.event.util;
import com.zzsn.event.constant.ErrorCodeEnum;
/**
* 文档异常封装类
* @author zhangcx
*/
public final class DocumentException extends RuntimeException {
private ErrorCodeEnum errorCode;
public DocumentException(ErrorCodeEnum errorCode) {
super(errorCode.getMsg());
this.errorCode = errorCode;
}
public DocumentException(ErrorCodeEnum errorCode, Throwable t) {
super(errorCode.getMsg(), t);
this.errorCode = errorCode;
}
public ErrorCodeEnum getErrorCode() {
return errorCode;
}
}
......@@ -905,13 +905,14 @@ public class EsOpUtil<T> {
* @param id 资讯id
*/
public Map<String, Object> searchDoc(String index, String id) {
Map<String, Object> map = new HashMap<>();
try {
GetRequest searchRequest = new GetRequest(index, id);
GetResponse documentFields = client.get(searchRequest, RequestOptions.DEFAULT);
return documentFields.getSourceAsMap();
map = documentFields.getSourceAsMap();
} catch (IOException e) {
log.warn("查询doc异常,index=[{}],id=[{}], ex=[{}]", index, id, e.getMessage());
}
return null;
return map;
}
}
package com.zzsn.event.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.io.ClassPathResource;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
/**
* @author 闫鑫
* @date 2022/6/21 12:01
*/
@Slf4j
public class FileUtil {
/**
* @Description: 读取resources 目录下的文件
* @param filePath 相对路径
* @Return: 文件实际地址
**/
public static String getFilePath(String filePath){
return Thread.currentThread().getContextClassLoader().getResource(filePath).getPath();
}
/**
* 读取classpath路径下的文本文件,返回list
* @param filePath
* @return
* @throws IOException
*/
public static List<String> readFileList(String filePath){
List<String> list = new ArrayList<>();
InputStream inputStream = null;
InputStreamReader inputStreamReader = null;
BufferedReader bufferedReader = null;
try {
// ClassPathResource类的构造方法接收路径名称,自动去classpath路径下找文件
ClassPathResource classPathResource = new ClassPathResource(filePath);
// 打成jar包后,只能获取输入流对象
inputStream = classPathResource.getInputStream();
inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
bufferedReader = new BufferedReader(inputStreamReader);
String line = null;
while ((line = bufferedReader.readLine()) != null) {
if(oConvertUtils.isNotEmpty(line)){
list.add(line);
}
}
}catch (IOException e){
log.error("读取文件失败,filePath:{},e:{}",filePath,e);
}finally {
// 统一在finally中关闭流,防止发生异常的情况下,文件流未能正常关闭
try {
if (inputStream != null) {
inputStream.close();
}
if (inputStreamReader != null) {
inputStreamReader.close();
}
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return list;
}
public static InputStream DownloadFileFormServer(String strUrl) {
InputStream inputStream = null;
HttpURLConnection conn = null;
try {
URL url = new URL(strUrl);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(20 * 1000);
// 模板文件名
// 模板文件路径
inputStream = conn.getInputStream();
} catch (Exception e) {
} finally {
}
return inputStream;
}
/**
* 获取resource下的文件内容
*
* @param path
* @return
*/
public static String getResource(String path) throws IOException {
if (StringUtils.isBlank(path)) {
return null;
}
ClassPathResource classPathResource = new ClassPathResource(path);
StringBuilder stringBuilder = new StringBuilder();
InputStream inputStream =null;
try {
inputStream = classPathResource.getInputStream();
byte[] bytes = new byte[1024];
int lenth;
while ((lenth = inputStream.read(bytes)) != -1) {
stringBuilder.append(new String(bytes, 0, lenth));
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("读取文件错误");
}finally {
inputStream.close();
}
return stringBuilder.toString();
}
public static String getFileNameFormPath(String fileName){
if(fileName == null || StringUtils.isEmpty(fileName)){
return null;
}
fileName = fileName.trim();
fileName = fileName.replace("\\", "/");
while(fileName.endsWith("/")){
fileName = fileName.substring(0, fileName.length() -1);
}
if(fileName.contains("/")){
fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
}
return fileName;
}
/**
* 根据文件的字节大小计算显示大小
*
* @param size
* @return
*/
public static String readableFileSize(long size) {
if (size <= 0) return "0";
final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + units[digitGroups];
}
}
package com.zzsn.event.util;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* 在线程的run方法中使用注解@autoware注入的bean,会报空指针异常,原因是因为线程中为了线程安全,防注入。
* 获取bean实例的工具类组件
*/
@Component
public class GetBeanUtil implements ApplicationContextAware {
//Spring应用上下文环境
private static ApplicationContext applicationContext;
/**
* 实现ApplicationContextAware接口的回调方法,设置上下文环境
*/
public void setApplicationContext(ApplicationContext context) {
GetBeanUtil.applicationContext = context;
}
/**
* 获取对象 这里重写了bean方法,起主要作用
*/
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
}
package com.zzsn.event.util;
import java.security.MessageDigest;
public class MD5Util {
private static String byteArrayToHexString(byte[] b) {
StringBuilder resultSb = new StringBuilder();
for (byte value : b) {
resultSb.append(byteToHexString(value));
}
return resultSb.toString();
}
private static String byteToHexString(byte b) {
int n = b;
if (n < 0) {
n += 256;
}
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
public static String MD5Encode(String origin, String charsetName) {
String resultString = null;
try {
resultString = origin;
MessageDigest md = MessageDigest.getInstance("MD5");
if (charsetName == null || "".equals(charsetName)) {
resultString = byteArrayToHexString(md.digest(resultString.getBytes()));
} else {
resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetName)));
}
} catch (Exception e) {
e.printStackTrace();
}
return resultString;
}
private static final String[] hexDigits = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
}
package com.zzsn.event.util;
import com.zzsn.event.vo.PropagationPathVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
......
package com.zzsn.event.util;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.*;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.Map;
/**
* 调用 Restful 接口 Util
*
* @author sunjianlei
*/
@Slf4j
public class RestUtil {
private static String domain = null;
public static String path = null;
public static String getPath() {
if (path == null) {
path = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path");
}
return oConvertUtils.getString(path);
}
/**
* RestAPI 调用器
*/
private final static RestTemplate RT;
static {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(100000);
requestFactory.setReadTimeout(100000);
RT = new RestTemplate(requestFactory);
RT.getMessageConverters().add(new XmMappingJackson2HttpMessageConverter());
// 解决乱码问题
RT.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
}
public static RestTemplate getRestTemplate() {
return RT;
}
/**
* 发送 get 请求
*/
public static JSONObject get(String url) {
return getNative(url, null, null).getBody();
}
/**
* 发送 get 请求
*/
public static JSONObject get(String url, JSONObject variables) {
return getNative(url, variables, null).getBody();
}
/**
* 发送 get 请求
*/
public static JSONObject get(String url, JSONObject variables, JSONObject params) {
return getNative(url, variables, params).getBody();
}
/**
* 发送 get 请求,返回原生 ResponseEntity 对象
*/
public static ResponseEntity<JSONObject> getNative(String url, JSONObject variables, JSONObject params) {
return request(url, HttpMethod.GET, variables, params);
}
/**
* 发送 Post 请求
*/
public static JSONObject post(String url) {
return postNative(url, null, null).getBody();
}
/**
* 发送 Post 请求
*/
public static JSONObject post(String url, JSONObject params) {
return postNative(url, null, params).getBody();
}
/**
* 发送 Post 请求
*/
public static JSONObject post(String url, JSONObject variables, JSONObject params) {
return postNative(url, variables, params).getBody();
}
/**
* 发送 POST 请求,返回原生 ResponseEntity 对象
*/
public static ResponseEntity<JSONObject> postNative(String url, JSONObject variables, JSONObject params) {
return request(url, HttpMethod.POST, variables, params);
}
/**
* 发送 put 请求
*/
public static JSONObject put(String url) {
return putNative(url, null, null).getBody();
}
/**
* 发送 put 请求
*/
public static JSONObject put(String url, JSONObject params) {
return putNative(url, null, params).getBody();
}
/**
* 发送 put 请求
*/
public static JSONObject put(String url, JSONObject variables, JSONObject params) {
return putNative(url, variables, params).getBody();
}
/**
* 发送 put 请求,返回原生 ResponseEntity 对象
*/
public static ResponseEntity<JSONObject> putNative(String url, JSONObject variables, JSONObject params) {
return request(url, HttpMethod.PUT, variables, params);
}
/**
* 发送 delete 请求
*/
public static JSONObject delete(String url) {
return deleteNative(url, null, null).getBody();
}
/**
* 发送 delete 请求
*/
public static JSONObject delete(String url, JSONObject variables, JSONObject params) {
return deleteNative(url, variables, params).getBody();
}
/**
* 发送 delete 请求,返回原生 ResponseEntity 对象
*/
public static ResponseEntity<JSONObject> deleteNative(String url, JSONObject variables, JSONObject params) {
return request(url, HttpMethod.DELETE, null, variables, params, JSONObject.class);
}
/**
* 发送请求
*/
public static ResponseEntity<JSONObject> request(String url, HttpMethod method, JSONObject variables, JSONObject params) {
return request(url, method, getHeaderApplicationJson(), variables, params, JSONObject.class);
}
/**
* 发送请求
*
* @param url 请求地址
* @param method 请求方式
* @param headers 请求头 可空
* @param variables 请求url参数 可空
* @param params 请求body参数 可空
* @param responseType 返回类型
* @return ResponseEntity<responseType>
*/
public static <T> ResponseEntity<T> request(String url, HttpMethod method, HttpHeaders headers, JSONObject variables, Object params, Class<T> responseType) {
if (StringUtils.isEmpty(url)) {
throw new RuntimeException("url 不能为空");
}
if (method == null) {
throw new RuntimeException("method 不能为空");
}
if (headers == null) {
headers = new HttpHeaders();
}
// 请求体
String body = "";
if (params != null) {
if (params instanceof JSONObject) {
body = ((JSONObject) params).toJSONString();
} else {
body = params.toString();
}
}
// 拼接 url 参数
if (variables != null && variables.size() > 0) {
url += ("?" + asUrlVariables(variables));
}
// 发送请求
HttpEntity<String> request = new HttpEntity<>(body, headers);
return RT.exchange(url, method, request, responseType);
}
/**
* 获取JSON请求头
*/
public static HttpHeaders getHeaderApplicationJson() {
return getHeader(MediaType.APPLICATION_JSON_UTF8_VALUE);
}
/**
* 获取请求头
*/
public static HttpHeaders getHeader(String mediaType) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType(mediaType));
headers.add("Accept", mediaType);
return headers;
}
/**
* 将 JSONObject 转为 a=1&b=2&c=3...&n=n 的形式
*/
public static String asUrlVariables(JSONObject variables) {
Map<String, Object> source = variables.getInnerMap();
Iterator<String> it = source.keySet().iterator();
StringBuilder urlVariables = new StringBuilder();
while (it.hasNext()) {
String key = it.next();
String value = "";
Object object = source.get(key);
if (object != null) {
if (!StringUtils.isEmpty(object.toString())) {
value = object.toString();
}
}
urlVariables.append("&").append(key).append("=").append(value);
}
// 去掉第一个&
return urlVariables.substring(1);
}
}
......@@ -16,26 +16,19 @@ public class SortUtil {
public static List<Map.Entry<String, Integer>> sortMap(Map<String,Integer> map){
if(map!=null){
List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
Collections.sort(list,new Comparator<Map.Entry<String, Integer>>() {
@Override
public int compare(Map.Entry<String, Integer> o1,
Map.Entry<String, Integer> o2) {
return o2.getValue() - o1.getValue();
}
});
list.sort((o1, o2) -> o2.getValue() - o1.getValue());
return list;
}
return new ArrayList<Map.Entry<String, Integer>>();
return new ArrayList<>();
}
public static int dateLg(String s1,String s2){
if(s1.equals(s2)){
return 0;
}
int temp = 0;
int temp;
if(s1.length()==10){
s1 = s1 +" 00:00:00";
}
if(s2.length()==10){
s2 = s2 +" 00:00:00";
......@@ -43,23 +36,11 @@ public class SortUtil {
try {
LocalDateTime localDateTime1 = LocalDateTime.parse(s1, dtf2);
LocalDateTime localDateTime2 = LocalDateTime.parse(s2, dtf2);
if(localDateTime1.isEqual(localDateTime2)){
temp = 0;
}
temp = localDateTime1.isBefore(localDateTime2)==true? 1:-1;
StringBuilder sb = new StringBuilder();
sb.append("s1对比s2").append(s1).append(":").append(s2).append("返回结果").append(temp);
temp = localDateTime1.isBefore(localDateTime2) ? 1:-1;
return temp;
}catch (Exception e){
e.printStackTrace();
return -1;
}
}
public static void main(String[] args) {
String s1= "2020-10-22" ;
String s2= "2020-10-23";
System.out.println(s1.length());
System.out.println(dateLg(s1, s2));
}
}
package com.zzsn.event.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
@Component
public class SpringContextUtils implements ApplicationContextAware {
/**
* 上下文对象实例
*/
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
applicationContext = applicationContext;
}
/**
* 获取applicationContext
*
* @return
*/
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
/**
* 获取HttpServletRequest
*/
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
public static String getOrigin(){
HttpServletRequest request = getHttpServletRequest();
return request.getHeader("Origin");
}
/**
* 通过name获取 Bean.
*
* @param name
* @return
*/
public static Object getBean(String name) {
return getApplicationContext().getBean(name);
}
/**
* 通过class获取Bean.
*
* @param clazz
* @param <T>
* @return
*/
public static <T> T getBean(Class<T> clazz) {
return getApplicationContext().getBean(clazz);
}
/**
* 通过name,以及Clazz返回指定的Bean
*
* @param name
* @param clazz
* @param <T>
* @return
*/
public static <T> T getBean(String name, Class<T> clazz) {
return getApplicationContext().getBean(name, clazz);
}
}
package com.zzsn.event.util;
import com.hankcs.hanlp.collection.trie.DoubleArrayTrie;
import java.util.Collection;
import java.util.Iterator;
import java.util.TreeMap;
/**
* @author kongliufeng
* @Description TODO:
* @create 2020-09-03 16:30
* @Version 1.0
*/
public class StopWordsUtil {
private static final String path = "hanlp/cloudstopwords.txt";
private static DoubleArrayTrie<String> tree;
static {
TreeMap<String, String> map = new TreeMap<>();
for (String word : FileUtil.readFileList(path)) {
map.put(word,word);
}
tree = new DoubleArrayTrie<>(map);
}
/**
* @Description 判断一个词是否为停用词
* @author kongliufeng
* @创建时间 2020/9/3 17:08
* @Version 1.0
*/
public static Boolean isStopWord(String word){
if(tree.containsKey(word)){
return true;
}
return false;
}
/**
* @Description 对已有的集合移除停用词
* @author kongliufeng
* @创建时间 2020/9/3 17:11
* @Version 1.0
*/
public static void removeStopWords(Collection<String> collection, String excludeWord){
if(collection!=null){
Iterator<String> iterator = collection.iterator();
while (iterator.hasNext()){
String next = iterator.next();
if(excludeWord!=null){
if(excludeWord.equals(next)){
iterator.remove();
}
}
if(tree.containsKey(next))
iterator.remove();
}
}
}
public static void removeStopWords(Collection<String> collection){
if(collection!=null){
Iterator<String> iterator = collection.iterator();
while (iterator.hasNext()){
if(tree.containsKey(iterator.next()))
iterator.remove();
}
}
}
}
package com.zzsn.event.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
/**
* 文件上传字符串过滤特殊字符
*/
public class StrAttackFilter {
public static String filter(String str) throws PatternSyntaxException {
// 清除掉所有特殊字符
String regEx = "[`_《》~!@#$%^&*()+=|{}':;',\\[\\].<>?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
return m.replaceAll("").trim();
}
// public static void main(String[] args) {
// String filter = filter("@#jeecg/《》【bo】¥%……&*(o))))!@t<>,.,/?'\'~~`");
// System.out.println(filter);
// }
}
package com.zzsn.event.util;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author lkg
* @date 2023/5/27
*/
public class XmMappingJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter {
public XmMappingJackson2HttpMessageConverter() {
List<MediaType> mediaTypeList = new ArrayList<>();
mediaTypeList.add(MediaType.TEXT_HTML);
setSupportedMediaTypes(mediaTypeList);
}
}
package com.zzsn.event.vo;
package com.zzsn.event.util.tree;
import lombok.Data;
......@@ -6,13 +6,15 @@ import java.util.List;
/**
* @author lkg
* @description: 旧专题响应数据封装类-统计分析数据
* @date 2022/7/29 14:59
* @description: 树形节点
* @date 2021/12/15 14:11
*/
@Data
public class StatisticAnalysisVo {
public class Node {
private String id;
private String name;
private String key;
private Integer num;
List<StatisticAnalysisVo> list;
private String pid;
private String topId;
private Integer hasChild;
private List<? extends Node> children;
}
package com.zzsn.event.util.tree;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author lkg
* @description: 构造树形结构工具类
* @date 2021/12/15 14:18
*/
public class TreeUtil {
/**
* 单个树
*
* @param list 数据集合
* @param node 根节点数据
* @author lkg
* @date 2021/12/17 16:33
*/
public static <T extends Node> void tree(List<T> list, T node) {
String id = node.getId();
List<T> tree = tree(list, id);
node.setChildren(tree);
}
/**
* 树 集合
*
* @param list 数据集合
* @param rootId 根节点id
* @author lkg
* @date 2021/12/17 16:33
*/
public static <T extends Node> List<T> tree(List<T> list, String rootId) {
Map<String, List<T>> treeMap = new HashMap<>();
for (T item : list) {
String parentId = item.getPid();
List<T> children;
if (treeMap.containsKey(parentId)) {
children = treeMap.get(parentId);
} else {
children = new ArrayList<>();
treeMap.put(parentId, children);
}
children.add(item);
}
return getTreeByMap(treeMap, rootId);
}
/**
* 根据当前节点获取所有上级节点
*
* @param list 数据集合
* @param currentNode 当前节点
* @param flag 是否包含自己本身(true-是;false-否)
* @author lkg
* @date 2022/12/27 11:32
*/
public static <T extends Node> LinkedHashSet<T> getUpList(List<T> list, T currentNode, boolean flag) {
if (ObjectUtils.isNotEmpty(currentNode)) {
LinkedHashSet<T> treeSet = new LinkedHashSet<>();
if (flag) {
treeSet.add(currentNode);
}
String pid = currentNode.getPid();
List<T> parentNodes = list.stream().filter(node -> node.getId().equals(pid)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(parentNodes)) {
T parentNode = parentNodes.get(0);
treeSet.add(parentNode);
LinkedHashSet<T> upTreeSet = getUpList(list, parentNode, flag);
if (CollectionUtils.isNotEmpty(upTreeSet)) {
treeSet.addAll(upTreeSet);
}
}
return treeSet;
}
return null;
}
/**
* 获取某节点下所有节点id得集合
*
* @param list: 数据集合
* @param rootId: 节点id
* @param flag: 是否包含自己本身(true-是;false-否)
* @author lkg
* @date 2023/2/23
*/
public static <T extends Node> List<String> belowList(List<T> list, String rootId, boolean flag) {
List<String> nodes = new ArrayList<>();
if (flag) {
nodes.add(rootId);
}
Map<String, List<T>> treeMap = new HashMap<>();
for (T item : list) {
String parentId = item.getPid();
List<T> children;
if (treeMap.containsKey(parentId)) {
children = treeMap.get(parentId);
} else {
children = new ArrayList<>();
treeMap.put(parentId, children);
}
children.add(item);
}
getBelowList(treeMap, rootId, nodes);
return nodes;
}
private static <T extends Node> List<T> getBelowList(Map<String, List<T>> treeMap, String parentId, List<String> belowList) {
List<T> children = treeMap.get(parentId);
if (children == null) {
return null;
}
for (T item : children) {
belowList.add(item.getId());
item.setChildren(getBelowList(treeMap, item.getId(), belowList));
}
return children;
}
private static <T extends Node> List<T> getTreeByMap(Map<String, List<T>> treeMap, String parentId) {
List<T> children = treeMap.get(parentId);
if (children == null) {
return null;
}
for (Node item : children) {
item.setChildren(getTreeByMap(treeMap, item.getId()));
}
return children;
}
}
......@@ -3,6 +3,8 @@ package com.zzsn.event.vo;
import com.zzsn.event.entity.Event;
import lombok.Data;
import java.util.List;
@Data
public class AddEventParam extends Event {
private String corn;
......@@ -10,4 +12,6 @@ public class AddEventParam extends Event {
private Integer extractHotWords;
// time unit minute
private Integer period;
private List<RegionVO> regionList;
}
package com.zzsn.event.vo;
import lombok.Data;
import java.util.List;
@Data
public class DisplayInfo {
//说明:...Raw 表示原文,即原语言
//作者
private String author;
private String authorRaw;
//正文
private String content;
private String contentRaw;
//带标签正文
private String contentWithTag;
private String contentWithTagRaw;
//入库时间
private String createDate;
//信息id
private String id;
//信息来源id(信息源或者关键词)
private String sid;
//语言
private String lang;
private String langRaw;
//来源(信息来源)
private String origin;
private String originRaw;
//发布时间
private String publishDate;
//原始时间(网页上,没有解析之前的时间)
private String originalTime;
//发布地址
private String sourceAddress;
//摘要
private String summary;
private String summaryRaw;
//关键词
private String keyWords;
//标题
private String title;
private String titleRaw;
//采集来源(如通用、定制、微信公众号等)
private String source;
//附加字段
private String type;
//标签信息
private List<Label> labels;
//视频下载链接
private String downLoadUrl;
//视频链接(原链接 网页版)
private String videoUrl;
//视频链接(原链接 手机版)
private String videoPhoneUrl;
//视频时长
private Long videoTime;
//视频第一帧图片
private String videoImg;
//自定义标签
private List<String> customLabel;
private Double score;
//专题库类型(0: 其它 1:政策;2:领导讲话;3:专家观点;4:企业案例)
private Integer classificationType;
//置顶排位(默认为0)
private Integer topNum;
//删除标记(1:删除;0:保留)
private Integer deleteFlag;
private String subjectId;
//审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0)
private Integer checkStatus;
//阅读数
private Long readNum = 0L;
//是否收藏
private boolean ynCollect = false;
//重复id
private String repeatId;
//(1:主条目 0:非主条目)
private String flag;
//关联的主条目id
private String masterEntryId;
//原始id(去重服务生成的id,因为一条信息可以属于多个专题,原始id会发生改变,所以存储一个原始id,找寻对应关系)
private String originalId;
//快照地址
private String screenShotImg;
//资讯更新时间
private String updateDate;
//信息类别(1:报刊 2:博客 3:客户端 4:论坛 5:视频 6:外媒 7:网站 8:微博 9:微信 10:新闻 11:政务 12:其它)
private String infoSourceType;
//数据类型 qbyw:情报要闻 qbnc:情报内参
private String dataType;
//abi报表地址
private String abiUrl;
//abi报表id
private String abiId;
//栏目code列表
private List<String> programaIds;
//数据库code列表
private List<String> databaseIds;
//是否风险
private Integer isRisk;
//风险类型
private List<String> riskTypes;
//资讯关联的附件id
private List<String> attachmentIds;
//是否为资讯(true:资讯 false:附件类)
private Boolean ynArticle = true;
//法规号
private String contentNo;
//来源 (政策发文机关)
private String organ;
//政策文件分类
private String topicClassification;
//发文字号
private String issuedNumber;
//成文时间
private String writtenDate;
//数据所在的索引名称
private String index;
/**
* 是否是主条目,0为非主条目,1为主条目
*/
private Integer ismain;
private Integer similarNumber;
}
package com.zzsn.event.vo;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/4/10
*/
@Data
public class EventExcelVO {
private String id;
private String eventName;
private String eventDescribe;
private String publishDate;
private Integer totalHot;
public List<String> toList(){
List<String> list = new ArrayList<>();
if (StringUtils.isEmpty(id)) {
list.add("");
} else {
list.add(id);
}
if (StringUtils.isEmpty(eventName)) {
list.add("");
} else {
list.add(eventName);
}
if (StringUtils.isEmpty(eventDescribe)) {
list.add("");
} else {
list.add(eventDescribe);
}
if (StringUtils.isEmpty(publishDate)) {
list.add("");
} else {
list.add(publishDate);
}
if (totalHot == null) {
list.add("");
} else {
list.add(totalHot.toString());
}
return list;
}
}
package com.zzsn.event.vo;
import lombok.Data;
/**
*
*
* @author lkg
* @date 2024/4/8
*/
@Data
public class EventFrontVO {
private String id;
private String eventIcon;
private String eventName;
private String startTime;
private String endTime;
private String firstOrigin;
private String eventDescribe;
private String eventLabel;
private String publishDate;
private Integer totalHot;
private String extractIndustryTag;
private String extractCompanyTag;
private String extractPersonTag;
private String extractSentimentTag;
private String extractKeywordsTag;
private String extractLocationTag;
private String extractTimeTag;
}
package com.zzsn.event.vo;
import lombok.Data;
/**
*
*
* @author lkg
* @date 2024/4/8
*/
@Data
public class EventManageVO {
private String id;
private String eventIcon;
private String eventName;
private String eventType;
private String eventLabel;
private Integer facePublic;
private Integer publishStatus;
private String createTime;
private String publishDate;
private String startTime;
private String endTime;
}
......@@ -3,14 +3,15 @@ package com.zzsn.event.vo;
import lombok.Data;
/**
* 报告所属栏目信息封装
*
*
* @author lkg
* @date 2023/9/21
* @date 2024/4/10
*/
@Data
public class ReportExtendVo {
public class EventRegionVO {
private String projectId;
private String columnId;
private String eventId;
private String eventName;
private String regionName;
}
......@@ -3,16 +3,18 @@ package com.zzsn.event.vo;
import lombok.Data;
/**
* 负面信息
* 时间雷达图数据封装
*
* @author lkg
* @date 2024/2/29
* @date 2024/4/8
*/
@Data
public class NegativeDataVO {
public class EventTopVO {
private String id;
private String title;
private String origin;
private String eventName;
private String publishDate;
private Integer totalHot;
private String typeName;
}
package com.zzsn.event.vo;
import lombok.Data;
import java.util.List;
/**
* 媒体分布统计
*
* @author lkg
* @date 2023/6/20
*/
@Data
public class MediaVO {
//媒体性质
private String name;
//数据量
private Long value;
//占比
private String percentage;
//媒体数量
private Long mediaNum;
//热门媒体
private List<String> hotList;
//媒体性质
private String key;
//数据量
private Long count;
//序号
private Integer order;
}
......@@ -3,17 +3,16 @@ package com.zzsn.event.vo;
import lombok.Data;
/**
* 报告资讯列表数据封装
*
*
* @author lkg
* @date 2023/3/29
* @date 2024/4/9
*/
@Data
public class ReportDataVo {
public class RegionVO {
private String title;
private String summary;
private String origin;
private String publishDate;
private String sourceAddress;
private String id;
private String topId;
private String regionName;
private Integer type;
}
......@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public class RepeatHold {
private String articleId;
private String subjectId;
private String repeatMark;
}
package com.zzsn.event.vo;
import lombok.Data;
import java.util.List;
@Data
public class SpecialInformation {
//的索引名
private String dbIndex;
//说明:...Raw 表示原文,即原语言
//作者
private String author;
private String authorRaw;
//正文
private String content;
private String contentRaw;
//带标签正文
private String contentWithTag;
private String contentWithTagRaw;
//入库时间
private String createDate;
//信息id
private String id;
//信息来源id(信息源或者关键词)
private String sid;
//信息源分类id
private String infoSourceNatureId;
//语言
private String lang;
private String langRaw;
//来源(信息来源)
private String origin;
private String originRaw;
//发布时间
private String publishDate;
//原始时间(网页上,没有解析之前的时间)
private String originalTime;
//发布地址
private String sourceAddress;
//摘要
private String summary;
private String summaryRaw;
//关键词
private String keyWords;
//标题
private String title;
private String titleRaw;
//采集来源(如通用、定制、微信公众号等)
private String source;
//附加字段
private String type;
//视频下载链接
private String downLoadUrl;
//视频链接(原链接 网页版)
private String videoUrl;
//视频链接(原链接 手机版)
private String videoPhoneUrl;
//视频时长
private Long videoTime;
//视频第一帧图片
private String videoImg;
//自定义标签
private List<String> customLabel;
private Double score;
//专题库类型(0: 其它 1:政策;2:领导讲话;3:专家观点;4:企业案例)
private Integer classificationType;
//置顶排位(默认为0)
private Integer topNum;
//删除标记(1:删除;0:保留)
private Integer deleteFlag;
private String subjectId;
private List<String> subjectIdList;
//审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0)
private Integer checkStatus;
//阅读数
private Long readNum = 0L;
//是否收藏
private boolean ynCollect = false;
//重复id
private String repeatId;
//(1:主条目 0:非主条目)
private String flag;
//关联的主条目id
private String masterEntryId;
//原始id(去重服务生成的id,因为一条信息可以属于多个专题,原始id会发生改变,所以存储一个原始id,找寻对应关系)
private String originalId;
//快照地址
private String screenShotImg;
//资讯更新时间
private String updateDate;
//信息类别(1:报刊 2:博客 3:客户端 4:论坛 5:视频 6:外媒 7:网站 8:微博 9:微信 10:新闻 11:政务 12:其它)
private String infoSourceType;
//舆情监测:yqjc、舆情预警:yqyj、舆情分析:yqfx、舆情报告:yqbg、竞争情报:jzqb、口碑监测:kbjc
private String dataType;
//资讯关联的附件id
private List<String> attachmentIds;
//数据入专题库时间
private String processDate;
//点赞数字
private Integer likesNum = 0;
//法规号
private String contentNo;
//用户id
private String userId;
//封面附件id
private String coverEnclosureId;
//封面图url地址
private String coverImgUrl;
//发布状态 checkStatus=1时生效(0/null:待发布 1:已发布 2:已下架 默认值为null)
private Integer publishStatus;
//关联附件id
private List<String> enclosureIds;
private String imgDisposeStatus;
/**公开方式 0会员 1公开*/
private Integer publishMethod=0;
/**栏目id*/
private List<String> columnIds;
/**抖音微博作品点赞数*/
private Integer likeNum;
/**抖音微博贴吧作品评论数*/
private Integer commentNum;
/**抖音收藏数*/
private Integer collectNum;
/**抖音微博 分享数*/
private Integer shareNum;
/**作品、帖子唯一标识*/
private String articleId;
/**作品、帖子唯一标识*/
private String index;
/**信息源类别id*/
private String infoSourceTypeId;
/**资讯是否包含图片,1:资讯包含图片 0:资讯不包含图片*/
private String isIncludeImg;
//关键词
private List<String> keyWordsList;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论