信号规则相关代码

This commit is contained in:
sunflower2014 2025-11-28 19:04:52 +08:00
parent dbe691ec67
commit 4aa1832301
26 changed files with 771 additions and 116 deletions

View File

@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {
"com.jinrui.reference.admin",
"com.jinrui.reference.core"
@ -16,7 +17,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class AdminApplication {
public static void main(String[] args) {
SpringApplication.run(AdminApplication.class, args);
}

View File

@ -1,10 +1,13 @@
package com.jinrui.reference.admin.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
@ -23,6 +26,8 @@ import com.jinrui.reference.admin.model.dto.news.PublishNewsDTO;
import com.jinrui.reference.admin.model.entity.AdminUser;
import com.jinrui.reference.admin.service.AdminJwtService;
import com.jinrui.reference.core.model.dto.news.SaveNewsDTO;
import com.jinrui.reference.core.model.entity.ListedCompany;
import com.jinrui.reference.core.model.entity.SignalRule;
import com.jinrui.reference.core.model.vo.PageObject;
import com.jinrui.reference.core.model.vo.ResultObject;
import com.jinrui.reference.core.model.vo.news.NewsDetailVO;
@ -30,6 +35,7 @@ import com.jinrui.reference.core.model.vo.news.NewsLogVO;
import com.jinrui.reference.core.model.vo.news.NewsScoreVO;
import com.jinrui.reference.core.model.vo.news.NewsTranslatorVO;
import com.jinrui.reference.core.model.vo.news.NewsVO;
import com.jinrui.reference.core.model.vo.news.SignalRuleVO;
import com.jinrui.reference.core.service.NewsService;
import redis.clients.jedis.Jedis;
@ -321,6 +327,10 @@ public class NewsController {
@RequestParam(value = "dateline_to", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date datelineTo,
@RequestParam(value = "deleted", required = false) Integer deleted,
@RequestParam(value = "rating", required = false) Byte rating,
@RequestParam(value = "exclusive", required = false) Integer exclusive,
@RequestParam(value = "includeRuleIds", required = false) String includeRuleIds,
@RequestParam(value = "excludeRuleIds", required = false) String excludeRuleIds,
@RequestParam(value = "companyName", required = false) String companyName,
@RequestParam(value = "range", required = false, defaultValue = "all") String range
) {
if (!StringUtils.hasText(token)) {
@ -356,7 +366,7 @@ public class NewsController {
}
isSecondReviewRange = true;
}
return newsService.queryNews(keyword, columnList, status, page, size, last, current, orderBy, minScore, maxScore, tag, industry, mediaId, datelineFrom, datelineTo, deleted, rating, isReviewRange, isSecondReviewRange);
return newsService.queryNews(keyword, columnList, status, page, size, last, current, orderBy, minScore, maxScore, tag, industry, mediaId, datelineFrom, datelineTo, deleted, rating, exclusive, isReviewRange, isSecondReviewRange, includeRuleIds, excludeRuleIds, companyName);
} catch (Exception e) {
log.error("解析登陆Token出错!", e);
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
@ -523,6 +533,24 @@ public class NewsController {
}
}
@GetMapping("/getSignalRulesList")
public ResultObject<List<SignalRuleVO>> getSignalRulesList() {
List<SignalRule> signalRules = newsService.getSignalRulesList();
List<SignalRuleVO> signalRulesList = new ArrayList<>(signalRules.size());
for (SignalRule signalRule: signalRules) {
SignalRuleVO signalRuleVO = new SignalRuleVO();
BeanUtils.copyProperties(signalRule, signalRuleVO);
signalRulesList.add(signalRuleVO);
}
return ResultObject.success(signalRulesList);
}
@GetMapping("/getCompanyNames")
public ResultObject<List<ListedCompany>> getCompanyNames(@Param("companyName") String companyName) {
List<ListedCompany> listedCompanyList = newsService.getAllListedCompany(companyName);
return ResultObject.success(listedCompanyList);
}
/**
*
* @param newsId

View File

@ -0,0 +1,54 @@
package com.jinrui.reference.admin.job;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.jinrui.reference.core.mapper.ListedCompanyMapper;
import com.jinrui.reference.core.mapper.NewsMapper;
import com.jinrui.reference.core.model.entity.ListedCompany;
import com.jinrui.reference.core.model.entity.News;
@Component
public class NewsCompanyCollectJob {
@Autowired
private ListedCompanyMapper listedCompanyMappr;
@Autowired
private NewsMapper newsMapper;
@Scheduled(fixedDelay=5, initialDelay=0, timeUnit = TimeUnit.MINUTES)
public void collectNewsCompany() {
ListedCompany listdCompany = listedCompanyMappr.getLastCollectedCompany();
List<News> newsList = newsMapper.getCompanyRelatedNews(listdCompany.getCollectTime());
for (News news: newsList) {
String companyNameStr = news.getCompanyName();
String[] companyNames = companyNameStr.split("[,|、|;]");
if (companyNames.length > 1) {
for (String companyName: companyNames) {
listedCompanyMappr.saveNewsCompany(companyName.trim(), news.getCreateTime());
}
continue;
}
if (companyNameStr.contains("")) {
String[] companyNames2 = companyNameStr.split("");
boolean existed = false;
for (String companyName:companyNames2) {
ListedCompany listedCompany = listedCompanyMappr.getByCompanyName(companyName);
if (listedCompany != null) {
existed = true;
}
}
if (existed) {
for (String companyName:companyNames2) {
listedCompanyMappr.saveNewsCompany(companyName.trim(), news.getCreateTime());
}
continue;
}
}
listedCompanyMappr.saveNewsCompany(companyNameStr.trim(), news.getCreateTime());
}
}
}

View File

@ -16,7 +16,6 @@ import com.jinrui.reference.core.service.NewsService;
@Component
public class NewsDeduplicationJob {
@Autowired
private NewsService newsService;
@Autowired

View File

@ -0,0 +1,39 @@
package com.jinrui.reference.admin.job;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.jinrui.reference.core.mapper.NewsMapper;
import com.jinrui.reference.core.mapper.NewsSignalRuleRelMapper;
import com.jinrui.reference.core.mapper.SignalRuleMapper;
import com.jinrui.reference.core.model.entity.News;
import com.jinrui.reference.core.model.entity.NewsSignalRuleRel;
import com.jinrui.reference.core.model.entity.SignalRule;
@Component
public class NewsSignalRuleCheckJob {
@Autowired
private NewsSignalRuleRelMapper newsSignalRuleRelMapper;
@Autowired
private SignalRuleMapper signalRuleMapper;
@Autowired
private NewsMapper newsMapper;
@Scheduled(fixedDelay=5, initialDelay=0, timeUnit = TimeUnit.MINUTES)
public void checkNewsSigalRule() {
List<SignalRule> signalRules = signalRuleMapper.queryAll();
NewsSignalRuleRel newsSignalRuleRel = newsSignalRuleRelMapper.getLastCheckedSignalRule();
for (SignalRule signalRule: signalRules) {
List<News> signalRuleNewsList = newsMapper.getSignalRuleNews(newsSignalRuleRel.getCheckTime(), signalRule.getRuleTrigger());
for (News news: signalRuleNewsList) {
newsSignalRuleRelMapper.saveNewsSignalRuleRel(news.getId(), signalRule.getId(), news.getCreateTime());
}
}
}
}

View File

@ -53,7 +53,7 @@ public class NewsTagsIndustryLabelRepairJob {
@Autowired
private NewsTagsMapper newsTagsMapper;
// @Scheduled(fixedDelay=15, initialDelay=0, timeUnit = TimeUnit.MINUTES)
@Scheduled(fixedDelay=15, initialDelay=0, timeUnit = TimeUnit.MINUTES)
public void startToRepair() {
List<Query> filters = new ArrayList<>();
filters.add(ExistsQuery.of(e -> e.field("news_tags.industry_label"))._toQuery());

View File

@ -59,7 +59,7 @@ public interface AdminUserMapper {
void delete(@Param("id") long id);
@Insert("<script>" +
"insert into admin_user(phone, password, userType, create_time, update_time" +
"insert into admin_user(phone, password, user_type, create_time, update_time" +
"<if test=\"name != null and !name.isEmpty()\">" +
", name" +
"</if>" +

View File

@ -1,6 +1,3 @@
logging:
level:
root: DEBUG
server:
port: 13579
compression:
@ -25,21 +22,21 @@ spring:
# url: jdbc:mysql://192.168.0.142:3306/reference?autoReconnect=true&useUnicode=true&useSSL=false&allowMultiQueries=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
# username: financial_prod
# password: mmTFncqmDal5HLRGY0BV
url: jdbc:mysql://121.37.185.246:3306/reference?autoReconnect=true&useUnicode=true&useSSL=false&allowMultiQueries=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: root
password: Xgf_8000
url: jdbc:mysql://10.127.2.207:3306/reference?autoReconnect=true&useUnicode=true&useSSL=false&allowMultiQueries=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: financial_prod
password: mmTFncqmDal5HLRGY0BV
redis:
# host: 192.168.0.172
# port: 6379
# password: Xgf_redis
host: 123.60.153.169
host: 10.127.2.209
port: 6379
password: Xgf_redis
password: dMrt4kmwiW6LDJXy
elasticsearch:
scheme: http
# 111.13.176.3 部署地址
# 10.127.2.194 本地测试地址
host: 111.13.176.3
host: 10.127.2.194
port: 9200
enable: true
username: elastic

View File

@ -0,0 +1,2 @@
ALTER TABLE `reference`.`news`
ADD COLUMN `exclusive` tinyint(2) DEFAULT '0';

View File

@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
@ -17,7 +18,7 @@ import com.jinrui.reference.core.model.entity.Industry;
import com.jinrui.reference.core.model.entity.NewsIndustryRel;
public interface IndustryMapper {
@Results({
@Results(id="industryMap", value = {
@Result(column = "id", property = "id", id = true),
@Result(column = "primary_name", property = "primaryName"),
@Result(column = "secondary_name", property = "secondaryName"),
@ -27,6 +28,20 @@ public interface IndustryMapper {
@Select("select * from industry order by primary_name")
List<Industry> queryAll();
@ResultMap("industryMap")
@Select("<script>" +
"select * from industry " +
"<where>" +
" <if test=\"ids != null and ids.size() > 0\"> " +
" id in " +
"<foreach collection=\"ids\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
" </if> " +
"</where>" +
"</script>")
List<Industry> getByIds(@Param("ids") List<Long> ids);
@Select("select id, draft_id as draftId, industry_id as industryId " +
"from draft_industry_rel where draft_id = #{draftId}")
List<DraftIndustryRel> getDraftIndustryRelList(@Param("draftId") Long draftId);
@ -77,14 +92,7 @@ public interface IndustryMapper {
@Insert("insert into news_industry_rel(news_id, industry_id) values (#{newsId}, #{industryId})")
void saveNewsIndustryRel(@Param("newsId") Long newsId, @Param("industryId") Long industryId);
@Results({
@Result(column = "id", property = "id", id = true),
@Result(column = "parent_id", property = "parentId"),
@Result(column = "primary_name", property = "primaryName"),
@Result(column = "secondary_name", property = "secondaryName"),
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)
})
@ResultMap("industryMap")
@Select("<script>" +
"select * from industry" +
"<where>" +

View File

@ -0,0 +1,44 @@
package com.jinrui.reference.core.mapper;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import com.jinrui.reference.core.model.entity.ListedCompany;
public interface ListedCompanyMapper {
@Results(id = "listedCompanyMap", value = {
@Result(column = "id", property = "id", id = true),
@Result(column = "company_name", property = "companyName"),
@Result(column = "collect_time", property = "collectTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)
})
@Select("<script>" +
"select * from listed_company " +
"<where>" +
"<if test=\"companyName != null\">" +
" and company_name like concat('%', #{companyName}, '%') " +
"</if>" +
"</where>" +
"</script>")
List<ListedCompany> queryAll(@Param("companyName") String companyName);
@ResultMap("listedCompanyMap")
@Select("select * from listed_company order by collect_time desc limit 1")
ListedCompany getLastCollectedCompany();
@ResultMap("listedCompanyMap")
@Select("select * from listed_company where company_name = #{companyName}")
ListedCompany getByCompanyName(@Param("companyName") String companyName);
@Insert("insert into listed_company(company_name, collect_time, create_time, update_time) values (#{companyName}, #{newsCreateTime}, now(), now()) on duplicate key update collect_time = #{newsCreateTime}, update_time = now()")
void saveNewsCompany(@Param("companyName") String companyName, @Param("newsCreateTime") Date newsCreateTime);
}

View File

@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;
import com.jinrui.reference.core.model.entity.News;
import com.jinrui.reference.core.model.entity.NewsDraft;
@ -39,6 +40,7 @@ public interface NewsMapper {
"update_time as updateTime, " +
"is_delete as deleted, " +
"rating, " +
"exclusive, " +
"revision, " +
"newsinfo_id as newsinfoId " +
"from news where id = #{id}")
@ -58,12 +60,13 @@ public interface NewsMapper {
"status = #{news.status}," +
"newsinfo_id = #{news.newsinfoId}," +
"rating = #{news.rating}," +
"exclusive = #{news.exclusive}," +
"revision = #{news.revision}," +
"update_time = now()" +
"where id = #{news.id} and status = #{oldStatus}")
int updateNews(News news, Integer oldStatus);
@Select("select id, draft_id as draftId, status, newsinfo_id as newsinfoId, is_delete as deleted, rating, revision from news where id = #{id}")
@Select("select id, draft_id as draftId, status, newsinfo_id as newsinfoId, is_delete as deleted, rating, exclusive, revision from news where id = #{id}")
News getById(@Param("id") Long id);
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@ -72,8 +75,8 @@ public interface NewsMapper {
void saveDraft(NewsDraft newsDraft);
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@Insert("insert into news(draft_id, title, summary, picture, type, content, create_time, update_time, status, publish_time, content_text, newsinfo_id, llm_title, llm_content, rating, overseas_event, overseas_macro, china_macro, industry_news, company_news, reprint_source, company_name)" +
"values (#{draftId}, #{title}, #{summary}, #{picture}, #{type}, #{content}, now(), now(), #{status}, #{publishTime}, #{contentText}, #{newsinfoId}, #{llmTitle}, #{llmContent}, #{rating}, #{overseasEvent}, #{overseasMacro}, #{chinaMacro}, #{industryNews}, #{companyNews}, #{reprintSource}, #{companyName})")
@Insert("insert into news(draft_id, title, summary, picture, type, content, create_time, update_time, status, publish_time, content_text, newsinfo_id, llm_title, llm_content, rating, exclusive, overseas_event, overseas_macro, china_macro, industry_news, company_news, reprint_source, company_name)" +
"values (#{draftId}, #{title}, #{summary}, #{picture}, #{type}, #{content}, now(), now(), #{status}, #{publishTime}, #{contentText}, #{newsinfoId}, #{llmTitle}, #{llmContent}, #{rating},#{exclusive}, #{overseasEvent}, #{overseasMacro}, #{chinaMacro}, #{industryNews}, #{companyNews}, #{reprintSource}, #{companyName})")
void saveNews(News news);
@Select("<script>" +
@ -87,24 +90,15 @@ public interface NewsMapper {
"news.update_time as updateTime, " +
"news.newsinfo_id as newsinfoId, " +
"news.is_delete as deleted, " +
"news.rating as rating, " +
"news_tags.news_score as score " +
"news.rating, " +
"news.exclusive, " +
"news.company_name as companyName," +
"news_tags.news_score as score, " +
"news_tags.source as sourceName " +
"from news " +
"<if test=\"column != null and !column.isEmpty()\">" +
"inner join news_column_rel on news.id = news_column_rel.news_id " +
"</if>" +
"<if test=\"tags != null and !tags.isEmpty()\">" +
" inner join news_tag_rel on news.id = news_tag_rel.news_id and tag_id in " +
"<foreach collection=\"tags\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
"</if>" +
"<if test=\"industries != null and !industries.isEmpty()\">" +
" inner join news_industry_rel on news.id = news_industry_rel.news_id and industry_id in " +
"<foreach collection=\"industries\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
"</if>" +
" left join news_tags on news.newsinfo_id = news_tags.newsinfo_id " +
"<where>" +
"<if test=\"tags != null and tags.isEmpty()\">" +
@ -140,6 +134,9 @@ public interface NewsMapper {
"<if test=\"rating != null\">" +
"and news.rating = #{rating} " +
"</if>" +
"<if test=\"exclusive != null\">" +
"and news.exclusive = #{exclusive} " +
"</if>" +
"<if test=\"last != null\">" +
"and news.id &gt; #{last}" +
"</if>" +
@ -149,6 +146,37 @@ public interface NewsMapper {
"<if test=\"isSecondReviewRange == true\">" +
"and news.status in (-1, 2, 3, 4) " +
"</if>" +
"<if test=\"tags != null and !tags.isEmpty()\">" +
"and exists (select 1 from news_tag_rel where news.id = news_tag_rel.news_id and tag_id in " +
"<foreach collection=\"tags\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
") " +
"</if>" +
"<if test=\"industries != null and !industries.isEmpty()\">" +
"and exists (select 1 from news_industry_rel where news.id = news_industry_rel.news_id and industry_id in " +
"<foreach collection=\"industries\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
") " +
"</if>" +
"<if test=\"includeRuleIds != null and !includeRuleIds.isEmpty()\">" +
"and exists (select 1 from news_signal_rule_rel where news.id = news_signal_rule_rel.news_id and signal_rule_id in " +
"<foreach collection=\"includeRuleIds\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
") " +
"</if>" +
"<if test=\"excludeRuleIds != null and !excludeRuleIds.isEmpty()\">" +
"and not exists (select 1 from news_signal_rule_rel where news.id = news_signal_rule_rel.news_id and signal_rule_id in " +
"<foreach collection=\"excludeRuleIds\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
") " +
"</if>" +
"<if test=\"companyName != null and companyName.trim().length() > 0\">" +
"and news.company_name like concat('%', #{companyName}, '%') " +
"</if>" +
"</where>" +
"<if test=\"orderBy != null\">" +
"order by ${orderBy} " +
@ -170,26 +198,18 @@ public interface NewsMapper {
@Param("datelineTo") Date datelineTo,
@Param("deleted") Integer deleted,
@Param("rating") Byte rating,
@Param("exclusive") Integer exclusive,
@Param("isReviewer") boolean isReviewer,
@Param("isSecondReviewRange") boolean isSecondReviewRange);
@Param("isSecondReviewRange") boolean isSecondReviewRange,
@Param("includeRuleIds") List<Long> includeRuleIds,
@Param("excludeRuleIds") List<Long> excludeRuleIds,
@Param("companyName") String companyName);
@Select("<script>" +
"select count(*) from (select distinct news.* from news " +
"select count(*) from news " +
"<if test=\"column != null and !column.isEmpty() \">" +
"inner join news_column_rel on news.id = news_column_rel.news_id " +
"</if>" +
"<if test=\"tags != null and !tags.isEmpty()\">" +
" inner join news_tag_rel on news.id = news_tag_rel.news_id and tag_id in " +
"<foreach collection=\"tags\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
"</if>" +
"<if test=\"industries != null and !industries.isEmpty()\">" +
" inner join news_industry_rel on news.id = news_industry_rel.news_id and industry_id in " +
"<foreach collection=\"industries\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
"</if>" +
"<if test=\"minScore != null or maxScore != null \">" +
"left join news_tags on news.newsinfo_id = news_tags.newsinfo_id " +
"</if>" +
@ -227,13 +247,47 @@ public interface NewsMapper {
"<if test=\"rating != null\">" +
"and news.rating = #{rating} " +
"</if>" +
"<if test=\"exclusive != null\">" +
"and news.exclusive = #{exclusive} " +
"</if>" +
"<if test=\"isReviewer == true\">" +
"and news.status in (-1, 2, 4) " +
"</if>" +
"<if test=\"isSecondReviewRange == true\">" +
"and news.status in (-1, 2, 3, 4) " +
"</if>" +
"</where>) tmp" +
"<if test=\"tags != null and !tags.isEmpty()\">" +
"and exists (select 1 from news_tag_rel where news.id = news_tag_rel.news_id and tag_id in " +
"<foreach collection=\"tags\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
") " +
"</if>" +
"<if test=\"industries != null and !industries.isEmpty()\">" +
"and exists (select 1 from news_industry_rel where news.id = news_industry_rel.news_id and industry_id in " +
"<foreach collection=\"industries\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
") " +
"</if>" +
"<if test=\"includeRuleIds != null and !includeRuleIds.isEmpty()\">" +
"and exists (select 1 from news_signal_rule_rel where news.id = news_signal_rule_rel.news_id and signal_rule_id in " +
"<foreach collection=\"includeRuleIds\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
") " +
"</if>" +
"<if test=\"excludeRuleIds != null and !excludeRuleIds.isEmpty()\">" +
"and not exists (select 1 from news_signal_rule_rel where news.id = news_signal_rule_rel.news_id and signal_rule_id in " +
"<foreach collection=\"excludeRuleIds\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
") " +
"</if>" +
"<if test=\"companyName != null and companyName.trim().length() > 0 \">" +
"and news.company_name like concat('%', #{companyName}, '%') " +
"</if>" +
"</where>" +
"</script>")
int queryTotal(@Param("keywords") List<String> keywords,
@Param("minScore") Double minScore,
@ -246,8 +300,12 @@ public interface NewsMapper {
@Param("datelineTo") Date datelineTo,
@Param("deleted") Integer deleted,
@Param("rating") Byte rating,
@Param("exclusive") Integer exclusive,
@Param("isReviewer") boolean isReviewer,
@Param("isSecondReviewRange") boolean isSecondReviewRange);
@Param("isSecondReviewRange") boolean isSecondReviewRange,
@Param("includeRuleIds") List<Long> includeRuleIds,
@Param("excludeRuleIds") List<Long> excludeRuleIds,
@Param("companyName") String companyName);
@Select("select id, llm_title as title, summary, picture, llm_content as content, status, " +
"create_time as createTime, " +
@ -320,4 +378,20 @@ public interface NewsMapper {
" limit ${limit}" +
"</script>")
List<NewsApiVO> queryNewsByApi(@Param("last") Long last, @Param("limit") int limit, @Param("clientType") int clientType);
@Results({
@Result(column = "id", property = "id", id = true),
@Result(column = "company_name", property = "companyName"),
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
})
@Select("select id, company_name, create_time from news where is_delete = 0 and company_name is not null and length(company_name) > 0 and create_time > #{lastCollectTime}")
List<News> getCompanyRelatedNews(@Param("lastCollectTime") Date lastCollectTime);
@Results({
@Result(column = "id", property = "id", id = true),
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
})
@Select(" select id, create_time from news " +
" where is_delete = 0 and create_time > #{lastCheckTime} and ${signalRule} ")
List<News> getSignalRuleNews(@Param("lastCheckTime") Date lastCheckTime, @Param("signalRule") String signalRule);
}

View File

@ -0,0 +1,33 @@
package com.jinrui.reference.core.mapper;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import com.jinrui.reference.core.model.entity.NewsSignalRuleRel;
public interface NewsSignalRuleRelMapper {
@Results({
@Result(column = "id", property = "id", id = true),
@Result(column = "news_id", property = "newsId"),
@Result(column = "signal_rule_id", property = "signalRuleId"),
@Result(column = "check_time", property = "checkTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)
})
@Select("select * from news_signal_rule_rel order by check_time desc limit 1")
NewsSignalRuleRel getLastCheckedSignalRule();
@Select("select signal_rule.rule_name from news_signal_rule_rel, signal_rule where news_signal_rule_rel.news_id = #{newsId} and news_signal_rule_rel.signal_rule_id = signal_rule.id")
List<String> getNewsSignalRuleNames(@Param("newsId") Long newsId);
@Insert("insert into news_signal_rule_rel(news_id, signal_rule_id, check_time, create_time, update_time) values (#{newsId}, #{signalRuleId}, #{checkTime}, now(), now())")
void saveNewsSignalRuleRel(@Param("newsId") Long newsId, @Param("signalRuleId") Long signalRuleId, @Param("checkTime") Date checkTime);
}

View File

@ -0,0 +1,24 @@
package com.jinrui.reference.core.mapper;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import com.jinrui.reference.core.model.entity.SignalRule;
public interface SignalRuleMapper {
@Results({
@Result(column = "id", property = "id", id = true),
@Result(column = "rule_name", property = "ruleName"),
@Result(column = "rule_trigger", property = "ruleTrigger"),
@Result(column = "disabled", property = "disabled"),
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)
})
@Select("select * from signal_rule where disabled = 0")
List<SignalRule> queryAll();
}

View File

@ -1,23 +1,25 @@
package com.jinrui.reference.core.mapper;
import com.jinrui.reference.core.model.entity.DraftTagRel;
import com.jinrui.reference.core.model.entity.NewsTagRel;
import com.jinrui.reference.core.model.entity.Tag;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import java.util.Date;
import java.util.List;
import com.jinrui.reference.core.model.entity.DraftTagRel;
import com.jinrui.reference.core.model.entity.NewsTagRel;
import com.jinrui.reference.core.model.entity.Tag;
public interface TagMapper {
@Results({
@Results(id = "tagMap", value = {
@Result(column = "id", property = "id", id = true),
@Result(column = "parent_id", property = "parentId"),
@Result(column = "parent_name", property = "parentName"),
@ -28,6 +30,20 @@ public interface TagMapper {
@Select("select * from tag")
List<Tag> queryAll();
@ResultMap("tagMap")
@Select("<script>" +
"select * from tag " +
"<where>" +
" <if test=\"ids != null and ids.size() > 0\"> " +
" id in " +
"<foreach collection=\"ids\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
"#{id}\n" +
"</foreach>" +
" </if> " +
"</where>" +
"</script>")
List<Tag> getByIds(@Param("ids") List<Long> ids);
@Select("select id, parent_id as parentId, name from tag where id = #{id}")
Tag queryById(@Param("id") Long id);
@ -56,10 +72,10 @@ public interface TagMapper {
@Delete("delete from draft_tag_rel where draft_id = #{draftId}")
void deleteDraft(@Param("draftId") Long draftId);
@Insert("insert into draft_tag_rel(draft_id, tag_id) values (#{draftId}, #{tagId})")
@Insert("insert into draft_tag_rel(draft_id, tag_id) values (#{draftId}, #{tagId}) on duplicate key update tag_id = #{tagId}")
void saveDraftTagRel(@Param("draftId") Long draftId, @Param("tagId") Long tagId);
@Insert("insert into news_tag_rel(news_id, tag_id) values (#{newsId}, #{tagId})")
@Insert("insert into news_tag_rel(news_id, tag_id) values (#{newsId}, #{tagId}) on duplicate key update tag_id = #{tagId}")
void saveNewsTagRel(@Param("newsId") Long newsId, @Param("tagId") Long tagId);
// @Insert("insert into tag(parent_id, name, create_time, update_time) values (#{parentId},#{name}, now(), now())")
@ -76,14 +92,7 @@ public interface TagMapper {
@Delete("delete from tag where id = #{id}")
void deleteTag(@Param("id") Long id);
@Results({
@Result(column = "id", property = "id", id = true),
@Result(column = "parent_id", property = "parentId"),
@Result(column = "parent_name", property = "parentName"),
@Result(column = "name", property = "name"),
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(column = "update_time", property = "updateTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)
})
@ResultMap("tagMap")
@Select("<script>" +
"select * from tag" +
"<where>" +

View File

@ -43,6 +43,7 @@ public interface UserOperationLogMapper {
@Result(column = "behavior", property = "behavior"),
@Result(column = "create_time", property = "createTime", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
})
@Select("select * from user_operation_log where data_id = #{dataId} and type = #{type} and behavior = #{behavior} order by create_time desc limit 1")
UserOperationLog selectLastOperation(@Param("dataId") Long dataId, @Param("type") String type, @Param("behavior") String behavior);
@Select("select * from user_operation_log where data_id = #{dataId} and type = #{type} and behavior = #{behavior} and user_type = #{userType} order by create_time desc limit 1")
UserOperationLog selectLastOperation(@Param("dataId") Long dataId, @Param("type") String type, @Param("behavior") String behavior, @Param("userType") String userType);
}

View File

@ -2,12 +2,15 @@ package com.jinrui.reference.core.model.dto.news;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import com.jinrui.reference.core.model.entity.NewsInfo;
import com.jinrui.reference.core.model.entity.NewsTags;
import com.jinrui.reference.core.model.vo.news.NewsDetailIndustry;
import com.jinrui.reference.core.model.vo.news.NewsDetailVO;
@SuppressWarnings("unused")
@ -36,6 +39,8 @@ public class SaveNewsDTO {
private Byte rating;
private Integer exclusive;
private String revision;
public SaveNewsDTO() {}
@ -48,6 +53,12 @@ public class SaveNewsDTO {
this.tag = new SaveDraftTag(newsDetailVO.getTag());
this.column = new SaveDraftColumn(newsDetailVO.getColumn());
this.content = newsDetailVO.getContent();
if (!CollectionUtils.isEmpty(newsDetailVO.getIndustry())) {
this.industries = newsDetailVO.getIndustry().stream().map(NewsDetailIndustry::getId).collect(Collectors.toList());
}
this.rating = newsDetailVO.getRating();
this.exclusive = newsDetailVO.getExclusive();
this.revision = newsDetailVO.getRevision();
}
public Long getId() {
@ -164,6 +175,14 @@ public class SaveNewsDTO {
this.rating = rating;
}
public Integer getExclusive() {
return exclusive;
}
public void setExclusive(Integer exclusive) {
this.exclusive = exclusive;
}
public String getRevision() {
return revision;
}

View File

@ -0,0 +1,42 @@
package com.jinrui.reference.core.model.entity;
import java.util.Date;
public class ListedCompany {
private Long id;
private String companyName;
private Date collectTime;
private Date createTime;
private Date updateTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getCollectTime() {
return collectTime;
}
public void setCollectTime(Date collectTime) {
this.collectTime = collectTime;
}
}

View File

@ -87,6 +87,8 @@ public class News {
private Byte rating;
private Integer exclusive;
private String revision;
private Integer overseasEvent;
@ -103,6 +105,8 @@ public class News {
private String companyName;
private String sourceName;
public News() {}
public News(SaveNewsDTO saveNewsDTO) {
@ -118,6 +122,7 @@ public class News {
this.llmTitle = saveNewsDTO.getTitle();
this.llmContent = saveNewsDTO.getContent();
this.rating = saveNewsDTO.getRating();
this.exclusive = saveNewsDTO.getExclusive();
this.revision = saveNewsDTO.getRevision();
this.createTime = new Date();
this.updateTime = new Date();
@ -275,6 +280,14 @@ public class News {
this.rating = rating;
}
public Integer getExclusive() {
return exclusive;
}
public void setExclusive(Integer exclusive) {
this.exclusive = exclusive;
}
public void setRevision(String revision) {
this.revision = revision;
}
@ -338,4 +351,12 @@ public class News {
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
}

View File

@ -0,0 +1,49 @@
package com.jinrui.reference.core.model.entity;
import java.util.Date;
public class NewsSignalRuleRel {
private Long id;
private Long newsId;
private Long signalRuleId;
private Date checkTime;
private Date createTime;
private Date updateTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getNewsId() {
return newsId;
}
public void setNewsId(Long newsId) {
this.newsId = newsId;
}
public Long getSignalRuleId() {
return signalRuleId;
}
public void setSignalRuleId(Long signalRuleId) {
this.signalRuleId = signalRuleId;
}
public Date getCheckTime() {
return checkTime;
}
public void setCheckTime(Date checkTime) {
this.checkTime = checkTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View File

@ -0,0 +1,49 @@
package com.jinrui.reference.core.model.entity;
import java.util.Date;
public class SignalRule {
private Long id;
private String ruleName;
private String ruleTrigger;
private Boolean disabled;
private Date createTime;
private Date updateTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getRuleTrigger() {
return ruleTrigger;
}
public void setRuleTrigger(String ruleTrigger) {
this.ruleTrigger = ruleTrigger;
}
public Boolean getDisabled() {
return disabled;
}
public void setDisabled(Boolean disabled) {
this.disabled = disabled;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View File

@ -41,6 +41,8 @@ public class NewsDetailVO {
private Byte rating; // 打分
private Integer exclusive;
private String revision; // 修订说明
public NewsDetailVO() {
@ -56,6 +58,7 @@ public class NewsDetailVO {
this.deleted = news.getDeleted();
this.newsInfoId = news.getNewsinfoId();
this.rating = news.getRating();
this.exclusive = news.getExclusive();
this.revision = news.getRevision();
}
@ -194,6 +197,14 @@ public class NewsDetailVO {
this.rating = rating;
}
public Integer getExclusive() {
return exclusive;
}
public void setExclusive(Integer exclusive) {
this.exclusive = exclusive;
}
public String getRevision() {
return revision;
}

View File

@ -55,18 +55,24 @@ public class NewsVO {
private Double score;
private String submitter;
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
private String submitterSecond;
private String sourceName;
private String companyName;
private List<String> industryLabels;
private List<String> conceptLabels;
private Integer exclusive;
private Boolean deleted; // 删除标识
private Byte rating; // 打分
private List<String> ruleName;
public NewsVO(News news) {
this.id = news.getId();
@ -78,6 +84,9 @@ public class NewsVO {
this.score = news.getScore();
this.deleted = news.getDeleted();
this.rating = news.getRating();
this.sourceName = news.getSourceName();
this.companyName = news.getCompanyName();
this.exclusive = news.getExclusive();
}
public Long getId() {
@ -155,4 +164,69 @@ public class NewsVO {
public void setSubmitter(String submitter) {
this.submitter = submitter;
}
public String getSubmitterSecond() {
return submitterSecond;
}
public void setSubmitterSecond(String submitterSecond) {
this.submitterSecond = submitterSecond;
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public List<String> getIndustryLabels() {
return industryLabels;
}
public void setIndustryLabels(List<String> industryLabels) {
this.industryLabels = industryLabels;
}
public List<String> getConceptLabels() {
return conceptLabels;
}
public void setConceptLabels(List<String> conceptLabels) {
this.conceptLabels = conceptLabels;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
public Integer getExclusive() {
return exclusive;
}
public void setExclusive(Integer exclusive) {
this.exclusive = exclusive;
}
public List<String> getRuleName() {
return ruleName;
}
public void setRuleName(List<String> ruleName) {
this.ruleName = ruleName;
}
}

View File

@ -0,0 +1,19 @@
package com.jinrui.reference.core.model.vo.news;
public class SignalRuleVO {
private Long id;
private String ruleName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
}

View File

@ -119,6 +119,31 @@ public class NewsInfoService {
}
newsMapper.saveNews(relNews);
saveNewsRel(id, relNews.getId());
} else {
NewsTags newsTags = newsTagsMapper.getNewsTagsByNewsId(id);
if (!ObjectUtils.isEmpty(newsTags.getIndustryLabel())) {
List<Industry> industries = industryMapper.queryAll();
for (String industryLabel: newsTags.getIndustryLabel()) {
for (Industry industry: industries) {
if (industryLabel.equals(industry.getDisplayName())) {
industryMapper.saveNewsIndustryRel(relateNews.getId(), industry.getId());
break;
}
}
}
}
if (!ObjectUtils.isEmpty(newsTags.getConceptLabel())) {
List<Tag> tags = tagMapper.queryAll().stream().filter(e -> e.getParentId() > 1L && e.getLevel() == 2).collect(Collectors.toList());
for (String conceptLabel: newsTags.getConceptLabel()) {
for (Tag tag: tags) {
if (conceptLabel.equals(tag.getDisplayName())) {
tagMapper.saveNewsTagRel(relateNews.getId(), tag.getId());
break;
}
}
}
}
}
NewsInfo publishedNewsInfo = new NewsInfo();

View File

@ -31,9 +31,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.jinrui.reference.core.mapper.ColumnMapper;
import com.jinrui.reference.core.mapper.IndustryMapper;
import com.jinrui.reference.core.mapper.ListedCompanyMapper;
import com.jinrui.reference.core.mapper.NewsDeletedMapper;
import com.jinrui.reference.core.mapper.NewsMapper;
import com.jinrui.reference.core.mapper.NewsSignalRuleRelMapper;
import com.jinrui.reference.core.mapper.NewsTagsMapper;
import com.jinrui.reference.core.mapper.SignalRuleMapper;
import com.jinrui.reference.core.mapper.TagMapper;
import com.jinrui.reference.core.mapper.UserOperationLogMapper;
import com.jinrui.reference.core.model.dto.news.SaveDraftColumn;
@ -46,6 +49,7 @@ import com.jinrui.reference.core.model.entity.DraftColumnRel;
import com.jinrui.reference.core.model.entity.DraftIndustryRel;
import com.jinrui.reference.core.model.entity.DraftTagRel;
import com.jinrui.reference.core.model.entity.Industry;
import com.jinrui.reference.core.model.entity.ListedCompany;
import com.jinrui.reference.core.model.entity.News;
import com.jinrui.reference.core.model.entity.NewsColumnRel;
import com.jinrui.reference.core.model.entity.NewsDeleted;
@ -54,11 +58,11 @@ import com.jinrui.reference.core.model.entity.NewsIndustryRel;
import com.jinrui.reference.core.model.entity.NewsInfo;
import com.jinrui.reference.core.model.entity.NewsTagRel;
import com.jinrui.reference.core.model.entity.NewsTags;
import com.jinrui.reference.core.model.entity.SignalRule;
import com.jinrui.reference.core.model.entity.Tag;
import com.jinrui.reference.core.model.entity.UserOperationLog;
import com.jinrui.reference.core.model.vo.PageObject;
import com.jinrui.reference.core.model.vo.ResultObject;
import com.jinrui.reference.core.model.vo.column.ColumnVO;
import com.jinrui.reference.core.model.vo.news.NewsApiVO;
import com.jinrui.reference.core.model.vo.news.NewsDetailColumn;
import com.jinrui.reference.core.model.vo.news.NewsDetailColumnVip;
@ -89,6 +93,9 @@ public class NewsService {
private final NewsTagsMapper newsTagsMapper;
private final NewsDeletedMapper newsDeletedMapper;
private final UserOperationLogMapper userOperationLogMapper;
private final SignalRuleMapper signalRuleMapper;
private final ListedCompanyMapper listedCompanyMapper;
private final NewsSignalRuleRelMapper newsSignalRuleRelMapper;
public NewsService(NewsMapper newsMapper,
ColumnMapper columnMapper,
@ -98,7 +105,10 @@ public class NewsService {
ElasticsearchClient elasticsearchClient,
NewsTagsMapper newsTagsMapper,
NewsDeletedMapper newsDeletedMapper,
UserOperationLogMapper userOperationLogMapper) {
UserOperationLogMapper userOperationLogMapper,
SignalRuleMapper signalRuleMapper,
ListedCompanyMapper listedCompanyMapper,
NewsSignalRuleRelMapper newsSignalRuleRelMapper) {
this.newsMapper = newsMapper;
this.columnMapper = columnMapper;
this.objectMapper = objectMapper;
@ -108,6 +118,9 @@ public class NewsService {
this.newsTagsMapper = newsTagsMapper;
this.newsDeletedMapper = newsDeletedMapper;
this.userOperationLogMapper = userOperationLogMapper;
this.signalRuleMapper = signalRuleMapper;
this.listedCompanyMapper = listedCompanyMapper;
this.newsSignalRuleRelMapper = newsSignalRuleRelMapper;
}
public ResultObject<Void> publish(long id, long editorId, boolean isReviewer) {
@ -169,6 +182,7 @@ public class NewsService {
newsDetailVO.setDeleted(news.getDeleted());
newsDetailVO.setNewsInfoId(news.getNewsinfoId());
newsDetailVO.setRating(news.getRating());
newsDetailVO.setExclusive(news.getExclusive());
newsDetailVO.setRevision(news.getRevision());
Set<Long> set = new HashSet<>();
@ -833,8 +847,12 @@ public class NewsService {
Integer last, Integer current, String orderBy, Double minScore, Double maxScore,
String tag, String industry, Long mediaId,
Date datelineFrom, Date datelineTo, Integer deleted, Byte rating,
Integer exclusive,
boolean isReviewer,
boolean isSecondReviewRange) {
boolean isSecondReviewRange,
String includeRuleIds,
String excludeRuleIds,
String companyName) {
String orderByClause = null;
if (StringUtils.hasText(orderBy)) {
String orderByStr = orderBy;
@ -896,10 +914,20 @@ public class NewsService {
if (StringUtils.hasText(keyword)) {
keywords.addAll(Arrays.asList(keyword.trim().split("\\s+")));
}
List<Long> includeSignalRules = null;
if (StringUtils.hasText(includeRuleIds)) {
includeSignalRules = Arrays.stream(includeRuleIds.split(",")).map(Long::parseLong).collect(Collectors.toList());
}
List<Long> excludeSignalRules = null;
if (StringUtils.hasText(excludeRuleIds)) {
excludeSignalRules = Arrays.stream(excludeRuleIds.split(",")).map(Long::parseLong).collect(Collectors.toList());
}
List<News> newsList;
try {
newsList = newsMapper.queryNews(keywords, minScore, maxScore, columnParam, status, last, orderByClause, size, offset, tags, industries, datelineFrom, datelineTo, deleted, rating, isReviewer, isSecondReviewRange);
newsList = newsMapper.queryNews(keywords, minScore, maxScore, columnParam, status, last, orderByClause, size, offset, tags, industries, datelineFrom, datelineTo, deleted, rating,exclusive, isReviewer, isSecondReviewRange, includeSignalRules, excludeSignalRules, companyName);
} catch (Exception e) {
log.error("搜索新闻异常!", e);
return PageObject.failedPage(500, "服务器错误,请联系系统管理员!");
@ -908,7 +936,7 @@ public class NewsService {
PageObject<NewsVO> pageObject = new PageObject<>();
if (page == 1) {
try {
int total = newsMapper.queryTotal(keywords,minScore, maxScore, columnParam, status, tags, industries, datelineFrom, datelineTo, deleted, rating, isReviewer, isSecondReviewRange);
int total = newsMapper.queryTotal(keywords,minScore, maxScore, columnParam, status, tags, industries, datelineFrom, datelineTo, deleted, rating,exclusive, isReviewer, isSecondReviewRange, includeSignalRules, excludeSignalRules, companyName);
pageObject.setTotal(total);
} catch (Exception e) {
log.error("获取新闻总数异常!", e);
@ -938,36 +966,25 @@ public class NewsService {
newsMap.put(newsVO.getId(), newsVO);
}
resultList.add(newsVO);
if (isReviewer||isSecondReviewRange) {
newsVO.setSubmitter(this.getNewsLastSubmitter(news.getId()));
newsVO.setSubmitter(this.getNewsLastEditor(news.getId()));
if (isReviewer) {
newsVO.setSubmitterSecond(this.getNewsLastReviewer(news.getId()));
}
}
List<Column> columns = columnMapper.queryAll();
Map<Long, ColumnVO> columnMap = columns.stream()
.map(ColumnVO::new)
.collect(Collectors.toMap(ColumnVO::getId, Function.identity()));
if (!CollectionUtils.isEmpty(draftMap)) {
List<DraftColumnRel> draftRelList = columnMapper.queryDraftRel(draftMap.keySet());
for (DraftColumnRel rel : draftRelList) {
Long draftId = rel.getDraftId();
Long columnId = rel.getColumnId();
ColumnVO columnObject = columnMap.get(columnId);
NewsVO newsVO = draftMap.get(draftId);
List<ColumnVO> columnList = newsVO.getColumns();
columnList.add(columnObject);
List<NewsTagRel> newsTagList = tagMapper.getNewsTagRelList(news.getId());
if (!CollectionUtils.isEmpty(newsTagList)) {
List<Tag> newsConceptLabels = tagMapper.getByIds(newsTagList.stream().map(NewsTagRel::getTagId).collect(Collectors.toList()));
newsVO.setConceptLabels(newsConceptLabels.stream().filter(e -> !Objects.equals(e.getParentId(), 1L)).map(Tag::getDisplayName).collect(Collectors.toList()));
}
}
if (!CollectionUtils.isEmpty(newsMap)) {
List<NewsColumnRel> newsRelList = columnMapper.queryNewsRel(newsMap.keySet());
for (NewsColumnRel rel : newsRelList) {
Long newsId = rel.getNewsId();
Long columnId = rel.getColumnId();
ColumnVO columnObject = columnMap.get(columnId);
NewsVO newsVO = newsMap.get(newsId);
List<ColumnVO> columnList = newsVO.getColumns();
columnList.add(columnObject);
List<NewsIndustryRel> newsIndustryList = industryMapper.getNewsIndustryRelList(news.getId());
if (!CollectionUtils.isEmpty(newsIndustryList)) {
List<Industry> newsIndustryLabels = industryMapper.getByIds(newsIndustryList.stream().map(NewsIndustryRel::getIndustryId).collect(Collectors.toList()));
newsVO.setIndustryLabels(newsIndustryLabels.stream().map(Industry::getDisplayName).collect(Collectors.toList()));
}
List<String> newsSignalRuleNames = newsSignalRuleRelMapper.getNewsSignalRuleNames(news.getId());
newsVO.setRuleName(newsSignalRuleNames);
}
pageObject.setData(resultList);
@ -980,14 +997,23 @@ public class NewsService {
return pageObject;
}
private String getNewsLastSubmitter(Long newsId) {
UserOperationLog userOperationLog = userOperationLogMapper.selectLastOperation(newsId, "news", "送审");
private String getNewsLastEditor(Long newsId) {
return getNewsLastOperator(newsId, "送审", "00");
}
private String getNewsLastReviewer(Long newsId) {
return getNewsLastOperator(newsId, "复审", "02");
}
private String getNewsLastOperator(Long newsId, String operation, String userType) {
UserOperationLog userOperationLog = userOperationLogMapper.selectLastOperation(newsId, "news", operation, userType);
if (userOperationLog == null) {
return null;
}
return userOperationLog.getUsername();
}
public ResultObject<NewsScoreVO> getScore(Long id) {
News news = newsMapper.getById(id);
String newsinfoId = news.getNewsinfoId();
@ -1241,4 +1267,12 @@ public class NewsService {
}
return pageObject;
}
public List<SignalRule> getSignalRulesList() {
return signalRuleMapper.queryAll();
}
public List<ListedCompany> getAllListedCompany(String companyName) {
return listedCompanyMapper.queryAll(companyName);
}
}