123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- package com.fdkankan.scene.controller;
- import cn.hutool.core.lang.TypeReference;
- import cn.hutool.json.JSONUtil;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.fdkankan.common.constant.ConstantFilePath;
- import com.fdkankan.common.util.MatrixToImageWriterUtil;
- import com.fdkankan.mq.message.BaseBuildSceneMessage;
- import com.fdkankan.mq.message.BuildSceneResultMqMessage;
- import com.fdkankan.mq.message.MQBodyBean;
- import com.fdkankan.mq.util.RocketMQProducer;
- import com.fdkankan.platform.api.feign.PlatformClient;
- import com.fdkankan.platform.api.vo.Camera;
- import com.fdkankan.platform.api.vo.User;
- import com.fdkankan.redis.util.RedisUtil;
- import com.fdkankan.scene.service.ISceneService;
- import com.fdkankan.scene.vo.SceneVO;
- import com.google.common.collect.Lists;
- import org.apache.poi.ss.formula.functions.T;
- import org.apache.rocketmq.client.producer.SendResult;
- import org.apache.rocketmq.common.message.Message;
- import org.apache.rocketmq.spring.core.RocketMQTemplate;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.cloud.context.config.annotation.RefreshScope;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.io.File;
- import java.util.*;
- @RefreshScope
- @RestController
- @RequestMapping("/api/device")
- public class TestController {
- @Autowired
- PlatformClient platformClient;
- @Autowired
- RedisUtil redisUtil;
- @GetMapping("/test")
- public String test() throws Exception {
- // platformClient.getCameraByChildName()
- MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
- null);
- return null;
- }
- public static void main(String[] args) throws Exception {
- MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
- null);
- // MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
- // ConstantFilePath.SCENE_PATH + "images/images" + "123123" + "/QRShareLogo.png");
- }
- @GetMapping("/testSetStr")
- public void testSetStr() throws Exception {
- redisUtil.set("testIncr", "1");
- redisUtil.incr("testIncr",1);
- String testIncr = redisUtil.get("testIncr");
- System.out.println(testIncr);
- }
- @GetMapping("/testGetStr")
- public String testGetStr() throws Exception {
- boolean b = redisUtil.hasKey("90c82bdac_202201050951313830");
- String abc = (String)redisUtil.get("abc");
- return "123";
- }
- @Autowired
- RedisTemplate<String, String> redisTemplate;
- @GetMapping("/testSetObject")
- public boolean testSetObject() throws Exception {
- User user = new User();
- user.setCity("珠海");
- user.setId(123l);
- String jsons = JSON.toJSONString(user);
- redisTemplate.opsForValue().set("test:66", jsons);
- redisTemplate.opsForValue().set("test:67", jsons);
- return true;
- }
- //
- @GetMapping("/testGetObject")
- public User testGetObject() throws Exception {
- String test12 = redisTemplate.opsForValue().get("test66");
- User user = JSONObject.parseObject(test12, User.class);
- return user;
- }
- @GetMapping("/testSetList")
- public boolean testSetList() throws Exception {
- List<String> users = Lists.newArrayList();
- users.add("sdfsdf");
- users.add("dfgdfg");
- return redisUtil.lRightPushAll("test5595jj", users);
- }
- @GetMapping("/testGetList")
- public List<String> testGetList() throws Exception {
- return redisUtil.lGet("test5595jj", 0, -1);
- }
- @GetMapping("/testSetMap")
- public boolean testSetMap() throws Exception {
- Map<String, User> userMap = new HashMap<>();
- User user1 = new User();
- user1.setCity("珠海");
- user1.setId(123l);
- User user2 = new User();
- user2.setCity("广州");
- user2.setId(124l);
- userMap.put("user1", user1);
- userMap.put("user2", user2);
- // return redisUtil.hmset("userMap", userMap);
- return true;
- }
- @GetMapping("/testGetMap")
- public Map<String ,User> testGetMap() throws Exception {
- return null;
- // return redisUtil.hmget("userMap");
- }
- @Autowired
- ISceneService sceneService;
- @GetMapping("/testSchedule")
- public void testSchedule(){
- sceneService.updatePv();
- }
- @Autowired
- RocketMQProducer rocketMQProducer;
- @GetMapping("/testMQ")
- public SendResult testMQ(){
- SceneVO body = SceneVO.builder().buildType("123").childName("sdfsdfsdf").dataSource("sadfdhgf").id(1213L).build();
- SendResult sendResult = rocketMQProducer.syncSend("kkk", "tag2", UUID.randomUUID().toString(), body, 5000l);
- return sendResult;
- }
- @GetMapping("/testAsynMQ")
- public void testAsynMQ(){
- SceneVO body = SceneVO.builder().buildType("123").childName("sdfsdfsdf").dataSource("sadfdhgf").id(1213L).build();
- rocketMQProducer.asyncSend("abc","tag3", UUID.randomUUID().toString(), body,null,5000l);
- }
- @GetMapping("/testsenOnway")
- public void testsenOnway(){
- SceneVO body = SceneVO.builder().buildType("123").childName("sdfsdfsdf").dataSource("sadfdhgf").id(1213L).build();
- rocketMQProducer.sendOneWay("qqq","tag6", UUID.randomUUID().toString(), body);
- }
- @Value("${rocketmq.build-scene.topicName.topic-modeling-a}")
- private String topicModelingA;
- @RefreshScope
- @GetMapping("/testsenOnway1")
- public void testsenOnway1(){
- SceneVO body = SceneVO.builder().buildType("123").childName("sdfsdfsdf").dataSource("sadfdhgf").id(1213L).build();
- rocketMQProducer.sendOneWay(topicModelingA, null);
- }
- @RefreshScope
- @GetMapping("/testResult")
- public void testResult(){
- // rocketMQProducer.sendOneWay("topic_modeling_a_result", BuildSceneResultMqMessage.builder().buildSuccess(true).cameraType("3").build());
- String dsfsdf = (String) redisUtil.get("dsfsdf");
- System.out.println(2134);
- }
- }
|