feat: There is no way the
This commit is contained in:
@@ -35,6 +35,15 @@
|
|||||||
<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>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- Feign客户端 -->
|
<!-- Feign客户端 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.ydw.bat.wkflow.business_mq.service;
|
||||||
|
|
||||||
|
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessNew;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.amqp.core.AmqpTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CreateMQService {
|
||||||
|
@Autowired
|
||||||
|
private AmqpTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: super_liu
|
||||||
|
* @date: 2021年09月17日 14:40
|
||||||
|
**/
|
||||||
|
public void setTodoDoneMq(BusProcessNew object) throws Exception{
|
||||||
|
|
||||||
|
//发送消息队列
|
||||||
|
this.rabbitTemplate.convertAndSend("sendDone-exchange_MQ_GSAR", "sendDone-key_MQ_GSAR", object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: super_liu
|
||||||
|
* @date: 2021年09月17日 14:40
|
||||||
|
**/
|
||||||
|
public void sendTodoMq(BusProcessNew object){
|
||||||
|
|
||||||
|
//发送消息队列
|
||||||
|
this.rabbitTemplate.convertAndSend("send-exchange_MQ_GSAR", "send-key_MQ_GSAR", object);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
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.service.ISendTodoLogService;
|
||||||
|
import com.ydw.bat.wkflow.business_oa.sendTodoLog.service.impl.SendTodoLogServiceImpl;
|
||||||
|
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.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SendMQService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SendMQService.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CreateMQService convertMq;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISendTodoLogService iSendTodoLogService;
|
||||||
|
|
||||||
|
|
||||||
|
@RabbitListener(bindings = @QueueBinding(
|
||||||
|
value = @Queue(value = "createMQ_SQ_GSAR", durable = "true"),
|
||||||
|
exchange = @Exchange(value = "send-exchange_MQ_GSAR", ignoreDeclarationExceptions = "true"),
|
||||||
|
key = "send-key_MQ_GSAR"))
|
||||||
|
public void createMQ(BusProcessNew object, Message message, Channel channel) throws Exception{
|
||||||
|
try{
|
||||||
|
try{
|
||||||
|
Thread.sleep(5000);
|
||||||
|
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(BusProcessNew object) throws Exception {
|
||||||
|
try {
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
this.restartSendMq(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restartSendMq(BusProcessNew object) throws Exception{
|
||||||
|
SendTodoLog sendTodoLog = new SendTodoLog();
|
||||||
|
QueryWrapper wrapper = new QueryWrapper();
|
||||||
|
wrapper.eq("TODO_ID",object.getId());
|
||||||
|
List<SendTodoLog> list = iSendTodoLogService.list(wrapper);
|
||||||
|
if(!list.isEmpty()){
|
||||||
|
sendTodoLog = list.get(0);
|
||||||
|
}
|
||||||
|
if(sendTodoLog != null){
|
||||||
|
int againNumNew = Integer.valueOf(sendTodoLog.getErrNum());
|
||||||
|
if(againNumNew >= 9){
|
||||||
|
// 发送待办 或 发送给管理员邮箱
|
||||||
|
logger.info("发送失败9次,发送给管理员邮箱");
|
||||||
|
|
||||||
|
}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("已重新加入转换");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
sendTodoLog.setMsgType("0");
|
||||||
|
sendTodoLog.setTodoId(object.getId());
|
||||||
|
sendTodoLog.setUserId(object.getUserId());
|
||||||
|
// sendTodoLog.set
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ydw.bat.wkflow.business_oa.sendTodoLog.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* OA日志表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author super_liu
|
||||||
|
* @since 2021-09-17
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sendTodoLog")
|
||||||
|
public class SendTodoLogController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.ydw.bat.wkflow.business_oa.sendTodoLog.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* OA日志表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author super_liu
|
||||||
|
* @since 2021-09-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value="SendTodoLog对象", description="OA日志表")
|
||||||
|
public class SendTodoLog implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
@TableId("ID")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "类型 0 待办, 1已办, 2 取消, 3 删除")
|
||||||
|
@TableField("MSG_TYPE")
|
||||||
|
private String msgType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "待办ID")
|
||||||
|
@TableField("TODO_ID")
|
||||||
|
private String todoId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "待办用户ID")
|
||||||
|
@TableField("USER_ID")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "邮箱用户ID")
|
||||||
|
@TableField("EMAIL_USER_ID")
|
||||||
|
private String emailUserId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "待办对象JSON")
|
||||||
|
@TableField("MESG")
|
||||||
|
private String mesg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态 1 待发送 2 成功 3 失败 4 无需发送")
|
||||||
|
@TableField("MSG_STATUS")
|
||||||
|
private String msgStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "失败次数")
|
||||||
|
@TableField("ERR_NUM")
|
||||||
|
private int errNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
@TableField("CREATE_TIME")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
@TableField("UPDATE_TIME")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private String updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "参数1")
|
||||||
|
@TableField("PARAM1")
|
||||||
|
private String param1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "参数2")
|
||||||
|
@TableField("PARAM2")
|
||||||
|
private String param2;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* OA日志表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author super_liu
|
||||||
|
* @since 2021-09-17
|
||||||
|
*/
|
||||||
|
public interface SendTodoLogMapper extends BaseMapper<SendTodoLog> {
|
||||||
|
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package com.ydw.bat.wkflow.business_oa.sendTodoLog.service;
|
||||||
|
|
||||||
|
import com.ydw.bat.wkflow.business_oa.sendTodoLog.entity.SendTodoLog;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* OA日志表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author super_liu
|
||||||
|
* @since 2021-09-17
|
||||||
|
*/
|
||||||
|
public interface ISendTodoLogService extends IService<SendTodoLog> {
|
||||||
|
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.ydw.bat.wkflow.business_oa.sendTodoLog.service.impl;
|
||||||
|
|
||||||
|
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.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* OA日志表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author super_liu
|
||||||
|
* @since 2021-09-17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SendTodoLogServiceImpl extends ServiceImpl<SendTodoLogMapper, SendTodoLog> implements ISendTodoLogService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.ydw.bat.wkflow.listener.standardLibrary;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
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_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.util.SpringContextUtil;
|
import com.ydw.bat.wkflow.util.SpringContextUtil;
|
||||||
import org.activiti.engine.delegate.DelegateTask;
|
import org.activiti.engine.delegate.DelegateTask;
|
||||||
@@ -17,7 +18,7 @@ public class CountersignBefore 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());
|
||||||
queryWrapper1.eq("USER_ID",delegateTask.getAssignee());
|
queryWrapper1.eq("USER_ID",delegateTask.getAssignee());
|
||||||
@@ -30,7 +31,7 @@ public class CountersignBefore implements TaskListener{
|
|||||||
|
|
||||||
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
// 发送 oa 待办 设置 跳转页面 router ? 后面流程类型
|
||||||
one1.setLink("bzrkStep3?prcType=1");
|
one1.setLink("bzrkStep3?prcType=1");
|
||||||
oaService.sendTodo(one1);
|
oaService.sendTodoMq(one1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,23 @@ spring:
|
|||||||
check-process-definitions: false
|
check-process-definitions: false
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
|
# 相关服务配置同业务系统
|
||||||
|
rabbitmq:
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 5672
|
||||||
|
username: guest
|
||||||
|
password: guest
|
||||||
|
listener:
|
||||||
|
simple:
|
||||||
|
acknowledge-mode: manual
|
||||||
|
#消费失败消息干掉
|
||||||
|
default-requeue-rejected: true
|
||||||
|
retry:
|
||||||
|
#5秒
|
||||||
|
initial-interval: 5000
|
||||||
|
enabled: true
|
||||||
|
#最大重试9次
|
||||||
|
max-attempts: 9
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
configuration:
|
configuration:
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
@@ -50,3 +67,4 @@ ribbon:
|
|||||||
|
|
||||||
# 配置前端服务全路径地址 如下 /#/
|
# 配置前端服务全路径地址 如下 /#/
|
||||||
webUrl: http://127.0.0.1:10088/#/
|
webUrl: http://127.0.0.1:10088/#/
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ydw.bat.wkflow.business_oa.sendTodoLog.mapper.SendTodoLogMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user