正在显示
7 个修改的文件
包含
25 行增加
和
210 行删除
@@ -29,7 +29,6 @@ public class CustomAnalysisBootApplication { | @@ -29,7 +29,6 @@ public class CustomAnalysisBootApplication { | ||
29 | 29 | ||
30 | public static void main(String[] args) { | 30 | public static void main(String[] args) { |
31 | SpringApplication.run(CustomAnalysisBootApplication.class, args); | 31 | SpringApplication.run(CustomAnalysisBootApplication.class, args); |
32 | -// initCompent(); | ||
33 | } | 32 | } |
34 | 33 | ||
35 | @Bean | 34 | @Bean |
@@ -39,10 +38,5 @@ public class CustomAnalysisBootApplication { | @@ -39,10 +38,5 @@ public class CustomAnalysisBootApplication { | ||
39 | return builder.setConnectTimeout(Duration.ofSeconds(3)).setReadTimeout(Duration.ofSeconds(3)) | 38 | return builder.setConnectTimeout(Duration.ofSeconds(3)).setReadTimeout(Duration.ofSeconds(3)) |
40 | .build(); | 39 | .build(); |
41 | } | 40 | } |
42 | - | ||
43 | - public static void initCompent(){ | ||
44 | - WlptBaseModel wlptBaseModel = (WlptBaseModel) SpringBeanUtitl.getBean("wlptBase"); | ||
45 | - wlptBaseModel.init(); | ||
46 | - } | ||
47 | } | 41 | } |
48 | 42 |
1 | -package com.tianbo.analysis.model; | ||
2 | - | ||
3 | -import com.rabbitmq.client.BuiltinExchangeType; | ||
4 | -import com.rabbitmq.client.Channel; | ||
5 | -import com.rabbitmq.client.Connection; | ||
6 | -import com.rabbitmq.client.Consumer; | ||
7 | -import com.tianbo.analysis.service.rabbit.RabbitGetMessage; | ||
8 | -import com.tianbo.util.RabitMq.ConnectionUtil; | ||
9 | -import lombok.extern.slf4j.Slf4j; | ||
10 | - | ||
11 | -import java.io.IOException; | ||
12 | -import java.util.concurrent.TimeoutException; | ||
13 | - | ||
14 | -@Slf4j | ||
15 | -public class RabbitMQ { | ||
16 | - | ||
17 | - public static String status = "not runing"; | ||
18 | - | ||
19 | - private String queueName; | ||
20 | - | ||
21 | - private String exchangeName; | ||
22 | - | ||
23 | - private String routingKey; | ||
24 | - | ||
25 | - private String mqIp; | ||
26 | - | ||
27 | - private int mqPort; | ||
28 | - | ||
29 | - private String mqVhost; | ||
30 | - | ||
31 | - private String mqUsername; | ||
32 | - | ||
33 | - private String mqPassword; | ||
34 | - | ||
35 | - public String getQueueName() { | ||
36 | - return queueName; | ||
37 | - } | ||
38 | - | ||
39 | - public void setQueueName(String queueName) { | ||
40 | - this.queueName = queueName; | ||
41 | - } | ||
42 | - | ||
43 | - public String getExchangeName() { | ||
44 | - return exchangeName; | ||
45 | - } | ||
46 | - | ||
47 | - public void setExchangeName(String exchangeName) { | ||
48 | - this.exchangeName = exchangeName; | ||
49 | - } | ||
50 | - | ||
51 | - public String getRoutingKey() { | ||
52 | - return routingKey; | ||
53 | - } | ||
54 | - | ||
55 | - public void setRoutingKey(String routingKey) { | ||
56 | - this.routingKey = routingKey; | ||
57 | - } | ||
58 | - | ||
59 | - public String getMqIp() { | ||
60 | - return mqIp; | ||
61 | - } | ||
62 | - | ||
63 | - public void setMqIp(String mqIp) { | ||
64 | - this.mqIp = mqIp; | ||
65 | - } | ||
66 | - | ||
67 | - public int getMqPort() { | ||
68 | - return mqPort; | ||
69 | - } | ||
70 | - | ||
71 | - public void setMqPort(int mqPort) { | ||
72 | - this.mqPort = mqPort; | ||
73 | - } | ||
74 | - | ||
75 | - public String getMqVhost() { | ||
76 | - return mqVhost; | ||
77 | - } | ||
78 | - | ||
79 | - public void setMqVhost(String mqVhost) { | ||
80 | - this.mqVhost = mqVhost; | ||
81 | - } | ||
82 | - | ||
83 | - public String getMqUsername() { | ||
84 | - return mqUsername; | ||
85 | - } | ||
86 | - | ||
87 | - public void setMqUsername(String mqUsername) { | ||
88 | - this.mqUsername = mqUsername; | ||
89 | - } | ||
90 | - | ||
91 | - public String getMqPassword() { | ||
92 | - return mqPassword; | ||
93 | - } | ||
94 | - | ||
95 | - public void setMqPassword(String mqPassword) { | ||
96 | - this.mqPassword = mqPassword; | ||
97 | - } | ||
98 | - | ||
99 | - public RabbitMQ(String mqIp, int mqPort, String mqVhost, String mqUsername, String mqPassword,String queueName) { | ||
100 | - this.mqIp = mqIp; | ||
101 | - this.mqPort = mqPort; | ||
102 | - this.mqVhost = mqVhost; | ||
103 | - this.mqUsername = mqUsername; | ||
104 | - this.mqPassword = mqPassword; | ||
105 | - this.queueName = queueName; | ||
106 | - } | ||
107 | - | ||
108 | - public void getResponseFromMq() { | ||
109 | - try { | ||
110 | - // 获取到连接以及mq通道 | ||
111 | - Connection connection = ConnectionUtil.getConnection( | ||
112 | - mqIp, | ||
113 | - mqPort, | ||
114 | - mqVhost, | ||
115 | - mqUsername, | ||
116 | - mqPassword); | ||
117 | - // 从连接中创建通道 | ||
118 | - Channel channel = connection.createChannel(); | ||
119 | - // 声明(创建)队列 | ||
120 | -// channel.exchangeDeclare(exchangeName, BuiltinExchangeType.TOPIC,true); | ||
121 | -// channel.queueDeclare(queueName, true, false, false, null); | ||
122 | - channel.queueBind(queueName,exchangeName,routingKey); | ||
123 | - channel.basicQos(10); | ||
124 | - channel.basicConsume(queueName, false, new RabbitGetMessage(channel)); | ||
125 | - status = "runing"; | ||
126 | - }catch (IOException e){ | ||
127 | - status = "not runing"; | ||
128 | - e.printStackTrace(); | ||
129 | - log.error("MQ服务器连接失败,连接不上服务器:{},异常退出",e.toString()); | ||
130 | - }catch (TimeoutException e){ | ||
131 | - status = "not runing"; | ||
132 | - e.printStackTrace(); | ||
133 | - log.error("MQ服务器连接失败,连接超时:{},异常退出",e.toString()); | ||
134 | - } | ||
135 | - } | ||
136 | -} |
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
15 | import org.springframework.scheduling.annotation.Async; | 15 | import org.springframework.scheduling.annotation.Async; |
16 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
17 | 17 | ||
18 | +import javax.annotation.Resource; | ||
18 | import java.math.BigDecimal; | 19 | import java.math.BigDecimal; |
19 | import java.util.Date; | 20 | import java.util.Date; |
20 | import java.util.List; | 21 | import java.util.List; |
@@ -25,27 +26,26 @@ import java.util.List; | @@ -25,27 +26,26 @@ import java.util.List; | ||
25 | */ | 26 | */ |
26 | @Service | 27 | @Service |
27 | @Slf4j | 28 | @Slf4j |
28 | -@Async | ||
29 | public class CoustomAnalysisServiceImp extends NmmsBase implements CoustomAnalysisService { | 29 | public class CoustomAnalysisServiceImp extends NmmsBase implements CoustomAnalysisService { |
30 | 30 | ||
31 | - @Autowired | 31 | + @Resource |
32 | SENDLOGMapper sendlogMapper; | 32 | SENDLOGMapper sendlogMapper; |
33 | - @Autowired | 33 | + @Resource |
34 | ORIGINMANIFESTMASTERMapper originmanifestmasterMapper; | 34 | ORIGINMANIFESTMASTERMapper originmanifestmasterMapper; |
35 | - @Autowired | 35 | + @Resource |
36 | OriginmanifestsecondaryMapper originmanifestsecondaryMapper; | 36 | OriginmanifestsecondaryMapper originmanifestsecondaryMapper; |
37 | 37 | ||
38 | public CoustomAnalysisServiceImp(){ | 38 | public CoustomAnalysisServiceImp(){ |
39 | - //处理多线程时 springboot 无法注入bean的问题 | ||
40 | - if (this.sendlogMapper==null){ | ||
41 | - this.sendlogMapper = SpringBeanUtitl.getBean(SENDLOGMapper.class); | ||
42 | - } | ||
43 | - if (this.originmanifestmasterMapper==null){ | ||
44 | - this.originmanifestmasterMapper = SpringBeanUtitl.getBean(ORIGINMANIFESTMASTERMapper.class); | ||
45 | - } | ||
46 | - if (this.originmanifestsecondaryMapper==null){ | ||
47 | - this.originmanifestsecondaryMapper = SpringBeanUtitl.getBean(OriginmanifestsecondaryMapper.class); | ||
48 | - } | 39 | +// //处理多线程时 springboot 无法注入bean的问题 |
40 | +// if (this.sendlogMapper==null){ | ||
41 | +// this.sendlogMapper = SpringBeanUtitl.getBean(SENDLOGMapper.class); | ||
42 | +// } | ||
43 | +// if (this.originmanifestmasterMapper==null){ | ||
44 | +// this.originmanifestmasterMapper = SpringBeanUtitl.getBean(ORIGINMANIFESTMASTERMapper.class); | ||
45 | +// } | ||
46 | +// if (this.originmanifestsecondaryMapper==null){ | ||
47 | +// this.originmanifestsecondaryMapper = SpringBeanUtitl.getBean(OriginmanifestsecondaryMapper.class); | ||
48 | +// } | ||
49 | } | 49 | } |
50 | 50 | ||
51 | @Override | 51 | @Override |
@@ -50,7 +50,7 @@ public class ShareServiceImp { | @@ -50,7 +50,7 @@ public class ShareServiceImp { | ||
50 | CUSTOMSMESSAGEMapper customsmessageMapper; | 50 | CUSTOMSMESSAGEMapper customsmessageMapper; |
51 | 51 | ||
52 | public ShareServiceImp(){ | 52 | public ShareServiceImp(){ |
53 | - customsmessageMapper = SpringBeanUtitl.getBean(CUSTOMSMESSAGEMapper.class); | 53 | +// customsmessageMapper = SpringBeanUtitl.getBean(CUSTOMSMESSAGEMapper.class); |
54 | } | 54 | } |
55 | 55 | ||
56 | public int share(String type, CustomReception customReception){ | 56 | public int share(String type, CustomReception customReception){ |
1 | -package com.tianbo.analysis.task; | ||
2 | - | ||
3 | -import com.tianbo.analysis.model.RabbitMQ; | ||
4 | -import lombok.extern.slf4j.Slf4j; | ||
5 | -import org.springframework.beans.factory.annotation.Value; | ||
6 | -import org.springframework.scheduling.annotation.Scheduled; | ||
7 | -import org.springframework.stereotype.Component; | ||
8 | - | ||
9 | -@Slf4j | ||
10 | -@Component | ||
11 | -public class MqGetMessageTask { | ||
12 | - | ||
13 | - @Value("${mq.connection.ip}") | ||
14 | - private String mqIp; | ||
15 | - | ||
16 | - @Value("${mq.connection.port}") | ||
17 | - private int mqPort; | ||
18 | - | ||
19 | - @Value("${mq.connection.vHost}") | ||
20 | - private String mqVhost; | ||
21 | - | ||
22 | - @Value("${mq.connection.username}") | ||
23 | - private String mqUsername; | ||
24 | - | ||
25 | - @Value("${mq.connection.password}") | ||
26 | - private String mqPassword; | ||
27 | - | ||
28 | - @Value("${mq.queue.read-from-mq}") | ||
29 | - private String queueName; | ||
30 | - | ||
31 | - @Value("${mq.exchange.name}") | ||
32 | - private String exchangeName; | ||
33 | - | ||
34 | - @Value("${mq.exchange.routing-key}") | ||
35 | - private String routingKey; | ||
36 | - | ||
37 | - private final static String MQ_RUNING_STATE= "runing"; | ||
38 | - | ||
39 | - @Scheduled(fixedRate = 5000) | ||
40 | - public void startTask(){ | ||
41 | - RabbitMQ rabbit = new RabbitMQ(mqIp,mqPort,mqVhost,mqUsername,mqPassword,queueName); | ||
42 | - rabbit.setExchangeName(exchangeName); | ||
43 | - rabbit.setRoutingKey(routingKey); | ||
44 | - if (!MQ_RUNING_STATE.equals(RabbitMQ.status)){ | ||
45 | - rabbit.getResponseFromMq(); | ||
46 | - } | ||
47 | - log.info("解析程序执行中。。。"); | ||
48 | - } | ||
49 | - | ||
50 | - | ||
51 | - | ||
52 | -} |
@@ -38,7 +38,7 @@ public class TaskAnalysis { | @@ -38,7 +38,7 @@ public class TaskAnalysis { | ||
38 | */ | 38 | */ |
39 | private final static int theadamount = 64; | 39 | private final static int theadamount = 64; |
40 | 40 | ||
41 | -// @Scheduled(fixedRate = 5000) | 41 | + @Scheduled(fixedRate = 5000) |
42 | public void startTask(){ | 42 | public void startTask(){ |
43 | final SimpleDateFormat sdf = new SimpleDateFormat( | 43 | final SimpleDateFormat sdf = new SimpleDateFormat( |
44 | "yyyy-MM-dd HH:mm:ss"); | 44 | "yyyy-MM-dd HH:mm:ss"); |
@@ -2,10 +2,19 @@ package com.tianbo.analysis.tools; | @@ -2,10 +2,19 @@ package com.tianbo.analysis.tools; | ||
2 | 2 | ||
3 | import org.apache.commons.lang.StringUtils; | 3 | import org.apache.commons.lang.StringUtils; |
4 | 4 | ||
5 | +import java.util.regex.Pattern; | ||
6 | + | ||
5 | public class AWBTools { | 7 | public class AWBTools { |
6 | 8 | ||
7 | public static String awbFormat(String awbNo) { | 9 | public static String awbFormat(String awbNo) { |
8 | if (!StringUtils.isEmpty(awbNo)) { | 10 | if (!StringUtils.isEmpty(awbNo)) { |
11 | + //适配邮单解析 | ||
12 | + String pattern = "\\d{11}"; | ||
13 | + boolean isMatch = Pattern.matches(pattern, awbNo); | ||
14 | + if (!isMatch){ | ||
15 | + return awbNo; | ||
16 | + } | ||
17 | + | ||
9 | StringBuffer stringBuffer = new StringBuffer(awbNo); | 18 | StringBuffer stringBuffer = new StringBuffer(awbNo); |
10 | stringBuffer.insert(3, "-"); | 19 | stringBuffer.insert(3, "-"); |
11 | awbNo = stringBuffer.toString(); | 20 | awbNo = stringBuffer.toString(); |
-
请 注册 或 登录 后发表评论