Search in sources :

Example 1 with KV

use of com.topcom.cms.es.vo.KV in project topcom-cloud by 545314690.

the class AccidentYuqingController method hotAccidentComment.

/**
 * 获取死亡人数前5名的事故文章的评论数量
 *
 * @param request
 * @param dateParam
 * @return
 */
@RequestMapping(value = "/hotAccidentComment", method = RequestMethod.POST)
public List<KV> hotAccidentComment(HttpServletRequest request, @RequestBody DateParam dateParam) {
    List<Accident> accidentList = accidentService.getTopNAccidents(dateParam, 5);
    List<KV> kvs = new ArrayList<>();
    for (Accident accident : accidentList) {
        // 事故概要
        String outline = accident.outline();
        AggRequest aggRequest = new AggRequest();
        aggRequest.setDate(dateParam);
        String companyName = accident.getCompanyName();
        String atype = accident.getAtype();
        String city = accident.getCity();
        com.topcom.cms.es.vo.Keyword keywords = null;
        if (StringUtils.isNotBlank(companyName)) {
            keywords = new Keyword(companyName, atype + "@" + city);
        } else {
            keywords = new Keyword("事故", atype + "@" + city);
        }
        aggRequest.setKeyword(keywords);
        long count = commentsService.countByArticle(aggRequest);
        kvs.add(new KV(outline, count));
    }
    kvs.sort(new Comparator<KV>() {

        @Override
        public int compare(KV o1, KV o2) {
            return o1.compareTo(o2);
        }
    });
    return kvs;
}
Also used : AggRequest(com.topcom.cms.es.vo.AggRequest) Keyword(com.topcom.cms.es.vo.Keyword) KV(com.topcom.cms.es.vo.KV) Keyword(com.topcom.cms.es.vo.Keyword) Accident(com.topcom.cms.mongo.domain.Accident)

Example 2 with KV

use of com.topcom.cms.es.vo.KV in project topcom-cloud by 545314690.

the class DescriptionManagerImpl method keyInListKV.

private List<KV> keyInListKV(List<KV> kvList, String s, String locality) {
    if (StringUtils.isEmpty(locality)) {
        return kvList;
    }
    if (kvList.size() < 1) {
        kvList.add(new KV(locality, s));
        return kvList;
    }
    Boolean haveKey = false;
    for (int i = 0; i < kvList.size(); i++) {
        KV kv = kvList.get(i);
        if (locality.equals(kv.getKey())) {
            kv.setValue(kv.getValue().toString() + "," + s);
            // kvList.add(i,kv);
            haveKey = true;
            break;
        }
    }
    if (!haveKey) {
        kvList.add(new KV(locality, s));
    }
    return kvList;
}
Also used : KV(com.topcom.cms.es.vo.KV)

Example 3 with KV

use of com.topcom.cms.es.vo.KV in project topcom-cloud by 545314690.

the class DescriptionManagerImpl method getMaxType.

private List<KV> getMaxType(BoolQueryRequest boolQueryRequest, String groupName) {
    Keyword keyword = boolQueryRequest.getKeyword();
    DateParam dateParam = boolQueryRequest.getDate();
    String articleType = "";
    String[] type = boolQueryRequest.getType();
    if (type != null && type.length > 0) {
        articleType = type[0];
        for (int i = 1; i < type.length; i++) {
            articleType = articleType + "@" + type[i];
        }
    } else {
        articleType = "article";
    }
    List<KV> groupByType = allESDataService.filterAndGroupBy(keyword.getMustWord(), keyword.getShouldWord(), keyword.getMustNotWord(), dateParam.getStartDate(), dateParam.getEndDate(), boolQueryRequest.getFiled(), groupName, articleType, null, 20);
    if (groupByType == null || groupByType.size() == 0) {
        return null;
    }
    return groupByType;
}
Also used : Keyword(com.topcom.cms.es.vo.Keyword) KV(com.topcom.cms.es.vo.KV) DateParam(com.topcom.cms.common.page.DateParam)

Example 4 with KV

use of com.topcom.cms.es.vo.KV 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 5 with KV

use of com.topcom.cms.es.vo.KV in project topcom-cloud by 545314690.

the class AccidentYuqingController method hotAccident.

/**
 * 获取死亡人数前5名的事故文章数量
 *
 * @param request
 * @param dateParam
 * @return
 */
@RequestMapping(value = "/hotAccident", method = RequestMethod.POST)
public List<KV> hotAccident(HttpServletRequest request, @RequestBody DateParam dateParam) {
    List<Accident> accidentList = accidentService.getTopNAccidents(dateParam, 5);
    List<KV> kvs = new ArrayList<>();
    for (Accident accident : accidentList) {
        // 事故概要
        String outline = accident.outline();
        long count = getAccidentArticle(dateParam, accident).getTotalElements();
        kvs.add(new KV(outline, count));
    }
    kvs.sort(new Comparator<KV>() {

        @Override
        public int compare(KV o1, KV o2) {
            return o1.compareTo(o2);
        }
    });
    return kvs;
}
Also used : Accident(com.topcom.cms.mongo.domain.Accident) KV(com.topcom.cms.es.vo.KV)

Aggregations

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