|
|
|
@ -5,8 +5,6 @@ import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.config.rabbit.TopicRabbitConfig;
|
|
|
|
|
import com.glxp.api.util.DateUtil;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
@ -19,14 +17,13 @@ import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Api(tags = "测试相关接口")
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class TestController {
|
|
|
|
|
@Resource
|
|
|
|
|
private final RabbitTemplate rabbitTemplate;
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "发送UDI码",response = BaseResponse.class)
|
|
|
|
|
@GetMapping("/sendUdi")
|
|
|
|
|
public BaseResponse sendUdi(String key) {
|
|
|
|
|
String messageId = String.valueOf(UUID.randomUUID());
|
|
|
|
@ -38,15 +35,29 @@ public class TestController {
|
|
|
|
|
return ResultVOUtils.success("发送成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "发送备注",response = BaseResponse.class)
|
|
|
|
|
// @GetMapping("/sendCommon")
|
|
|
|
|
// public BaseResponse sendCommon(String key) {
|
|
|
|
|
// String messageId = String.valueOf(UUID.randomUUID());
|
|
|
|
|
// Map<String, Object> messageMap = new HashMap<>();
|
|
|
|
|
// messageMap.put("messageId", messageId);
|
|
|
|
|
// messageMap.put("messageData", key);
|
|
|
|
|
// messageMap.put("createTime", DateUtil.formatDate(new Date()));
|
|
|
|
|
// System.out.println(key+"5555555555555555555555555555555555555555");
|
|
|
|
|
// rabbitTemplate.convertAndSend("trace.topic.exchange", TopicRabbitConfig.common, messageMap);
|
|
|
|
|
// return ResultVOUtils.success("发送成功");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@GetMapping("/sendCommon")
|
|
|
|
|
public BaseResponse sendCommon(String key) {
|
|
|
|
|
public BaseResponse sendCommon(@RequestBody MqTraceMessage mqTraceMessage) {
|
|
|
|
|
String messageId = String.valueOf(UUID.randomUUID());
|
|
|
|
|
Map<String, Object> messageMap = new HashMap<>();
|
|
|
|
|
messageMap.put("messageId", messageId);
|
|
|
|
|
messageMap.put("messageData", key);
|
|
|
|
|
messageMap.put("createTime", DateUtil.formatDate(new Date()));
|
|
|
|
|
rabbitTemplate.convertAndSend("topicExchange", TopicRabbitConfig.common, messageMap);
|
|
|
|
|
// MqTraceMessage mqTraceMessage = new MqTraceMessage();
|
|
|
|
|
System.out.println(mqTraceMessage);
|
|
|
|
|
|
|
|
|
|
mqTraceMessage.setMessageId(messageId);
|
|
|
|
|
mqTraceMessage.setMessageData(String.valueOf(mqTraceMessage));
|
|
|
|
|
mqTraceMessage.setCreateTime(new Date());
|
|
|
|
|
String messageJson = JSON.toJSONString(mqTraceMessage);
|
|
|
|
|
rabbitTemplate.convertAndSend("trace.topic.exchange", TopicRabbitConfig.common, messageJson);
|
|
|
|
|
return ResultVOUtils.success("发送成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|