list = sendTodoLogMapper.selectList(wrapper);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
if(!list.isEmpty()){
- sendTodoLog = list.get(0);
- }
- if(sendTodoLog != null){
+ SendTodoLog sendTodoLog = list.get(0);
int againNumNew = Integer.valueOf(sendTodoLog.getErrNum());
- if(againNumNew >= 9){
+ if(againNumNew >= 6){
// 发送待办 或 发送给管理员邮箱
- logger.info("发送失败9次,发送给管理员邮箱");
-
+ logger.info("发送失败6次,发送给管理员邮箱");
}else {
- // 发送失败连续持续3次, 如果在失败等待1个小时后重试3次
- if(againNumNew == 3 || againNumNew == 6){
- Thread.sleep(3600000);
- logger.info("发送失败连续持续3次,等待1个小时后重试3次!!!!!!!!!");
-
- }else {
- logger.info("发送失败连续持续"+againNumNew+"次!!");
- }
- sendTodoLog.setErrNum(sendTodoLog.getErrNum()+1);
- iSendTodoLogService.save(sendTodoLog);
- convertMq.sendTodoMq(object);
- logger.info("已重新加入转换");
+ restSendTodo(object, sdf, sendTodoLog, againNumNew);
}
}else {
- sendTodoLog.setMsgType("0");
- sendTodoLog.setTodoId(object.getId());
- sendTodoLog.setUserId(object.getUserId());
-// sendTodoLog.set
+ sendTodoSave(object, sdf, "3");
}
+ }
+ private void restSendTodo(BusProcessNew object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew) throws Exception{
+ // 失败次数小于6次,放入失败队列延迟消费
+ if((againNumNew < 6)){
+ Thread.sleep(3000);
+ logger.info("发送失败连续持续"+againNumNew+"次,存入延迟重试队列!!!!!!!!!");
+ }else {
+ logger.info("发送失败连续持续"+againNumNew+"次!!");
+ }
+ sendTodoLog.setErrNum(sendTodoLog.getErrNum()+1);
+ sendTodoLog.setUpdateTime(sdf.format(new Date()));
+ sendTodoLogMapper.updateById(sendTodoLog);
+ convertMq.sendTodoMq(object);
+ logger.info("已重新加入延迟队列");
+ }
+ private void sendTodoSave(BusProcessNew object, SimpleDateFormat sdf, String s) {
+ SendTodoLog sendTodoLog = new SendTodoLog();
+ sendTodoLog.setMsgType("0");
+ sendTodoLog.setTodoId(object.getId());
+ sendTodoLog.setUserId(object.getUserId());
+ JSONObject json = JSONObject.fromObject(object);
+ sendTodoLog.setMesg(json.toString());
+ sendTodoLog.setMsgStatus(s);
+ sendTodoLog.setErrNum(1);
+ sendTodoLog.setCreateTime(sdf.format(new Date()));
+ sendTodoLog.setUpdateTime(sdf.format(new Date()));
+ sendTodoLogMapper.insert(sendTodoLog);
+ convertMq.sendTodoMq(object);
+ logger.info("已重新加入延迟队列");
}
}
diff --git a/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/entity/SendTodoLog.java b/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/entity/SendTodoLog.java
index 89a62f57..83ec9622 100644
--- a/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/entity/SendTodoLog.java
+++ b/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/entity/SendTodoLog.java
@@ -1,5 +1,6 @@
package com.ydw.bat.wkflow.business_oa.sendTodoLog.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -30,7 +31,7 @@ public class SendTodoLog implements Serializable {
private static final long serialVersionUID=1L;
@ApiModelProperty(value = "主键")
- @TableId("ID")
+ @TableId(value = "ID", type = IdType.UUID)
private String id;
@ApiModelProperty(value = "类型 0 待办, 1已办, 2 取消, 3 删除")
diff --git a/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/mapper/SendTodoLogMapper.java b/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/mapper/SendTodoLogMapper.java
index 6629bea1..e72f815b 100644
--- a/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/mapper/SendTodoLogMapper.java
+++ b/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/mapper/SendTodoLogMapper.java
@@ -2,6 +2,7 @@ package com.ydw.bat.wkflow.business_oa.sendTodoLog.mapper;
import com.ydw.bat.wkflow.business_oa.sendTodoLog.entity.SendTodoLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
/**
*
@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author super_liu
* @since 2021-09-17
*/
+@Repository
public interface SendTodoLogMapper extends BaseMapper {
}
diff --git a/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/service/impl/SendTodoLogServiceImpl.java b/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/service/impl/SendTodoLogServiceImpl.java
index 94a939aa..f37385f4 100644
--- a/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/service/impl/SendTodoLogServiceImpl.java
+++ b/src/main/java/com/ydw/bat/wkflow/business_oa/sendTodoLog/service/impl/SendTodoLogServiceImpl.java
@@ -4,6 +4,7 @@ import com.ydw.bat.wkflow.business_oa.sendTodoLog.entity.SendTodoLog;
import com.ydw.bat.wkflow.business_oa.sendTodoLog.mapper.SendTodoLogMapper;
import com.ydw.bat.wkflow.business_oa.sendTodoLog.service.ISendTodoLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@@ -17,4 +18,7 @@ import org.springframework.stereotype.Service;
@Service
public class SendTodoLogServiceImpl extends ServiceImpl implements ISendTodoLogService {
+ @Autowired
+ private SendTodoLogMapper sendTodoLogMapper;
+
}
diff --git a/src/main/java/com/ydw/bat/wkflow/business_oa/webService/controller/WebServiceOAController.java b/src/main/java/com/ydw/bat/wkflow/business_oa/webService/controller/WebServiceOAController.java
index 82fdeb15..c4a5a7f4 100644
--- a/src/main/java/com/ydw/bat/wkflow/business_oa/webService/controller/WebServiceOAController.java
+++ b/src/main/java/com/ydw/bat/wkflow/business_oa/webService/controller/WebServiceOAController.java
@@ -63,7 +63,7 @@ public class WebServiceOAController extends BaseAction {
@ApiOperation(value = "发送待办接口(")
@PostMapping("/sendTodo")
- public NotifyTodoAppResult sendTodo(){
+ public NotifyTodoAppResult sendTodo() throws Exception{
return webServiceOAService.sendTodo(new BusProcessNew());
}
}
diff --git a/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/WebServiceOAService.java b/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/WebServiceOAService.java
index 6972e3a3..2c2bc19b 100644
--- a/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/WebServiceOAService.java
+++ b/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/WebServiceOAService.java
@@ -6,8 +6,8 @@ import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
public interface WebServiceOAService {
- NotifyTodoAppResult sendTodo(BusProcessNew busProcessNew);
+ NotifyTodoAppResult sendTodo(BusProcessNew busProcessNew) throws Exception;
- NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext);
+ NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext) throws Exception;
}
diff --git a/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/impl/WebServiceOAServiceImpl.java b/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/impl/WebServiceOAServiceImpl.java
index 31dadf34..a5966656 100644
--- a/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/impl/WebServiceOAServiceImpl.java
+++ b/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/impl/WebServiceOAServiceImpl.java
@@ -69,106 +69,108 @@ public class WebServiceOAServiceImpl implements WebServiceOAService {
@Override
@Async
- public NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext){
+ public NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext) throws Exception{
NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult();
String result = "";
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
- try {
- JsonSend jsonSend = new JsonSend();
- HEAD head = new HEAD();
- head.setACCOUNT("OA");
- head.setBIZTRANSACTIONID("SYC_161320210206133219");
- head.setCONSUMER("FOTON");
- head.setCOUNT("1");
- head.setPASSWORD("TEST_oa201611241710");
- head.setSRVLEVEL("1");
- List