Search in sources :

Example 1 with AggRequest

use of com.topcom.cms.es.vo.AggRequest 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)

Aggregations

AggRequest (com.topcom.cms.es.vo.AggRequest)1 KV (com.topcom.cms.es.vo.KV)1 Keyword (com.topcom.cms.es.vo.Keyword)1 Accident (com.topcom.cms.mongo.domain.Accident)1