feat: There is no way the MQ conf
This commit is contained in:
@@ -24,7 +24,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
|
||||
org.activiti.spring.boot.SecurityAutoConfiguration.class })
|
||||
@MapperScan("com.ydw.bat.wkflow.business.*.mapper")
|
||||
@MapperScan("com.ydw.bat.wkflow.business_oa.*")
|
||||
@EnableScheduling
|
||||
public class BatWkflowApplication {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.ydw.bat.wkflow.business_oa.sendTodoLog.controller;
|
||||
package com.ydw.bat.wkflow.business_main.datas.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
package com.ydw.bat.wkflow.business_oa.sendTodoLog.entity;
|
||||
package com.ydw.bat.wkflow.business_main.datas.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -62,6 +62,10 @@ public class SendTodoLog implements Serializable {
|
||||
@TableField("ERR_NUM")
|
||||
private int errNum;
|
||||
|
||||
@ApiModelProperty(value = "操作信息")
|
||||
@TableField("OPER_MESG")
|
||||
private String operMesg;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField("CREATE_TIME")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.ydw.bat.wkflow.business_oa.sendTodoLog.mapper;
|
||||
package com.ydw.bat.wkflow.business_main.datas.mapper;
|
||||
|
||||
import com.ydw.bat.wkflow.business_oa.sendTodoLog.entity.SendTodoLog;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.SendTodoLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.ydw.bat.wkflow.business_oa.sendTodoLog.service;
|
||||
package com.ydw.bat.wkflow.business_main.datas.service;
|
||||
|
||||
import com.ydw.bat.wkflow.business_oa.sendTodoLog.entity.SendTodoLog;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.SendTodoLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
package com.ydw.bat.wkflow.business_oa.sendTodoLog.service.impl;
|
||||
package com.ydw.bat.wkflow.business_main.datas.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.ydw.bat.wkflow.business_main.datas.entity.SendTodoLog;
|
||||
import com.ydw.bat.wkflow.business_main.datas.mapper.SendTodoLogMapper;
|
||||
import com.ydw.bat.wkflow.business_main.datas.service.ISendTodoLogService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -2,14 +2,13 @@ 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_main.datas.entity.SendTodoLog;
|
||||
import com.ydw.bat.wkflow.business_main.datas.mapper.SendTodoLogMapper;
|
||||
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.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
@@ -19,7 +18,6 @@ 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;
|
||||
@@ -68,22 +66,35 @@ public class SendDoneMQService {
|
||||
NotifyTodoAppResult todoAppResult = webServiceOAService.setTodoDone(object);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||
|
||||
if(todoAppResult.getSIGN().equals("0") && todoAppResult.getMASSAGE().equals("操作成功")){
|
||||
if(todoAppResult.getSIGN().equals("0") || todoAppResult.getMASSAGE().equals("操作成功")){
|
||||
logger.info("--------------------------成功发送 ESP 已办任务----------------------------");
|
||||
sendTodoSave(object, sdf, "2");
|
||||
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 sendTodoLog = list.get(0);
|
||||
sendTodoLog.setOperMesg(todoAppResult.getMASSAGE());
|
||||
sendTodoLog.setMsgStatus("2");
|
||||
sendTodoLog.setCreateTime(sdf.format(new Date()));
|
||||
sendTodoLog.setUpdateTime(sdf.format(new Date()));
|
||||
sendTodoLogMapper.updateById(sendTodoLog);
|
||||
}else {
|
||||
sendTodoSave(object, sdf, "2",todoAppResult.getMASSAGE());
|
||||
}
|
||||
}else {
|
||||
logger.error("ESP 发送待办任务异常 :" + "SIGN: "+todoAppResult.getSIGN()+",MASSAGE: "+todoAppResult.getMASSAGE());
|
||||
// 重试发送待办
|
||||
logger.info("重试发送待办");
|
||||
this.restartSendMq(object);
|
||||
this.restartSendMq(object,todoAppResult.getMASSAGE());
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage(),e);
|
||||
this.restartSendMq(object);
|
||||
this.restartSendMq(object, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void restartSendMq(NotifyTodoSendContext object) throws Exception{
|
||||
public void restartSendMq(NotifyTodoSendContext object,String operMesg) throws Exception{
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("TODO_ID",object.getModelId());
|
||||
wrapper.eq("MSG_TYPE","1");
|
||||
@@ -97,15 +108,15 @@ public class SendDoneMQService {
|
||||
logger.info("发送失败6次,发送给管理员邮箱");
|
||||
|
||||
}else {
|
||||
restSendDoneTodo(object, sdf, sendTodoLog, againNumNew);
|
||||
restSendDoneTodo(object, sdf, sendTodoLog, againNumNew,operMesg);
|
||||
}
|
||||
|
||||
}else {
|
||||
sendTodoSave(object, sdf, "3");
|
||||
sendTodoSave(object, sdf, "3",operMesg);
|
||||
}
|
||||
}
|
||||
|
||||
private void restSendDoneTodo(NotifyTodoSendContext object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew) throws Exception{
|
||||
private void restSendDoneTodo(NotifyTodoSendContext object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew,String operMesg) throws Exception{
|
||||
// 发送失败连续持续3次, 如果在失败等待1个小时后重试3次
|
||||
if(againNumNew < 6){
|
||||
Thread.sleep(3000);
|
||||
@@ -116,12 +127,13 @@ public class SendDoneMQService {
|
||||
}
|
||||
sendTodoLog.setErrNum(sendTodoLog.getErrNum()+1);
|
||||
sendTodoLog.setUpdateTime(sdf.format(new Date()));
|
||||
sendTodoLog.setOperMesg(operMesg);
|
||||
sendTodoLogMapper.updateById(sendTodoLog);
|
||||
convertMq.setTodoDoneMq(object);
|
||||
logger.info("已重新加入延迟队列");
|
||||
}
|
||||
|
||||
private void sendTodoSave(NotifyTodoSendContext object, SimpleDateFormat sdf, String s) {
|
||||
private void sendTodoSave(NotifyTodoSendContext object, SimpleDateFormat sdf, String s,String operMesg) {
|
||||
SendTodoLog sendTodoLog = new SendTodoLog();
|
||||
sendTodoLog.setMsgType("1");
|
||||
JSONObject json = JSONObject.fromObject(object);
|
||||
@@ -129,12 +141,18 @@ public class SendDoneMQService {
|
||||
sendTodoLog.setMesg(json.toString());
|
||||
sendTodoLog.setMsgStatus(s);
|
||||
sendTodoLog.setErrNum(1);
|
||||
sendTodoLog.setOperMesg(operMesg);
|
||||
sendTodoLog.setCreateTime(sdf.format(new Date()));
|
||||
sendTodoLog.setUpdateTime(sdf.format(new Date()));
|
||||
sendTodoLog.setUserId(object.getUserId());
|
||||
sendTodoLogMapper.insert(sendTodoLog);
|
||||
convertMq.setTodoDoneMq(object);
|
||||
logger.info("已重新加入延迟队列");
|
||||
if(s.equals("2")){
|
||||
logger.info("发送成功,存入OA日志");
|
||||
}else{
|
||||
convertMq.setTodoDoneMq(object);
|
||||
logger.info("已重新加入延迟队列");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ 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.sendTodoLog.service.impl.SendTodoLogServiceImpl;
|
||||
import com.ydw.bat.wkflow.business_main.datas.entity.SendTodoLog;
|
||||
import com.ydw.bat.wkflow.business_main.datas.mapper.SendTodoLogMapper;
|
||||
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.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
@@ -19,7 +18,6 @@ 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;
|
||||
@@ -68,21 +66,34 @@ public class SendMQService {
|
||||
NotifyTodoAppResult todoAppResult = webServiceOAService.sendTodo(object);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||
|
||||
if(todoAppResult.getSIGN().equals("1")){
|
||||
if(todoAppResult.getSIGN().equals("0") || todoAppResult.getMASSAGE().equals("操作成功")){
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("TODO_ID",object.getId());
|
||||
wrapper.eq("MSG_TYPE","0");
|
||||
List<SendTodoLog> list = sendTodoLogMapper.selectList(wrapper);
|
||||
if(!list.isEmpty()) {
|
||||
SendTodoLog sendTodoLog = list.get(0);
|
||||
sendTodoLog.setMsgStatus("2");
|
||||
sendTodoLog.setOperMesg(todoAppResult.getMASSAGE());
|
||||
sendTodoLog.setCreateTime(sdf.format(new Date()));
|
||||
sendTodoLog.setUpdateTime(sdf.format(new Date()));
|
||||
sendTodoLogMapper.updateById(sendTodoLog);
|
||||
}else {
|
||||
sendTodoSave(object, sdf, "2",todoAppResult.getMASSAGE());
|
||||
}
|
||||
}else {
|
||||
// 重试发送待办
|
||||
logger.info("重试发送待办");
|
||||
this.restartSendMq(object);
|
||||
}else {
|
||||
sendTodoSave(object, sdf, "2");
|
||||
this.restartSendMq(object,todoAppResult.getMASSAGE());
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage(),e);
|
||||
this.restartSendMq(object);
|
||||
this.restartSendMq(object, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void restartSendMq(BusProcessNew object) throws Exception{
|
||||
public void restartSendMq(BusProcessNew object,String operMesg) throws Exception{
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("TODO_ID",object.getId());
|
||||
wrapper.eq("MSG_TYPE","0");
|
||||
@@ -95,14 +106,14 @@ public class SendMQService {
|
||||
// 发送待办 或 发送给管理员邮箱
|
||||
logger.info("发送失败6次,发送给管理员邮箱");
|
||||
}else {
|
||||
restSendTodo(object, sdf, sendTodoLog, againNumNew);
|
||||
restSendTodo(object, sdf, sendTodoLog, againNumNew,operMesg);
|
||||
}
|
||||
}else {
|
||||
sendTodoSave(object, sdf, "3");
|
||||
sendTodoSave(object, sdf, "3",operMesg);
|
||||
}
|
||||
}
|
||||
|
||||
private void restSendTodo(BusProcessNew object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew) throws Exception{
|
||||
private void restSendTodo(BusProcessNew object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew,String operMesg) throws Exception{
|
||||
// 失败次数小于6次,放入失败队列延迟消费
|
||||
if((againNumNew < 6)){
|
||||
Thread.sleep(3000);
|
||||
@@ -112,12 +123,13 @@ public class SendMQService {
|
||||
}
|
||||
sendTodoLog.setErrNum(sendTodoLog.getErrNum()+1);
|
||||
sendTodoLog.setUpdateTime(sdf.format(new Date()));
|
||||
sendTodoLog.setOperMesg(operMesg);
|
||||
sendTodoLogMapper.updateById(sendTodoLog);
|
||||
convertMq.sendTodoMq(object);
|
||||
logger.info("已重新加入延迟队列");
|
||||
}
|
||||
|
||||
private void sendTodoSave(BusProcessNew object, SimpleDateFormat sdf, String s) {
|
||||
private void sendTodoSave(BusProcessNew object, SimpleDateFormat sdf, String s,String operMesg) {
|
||||
SendTodoLog sendTodoLog = new SendTodoLog();
|
||||
sendTodoLog.setMsgType("0");
|
||||
sendTodoLog.setTodoId(object.getId());
|
||||
@@ -126,11 +138,16 @@ public class SendMQService {
|
||||
sendTodoLog.setMesg(json.toString());
|
||||
sendTodoLog.setMsgStatus(s);
|
||||
sendTodoLog.setErrNum(1);
|
||||
sendTodoLog.setOperMesg(operMesg);
|
||||
sendTodoLog.setCreateTime(sdf.format(new Date()));
|
||||
sendTodoLog.setUpdateTime(sdf.format(new Date()));
|
||||
sendTodoLogMapper.insert(sendTodoLog);
|
||||
convertMq.sendTodoMq(object);
|
||||
logger.info("已重新加入延迟队列");
|
||||
if(s.equals("2")){
|
||||
logger.info("发送成功,存入OA日志");
|
||||
}else{
|
||||
convertMq.sendTodoMq(object);
|
||||
logger.info("已重新加入延迟队列");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ public class OkHttpUtil {
|
||||
* @param headerParams post form 提交的参数
|
||||
* @return
|
||||
*/
|
||||
public String postForJson(String url, String json, Map<String, String> headerParams) {
|
||||
public String postForJson(String url, String json, Map<String, String> headerParams){
|
||||
RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), json);
|
||||
String responseBody = "";
|
||||
Request.Builder requestBuilder = new Request.Builder().url(url);
|
||||
@@ -266,6 +266,7 @@ public class OkHttpUtil {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
||||
return "okhttp post error >> ex = {} "+ e.getMessage();
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
|
||||
+6
-4
@@ -29,8 +29,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static java.awt.SystemColor.info;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: super_liu
|
||||
@@ -92,13 +90,15 @@ public class WebServiceOAServiceImpl implements WebServiceOAService {
|
||||
log.info("处理完文件数据,开始请求发送已办接口数据:【"+sdf.format(new Date())+"】");
|
||||
result = okHttpUtil.postForJson("http://172.24.12.64:85/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1021_SendNotifyTodo_PS",json.toString(),mapCtr);
|
||||
log.info("请求发送已办接口完毕,返回响应状态:【"+sdf.format(new Date())+"】");
|
||||
notifyTodoAppResult = (NotifyTodoAppResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppResult.class);
|
||||
// JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if(!result.contains("操作成功")){
|
||||
log.error("请求发送已办接口出现异常:"+result);
|
||||
notifyTodoAppResult.setSIGN("1");
|
||||
notifyTodoAppResult.setMASSAGE(result);
|
||||
}else {
|
||||
log.info("--------------------------成功发送 ESP 已办 模块ID"+notifyTodoSendContext.getModelId()+"----------------------------");
|
||||
log.info("okHttp请求发送已办接口成功结果:"+result);
|
||||
notifyTodoAppResult = (NotifyTodoAppResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppResult.class);
|
||||
}
|
||||
// try {
|
||||
//
|
||||
@@ -158,12 +158,14 @@ public class WebServiceOAServiceImpl implements WebServiceOAService {
|
||||
log.info("处理完文件数据,开始请求发送待办接口数据:【"+sdf.format(new Date())+"】");
|
||||
result = okHttpUtil.postForJson("http://172.24.12.64:85/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1019_SendTodo_PS",json.toString(),mapCtr);
|
||||
log.info("请求发送待办接口完毕,返回响应状态:【"+sdf.format(new Date())+"】");
|
||||
notifyTodoAppResult = (NotifyTodoAppResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppResult.class);
|
||||
// JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if(!result.contains("操作成功")){
|
||||
log.error("请求发送待办接口出现异常:"+result);
|
||||
notifyTodoAppResult.setSIGN("1");
|
||||
notifyTodoAppResult.setMASSAGE(result);
|
||||
}else {
|
||||
log.info("okHttp请求发送待办接口成功结果:"+result);
|
||||
notifyTodoAppResult = (NotifyTodoAppResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppResult.class);
|
||||
}
|
||||
// try {
|
||||
//
|
||||
|
||||
@@ -1,5 +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 namespace="com.ydw.bat.wkflow.business_main.datas.mapper.SendTodoLogMapper">
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user