use of com.topcom.cms.yuqing.domain.CustomSubject in project topcom-cloud by 545314690.
the class WarningTaskWatcher method doAroundUpdate.
@Around("saveOrUpdateMethod()")
public Object doAroundUpdate(ProceedingJoinPoint joinPoint) throws BusinessException {
Object[] args = joinPoint.getArgs();
if (args.length >= 1) {
try {
Object proceed = joinPoint.proceed(args);
final CustomSubject subject = (CustomSubject) proceed;
if (subject != null) {
/**
* 如果是调用新增方法(1个参数,update是两个参数),调用生成专报方法
*/
if (args.length == 1) {
briefingCreator.createSpecial(subject);
}
/**
* 预警任务调度
*/
if (subject.isEnableWarning() == true) {
// 如果是开启
scheduleJob(subject);
LogUtil.logger.info("更新任务:" + subject.getName() + "成功");
} else {
// 如果是关闭
deleteJob(String.valueOf(subject.getId()));
}
/**
*发送到kafka
*/
sendToKafka(subject);
}
return subject;
} catch (Throwable throwable) {
throwable.printStackTrace();
throw new BusinessException("更新失败");
}
}
return null;
}
use of com.topcom.cms.yuqing.domain.CustomSubject in project topcom-cloud by 545314690.
the class KafkaTest method sendSubject.
@Test
public void sendSubject() {
KafkaSender kafkaSender = new KafkaSender();
kafkaSender.setProps(props);
CustomSubject subject = new CustomSubject();
subject.setMustWord("江苏@幼儿园@爆炸");
subject.setName("江苏幼儿园爆炸");
subject.setShouldWord("爆炸");
subject.setStartDate(DateUtils.addDays(new Date(), -5));
subject.setEndDate(DateUtils.addDays(new Date(), 30));
for (int i = 0; i < 1000; i++) {
if (i % 2 == 0)
subject.setDeleted(true);
else
subject.setDeleted(false);
kafkaSender.getProducer().send(new ProducerRecord<String, String>(SUBJECT_TOPIC, net.sf.json.JSONObject.fromObject(subject).toString()));
}
}
use of com.topcom.cms.yuqing.domain.CustomSubject in project topcom-cloud by 545314690.
the class BriefingCreatorImpl method updateSpecial.
/**
* 根据专题id,更新专报
*
* @param id
* @return
* @throws Exception
*/
@Override
public Future updateSpecial(String id) throws Exception {
CustomSubject customSubject = subjectManager.findById(Long.valueOf(id));
// 更新状态
subjectManager.updateState(Long.valueOf(id), CustomSubject.State.CREATING);
return createSpecial(customSubject);
}
use of com.topcom.cms.yuqing.domain.CustomSubject in project topcom-cloud by 545314690.
the class WarningTaskWatcher method doAroundDeleteWarning.
@Around("deleteSubject()")
public void doAroundDeleteWarning(ProceedingJoinPoint joinPoint) throws Throwable {
Object[] args = joinPoint.getArgs();
if (args.length == 1) {
Long subjectId = (Long) args[0];
/**
* 为了给kafak发送消息,查询一次,并标记为删除
*/
CustomSubject subject = subjectManager.findById(subjectId);
/**
* 执行删除
*/
joinPoint.proceed(args);
subject.setDeleted(true);
// 发送到kafka
sendToKafka(subject);
// 删除任务
deleteJob(String.valueOf(subjectId));
/**
* 发送结束
*/
LogUtil.logger.info("删除任务:" + subjectId + "成功");
}
}
Aggregations