|  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.Test; | 
|---|
|  |  |  | import com.moral.api.entity.UnitConversion; | 
|---|
|  |  |  | import com.moral.api.mapper.SysDictDataMapper; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.account.AccountDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.accountRole.AccountRoleDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.adjust.AdjustDTO; | 
|---|
|  |  |  | import com.moral.api.service.DeviceService; | 
|---|
|  |  |  | import com.moral.api.service.SensorService; | 
|---|
|  |  |  | import com.moral.api.service.SysDictDataService; | 
|---|
|  |  |  | import com.moral.api.service.TestService; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | SysDictDataMapper sysDictDataMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceService deviceService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | HashMap<String, Object> deviceData = new HashMap<>(); | 
|---|
|  |  |  | deviceData.put("time","1691996716839"); | 
|---|
|  |  |  | deviceData.put("DataTime","20230814150000"); | 
|---|
|  |  |  | deviceData.put("mac","p5dnd7a0245362"); | 
|---|
|  |  |  | deviceData.put("a00e12","11479.2"); | 
|---|
|  |  |  | deviceData.put("a00e13","44.0"); | 
|---|
|  |  |  | deviceData.put("a21005","0.0264"); | 
|---|
|  |  |  | deviceData.put("a21004","20.0"); | 
|---|
|  |  |  | deviceData.put("a21026","30.5"); | 
|---|
|  |  |  | deviceData.put("a01001","38.1"); | 
|---|
|  |  |  | deviceData.put("a05024","279.6"); | 
|---|
|  |  |  | deviceData.put("a01002","54.2"); | 
|---|
|  |  |  | deviceData.put("a01007","2.45"); | 
|---|
|  |  |  | deviceData.put("a01006","805.834"); | 
|---|
|  |  |  | deviceData.put("a01008","102.0"); | 
|---|
|  |  |  | deviceData.put("a34002","4.9"); | 
|---|
|  |  |  | deviceData.put("a34004","4.9"); | 
|---|
|  |  |  | deviceData.put("a00e03","798.5"); | 
|---|
|  |  |  | deviceData.put("a00e04","2.9"); | 
|---|
|  |  |  | deviceData.put("a99054","0.0348"); | 
|---|
|  |  |  | deviceData.put("a31001","0.1"); | 
|---|
|  |  |  | Map<String, Object> map = deviceService.adjustDeviceData(deviceData, "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); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|