| | |
| | | package com.moral.api.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.Sensor; |
| | | import com.moral.api.entity.Test; |
| | | import com.moral.api.service.SensorService; |
| | | import com.moral.api.service.TestService; |
| | | import com.moral.api.service.impl.SensorServiceImpl; |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.KafkaConstants; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.redis.RedisUtil; |
| | | import com.moral.util.PageResult; |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import java.io.*; |
| | | import java.util.List; |
| | | |
| | | |
| | | @Slf4j |
| | |
| | | } |
| | | |
| | | /** |
| | | * kafka測試 |
| | | * 分钟主题kafka測試 |
| | | */ |
| | | @ApiOperation(value = "kafka測試", notes = "kafka測試") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "data", value = "data", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "kafkaTest", method = RequestMethod.GET) |
| | | public void kafkaTest() { |
| | | kafkaTemplate.send("test_topic", "{'mac': 'p5dnd1234567','DataTime':1623058244104,'e1':10,'e2':20,'ver':2}"); |
| | | @RequestMapping(value = "minuteKafkaTest", method = RequestMethod.GET) |
| | | public void minuteKafkaTest(String data) { |
| | | System.out.println(data); |
| | | kafkaTemplate.send(KafkaConstants.TOPIC_MINUTE, data); |
| | | } |
| | | |
| | | /** |
| | | * 小时主题kafka測試 |
| | | */ |
| | | @ApiOperation(value = "kafka測試", notes = "kafka測試") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "data", value = "data", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "hourKafkaTest", method = RequestMethod.GET) |
| | | public void hourKafkaTest(String data) { |
| | | System.out.println(data); |
| | | kafkaTemplate.send(KafkaConstants.TOPIC_HOUR, data); |
| | | } |
| | | |
| | | @GetMapping("testToken") |
| | |
| | | fis.close(); |
| | | } |
| | | |
| | | @GetMapping("testCacheUtils") |
| | | public void testCacheUtils(){ |
| | | CacheUtils.flushDeviceAlarmUnit(); |
| | | @Autowired |
| | | private SensorService sensorService; |
| | | |
| | | @ApiOperation(value = "因子测试", notes = "因子测试") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "getSensor", method = RequestMethod.GET) |
| | | public void getSensor() { |
| | | QueryWrapper<Sensor> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("code").eq("is_delete", Constants.NOT_DELETE); |
| | | List<Object> list = sensorService.listObjs(queryWrapper); |
| | | for (Object o : list) { |
| | | System.out.println(o); |
| | | } |
| | | } |
| | | |
| | | } |