use of com.topcom.cms.common.page.DateParam 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;
}
use of com.topcom.cms.common.page.DateParam 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;
}
use of com.topcom.cms.common.page.DateParam in project topcom-cloud by 545314690.
the class EsFileServiceImpl method search.
@Override
public com.topcom.yzswf.util.Page search(FileQueryVO fileQueryVO) throws Exception {
String searchType = fileQueryVO.getSearchType();
if (StringUtils.isNotBlank(searchType)) {
if ("content".equals(searchType)) {
searchType = "attachment.content";
}
} else {
searchType = "filename";
}
PageRequest pageRequest = fileQueryVO.getPageRequest();
ESQueryBuilderConstructor constructor = new ESQueryBuilderConstructor();
QueryWord queryWord = fileQueryVO.getQueryWord();
if (queryWord != null) {
constructor.must(new ESQueryBuilders().queryString(searchType + ":" + queryWord.toQueryString()));
}
// 查询返回条数,最大 10000
constructor.setSize(pageRequest.getLimit());
// 分页查询条目起始位置, 默认0
constructor.setFrom(pageRequest.getLimit() * (pageRequest.getPage() - 1));
List<Order> orders = pageRequest.getOrders();
if (StringUtils.isNotBlank(fileQueryVO.getType())) {
constructor.must(new ESQueryBuilders().term("type", fileQueryVO.getType()));
}
if (StringUtils.isNotBlank(fileQueryVO.getSource())) {
constructor.must(new ESQueryBuilders().term("source", fileQueryVO.getSource()));
}
if (CollectionUtils.isNotEmpty(fileQueryVO.getFileTypes())) {
constructor.must(new ESQueryBuilders().terms("fileType", fileQueryVO.getFileTypes()));
}
if (StringUtils.isNotBlank(fileQueryVO.getAccidentType())) {
constructor.must(new ESQueryBuilders().term("accidentType", fileQueryVO.getAccidentType()));
}
DateParam dateParam = fileQueryVO.getDateParam();
if (dateParam != null) {
Date startDate = dateParam.startDate();
Date endDate = dateParam.endDate();
constructor.must(new ESQueryBuilders().range("uploadTime", startDate.getTime(), endDate.getTime()));
}
if (orders != null && orders.size() > 0) {
Order order = orders.get(0);
Sort.Direction direction = order.getDirection();
if (Sort.Direction.ASC.equals(direction)) {
// 排序
constructor.setAsc(order.getOrderBy());
} else {
// 排序
constructor.setDesc(order.getOrderBy());
}
}
//
com.topcom.yzswf.util.Page page = elasticSearchService.search(EsConf.INDEX, EsConf.TYPE, constructor);
return page;
}
use of com.topcom.cms.common.page.DateParam in project topcom-cloud by 545314690.
the class DescriptionManagerImpl method getmom.
private Object getmom(BoolQueryRequest boolQueryRequest, String type) {
DateParam lastDateparam = lastDateparam(boolQueryRequest.getDate(), type);
Page thisMonth = allESDataService.findByMustShouldDateInType(boolQueryRequest);
BoolQueryRequest boolQueryRequestLast = new BoolQueryRequest(lastDateparam, boolQueryRequest.getKeyword());
boolQueryRequestLast.setType(boolQueryRequest.getType());
boolQueryRequestLast.setSearchKv(boolQueryRequest.getSearchKv());
boolQueryRequestLast.setPage(boolQueryRequest.getPage());
boolQueryRequestLast.setFiled(boolQueryRequest.getFiled());
Page lastMonth = allESDataService.findByMustShouldDateInType(boolQueryRequestLast);
return (double) (thisMonth.getTotalElements() - lastMonth.getTotalElements()) / lastMonth.getTotalElements();
}
use of com.topcom.cms.common.page.DateParam in project topcom-cloud by 545314690.
the class DescriptionManagerImpl method compareWithLastMonthEverySite.
private Object compareWithLastMonthEverySite(BoolQueryRequest boolQueryRequest, String type) {
DateParam lastDateparam = lastDateparam(boolQueryRequest.getDate(), type);
Map thisMonthGroupByType = KV.kvList2Map(getMaxType(boolQueryRequest, "type"));
boolQueryRequest.setDate(lastDateparam);
Map lastMonthGroupByType = KV.kvList2Map(getMaxType(boolQueryRequest, "type"));
Map<String, Double> routMap = new HashMap<>();
for (Object object : thisMonthGroupByType.keySet()) {
if (lastMonthGroupByType.containsKey(object)) {
long thisMonthcount = Long.parseLong(thisMonthGroupByType.get(object).toString());
long lastMonthcount = Long.parseLong(lastMonthGroupByType.get(object).toString());
double rout = (double) (thisMonthcount - lastMonthcount) / lastMonthcount;
routMap.put(object.toString(), rout);
}
}
return paixu(routMap);
}
Aggregations