添加定时向OA推送待办推送失败的数据
This commit is contained in:
@@ -535,3 +535,11 @@ ALTER TABLE laws_document_split ADD PRIMARY KEY (id);
|
|||||||
-- 2024-09-24 外来标准库增加 关联部门 字段长度
|
-- 2024-09-24 外来标准库增加 关联部门 字段长度
|
||||||
ALTER TABLE `laws_domestic_standard`
|
ALTER TABLE `laws_domestic_standard`
|
||||||
MODIFY COLUMN `associate_dept` text NULL COMMENT '关联部门';
|
MODIFY COLUMN `associate_dept` text NULL COMMENT '关联部门';
|
||||||
|
|
||||||
|
-- 2024-09-25 流程待办推送记录表
|
||||||
|
ALTER TABLE `laws_unified_todo_log`
|
||||||
|
MODIFY COLUMN `json_str` longtext NULL COMMENT '推送内容';
|
||||||
|
ALTER TABLE `laws_unified_todo_log`
|
||||||
|
MODIFY COLUMN `response_body` longtext NULL COMMENT '返回值';
|
||||||
|
CREATE INDEX lutl_idx_state ON laws_unified_todo_log(`state`);
|
||||||
|
CREATE INDEX lutl_idx_message_type ON laws_unified_todo_log(`message_type`);
|
||||||
|
|||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
package com.jero.modules.docking.hiwork.job;
|
||||||
|
|
||||||
|
import cn.hutool.http.Header;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.jero.common.api.PushWorkflowIntegrationAPI;
|
||||||
|
import com.jero.common.api.dto.message.UnifiedTodoVO;
|
||||||
|
import com.jero.modules.docking.hiwork.entity.LawsUnifiedTodoLog;
|
||||||
|
import com.jero.modules.docking.hiwork.service.LawsUnifiedTodoLogService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每天全量推送失败的待办
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SyncOaSendDataJob implements Job {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LawsUnifiedTodoLogService lawsUnifiedTodoLogService;
|
||||||
|
@Resource
|
||||||
|
private PushWorkflowIntegrationAPI pushWorkflowIntegrationAPI;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
|
LambdaQueryWrapper<LawsUnifiedTodoLog> queryLawsUnifiedTodoLog = new LambdaQueryWrapper<>();
|
||||||
|
queryLawsUnifiedTodoLog.eq(LawsUnifiedTodoLog::getState,"2");
|
||||||
|
queryLawsUnifiedTodoLog.eq(LawsUnifiedTodoLog::getMessageType,"1");
|
||||||
|
List<LawsUnifiedTodoLog> listLawsUnifiedTodoLog = lawsUnifiedTodoLogService.list(queryLawsUnifiedTodoLog);
|
||||||
|
if(CollectionUtils.isEmpty(listLawsUnifiedTodoLog)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (LawsUnifiedTodoLog lawsUnifiedTodoLog : listLawsUnifiedTodoLog) {
|
||||||
|
if(StringUtils.isBlank(lawsUnifiedTodoLog.getJsonStr())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
List<UnifiedTodoVO> unifiedTodoVOList = JSON.parseObject(lawsUnifiedTodoLog.getJsonStr(),
|
||||||
|
new TypeReference<List<UnifiedTodoVO>>() {});
|
||||||
|
try {
|
||||||
|
pushWorkflowIntegrationAPI.sendTodoTask(unifiedTodoVOList);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("OA推送待办异常" + e.getMessage());
|
||||||
|
}
|
||||||
|
LambdaUpdateWrapper<LawsUnifiedTodoLog> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(LawsUnifiedTodoLog::getId,lawsUnifiedTodoLog.getId());
|
||||||
|
updateWrapper.set(LawsUnifiedTodoLog::getState,1);
|
||||||
|
updateWrapper.set(LawsUnifiedTodoLog::getCreateBy,"admin");
|
||||||
|
updateWrapper.set(LawsUnifiedTodoLog::getUpdateTime,new Date());
|
||||||
|
lawsUnifiedTodoLogService.update(updateWrapper);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("OA推送待办定时推送异常" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
-30
@@ -143,40 +143,48 @@ public class UnifiedTodoServiceImpl implements PushWorkflowIntegrationAPI {
|
|||||||
while (retries < maxRetries) {
|
while (retries < maxRetries) {
|
||||||
log.info("==========OA调用");
|
log.info("==========OA调用");
|
||||||
// 远程调用
|
// 远程调用
|
||||||
HttpResponse execute = HttpRequest.post(url)
|
try {
|
||||||
.header(Header.CONTENT_TYPE, "application/json;charset=UTF-8")
|
HttpResponse execute = HttpRequest.post(url)
|
||||||
.body(jsonString)//表单内容
|
.header(Header.CONTENT_TYPE, "application/json;charset=UTF-8")
|
||||||
.timeout(3000)//超时,毫秒
|
.body(jsonString)//表单内容
|
||||||
.execute();
|
.timeout(3000)//超时,毫秒
|
||||||
if (execute.isOk()) {
|
.execute();
|
||||||
String body = execute.body();
|
log.info("==========OA调用成功");
|
||||||
List<JSONObject> listJson = JSONArray.parseArray(body,JSONObject.class);
|
if (execute.isOk()) {
|
||||||
if(!CollectionUtils.isEmpty(listJson)) {
|
String body = execute.body();
|
||||||
String operResult = String.valueOf(listJson.get(0).get("operResult"));
|
List<JSONObject> listJson = JSONArray.parseArray(body,JSONObject.class);
|
||||||
|
if(!CollectionUtils.isEmpty(listJson)) {
|
||||||
|
String operResult = String.valueOf(listJson.get(0).get("operResult"));
|
||||||
|
lawsUnifiedTodoLog.setResponseBody(body);
|
||||||
|
if (Objects.equals(operResult, "1")) {
|
||||||
|
log.info("统一待办推送成功");
|
||||||
|
lawsUnifiedTodoLog.setState(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("统一待办推送失败{}",body);
|
||||||
|
lawsUnifiedTodoLog.setState(2);
|
||||||
|
retries++;
|
||||||
|
}else {
|
||||||
|
String body = execute.body();
|
||||||
lawsUnifiedTodoLog.setResponseBody(body);
|
lawsUnifiedTodoLog.setResponseBody(body);
|
||||||
if (Objects.equals(operResult, "1")) {
|
List<JSONObject> listJson = JSONArray.parseArray(body,JSONObject.class);
|
||||||
log.info("统一待办推送成功");
|
if(!CollectionUtils.isEmpty(listJson)){
|
||||||
lawsUnifiedTodoLog.setState(1);
|
String operResult = String.valueOf(listJson.get(0).get("operResult"));
|
||||||
break;
|
if (Objects.equals(operResult, "1")) {
|
||||||
|
log.info("统一待办推送成功");
|
||||||
|
lawsUnifiedTodoLog.setState(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
log.info("统一待办推送失败{}",body);
|
||||||
|
lawsUnifiedTodoLog.setState(2);
|
||||||
|
retries++;
|
||||||
}
|
}
|
||||||
log.info("统一待办推送失败{}",body);
|
}catch (Exception e){
|
||||||
lawsUnifiedTodoLog.setState(2);
|
log.error("统一待办推送失败{}" + e.getMessage());
|
||||||
retries++;
|
|
||||||
}else {
|
|
||||||
String body = execute.body();
|
|
||||||
lawsUnifiedTodoLog.setResponseBody(body);
|
|
||||||
List<JSONObject> listJson = JSONArray.parseArray(body,JSONObject.class);
|
|
||||||
if(!CollectionUtils.isEmpty(listJson)){
|
|
||||||
String operResult = String.valueOf(listJson.get(0).get("operResult"));
|
|
||||||
if (Objects.equals(operResult, "1")) {
|
|
||||||
log.info("统一待办推送成功");
|
|
||||||
lawsUnifiedTodoLog.setState(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info("统一待办推送失败{}",body);
|
|
||||||
lawsUnifiedTodoLog.setState(2);
|
lawsUnifiedTodoLog.setState(2);
|
||||||
|
lawsUnifiedTodoLog.setResponseBody(e.getMessage());
|
||||||
retries++;
|
retries++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user