| | |
| | | import com.moral.api.service.SysDictDataService; |
| | | import com.moral.api.service.TestService; |
| | | import com.moral.api.service.impl.SensorServiceImpl; |
| | | import com.moral.api.util.AdjustDataUtils; |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.api.util.CompareFieldUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.KafkaConstants; |
| | | import com.moral.constant.RedisConstants; |
| | |
| | | private SensorService sensorService; |
| | | @Autowired |
| | | SysDictDataMapper sysDictDataMapper; |
| | | @Autowired |
| | | private AdjustDataUtils adjustDataUtils; |
| | | |
| | | @ApiOperation(value = "因子测试", notes = "因子测试") |
| | | @ApiImplicitParams({ |
| | |
| | | }) |
| | | @RequestMapping(value = "getSensor", method = RequestMethod.GET) |
| | | public void getSensor() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("time","1692364996898"); |
| | | map.put("mac","p5dnd7a0391986"); |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | HashMap<String, Object> map2 = new HashMap<>(); |
| | | Map<String, Object> adjust = adjustDataUtils.adjust(map, map1, map2, "2"); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("test") |
| | | public void test() throws IOException { |
| | | BufferedReader br = new BufferedReader(new FileReader(new File("C:\\Users\\cdl\\Desktop\\alarmLevels.json"))); |
| | | StringBuilder sb = new StringBuilder(); |
| | | String line = br.readLine(); |
| | | while (line != null) { |
| | | sb.append(line + "\r\n"); |
| | | line = br.readLine(); |
| | | } |
| | | |
| | | Map map = JSON.parseObject(sb.toString(), Map.class); |
| | | System.out.println(map); |
| | | |
| | | Map<String,Object> sensorMap = (Map<String, Object>) map.get("alarmLevels"); |
| | | |
| | | Set<String> sets = sensorMap.keySet(); |
| | | |
| | | Map<String,String> alarmLevels = new HashMap<>(); |
| | | for (String set : sets) { |
| | | Map<String,Object> map2 = (Map<String, Object>) sensorMap.get(set); |
| | | String increment = map2.get("increment").toString(); |
| | | alarmLevels.put(set,increment); |
| | | } |
| | | alarmLevels.remove("AQI"); |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | Map<String, String> ecodeMap = testService.getMap(); |
| | | |
| | | alarmLevels.forEach((key,value)->{ |
| | | resultMap.put(ecodeMap.get(key),value); |
| | | }); |
| | | |
| | | resultMap.forEach((key,value)->{ |
| | | SysDictData sysDictData = new SysDictData(); |
| | | sysDictData.setDataKey(key); |
| | | sysDictData.setDataValue(value.toString()); |
| | | sysDictData.setDictTypeId(25); |
| | | sysDictDataMapper.insert(sysDictData); |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |