Search in sources :

Example 1 with Keywords

use of com.topcom.cms.yuqing.domain.Keywords in project topcom-cloud by 545314690.

the class AccidentYuqingController method getAccidentArticle.

private Page<News> getAccidentArticle(DateParam dateParam, Accident accident) {
    String companyName = accident.getCompanyName();
    String atype = accident.getAtype();
    String city = accident.getCity();
    Keywords keywords = null;
    if (StringUtils.isNotBlank(companyName)) {
        keywords = new Keywords(companyName, atype + "@" + city);
    } else {
        keywords = new Keywords("事故", atype + "@" + city);
    }
    Page<News> page = newsService.findByMustShouldDateInType(keywords.getMustWord(), keywords.getShouldWord(), keywords.getMustNotWord(), DateUtil.dateToString(dateParam.startDate()), DateUtil.dateToString(dateParam.endDate()), "content", 0, 1, "pubTime", 1);
    return page;
}
Also used : Keywords(com.topcom.cms.yuqing.domain.Keywords) News(com.topcom.cms.data.domain.News)

Example 2 with Keywords

use of com.topcom.cms.yuqing.domain.Keywords in project topcom-cloud by 545314690.

the class BriefingCreatorImpl method sendRequestAndCreateBriefing.

/**
 * 根据报告类型和开始结束时间发送请求生成json,并创建附件,保存到数据库
 *
 * @param briefingTask
 * @param startTime
 * @param endTime
 * @return
 * @throws BusinessException
 */
private Future sendRequestAndCreateBriefing(BriefingTask briefingTask, long startTime, long endTime) throws BusinessException {
    FutureTask<JSONObject> futureTask = new FutureTask<>(() -> {
        Briefing.BriefingType type = briefingTask.getBriefingType();
        List<Keywords> keywordList = keywordsManager.findByUserIdAndType(briefingTask.getUserId(), Keywords.Type.BASIC);
        if (keywordList.size() > 0) {
            Keywords keyword = keywordList.get(0);
            String mustWord = keyword.getMustWord();
            String shouldWord = keyword.getShouldWord();
            String mustNotWord = keyword.getMustNotWord();
            try {
                String object = requestBriefingString(type, mustWord, shouldWord, mustNotWord, startTime, endTime, null);
                DBObject dbObject = (BasicDBObject) JSON.parse(object);
                dbObject.put("userId", briefingTask.getUserId());
                dbObject.put("type", type.name());
                dbObject.put("issue", briefingTask.getIssue());
                JSONObject json = JSONObject.fromObject(dbObject);
                json.put("dateCreated", endTime);
                saveBriefingToMongo(json);
                String message = "生成报告成功@" + new Date() + "@" + type.name();
                LogUtil.logger.info(message);
                return json;
            } catch (Exception e) {
                e.printStackTrace();
                String message = "生成报告失败@" + new Date() + "@" + type.name();
                LogUtil.logger.error(message);
                throw new BusinessException(message);
            }
        }
        return null;
    });
    executorService.submit(futureTask);
    return futureTask;
}
Also used : Keywords(com.topcom.cms.yuqing.domain.Keywords) Briefing(com.topcom.cms.yuqing.domain.Briefing) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) BusinessException(com.topcom.cms.exception.BusinessException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BasicDBObject(com.mongodb.BasicDBObject) BusinessException(com.topcom.cms.exception.BusinessException) JSONObject(net.sf.json.JSONObject)

Aggregations

Keywords (com.topcom.cms.yuqing.domain.Keywords)2 BasicDBObject (com.mongodb.BasicDBObject)1 DBObject (com.mongodb.DBObject)1 News (com.topcom.cms.data.domain.News)1 BusinessException (com.topcom.cms.exception.BusinessException)1 Briefing (com.topcom.cms.yuqing.domain.Briefing)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 JSONObject (net.sf.json.JSONObject)1