Search in sources :

Example 6 with PageRequest

use of com.topcom.cms.common.page.PageRequest in project topcom-cloud by 545314690.

the class WarningLogManagerImpl method getWarningInfo.

@Override
public Page getWarningInfo(WarningLog warningLog, int pageNum, int limit) {
    if (warningLog == null) {
        return new PageImpl<>(new ArrayList<>());
    }
    BoolQueryRequest request = new BoolQueryRequest();
    request.setType(null);
    request.setFiled(warningLog.getField());
    request.setKeyword(new Keyword(warningLog.getMustWord(), warningLog.getShouldWord(), warningLog.getMustNotWord()));
    /**
     * 数据发布时间:暂定三天内
     */
    // TODO:三天内合适不?
    // Date now = new Date();
    // request.setDate(new DateParam(DateUtil.dateToString(DateUtils.addDays(now, -3)), DateUtil.dateToString(now)));
    /**
     * 数据保存时间
     */
    request.setDateCreated(new DateParam(warningLog.getStartDate(), warningLog.getEndDate()));
    Date now = request.getDateCreated().endDate();
    request.setDate(new DateParam(DateUtil.dateToString(DateUtils.addDays(now, -3)), DateUtil.dateToString(now)));
    request.setPage(new PageRequest(pageNum, limit, new Order(Sort.Direction.DESC, "pubTime")));
    List<KV> kvList = new ArrayList<>();
    // 媒体类型
    String[] type = warningLog.getType();
    if (type != null && type.length > 0) {
        request.setType(type);
    }
    String[] sentimentLabel = warningLog.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) DateParam(com.topcom.cms.common.page.DateParam)

Example 7 with PageRequest

use of com.topcom.cms.common.page.PageRequest in project topcom-cloud by 545314690.

the class DescriptionManagerImpl method weeklyOutline.

@Override
public Object weeklyOutline(BoolQueryRequest boolQueryRequest) {
    boolQueryRequest.setPage(new PageRequest(1, 1));
    JSONObject jsonObject = new JSONObject();
    Page page = allESDataService.findByMustShouldDateInType(boolQueryRequest);
    jsonObject.put("weekCount", page.getTotalElements());
    jsonObject.put("wow", getmom(boolQueryRequest, "week"));
    jsonObject.put("maxSite", getMaxType(boolQueryRequest, "site"));
    jsonObject.put("maxType", getMaxType(boolQueryRequest, "type"));
    jsonObject.put("compare", compareWithLastMonthEverySite(boolQueryRequest, "week"));
    jsonObject.put("label", getMaxType(boolQueryRequest, "nlp.sentiment.label"));
    return jsonObject;
}
Also used : PageRequest(com.topcom.cms.common.page.PageRequest) JSONObject(net.sf.json.JSONObject) Page(org.springframework.data.domain.Page)

Aggregations

PageRequest (com.topcom.cms.common.page.PageRequest)7 Page (org.springframework.data.domain.Page)6 Date (java.util.Date)4 DateParam (com.topcom.cms.common.page.DateParam)3 Order (com.topcom.cms.common.page.Order)3 BoolQueryRequest (com.topcom.cms.es.vo.BoolQueryRequest)3 Keyword (com.topcom.cms.es.vo.Keyword)3 JSONObject (net.sf.json.JSONObject)3 KV (com.topcom.cms.es.vo.KV)2 ArrayList (java.util.ArrayList)2 PageImpl (org.springframework.data.domain.PageImpl)2 News (com.topcom.cms.data.domain.News)1 StaffSentiment (com.topcom.cms.yuqing.domain.StaffSentiment)1 WarningTask (com.topcom.cms.yuqing.domain.WarningTask)1 QueryWord (com.topcom.yzswf.util.QueryWord)1 ESQueryBuilderConstructor (com.topcom.yzswf.util.es.ESQueryBuilderConstructor)1 ESQueryBuilders (com.topcom.yzswf.util.es.ESQueryBuilders)1 Map (java.util.Map)1 Sort (org.springframework.data.domain.Sort)1