| | |
| | | import com.moral.api.pojo.ext.wind.WindListExt; |
| | | import com.moral.api.pojo.form.device.MonitorPointQueryForm; |
| | | import com.moral.api.pojo.form.historyFiveMinutely.QueryDeviceAndFiveMinuteDataForm; |
| | | import com.moral.api.pojo.vo.historyFiveMinutely.QueryFiveDataByMacVO; |
| | | import com.moral.api.pojo.vo.user.QxUser; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.HistoryFiveMinutelyService; |
| | |
| | | return orderSixParam(result); |
| | | } |
| | | |
| | | @Override |
| | | public QueryFiveDataByMacVO queryFiveDataByMac(String mac, String chooseTime, String time) { |
| | | Map<String, Object> datas = null; |
| | | if (chooseTime.equals("true")) { |
| | | String timeUnits = DateUtils.stringToDateString(time, "yyyy-MM-dd HH:mm", DateUtils.yyyyMM_EN); |
| | | String dbDataStr = historyHourlyMapper.queryLastHourlyMac(mac, time, timeUnits); |
| | | if (dbDataStr == null) { |
| | | return null; |
| | | } |
| | | datas = JSON.parseObject(dbDataStr, HashMap.class); |
| | | datas.put("dataTime", time); |
| | | } else { |
| | | datas = queryLastDataByMac(mac); |
| | | if (ObjectUtils.isEmpty(datas)){ |
| | | return null; |
| | | } |
| | | } |
| | | //构建返回对象 |
| | | Map<String, Object> result = new HashMap<>(); |
| | | |
| | | //创建返回因子code集合 |
| | | List<String> sensorCodes = Arrays.asList("a34004", "a34002", "a21005", "a21004", "a21026", "a05024", "a99054", "a01008", "a01007"); |
| | | //获取设备信息 |
| | | Device device = deviceService.getDeviceUnitAlramInforByMac(mac); |
| | | //转换数据单位和名称 |
| | | for (Sensor sensor : device.getVersion().getSensors()) { |
| | | if (!sensorCodes.contains(sensor.getCode())) |
| | | continue; |
| | | Object dataO = datas.get(sensor.getCode()); |
| | | if (dataO != null) { |
| | | String data = String.valueOf(dataO); |
| | | result.put(sensor.getCode(), data); |
| | | } else { |
| | | if (sensor.getCode().equals("a01008") ||sensor.getCode().equals("a01007")){ |
| | | result.put(sensor.getCode(), "-"); |
| | | }else { |
| | | result.put(sensor.getCode(), "0"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | QueryFiveDataByMacVO queryFiveDataByMacVO = new QueryFiveDataByMacVO(); |
| | | queryFiveDataByMacVO.setName(device.getName()); |
| | | queryFiveDataByMacVO.setDataTime(datas.get("dataTime").toString()); |
| | | queryFiveDataByMacVO.setA34004(result.get("a34004").toString()); |
| | | queryFiveDataByMacVO.setA34002(result.get("a34002").toString()); |
| | | queryFiveDataByMacVO.setA21026(result.get("a21026").toString()); |
| | | queryFiveDataByMacVO.setA21004(result.get("a21004").toString()); |
| | | queryFiveDataByMacVO.setA21005(result.get("a21005").toString()); |
| | | queryFiveDataByMacVO.setA05024(result.get("a05024").toString()); |
| | | queryFiveDataByMacVO.setA01008(result.get("a01008").toString()); |
| | | queryFiveDataByMacVO.setA01007(result.get("a01007").toString()); |
| | | queryFiveDataByMacVO.setA99054(result.get("a99054").toString()); |
| | | |
| | | return queryFiveDataByMacVO; |
| | | } |
| | | |
| | | //对六参以及时间进行排序 |
| | | private Map<String, Object> orderSixParam(Map<String, Object> data) { |
| | | LinkedHashMap result = new LinkedHashMap(); |