|
|
|
@@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.budwk.app.base.sms.impl.ncu.util.SmsTokenUtil;
|
|
|
|
|
import com.budwk.app.flow.engine.FlowEngine;
|
|
|
|
|
import com.budwk.app.flow.entity.ProcessDefine;
|
|
|
|
|
import com.budwk.app.flow.entity.ProcessInstance;
|
|
|
|
@@ -16,8 +15,8 @@ import com.budwk.app.todo.service.TodoService;
|
|
|
|
|
import com.budwk.app.todo.util.TodoPlatformTokenUtil;
|
|
|
|
|
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
|
|
|
|
import com.budwk.app.web.commons.base.Globals;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.batik.dom.svg12.Global;
|
|
|
|
|
import org.nutz.dao.Cnd;
|
|
|
|
|
import org.nutz.dao.Dao;
|
|
|
|
|
import org.nutz.integration.jedis.RedisService;
|
|
|
|
@@ -31,14 +30,12 @@ import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ClassName TodoServiceImpl
|
|
|
|
|
* @Author JyuHsin
|
|
|
|
|
* @Date 2026/3/12 14:12
|
|
|
|
|
* @Version 1.0
|
|
|
|
|
* @Description TODO
|
|
|
|
|
* 南昌大学统一待办平台接口实现
|
|
|
|
|
* @author JyuHsin
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@IocBean
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class TodoServiceImpl implements TodoService {
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
@@ -50,27 +47,96 @@ public class TodoServiceImpl implements TodoService {
|
|
|
|
|
@Inject
|
|
|
|
|
private TodoPlatformTokenUtil tokenUtil;
|
|
|
|
|
|
|
|
|
|
private static final String BASE_URL = "https://poa.ncu.edu.cn/apis/ttc/v1/transaction/poa/";
|
|
|
|
|
private static final String APP_ID = "72e34a101d3011f1a74cbae5193504f4";
|
|
|
|
|
private static final int SUCCESS_CODE = 0;
|
|
|
|
|
|
|
|
|
|
private interface ApiUrl {
|
|
|
|
|
String ADD_TRANSACTION = BASE_URL + "addTransaction";
|
|
|
|
|
String TASK_HANDLE = BASE_URL + "taskHandle";
|
|
|
|
|
String TASK_COMPLAINT = BASE_URL + "taskComplaint";
|
|
|
|
|
String TASK_WITHDRAW = BASE_URL + "taskWithdraw";
|
|
|
|
|
String TASK_TERMINATE = BASE_URL + "taskTerminate";
|
|
|
|
|
String TRANS_RECOVER = BASE_URL + "transRecover";
|
|
|
|
|
String TRANS_DELETED = BASE_URL + "transDeleted";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 统一发送POST请求
|
|
|
|
|
*/
|
|
|
|
|
private JSONObject sendPost(String url, Map<String, Object> params) {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
if(!Globals.sso) {
|
|
|
|
|
log.error("【待办平台】本地开发模式不允许调用待办");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!SecurityUtil.getUserLoginname().equals("338535821")) {
|
|
|
|
|
log.error("【待办平台】只有工号为338535821才能发送待办");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String token = tokenUtil.getToken();
|
|
|
|
|
log.info("【待办平台】调用接口:{},请求参数:{}", url, Json.toJson(params));
|
|
|
|
|
|
|
|
|
|
String body = HttpUtil.createPost(url)
|
|
|
|
|
.header("Authorization", token)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.form(params)
|
|
|
|
|
.execute()
|
|
|
|
|
.body();
|
|
|
|
|
|
|
|
|
|
log.info("【待办平台】接口响应:{}", body);
|
|
|
|
|
return JSONUtil.parseObj(body);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("【待办平台】接口调用异常:{}", e.getMessage(), e);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 统一处理响应结果
|
|
|
|
|
*/
|
|
|
|
|
private void handleResult(JSONObject result, String apiName) {
|
|
|
|
|
if (result == null) {
|
|
|
|
|
log.error("【待办平台】{} 调用失败:接口响应为空", apiName);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (result.getInt("code") == SUCCESS_CODE) {
|
|
|
|
|
log.info("【待办平台】{} 调用成功", apiName);
|
|
|
|
|
} else {
|
|
|
|
|
log.error("【待办平台】{} 调用失败:{}", apiName, result.getStr("message"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取处理人字符串
|
|
|
|
|
*/
|
|
|
|
|
private String getHandlers(Long taskId) {
|
|
|
|
|
List<ProcessTaskActor> list = dao.query(ProcessTaskActor.class,
|
|
|
|
|
Cnd.where(ProcessTaskActor::getProcessTaskId, "=", taskId));
|
|
|
|
|
return list.stream()
|
|
|
|
|
.map(ProcessTaskActor::getActorAccount)
|
|
|
|
|
.collect(Collectors.joining(","));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addTransaction(ProcessTask task) {
|
|
|
|
|
String url = "https://poa.ncu.edu.cn/apis/ttc/v1/transaction/poa/addTransaction";
|
|
|
|
|
String token = tokenUtil.getToken();
|
|
|
|
|
|
|
|
|
|
ProcessInstance instance = dao.fetch(ProcessInstance.class, task.getProcessInstanceId());
|
|
|
|
|
ProcessDefine define = dao.fetch(ProcessDefine.class, instance.getProcessDefineId());
|
|
|
|
|
Sys_user sysUser = dao.fetch(Sys_user.class, instance.getOperator());
|
|
|
|
|
List<ProcessTaskActor> taskActorList = dao.query(ProcessTaskActor.class, Cnd.where(ProcessTaskActor::getProcessTaskId, "=", task.getId()));
|
|
|
|
|
String handlers = taskActorList.stream().map(ProcessTaskActor::getActorAccount).collect(Collectors.joining(","));
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("appId", "72e34a101d3011f1a74cbae5193504f4");
|
|
|
|
|
params.put("appId", APP_ID);
|
|
|
|
|
params.put("nodeId", task.getId());
|
|
|
|
|
params.put("nodeName", task.getTaskName());
|
|
|
|
|
params.put("taskId", task.getId());
|
|
|
|
|
params.put("taskName", task.getDisplayName());
|
|
|
|
|
params.put("transTypeCode", define.getName());
|
|
|
|
|
params.put("transTypeName", define.getDisplayName());
|
|
|
|
|
params.put("handlers", handlers);
|
|
|
|
|
if(!ObjectUtil.equals(0, task.getTaskParentId())) {
|
|
|
|
|
params.put("handlers", getHandlers(task.getId()));
|
|
|
|
|
if (!ObjectUtil.equals(0, task.getTaskParentId())) {
|
|
|
|
|
params.put("previousTaskId", task.getTaskParentId());
|
|
|
|
|
}
|
|
|
|
|
params.put("canDelegate", 0);
|
|
|
|
@@ -81,199 +147,92 @@ public class TodoServiceImpl implements TodoService {
|
|
|
|
|
params.put("handleUrl", Globals.AppDomain + task.getFormKey());
|
|
|
|
|
params.put("mHandleUrl", Globals.AppDomain + task.getH5FormKey());
|
|
|
|
|
|
|
|
|
|
log.info("【log】调用创建待办任务接口,请求参数:{}", Json.toJson(params));
|
|
|
|
|
String body = HttpUtil.createPost(url)
|
|
|
|
|
.header("Authorization", token)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.form(params).execute().body();
|
|
|
|
|
JSONObject resultJsonBody = JSONUtil.parseObj(body);
|
|
|
|
|
log.info("【log】调用创建待办任务接口,接口响应数据:{}", body);
|
|
|
|
|
|
|
|
|
|
if (resultJsonBody.getInt("code") == 0) {
|
|
|
|
|
log.info("【log】调用创建待办任务接口成功");
|
|
|
|
|
} else {
|
|
|
|
|
log.info("【log】调用创建待办任务接口失败:{}", resultJsonBody.getStr("message"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject result = sendPost(ApiUrl.ADD_TRANSACTION, params);
|
|
|
|
|
handleResult(result, "创建待办任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void taskHandle(ProcessTask task) {
|
|
|
|
|
String url = "https://poa.ncu.edu.cn/apis/ttc/v1/transaction/poa/taskHandle";
|
|
|
|
|
String token = tokenUtil.getToken();
|
|
|
|
|
|
|
|
|
|
ProcessInstance instance = dao.fetch(ProcessInstance.class, task.getProcessInstanceId());
|
|
|
|
|
String status = instance.getState().equals(ProcessInstanceStateEnum.FINISHED.getCode()) ? "end" : "none";
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("appId", "72e34a101d3011f1a74cbae5193504f4");
|
|
|
|
|
params.put("appId", APP_ID);
|
|
|
|
|
params.put("handler", SecurityUtil.getUserLoginname());
|
|
|
|
|
params.put("previousTaskId", task.getId());
|
|
|
|
|
params.put("status", instance.getState().equals(ProcessInstanceStateEnum.FINISHED.getCode()) ? "end" : "none");
|
|
|
|
|
params.put("status", status);
|
|
|
|
|
|
|
|
|
|
log.info("【log】调用办理待办任务接口,请求参数:{}", Json.toJson(params));
|
|
|
|
|
String body = HttpUtil.createPost(url)
|
|
|
|
|
.header("Authorization", token)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.form(params).execute().body();
|
|
|
|
|
JSONObject resultJsonBody = JSONUtil.parseObj(body);
|
|
|
|
|
log.info("【log】调用办理待办任务接口,接口响应数据:{}", body);
|
|
|
|
|
|
|
|
|
|
if (resultJsonBody.getInt("code") == 0) {
|
|
|
|
|
log.info("【log】调用办理待办任务接口成功");
|
|
|
|
|
} else {
|
|
|
|
|
log.info("【log】调用办理待办任务接口失败:{}", resultJsonBody.getStr("message"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject result = sendPost(ApiUrl.TASK_HANDLE, params);
|
|
|
|
|
handleResult(result, "办理待办任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void taskComplaint(ProcessTask task) {
|
|
|
|
|
String url = "https://poa.ncu.edu.cn/apis/ttc/v1/transaction/poa/taskComplaint";
|
|
|
|
|
String token = tokenUtil.getToken();
|
|
|
|
|
|
|
|
|
|
ProcessInstance instance = dao.fetch(ProcessInstance.class, task.getProcessInstanceId());
|
|
|
|
|
Sys_user sysUser = dao.fetch(Sys_user.class, instance.getOperator());
|
|
|
|
|
List<ProcessTaskActor> taskActorList = dao.query(ProcessTaskActor.class, Cnd.where(ProcessTaskActor::getProcessTaskId, "=", task.getId()));
|
|
|
|
|
String handlers = taskActorList.stream().map(ProcessTaskActor::getActorAccount).collect(Collectors.joining(","));
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("appId", "72e34a101d3011f1a74cbae5193504f4");
|
|
|
|
|
params.put("appId", APP_ID);
|
|
|
|
|
params.put("createTime", "");
|
|
|
|
|
params.put("creater", sysUser.getLoginname());
|
|
|
|
|
params.put("creator", sysUser.getLoginname());
|
|
|
|
|
params.put("handlers", handlers);
|
|
|
|
|
params.put("handlers", getHandlers(task.getId()));
|
|
|
|
|
params.put("handlingGroup", "");
|
|
|
|
|
params.put("operator", sysUser.getLoginname());
|
|
|
|
|
params.put("taskId", task.getId());
|
|
|
|
|
|
|
|
|
|
log.info("【log】调用转办待办任务接口,请求参数:{}", Json.toJson(params));
|
|
|
|
|
String body = HttpUtil.createPost(url)
|
|
|
|
|
.header("Authorization", token)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.form(params).execute().body();
|
|
|
|
|
JSONObject resultJsonBody = JSONUtil.parseObj(body);
|
|
|
|
|
log.info("【log】调用转办待办任务接口,接口响应数据:{}", body);
|
|
|
|
|
|
|
|
|
|
if (resultJsonBody.getInt("code") == 0) {
|
|
|
|
|
log.info("【log】调用转办待办任务接口成功");
|
|
|
|
|
} else {
|
|
|
|
|
log.info("【log】调用转办待办任务接口失败:{}", resultJsonBody.getStr("message"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject result = sendPost(ApiUrl.TASK_COMPLAINT, params);
|
|
|
|
|
handleResult(result, "转办待办任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void taskWithdraw(ProcessTask task) {
|
|
|
|
|
/*String url = "https://poa.ncu.edu.cn/apis/ttc/v1/transaction/poa/taskWithdraw";
|
|
|
|
|
String token = tokenUtil.getToken();
|
|
|
|
|
|
|
|
|
|
ProcessInstance instance = dao.fetch(ProcessInstance.class, task.getProcessInstanceId());
|
|
|
|
|
Sys_user sysUser = dao.fetch(Sys_user.class, instance.getOperator());
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("appId", "72e34a101d3011f1a74cbae5193504f4");
|
|
|
|
|
params.put("taskId", task.getId());
|
|
|
|
|
params.put("creater", sysUser.getLoginname());
|
|
|
|
|
params.put("creator", sysUser.getLoginname());
|
|
|
|
|
params.put("status", "end");
|
|
|
|
|
|
|
|
|
|
log.info("【log】调用撤回待办任务接口,请求参数:{}", Json.toJson(params));
|
|
|
|
|
String body = HttpUtil.createPost(url)
|
|
|
|
|
.header("Authorization", token)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.form(params).execute().body();
|
|
|
|
|
JSONObject resultJsonBody = JSONUtil.parseObj(body);
|
|
|
|
|
log.info("【log】调用撤回待办任务接口,接口响应数据:{}", body);
|
|
|
|
|
|
|
|
|
|
if (resultJsonBody.getInt("code") == 0) {
|
|
|
|
|
log.info("【log】调用撤回待办任务接口成功");
|
|
|
|
|
} else {
|
|
|
|
|
log.info("【log】调用撤回待办任务接口失败:{}", resultJsonBody.getStr("message"));
|
|
|
|
|
}*/
|
|
|
|
|
// 已注释逻辑保持不变
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void taskTerminate(ProcessTask task) {
|
|
|
|
|
String url = "https://poa.ncu.edu.cn/apis/ttc/v1/transaction/poa/taskTerminate";
|
|
|
|
|
String token = tokenUtil.getToken();
|
|
|
|
|
|
|
|
|
|
ProcessInstance instance = dao.fetch(ProcessInstance.class, task.getProcessInstanceId());
|
|
|
|
|
Sys_user sysUser = dao.fetch(Sys_user.class, instance.getOperator());
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("appId", "72e34a101d3011f1a74cbae5193504f4");
|
|
|
|
|
params.put("appId", APP_ID);
|
|
|
|
|
params.put("creater", sysUser.getLoginname());
|
|
|
|
|
params.put("creator", sysUser.getLoginname());
|
|
|
|
|
params.put("handlers", "");
|
|
|
|
|
params.put("operator", SecurityUtil.getUserLoginname());
|
|
|
|
|
params.put("taskId", task.getId());
|
|
|
|
|
|
|
|
|
|
log.info("【log】调用终止待办任务接口,请求参数:{}", Json.toJson(params));
|
|
|
|
|
String body = HttpUtil.createPost(url)
|
|
|
|
|
.header("Authorization", token)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.form(params).execute().body();
|
|
|
|
|
JSONObject resultJsonBody = JSONUtil.parseObj(body);
|
|
|
|
|
log.info("【log】调用终止待办任务接口,接口响应数据:{}", body);
|
|
|
|
|
|
|
|
|
|
if (resultJsonBody.getInt("code") == 0) {
|
|
|
|
|
log.info("【log】调用终止待办任务接口成功");
|
|
|
|
|
} else {
|
|
|
|
|
log.info("【log】调用终止待办任务接口失败:{}", resultJsonBody.getStr("message"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject result = sendPost(ApiUrl.TASK_TERMINATE, params);
|
|
|
|
|
handleResult(result, "终止待办任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void transRecover(ProcessTask task) {
|
|
|
|
|
String url = "https://poa.ncu.edu.cn/apis/ttc/v1/transaction/poa/transRecover";
|
|
|
|
|
String token = tokenUtil.getToken();
|
|
|
|
|
|
|
|
|
|
ProcessInstance instance = dao.fetch(ProcessInstance.class, task.getProcessInstanceId());
|
|
|
|
|
Sys_user sysUser = dao.fetch(Sys_user.class, instance.getOperator());
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("appId", "72e34a101d3011f1a74cbae5193504f4");
|
|
|
|
|
params.put("appId", APP_ID);
|
|
|
|
|
params.put("creater", sysUser.getLoginname());
|
|
|
|
|
params.put("taskId", task.getId());
|
|
|
|
|
|
|
|
|
|
log.info("【log】调用事务恢复接口,请求参数:{}", Json.toJson(params));
|
|
|
|
|
String body = HttpUtil.createPost(url)
|
|
|
|
|
.header("Authorization", token)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.form(params).execute().body();
|
|
|
|
|
JSONObject resultJsonBody = JSONUtil.parseObj(body);
|
|
|
|
|
log.info("【log】调用事务恢复接口,接口响应数据:{}", body);
|
|
|
|
|
|
|
|
|
|
if (resultJsonBody.getInt("code") == 0) {
|
|
|
|
|
log.info("【log】调用事务恢复接口成功");
|
|
|
|
|
} else {
|
|
|
|
|
log.info("【log】调用事务恢复接口失败:{}", resultJsonBody.getStr("message"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject result = sendPost(ApiUrl.TRANS_RECOVER, params);
|
|
|
|
|
handleResult(result, "事务恢复");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void transDeleted(ProcessTask task) {
|
|
|
|
|
String url = "https://poa.ncu.edu.cn/apis/ttc/v1/transaction/poa/transDeleted";
|
|
|
|
|
String token = tokenUtil.getToken();
|
|
|
|
|
|
|
|
|
|
ProcessInstance instance = dao.fetch(ProcessInstance.class, task.getProcessInstanceId());
|
|
|
|
|
Sys_user sysUser = dao.fetch(Sys_user.class, instance.getOperator());
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("appId", "72e34a101d3011f1a74cbae5193504f4");
|
|
|
|
|
params.put("appId", APP_ID);
|
|
|
|
|
params.put("creater", sysUser.getLoginname());
|
|
|
|
|
params.put("creator", sysUser.getLoginname());
|
|
|
|
|
params.put("taskId", task.getId());
|
|
|
|
|
|
|
|
|
|
log.info("【log】调用事务删除接口,请求参数:{}", Json.toJson(params));
|
|
|
|
|
String body = HttpUtil.createPost(url)
|
|
|
|
|
.header("Authorization", token)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.form(params).execute().body();
|
|
|
|
|
JSONObject resultJsonBody = JSONUtil.parseObj(body);
|
|
|
|
|
log.info("【log】调用事务删除接口,接口响应数据:{}", body);
|
|
|
|
|
|
|
|
|
|
if (resultJsonBody.getInt("code") == 0) {
|
|
|
|
|
log.info("【log】调用事务删除接口成功");
|
|
|
|
|
} else {
|
|
|
|
|
log.info("【log】调用事务删除接口失败:{}", resultJsonBody.getStr("message"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject result = sendPost(ApiUrl.TRANS_DELETED, params);
|
|
|
|
|
handleResult(result, "事务删除");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|