Browse Source

# 巡检任务生成消息推送aop bug

zhongwei
haungxing 2 years ago
parent
commit
db0b8620e1
  1. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java
  2. 44
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java

@ -137,7 +137,7 @@ public class PlanController extends BladeController {
@ApiImplicitParam(name="status",value="0:待审核-->1:已审核-->2:派发中-->3:暂停-->4:结束-->5审核不通过-->6待提交")
})
public R<Boolean> modifyPlanStatus(@RequestParam(value = "id") @ApiParam(value = "主键ID",required = true) Long id,
@RequestParam @DictInvalid(dictKey = PlanContants.PLAN_STATUS) Integer status) {
@RequestParam Integer status) {
return R.status(planService.modifyPlanStatus(id, status));
}

44
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java

@ -15,8 +15,10 @@ import com.hnac.hzinfo.inspect.task.service.ITaskUserService;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springblade.core.secure.utils.AuthUtil;
@ -67,28 +69,30 @@ public class TaskGenerateAspect {
public void taskSaveCutBatch() {
}
@After("taskSaveCut()")
private void saveTask(ProceedingJoinPoint joinPoint) throws Throwable {
Object[] args = joinPoint.getArgs();
new Thread(() -> {
if(ObjectUtil.isNotEmpty(args[0]) && args[0] instanceof TaskEntity) {
TaskEntity task = JSONObject.parseObject(JSON.toJSONString(args[0]),TaskEntity.class);
this.pushMessageByTask(task);
}
},"巡检任务消息推送");
joinPoint.proceed();
@AfterReturning(value = "taskSaveCut()",returning = "result")
private void saveTask(JoinPoint joinPoint,boolean result) throws Throwable {
if(result) {
Object[] args = joinPoint.getArgs();
new Thread(() -> {
if(ObjectUtil.isNotEmpty(args[0]) && args[0] instanceof TaskEntity) {
TaskEntity task = JSONObject.parseObject(JSON.toJSONString(args[0]),TaskEntity.class);
this.pushMessageByTask(task);
}
},"巡检任务消息推送");
}
}
@After("taskSaveCutBatch()")
private void saveTaskBatch(ProceedingJoinPoint joinPoint) throws Throwable {
Object[] args = joinPoint.getArgs();
new Thread(() -> {
if(args.length == 1) {
List<TaskEntity> taskList = JSONArray.parseArray(JSON.toJSONString(args[0]),TaskEntity.class);
taskList.forEach(this::pushMessageByTask);
}
},"巡检任务消息批量推送").start();
joinPoint.proceed();
@AfterReturning(value = "taskSaveCutBatch()",returning = "result")
private void saveTaskBatch(JoinPoint joinPoint,boolean result) throws Throwable {
if(result) {
Object[] args = joinPoint.getArgs();
new Thread(() -> {
if(args.length == 1) {
List<TaskEntity> taskList = JSONArray.parseArray(JSON.toJSONString(args[0]),TaskEntity.class);
taskList.forEach(this::pushMessageByTask);
}
},"巡检任务消息批量推送").start();
}
}
/**

Loading…
Cancel
Save