feat: There is no way the
This commit is contained in:
@@ -35,11 +35,6 @@
|
|||||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
<version>2.0.0.RELEASE</version>
|
<version>2.0.0.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- scheduled所属资源为spring-context-support -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-context-support</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
|
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
|
||||||
org.activiti.spring.boot.SecurityAutoConfiguration.class })
|
org.activiti.spring.boot.SecurityAutoConfiguration.class })
|
||||||
@MapperScan("com.ydw.bat.wkflow.business.*.mapper")
|
@MapperScan("com.ydw.bat.wkflow.business.*.mapper")
|
||||||
|
@MapperScan("com.ydw.bat.wkflow.business_oa.*")
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
public class BatWkflowApplication {
|
public class BatWkflowApplication {
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,13 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessEntrustService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessEntrustService;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNameService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNameService;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
||||||
|
import com.ydw.bat.wkflow.business_mq.service.CreateMQService;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||||
import com.ydw.bat.wkflow.business_wkflow.form.dto.FormSubmitDto;
|
import com.ydw.bat.wkflow.business_wkflow.form.dto.FormSubmitDto;
|
||||||
import com.ydw.bat.wkflow.business_wkflow.form.service.FormValsService;
|
import com.ydw.bat.wkflow.business_wkflow.form.service.FormValsService;
|
||||||
|
import com.ydw.bat.wkflow.util.SpringContextUtil;
|
||||||
import org.activiti.bpmn.model.BpmnModel;
|
import org.activiti.bpmn.model.BpmnModel;
|
||||||
import org.activiti.bpmn.model.FlowNode;
|
import org.activiti.bpmn.model.FlowNode;
|
||||||
import org.activiti.engine.*;
|
import org.activiti.engine.*;
|
||||||
@@ -39,6 +41,7 @@ import org.activiti.engine.task.Task;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -89,7 +92,7 @@ public class TodoTaskController extends BaseAction {
|
|||||||
private LawsUserInfoService lawsUserInfoService;
|
private LawsUserInfoService lawsUserInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WebServiceOAService webServiceOAService;
|
private CreateMQService mqService;
|
||||||
|
|
||||||
@ApiOperation(value = "我的待办任务列表")
|
@ApiOperation(value = "我的待办任务列表")
|
||||||
@ApiImplicitParams({@ApiImplicitParam(name = "name", value = "名称"),
|
@ApiImplicitParams({@ApiImplicitParam(name = "name", value = "名称"),
|
||||||
@@ -336,9 +339,13 @@ public class TodoTaskController extends BaseAction {
|
|||||||
|
|
||||||
formValsService.saveFormVals(formSubmitDto, task.getTaskDefinitionKey());
|
formValsService.saveFormVals(formSubmitDto, task.getTaskDefinitionKey());
|
||||||
|
|
||||||
|
//发送OA已办
|
||||||
|
try {
|
||||||
//发送OA已办
|
//发送OA已办
|
||||||
completeOA(task);
|
completeOA(task);
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e.toString());
|
||||||
|
}
|
||||||
taskService.complete(busMes.getTaskId());
|
taskService.complete(busMes.getTaskId());
|
||||||
}
|
}
|
||||||
return WrapMapper.ok(task.getProcessInstanceId());
|
return WrapMapper.ok(task.getProcessInstanceId());
|
||||||
@@ -359,9 +366,13 @@ public class TodoTaskController extends BaseAction {
|
|||||||
formSubmitDto.setForm(busMes.getJson());
|
formSubmitDto.setForm(busMes.getJson());
|
||||||
formSubmitDto.setTask_id(taskId);
|
formSubmitDto.setTask_id(taskId);
|
||||||
formValsService.saveFormVals(formSubmitDto, task.getTaskDefinitionKey());
|
formValsService.saveFormVals(formSubmitDto, task.getTaskDefinitionKey());
|
||||||
|
|
||||||
|
try {
|
||||||
//发送OA已办
|
//发送OA已办
|
||||||
completeOA(task);
|
completeOA(task);
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e.toString());
|
||||||
|
}
|
||||||
taskService.complete(taskId);
|
taskService.complete(taskId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,6 +393,7 @@ public class TodoTaskController extends BaseAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void completeOA(Task task){
|
private void completeOA(Task task){
|
||||||
|
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
||||||
logger.info("--------------------------ESP 发送已办任务----------------------------");
|
logger.info("--------------------------ESP 发送已办任务----------------------------");
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||||
NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext();
|
NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext();
|
||||||
@@ -401,16 +413,8 @@ public class TodoTaskController extends BaseAction {
|
|||||||
map.put("LoginName",byId == null ? "" : byId.getData().getAccount());
|
map.put("LoginName",byId == null ? "" : byId.getData().getAccount());
|
||||||
JSONObject jsonLoginName = new JSONObject(map);
|
JSONObject jsonLoginName = new JSONObject(map);
|
||||||
notifyTodoSendContext.setTargets(jsonLoginName.toJSONString());
|
notifyTodoSendContext.setTargets(jsonLoginName.toJSONString());
|
||||||
NotifyTodoAppResult notifyTodoAppResult = webServiceOAService.setTodoDone(notifyTodoSendContext);
|
notifyTodoSendContext.setUserId(task.getAssignee());
|
||||||
if(notifyTodoAppResult != null){
|
oaService.setTodoDoneMq(notifyTodoSendContext);
|
||||||
if(notifyTodoAppResult.getSIGN().equals("0") && notifyTodoAppResult.getMASSAGE().equals("操作成功")){
|
|
||||||
logger.info("--------------------------成功发送 ESP 已办任务----------------------------");
|
|
||||||
}else {
|
|
||||||
logger.error("ESP 发送待办任务异常 :" + "SIGN: "+notifyTodoAppResult.getSIGN()+",MASSAGE: "+notifyTodoAppResult.getMASSAGE());
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
logger.error("--------------------ESP 发送待办任务异常----------------------");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ydw.bat.wkflow.business_mq.service;
|
package com.ydw.bat.wkflow.business_mq.service;
|
||||||
|
|
||||||
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||||
|
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.amqp.core.AmqpTemplate;
|
import org.springframework.amqp.core.AmqpTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -19,7 +20,7 @@ public class CreateMQService {
|
|||||||
* @author: super_liu
|
* @author: super_liu
|
||||||
* @date: 2021年09月17日 14:40
|
* @date: 2021年09月17日 14:40
|
||||||
**/
|
**/
|
||||||
public void setTodoDoneMq(BusProcessNew object) throws Exception{
|
public void setTodoDoneMq(NotifyTodoSendContext object){
|
||||||
|
|
||||||
//发送消息队列
|
//发送消息队列
|
||||||
this.rabbitTemplate.convertAndSend("sendDone-exchange_MQ_GSAR", "sendDone-key_MQ_GSAR", object);
|
this.rabbitTemplate.convertAndSend("sendDone-exchange_MQ_GSAR", "sendDone-key_MQ_GSAR", object);
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
package com.ydw.bat.wkflow.business_mq.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||||
|
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.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||||
|
import com.ydw.bat.wkflow.business_oa.webService.todoContent.NotifyTodoSendContext;
|
||||||
|
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.amqp.support.AmqpHeaders;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.messaging.Message;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SendDoneMQService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SendDoneMQService.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CreateMQService convertMq;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WebServiceOAService webServiceOAService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SendTodoLogMapper sendTodoLogMapper;
|
||||||
|
|
||||||
|
@RabbitListener(bindings = @QueueBinding(
|
||||||
|
value = @Queue(value = "createMQDone_SQ_GSAR", durable = "true"),
|
||||||
|
exchange = @Exchange(value = "sendDone-exchange_MQ_GSAR", ignoreDeclarationExceptions = "true"),
|
||||||
|
key = "sendDone-key_MQ_GSAR"))
|
||||||
|
public void createMQ(NotifyTodoSendContext object, Message message, Channel channel) throws Exception{
|
||||||
|
try{
|
||||||
|
try{
|
||||||
|
insertOrUpdateInfo(object);
|
||||||
|
}catch(InterruptedException e){
|
||||||
|
logger.error(e.toString());
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("消息队列进入添加数据方法前失败!");
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
}finally {
|
||||||
|
Long tag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
|
||||||
|
channel.basicAck(tag,false);
|
||||||
|
logger.debug("消息确认成功!!!!!!!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertOrUpdateInfo(NotifyTodoSendContext object) throws Exception {
|
||||||
|
try {
|
||||||
|
NotifyTodoAppResult todoAppResult = webServiceOAService.setTodoDone(object);
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
if(todoAppResult.getSIGN().equals("0") && todoAppResult.getMASSAGE().equals("操作成功")){
|
||||||
|
logger.info("--------------------------成功发送 ESP 已办任务----------------------------");
|
||||||
|
sendTodoSave(object, sdf, "2");
|
||||||
|
}else {
|
||||||
|
logger.error("ESP 发送待办任务异常 :" + "SIGN: "+todoAppResult.getSIGN()+",MASSAGE: "+todoAppResult.getMASSAGE());
|
||||||
|
// 重试发送待办
|
||||||
|
logger.info("重试发送待办");
|
||||||
|
this.restartSendMq(object);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
this.restartSendMq(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restartSendMq(NotifyTodoSendContext object) throws Exception{
|
||||||
|
SendTodoLog sendTodoLog = new SendTodoLog();
|
||||||
|
QueryWrapper wrapper = new QueryWrapper();
|
||||||
|
wrapper.eq("TODO_ID",object.getModelId());
|
||||||
|
wrapper.eq("MSG_TYPE","1");
|
||||||
|
List<SendTodoLog> list = sendTodoLogMapper.selectList(wrapper);
|
||||||
|
if(!list.isEmpty()){
|
||||||
|
sendTodoLog = list.get(0);
|
||||||
|
}
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||||
|
if(sendTodoLog != null){
|
||||||
|
int againNumNew = Integer.valueOf(sendTodoLog.getErrNum());
|
||||||
|
if(againNumNew >= 6){
|
||||||
|
// 发送待办 或 发送给管理员邮箱
|
||||||
|
logger.info("发送失败9次,发送给管理员邮箱");
|
||||||
|
|
||||||
|
}else {
|
||||||
|
restSendDoneTodo(object, sdf, sendTodoLog, againNumNew);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
sendTodoSave(object, sdf, "3");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restSendDoneTodo(NotifyTodoSendContext object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew) throws Exception{
|
||||||
|
// 发送失败连续持续3次, 如果在失败等待1个小时后重试3次
|
||||||
|
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.setTodoDoneMq(object);
|
||||||
|
logger.info("已重新加入延迟队列");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendTodoSave(NotifyTodoSendContext object, SimpleDateFormat sdf, String s) {
|
||||||
|
SendTodoLog sendTodoLog = new SendTodoLog();
|
||||||
|
sendTodoLog.setMsgType("1");
|
||||||
|
JSONObject json = JSONObject.fromObject(object);
|
||||||
|
sendTodoLog.setTodoId(object.getModelId());
|
||||||
|
sendTodoLog.setMesg(json.toString());
|
||||||
|
sendTodoLog.setMsgStatus(s);
|
||||||
|
sendTodoLog.setErrNum(1);
|
||||||
|
sendTodoLog.setCreateTime(sdf.format(new Date()));
|
||||||
|
sendTodoLog.setUpdateTime(sdf.format(new Date()));
|
||||||
|
sendTodoLog.setUserId(object.getUserId());
|
||||||
|
sendTodoLogMapper.insert(sendTodoLog);
|
||||||
|
convertMq.setTodoDoneMq(object);
|
||||||
|
logger.info("已重新加入延迟队列");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||||
import com.ydw.bat.wkflow.business_oa.sendTodoLog.entity.SendTodoLog;
|
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.ydw.bat.wkflow.business_oa.sendTodoLog.service.ISendTodoLogService;
|
||||||
import com.ydw.bat.wkflow.business_oa.sendTodoLog.service.impl.SendTodoLogServiceImpl;
|
import com.ydw.bat.wkflow.business_oa.sendTodoLog.service.impl.SendTodoLogServiceImpl;
|
||||||
|
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||||
|
import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||||
@@ -15,8 +19,11 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|||||||
import org.springframework.amqp.support.AmqpHeaders;
|
import org.springframework.amqp.support.AmqpHeaders;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.messaging.Message;
|
import org.springframework.messaging.Message;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -28,8 +35,10 @@ public class SendMQService {
|
|||||||
private CreateMQService convertMq;
|
private CreateMQService convertMq;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISendTodoLogService iSendTodoLogService;
|
private WebServiceOAService webServiceOAService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SendTodoLogMapper sendTodoLogMapper;
|
||||||
|
|
||||||
@RabbitListener(bindings = @QueueBinding(
|
@RabbitListener(bindings = @QueueBinding(
|
||||||
value = @Queue(value = "createMQ_SQ_GSAR", durable = "true"),
|
value = @Queue(value = "createMQ_SQ_GSAR", durable = "true"),
|
||||||
@@ -38,7 +47,6 @@ public class SendMQService {
|
|||||||
public void createMQ(BusProcessNew object, Message message, Channel channel) throws Exception{
|
public void createMQ(BusProcessNew object, Message message, Channel channel) throws Exception{
|
||||||
try{
|
try{
|
||||||
try{
|
try{
|
||||||
Thread.sleep(5000);
|
|
||||||
insertOrUpdateInfo(object);
|
insertOrUpdateInfo(object);
|
||||||
}catch(InterruptedException e){
|
}catch(InterruptedException e){
|
||||||
logger.error(e.toString());
|
logger.error(e.toString());
|
||||||
@@ -57,6 +65,16 @@ public class SendMQService {
|
|||||||
|
|
||||||
public void insertOrUpdateInfo(BusProcessNew object) throws Exception {
|
public void insertOrUpdateInfo(BusProcessNew object) throws Exception {
|
||||||
try {
|
try {
|
||||||
|
NotifyTodoAppResult todoAppResult = webServiceOAService.sendTodo(object);
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
if(todoAppResult.getSIGN().equals("1")){
|
||||||
|
// 重试发送待办
|
||||||
|
logger.info("重试发送待办");
|
||||||
|
this.restartSendMq(object);
|
||||||
|
}else {
|
||||||
|
sendTodoSave(object, sdf, "2");
|
||||||
|
}
|
||||||
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
logger.error(e.getMessage(),e);
|
logger.error(e.getMessage(),e);
|
||||||
@@ -65,41 +83,54 @@ public class SendMQService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void restartSendMq(BusProcessNew object) throws Exception{
|
public void restartSendMq(BusProcessNew object) throws Exception{
|
||||||
SendTodoLog sendTodoLog = new SendTodoLog();
|
|
||||||
QueryWrapper wrapper = new QueryWrapper();
|
QueryWrapper wrapper = new QueryWrapper();
|
||||||
wrapper.eq("TODO_ID",object.getId());
|
wrapper.eq("TODO_ID",object.getId());
|
||||||
List<SendTodoLog> list = iSendTodoLogService.list(wrapper);
|
wrapper.eq("MSG_TYPE","0");
|
||||||
|
List<SendTodoLog> list = sendTodoLogMapper.selectList(wrapper);
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||||
if(!list.isEmpty()){
|
if(!list.isEmpty()){
|
||||||
sendTodoLog = list.get(0);
|
SendTodoLog sendTodoLog = list.get(0);
|
||||||
}
|
|
||||||
if(sendTodoLog != null){
|
|
||||||
int againNumNew = Integer.valueOf(sendTodoLog.getErrNum());
|
int againNumNew = Integer.valueOf(sendTodoLog.getErrNum());
|
||||||
if(againNumNew >= 9){
|
if(againNumNew >= 6){
|
||||||
// 发送待办 或 发送给管理员邮箱
|
// 发送待办 或 发送给管理员邮箱
|
||||||
logger.info("发送失败9次,发送给管理员邮箱");
|
logger.info("发送失败6次,发送给管理员邮箱");
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
// 发送失败连续持续3次, 如果在失败等待1个小时后重试3次
|
restSendTodo(object, sdf, sendTodoLog, againNumNew);
|
||||||
if(againNumNew == 3 || againNumNew == 6){
|
}
|
||||||
Thread.sleep(3600000);
|
}else {
|
||||||
logger.info("发送失败连续持续3次,等待1个小时后重试3次!!!!!!!!!");
|
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 {
|
}else {
|
||||||
logger.info("发送失败连续持续"+againNumNew+"次!!");
|
logger.info("发送失败连续持续"+againNumNew+"次!!");
|
||||||
}
|
}
|
||||||
sendTodoLog.setErrNum(sendTodoLog.getErrNum()+1);
|
sendTodoLog.setErrNum(sendTodoLog.getErrNum()+1);
|
||||||
iSendTodoLogService.save(sendTodoLog);
|
sendTodoLog.setUpdateTime(sdf.format(new Date()));
|
||||||
|
sendTodoLogMapper.updateById(sendTodoLog);
|
||||||
convertMq.sendTodoMq(object);
|
convertMq.sendTodoMq(object);
|
||||||
logger.info("已重新加入转换");
|
logger.info("已重新加入延迟队列");
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
|
private void sendTodoSave(BusProcessNew object, SimpleDateFormat sdf, String s) {
|
||||||
|
SendTodoLog sendTodoLog = new SendTodoLog();
|
||||||
sendTodoLog.setMsgType("0");
|
sendTodoLog.setMsgType("0");
|
||||||
sendTodoLog.setTodoId(object.getId());
|
sendTodoLog.setTodoId(object.getId());
|
||||||
sendTodoLog.setUserId(object.getUserId());
|
sendTodoLog.setUserId(object.getUserId());
|
||||||
// sendTodoLog.set
|
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("已重新加入延迟队列");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ydw.bat.wkflow.business_oa.sendTodoLog.entity;
|
package com.ydw.bat.wkflow.business_oa.sendTodoLog.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
@@ -30,7 +31,7 @@ public class SendTodoLog implements Serializable {
|
|||||||
private static final long serialVersionUID=1L;
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
@ApiModelProperty(value = "主键")
|
@ApiModelProperty(value = "主键")
|
||||||
@TableId("ID")
|
@TableId(value = "ID", type = IdType.UUID)
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "类型 0 待办, 1已办, 2 取消, 3 删除")
|
@ApiModelProperty(value = "类型 0 待办, 1已办, 2 取消, 3 删除")
|
||||||
|
|||||||
@@ -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.ydw.bat.wkflow.business_oa.sendTodoLog.entity.SendTodoLog;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
* @author super_liu
|
* @author super_liu
|
||||||
* @since 2021-09-17
|
* @since 2021-09-17
|
||||||
*/
|
*/
|
||||||
|
@Repository
|
||||||
public interface SendTodoLogMapper extends BaseMapper<SendTodoLog> {
|
public interface SendTodoLogMapper extends BaseMapper<SendTodoLog> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -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.mapper.SendTodoLogMapper;
|
||||||
import com.ydw.bat.wkflow.business_oa.sendTodoLog.service.ISendTodoLogService;
|
import com.ydw.bat.wkflow.business_oa.sendTodoLog.service.ISendTodoLogService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,4 +18,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class SendTodoLogServiceImpl extends ServiceImpl<SendTodoLogMapper, SendTodoLog> implements ISendTodoLogService {
|
public class SendTodoLogServiceImpl extends ServiceImpl<SendTodoLogMapper, SendTodoLog> implements ISendTodoLogService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SendTodoLogMapper sendTodoLogMapper;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ public class WebServiceOAController extends BaseAction {
|
|||||||
|
|
||||||
@ApiOperation(value = "发送待办接口(")
|
@ApiOperation(value = "发送待办接口(")
|
||||||
@PostMapping("/sendTodo")
|
@PostMapping("/sendTodo")
|
||||||
public NotifyTodoAppResult sendTodo(){
|
public NotifyTodoAppResult sendTodo() throws Exception{
|
||||||
return webServiceOAService.sendTodo(new BusProcessNew());
|
return webServiceOAService.sendTodo(new BusProcessNew());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@ import com.ydw.bat.wkflow.business_oa.webService.todoResult.NotifyTodoAppResult;
|
|||||||
|
|
||||||
public interface WebServiceOAService {
|
public interface WebServiceOAService {
|
||||||
|
|
||||||
NotifyTodoAppResult sendTodo(BusProcessNew busProcessNew);
|
NotifyTodoAppResult sendTodo(BusProcessNew busProcessNew) throws Exception;
|
||||||
|
|
||||||
NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext);
|
NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-12
@@ -69,11 +69,11 @@ public class WebServiceOAServiceImpl implements WebServiceOAService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Async
|
@Async
|
||||||
public NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext){
|
public NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext) throws Exception{
|
||||||
NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult();
|
NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult();
|
||||||
String result = "";
|
String result = "";
|
||||||
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||||
try {
|
|
||||||
JsonSend jsonSend = new JsonSend();
|
JsonSend jsonSend = new JsonSend();
|
||||||
HEAD head = new HEAD();
|
HEAD head = new HEAD();
|
||||||
head.setACCOUNT("OA");
|
head.setACCOUNT("OA");
|
||||||
@@ -100,21 +100,21 @@ public class WebServiceOAServiceImpl implements WebServiceOAService {
|
|||||||
log.info("--------------------------成功发送 ESP 已办 模块ID"+notifyTodoSendContext.getModelId()+"----------------------------");
|
log.info("--------------------------成功发送 ESP 已办 模块ID"+notifyTodoSendContext.getModelId()+"----------------------------");
|
||||||
log.info("okHttp请求发送已办接口成功结果:"+result);
|
log.info("okHttp请求发送已办接口成功结果:"+result);
|
||||||
}
|
}
|
||||||
|
// try {
|
||||||
} catch (Exception e) {
|
//
|
||||||
log.error(errMes, e.getMessage());
|
// } catch (Exception e) {
|
||||||
}
|
// log.error(errMes, e.getMessage());
|
||||||
|
// }
|
||||||
|
|
||||||
return notifyTodoAppResult;
|
return notifyTodoAppResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Async
|
@Async
|
||||||
public NotifyTodoAppResult sendTodo(BusProcessNew busProcessNew){
|
public NotifyTodoAppResult sendTodo(BusProcessNew busProcessNew) throws Exception{
|
||||||
NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult();
|
NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult();
|
||||||
String result = "";
|
String result = "";
|
||||||
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||||
try {
|
|
||||||
JsonSend jsonSend = new JsonSend();
|
JsonSend jsonSend = new JsonSend();
|
||||||
HEAD head = new HEAD();
|
HEAD head = new HEAD();
|
||||||
head.setACCOUNT("OA");
|
head.setACCOUNT("OA");
|
||||||
@@ -165,10 +165,12 @@ public class WebServiceOAServiceImpl implements WebServiceOAService {
|
|||||||
}else {
|
}else {
|
||||||
log.info("okHttp请求发送待办接口成功结果:"+result);
|
log.info("okHttp请求发送待办接口成功结果:"+result);
|
||||||
}
|
}
|
||||||
|
// try {
|
||||||
} catch (Exception e) {
|
//
|
||||||
log.error(errMes, e.getMessage());
|
//
|
||||||
}
|
// } catch (Exception e) {
|
||||||
|
// log.error(errMes, e.getMessage());
|
||||||
|
// }
|
||||||
|
|
||||||
return notifyTodoAppResult;
|
return notifyTodoAppResult;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -69,4 +69,7 @@ public class NotifyTodoSendContext {
|
|||||||
@ApiModelProperty(value = "操作类型")
|
@ApiModelProperty(value = "操作类型")
|
||||||
private String optType;
|
private String optType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-4
@@ -11,12 +11,16 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class NotifyTodoAppResult {
|
public class NotifyTodoAppResult {
|
||||||
|
|
||||||
@ApiModelProperty(value = "返回状态 0:表示未操作 1:表示操作失败 2:表示操作成功")
|
// @ApiModelProperty(value = "返回状态 0:表示未操作 1:表示操作失败 2:表示操作成功")
|
||||||
|
@ApiModelProperty(value = "返回状态 0:表示操作成功 1:表示操作失败")
|
||||||
private String SIGN;
|
private String SIGN;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "返回信息 " +
|
||||||
|
// "返回状态值为0时,该值返回空 " +
|
||||||
|
// "返回状态值为1时,该值错误信息 " +
|
||||||
|
// "返回状态值为2时,该值返回空")
|
||||||
@ApiModelProperty(value = "返回信息 " +
|
@ApiModelProperty(value = "返回信息 " +
|
||||||
"返回状态值为0时,该值返回空 " +
|
"返回状态值为0时,表示操作成功 " +
|
||||||
"返回状态值为1时,该值错误信息 " +
|
"返回状态值为1时,该值错误信息 ")
|
||||||
"返回状态值为2时,该值返回空")
|
|
||||||
private String MASSAGE;
|
private String MASSAGE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
|||||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNameService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNameService;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.service.IDatasService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IDatasService;
|
||||||
|
import com.ydw.bat.wkflow.business_mq.service.CreateMQService;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||||
import com.ydw.bat.wkflow.util.SpringContextUtil;
|
import com.ydw.bat.wkflow.util.SpringContextUtil;
|
||||||
import org.activiti.engine.delegate.DelegateTask;
|
import org.activiti.engine.delegate.DelegateTask;
|
||||||
@@ -20,7 +21,7 @@ public class ApplyApplicantBefore implements TaskListener{
|
|||||||
@Override
|
@Override
|
||||||
public void notify(DelegateTask delegateTask) {
|
public void notify(DelegateTask delegateTask) {
|
||||||
IBusProcessNewService busBean = SpringContextUtil.getBean(IBusProcessNewService.class);
|
IBusProcessNewService busBean = SpringContextUtil.getBean(IBusProcessNewService.class);
|
||||||
WebServiceOAService oaService = SpringContextUtil.getBean(WebServiceOAService.class);
|
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
||||||
|
|
||||||
QueryWrapper queryWrapper1 = new QueryWrapper();
|
QueryWrapper queryWrapper1 = new QueryWrapper();
|
||||||
queryWrapper1.eq("P_ID",delegateTask.getProcessInstanceId());
|
queryWrapper1.eq("P_ID",delegateTask.getProcessInstanceId());
|
||||||
@@ -34,7 +35,7 @@ public class ApplyApplicantBefore implements TaskListener{
|
|||||||
|
|
||||||
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
||||||
one1.setLink("bzrkStep4?prcType=1");
|
one1.setLink("bzrkStep4?prcType=1");
|
||||||
oaService.sendTodo(one1);
|
oaService.sendTodoMq(one1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
|||||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNameService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNameService;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessNewService;
|
||||||
import com.ydw.bat.wkflow.business_main.datas.service.IDatasService;
|
import com.ydw.bat.wkflow.business_main.datas.service.IDatasService;
|
||||||
|
import com.ydw.bat.wkflow.business_mq.service.CreateMQService;
|
||||||
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
import com.ydw.bat.wkflow.business_oa.webService.service.WebServiceOAService;
|
||||||
import com.ydw.bat.wkflow.util.SpringContextUtil;
|
import com.ydw.bat.wkflow.util.SpringContextUtil;
|
||||||
import org.activiti.engine.TaskService;
|
import org.activiti.engine.TaskService;
|
||||||
@@ -22,7 +23,7 @@ public class ManagerApproveBefore implements TaskListener{
|
|||||||
@Override
|
@Override
|
||||||
public void notify(DelegateTask delegateTask) {
|
public void notify(DelegateTask delegateTask) {
|
||||||
IBusProcessNewService busBean = SpringContextUtil.getBean(IBusProcessNewService.class);
|
IBusProcessNewService busBean = SpringContextUtil.getBean(IBusProcessNewService.class);
|
||||||
WebServiceOAService oaService = SpringContextUtil.getBean(WebServiceOAService.class);
|
CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class);
|
||||||
|
|
||||||
QueryWrapper queryWrapper1 = new QueryWrapper();
|
QueryWrapper queryWrapper1 = new QueryWrapper();
|
||||||
queryWrapper1.eq("P_ID",delegateTask.getProcessInstanceId());
|
queryWrapper1.eq("P_ID",delegateTask.getProcessInstanceId());
|
||||||
@@ -36,7 +37,7 @@ public class ManagerApproveBefore implements TaskListener{
|
|||||||
busBean.saveOrUpdate(one1);
|
busBean.saveOrUpdate(one1);
|
||||||
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
||||||
one1.setLink("bzrkStep2?prcType=1");
|
one1.setLink("bzrkStep2?prcType=1");
|
||||||
oaService.sendTodo(one1);
|
oaService.sendTodoMq(one1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user