HeartbeatController.java
2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.tianbo.messagebus.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tianbo.messagebus.controller.response.ResultJson;
import com.tianbo.messagebus.dao.CUSTOM_RESPONSEMapper;
import com.tianbo.messagebus.model.CUSTOM_RESPONSE;
import com.tianbo.messagebus.model.HEADER;
import com.tianbo.messagebus.model.MSG;
import com.tianbo.messagebus.model.MSGS;
import com.tianbo.messagebus.myinterface.KafkaReciveApi;
import com.tianbo.messagebus.myinterface.KafkaSendApi;
import com.tianbo.messagebus.service.MessageBusProcessor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.Date;
@RestController()
@Slf4j
@RequestMapping("/")
public class HeartbeatController implements Serializable {
private static final long serialVersionUID = 1L;
@Autowired
KafkaReciveApi kafkaReciveApi;
@Resource
public CUSTOM_RESPONSEMapper custom_responseMapper_nmms20;
@Autowired
KafkaSendApi kafkaSendApi;
@Resource
CUSTOM_RESPONSEMapper custom_responseMapper;
@Autowired
private HttpServletRequest request;
@Autowired
MessageBusProcessor messageBusProcessor;
@PostMapping("login")
public void login(){
messageBusProcessor.login();
}
@PostMapping("getmsg")
public void getmsg(){
log.error("for test");
messageBusProcessor.getMsg();
}
@GetMapping("getOneMsg")
public void getonemsg(@RequestParam(value = "username") String username){
ResultJson resultJson= kafkaReciveApi.recive(username);
log.info("收到结果为:{}",resultJson.toString());
}
@PostMapping("send")
public void sendMsg(@RequestParam("msg") String msgBody){
MSGS msgs = new MSGS();
MSG msg = new MSG();
HEADER header = new HEADER();
header.setSNDR("TXD");
header.setDDTM("20210429103322081");
header.setSEQNO(2021042910);
header.setTYPE("HYXX");
header.setSTYPE("ISLI");
msg.setHEADER(header);
msg.setBODY(msgBody);
msgs.setMSG(msg);
ResultJson response = kafkaSendApi.send(msgs);
log.info(response.toString());
}
@PostMapping("parse")
public void parse(@RequestBody CUSTOM_RESPONSE custom_response){
int i = custom_responseMapper.insertSelective(custom_response);
log.info("插入数据为{}",i);
}
}