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

Loading…
Cancel
Save