Search in sources :

Example 1 with WarningTask

use of com.topcom.cms.yuqing.domain.WarningTask in project topcom-cloud by 545314690.

the class WarningManagerImpl method getSubjectWarningInfo.

@Deprecated
@Override
public Page<News> getSubjectWarningInfo(CustomSubject subject, int pageNum, int limit) {
    WarningTask warning = subject.getWarning();
    if (warning == null) {
        return new PageImpl<News>(new ArrayList<News>());
    }
    BoolQueryRequest request = new BoolQueryRequest();
    request.setType(null);
    request.setFiled(null);
    request.setKeyword(new Keyword(subject.getMustWord(), subject.getShouldWord(), subject.getMustNotWord()));
    // 本次预警时间
    Date thisWarningDate = new Date();
    // 上次预警时间
    Date lastWarningDate = warning.getLastWarningDate();
    if (lastWarningDate == null) {
        lastWarningDate = subject.getStartDate();
    }
    request.setDate(new DateParam(DateUtil.dateToString(lastWarningDate), DateUtil.dateToString(thisWarningDate)));
    request.setPage(new PageRequest(pageNum, limit, new Order(Sort.Direction.DESC, "pubTime")));
    List<KV> kvList = new ArrayList<>();
    // 媒体类型
    String[] type = warning.getType();
    if (type != null && type.length > 0) {
        kvList.add(new KV("type", type));
    }
    String[] sentimentLabel = warning.getSentimentLabel();
    // 情感类型
    if (sentimentLabel != null && sentimentLabel.length != 0) {
        kvList.add(new KV("nlp.sentiment.label", sentimentLabel));
    }
    request.setSearchKv(kvList);
    final Page page = newsService.findByMustShouldDateInType(request);
    return page;
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) Order(com.topcom.cms.common.page.Order) BoolQueryRequest(com.topcom.cms.es.vo.BoolQueryRequest) Keyword(com.topcom.cms.es.vo.Keyword) ArrayList(java.util.ArrayList) Page(org.springframework.data.domain.Page) KV(com.topcom.cms.es.vo.KV) Date(java.util.Date) PageRequest(com.topcom.cms.common.page.PageRequest) News(com.topcom.cms.data.domain.News) WarningTask(com.topcom.cms.yuqing.domain.WarningTask) DateParam(com.topcom.cms.common.page.DateParam)

Example 2 with WarningTask

use of com.topcom.cms.yuqing.domain.WarningTask in project topcom-cloud by 545314690.

the class WarningLogManagerImpl method formSubject.

@Override
public WarningLog formSubject(CustomSubject subject) {
    if (subject == null) {
        return null;
    }
    WarningTask warningTask = subject.getWarning();
    if (warningTask == null) {
        return null;
    }
    WarningLog warningLog = new WarningLog();
    warningLog.setUserId(subject.getUserId());
    warningLog.setSubjectName(subject.getName());
    warningLog.setSubjectId(subject.getId());
    warningLog.setMustWord(subject.getMustWord());
    warningLog.setShouldWord(subject.getShouldWord());
    warningLog.setMustNotWord(subject.getMustNotWord());
    // 本次预警时间
    Date thisWarningDate = new Date();
    // 上次预警时间
    Date lastWarningDate = warningTask.getLastWarningDate();
    if (lastWarningDate == null) {
        lastWarningDate = subject.getStartDate();
    }
    warningLog.setStartDate(DateUtil.dateToString(lastWarningDate));
    warningLog.setEndDate(DateUtil.dateToString(thisWarningDate));
    // 媒体类型
    warningLog.setType(warningTask.getType());
    // 情感
    warningLog.setSentimentLabel(warningTask.getSentimentLabel());
    warningLog.setWarningTaskId(warningTask.getId());
    warningLog.setField(warningTask.getFiled());
    return warningLog;
}
Also used : WarningLog(com.topcom.cms.yuqing.domain.WarningLog) WarningTask(com.topcom.cms.yuqing.domain.WarningTask) Date(java.util.Date)

Aggregations

WarningTask (com.topcom.cms.yuqing.domain.WarningTask)2 Date (java.util.Date)2 DateParam (com.topcom.cms.common.page.DateParam)1 Order (com.topcom.cms.common.page.Order)1 PageRequest (com.topcom.cms.common.page.PageRequest)1 News (com.topcom.cms.data.domain.News)1 BoolQueryRequest (com.topcom.cms.es.vo.BoolQueryRequest)1 KV (com.topcom.cms.es.vo.KV)1 Keyword (com.topcom.cms.es.vo.Keyword)1 WarningLog (com.topcom.cms.yuqing.domain.WarningLog)1 ArrayList (java.util.ArrayList)1 Page (org.springframework.data.domain.Page)1 PageImpl (org.springframework.data.domain.PageImpl)1