use of com.topcom.cms.mongo.domain.Accident 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;
}
use of com.topcom.cms.mongo.domain.Accident 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;
}
use of com.topcom.cms.mongo.domain.Accident in project topcom-cloud by 545314690.
the class AccidentYuqingController method getKeyWords.
/**
* 获取事故关键词用于es查询
* 把省市县公司集团煤矿等去掉,列为同现词,再加入时间,月与日
* 如 江西显亮煤业有限公司崇义县煤矿 2017-08-01 20:20:00 ---->>江西显亮@@崇义@@@7月1日
* @param id
* @return
*/
@RequestMapping(value = { "/keyWords/{id}" }, method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public JSONObject getKeyWords(@PathVariable String id) {
Accident accident = this.accidentService.findById(id);
Date date = accident.getAdate();
String companyFullName = accident.getCompanyFullName();
String mustWord = companyFullName.replaceAll(SENSITIVE_WORDS, "@");
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH) + 1;
mustWord = mustWord + "@" + month + "月" + day + "日";
JSONObject json = new JSONObject();
json.put("mustWord", mustWord);
return json;
}
Aggregations