BackInvokeService.java 1.31 KB
package com.huaheng.pc.task.taskHeader.service;

import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BackInvokeService {

    @Resource
    private BackQueue backQueue;
    @Resource
    private TaskHeaderService taskHeaderService;

    public void invokeBack(int taskId){
        new Thread(()->{
            backQueue.receiveBack(taskId, new CallBack() {
                @Override
                public void back(Boolean flag, String message) {
                    if(!flag){
                        TaskHeader taskHeader = taskHeaderService.getById(taskId);
                        taskHeader.setBackInfo(message);
                        taskHeader.setIsReturn(1);
                        taskHeader.setCompleteStatus(1);
                        taskHeaderService.updateById(taskHeader);
                    }else{
                        TaskHeader taskHeader = taskHeaderService.getById(taskId);
                        taskHeader.setCompleteStatus(2);
                        taskHeader.setBackInfo(message);
                        taskHeader.setIsReturn(2);
                        taskHeaderService.updateById(taskHeader);
                    }
                }
            });
        },"async-thread").start();
    }
}