|
|
@@ -22,6 +22,7 @@ import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import lombok.var;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
@@ -79,12 +80,37 @@ public class TbServiceImpl implements TBService {
|
|
|
}
|
|
|
|
|
|
/*TODO:接收TB推送的数据*/
|
|
|
+
|
|
|
+ //TODO:异步执行
|
|
|
+
|
|
|
+ // 耗时操作必须放在独立方法上(不能和 Controller 在同一个类!)
|
|
|
+ @Async("businessTaskExecutor") // 指定线程池
|
|
|
+ public McR tbTaskUpdate(Map body) throws JsonProcessingException{
|
|
|
+ try {
|
|
|
+ // 模拟耗时操作(实际替换为你的业务)
|
|
|
+// Thread.sleep(50000); // 50秒
|
|
|
+
|
|
|
+
|
|
|
+ tbTaskUpdate_A(body);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // ⚠ 异步任务异常不会抛到 Controller,必须自己处理!
|
|
|
+ log.error("异步业务执行失败, 宜搭前端传参{}", body, e);
|
|
|
+ // 可选:发送告警、存入重试队列等
|
|
|
+ }
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //TODO:原始方法
|
|
|
@SneakyThrows
|
|
|
@Override
|
|
|
- public McR tbTaskUpdate(Map body) throws JsonProcessingException {
|
|
|
+ public McR tbTaskUpdate_A(Map body) throws JsonProcessingException {
|
|
|
+ log.info("----开始接收webhook----");
|
|
|
String s = JSON.toJSONString(body);
|
|
|
JSONObject jsonObject = JSON.parseObject(s);
|
|
|
String event = jsonObject.getString("event");
|
|
|
+ log.info("event:{}",event);
|
|
|
//一层过滤:过滤事件[任务自定义字段更新事件]
|
|
|
if (event.equals("v3.task.customfield.update")){
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
@@ -248,7 +274,9 @@ public class TbServiceImpl implements TBService {
|
|
|
}
|
|
|
}
|
|
|
} else if (event.equals("v3.task.create")) {
|
|
|
+ log.info("---更新任务确认---");
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
+ log.info("data:{}",data);
|
|
|
String sfcId = data.getString("sfcId");
|
|
|
if (sfcId.equals("6878b3c0669d175c3c6bc679") || sfcId.equals("6878b3ceb5ffcf500365d17a") || sfcId.equals("6878b3d8f40485da4c5f99a2")
|
|
|
|| sfcId.equals("6878b39a27ae5f3cac355fb9") || sfcId.equals("6878b3a4090e6872fd6b78c6") || sfcId.equals("6878b3ad9e17ac8a027c6d37")
|