update:保存推送记录新增标题

This commit is contained in:
sunzheng
2024-07-29 15:09:14 +08:00
parent 3fdc3b3ef2
commit 04bf6c32f6
3 changed files with 19 additions and 9 deletions
@@ -252,9 +252,9 @@ public class FeiShuDockingServiceImpl implements IFeiShuDockingService {
HttpEntity<ApprovalsInstanceVo> entity = new HttpEntity<>(approvalsInstanceVo, headers);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
JSONObject jsonResponse = JSON.parseObject(response.getBody());
logMessage(JSON.toJSONString(instanceDto), jsonResponse, "/feishu/synchronizeApprovalInstance", Constant.FEISHU_PENDING);
logMessage(JSON.toJSONString(instanceDto), instanceDto.getTitle(), jsonResponse, "/feishu/synchronizeApprovalInstance", Constant.FEISHU_PENDING);
}catch (Exception e) {
logError(JSON.toJSONString(instanceDto), e.getMessage(), "/feishu/synchronizeApprovalInstance", Constant.FEISHU_PENDING);
logError(JSON.toJSONString(instanceDto), instanceDto.getTitle(), e.getMessage(), "/feishu/synchronizeApprovalInstance", Constant.FEISHU_PENDING);
log.error("同步三方审批实例异常" + e.getMessage());
}
}
@@ -423,7 +423,7 @@ public class FeiShuDockingServiceImpl implements IFeiShuDockingService {
BotMessageDto botMessageDto1 = new BotMessageDto();
BeanUtils.copyProperties(botMessageDto,botMessageDto1);
botMessageDto1.setReceiveIds(id);
logError(JSON.toJSONString(botMessageDto1), "用户id:" + id +"对应的飞书账用户不存在", "/feishu/sendHrefMessageByBot", Constant.FEISHU_MESSAGE);
logError(JSON.toJSONString(botMessageDto1), botMessageDto.getTitle(),"用户id:" + id +"对应的飞书账用户不存在", "/feishu/sendHrefMessageByBot", Constant.FEISHU_MESSAGE);
}
}
}
@@ -482,30 +482,32 @@ public class FeiShuDockingServiceImpl implements IFeiShuDockingService {
HttpEntity<BotMessageVo> entity = new HttpEntity<>(botMessageVo, headers);
ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
JSONObject jsonResponse = JSON.parseObject(response.getBody());
logMessage(JSON.toJSONString(botMessageDto), jsonResponse, "/feishu/sendHrefMessageByBot", Constant.FEISHU_MESSAGE);
logMessage(JSON.toJSONString(botMessageDto), botMessageDto.getTitle(), jsonResponse, "/feishu/sendHrefMessageByBot", Constant.FEISHU_MESSAGE);
}
} catch (Exception e) {
logError(JSON.toJSONString(botMessageDto), e.getMessage(), "/feishu/sendHrefMessageByBot", Constant.FEISHU_MESSAGE);
logError(JSON.toJSONString(botMessageDto),botMessageDto.getTitle(), e.getMessage(), "/feishu/sendHrefMessageByBot", Constant.FEISHU_MESSAGE);
}
}
private void logMessage(String dto, JSONObject jsonResponse, String url, Integer messageType) {
private void logMessage(String dto, String title, JSONObject jsonResponse, String url, Integer messageType) {
LawsUnifiedTodoLog logEntry = new LawsUnifiedTodoLog();
logEntry.setJsonStr(dto);
logEntry.setResponseBody(JSON.toJSONString(jsonResponse));
logEntry.setState("0".equals(jsonResponse.getString("code")) ? 1 : 2);
logEntry.setMessageType(messageType);
logEntry.setUrl(url);
logEntry.setTitle(title);
lawsUnifiedTodoLogService.add(logEntry);
}
private void logError(String dto, String errorMessage, String url, Integer messageType) {
private void logError(String dto, String title, String errorMessage, String url, Integer messageType) {
LawsUnifiedTodoLog logEntry = new LawsUnifiedTodoLog();
logEntry.setJsonStr(dto);
logEntry.setResponseBody(errorMessage);
logEntry.setState(2);
logEntry.setMessageType(messageType);
logEntry.setUrl(url);
logEntry.setTitle(title);
lawsUnifiedTodoLogService.add(logEntry);
log.error("飞书发送消息异常: " + errorMessage);
}
@@ -87,4 +87,11 @@ public class LawsUnifiedTodoLog {
@ApiModelProperty(value="更新时间")
private Date updateTime;
/**
* 标题
*/
@TableField(value = "title")
@ApiModelProperty(value="标题")
private String title;
}
@@ -111,13 +111,13 @@ public class UnifiedTodoServiceImpl implements PushWorkflowIntegrationAPI {
String reqJsonString = JSONObject.toJSONString(unifiedTodoVOList);
String jsonString = JSONObject.toJSONString(unifiedTodoList);
log.info("统一待办推送入参" + jsonString);
push(ip + todoUrl,jsonString, reqJsonString);
push(ip + todoUrl,jsonString, reqJsonString, unifiedTodoList.get(0).getRequestname());
}catch (Exception e){
log.error("统一待办推送异常",e);
}
}
private void push(String url, String jsonString, String reqJsonString) {
private void push(String url, String jsonString, String reqJsonString, String title) {
// 设置最大重试次数
int maxRetries = 3;
// 当前重试次数
@@ -151,6 +151,7 @@ public class UnifiedTodoServiceImpl implements PushWorkflowIntegrationAPI {
lawsUnifiedTodoLog.setUrl(url);
lawsUnifiedTodoLog.setJsonStr(reqJsonString);
lawsUnifiedTodoLog.setMessageType(1);
lawsUnifiedTodoLog.setTitle(title);
if (retries == maxRetries){
lawsUnifiedTodoLog.setState(2);
}else {