| | |
| | | import org.springframework.util.ObjectUtils;
|
| | |
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.alibaba.fastjson.TypeReference;
|
| | | import com.moral.common.util.CalculateUtils;
|
| | | import com.moral.common.util.ParameterUtils;
|
| | |
| | | }
|
| | | return listMapNew;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> getSensorDataMin(Map<String, Object> parameters) {
|
| | | String startTime=parameters.get("startTime").toString();
|
| | | Boolean flag=null;
|
| | | try {
|
| | | flag = DateUtils.isSameDay(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime), new Date());
|
| | | }catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | List<Sensor> sensors=sensorMapper.getSensorsByMac(parameters);
|
| | | List<String> sensorKeys=new ArrayList<>();
|
| | | for(Sensor sensor:sensors){
|
| | | sensorKeys.add(sensor.getSensorKey());
|
| | | }
|
| | | parameters.put("sensorKeys", sensorKeys);
|
| | | List<Map<String, Object>> listMap=null;
|
| | | if(flag){
|
| | | listMap = historyMapper.getSensorDataTodayMin(parameters);
|
| | | }else{
|
| | | listMap = historyMinutelyMapper.getSensorDataMin(parameters);
|
| | | }
|
| | | List<Map<String, Object>> listMapNew = new ArrayList<>();
|
| | | Map<String, Object> new_map = new LinkedHashMap<>();
|
| | | if (CollectionUtils.isNotEmpty(listMap)) {
|
| | | for (Map<String, Object> map : listMap) {
|
| | | new_map.put("时间", map.get("time"));
|
| | | for (String key : map.keySet()) {
|
| | | for (Sensor sensor : sensors) {
|
| | | if (sensor.getSensorKey().equals(key)) {
|
| | | if("e79".equals(key)||"e80".equals(key)||"e81".equals(key)){
|
| | | new_map.put(sensor.getDescription(), StringUtils.scientificCountingConversion(map.get(key).toString().replace("\"", "")));
|
| | | }else{
|
| | | new_map.put(sensor.getDescription(), map.get(key).toString().replace("\"", ""));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | listMapNew.add(new_map);
|
| | | new_map = new LinkedHashMap<>();
|
| | | }
|
| | | }
|
| | | return listMapNew;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> getSensorDataMax(Map<String, Object> parameters) {
|
| | | String startTime=parameters.get("startTime").toString();
|
| | | Boolean flag=null;
|
| | | try {
|
| | | flag = DateUtils.isSameDay(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime), new Date());
|
| | | }catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | List<Sensor> sensors=sensorMapper.getSensorsByMac(parameters);
|
| | | List<String> sensorKeys=new ArrayList<>();
|
| | | for(Sensor sensor:sensors){
|
| | | sensorKeys.add(sensor.getSensorKey());
|
| | | }
|
| | | parameters.put("sensorKeys", sensorKeys);
|
| | | List<Map<String, Object>> listMap=null;
|
| | | if(flag){
|
| | | listMap = historyMapper.getSensorDataTodayMax(parameters);
|
| | | }else{
|
| | | listMap = historyMinutelyMapper.getSensorDataMax(parameters);
|
| | | }
|
| | | List<Map<String, Object>> listMapNew = new ArrayList<>();
|
| | | Map<String, Object> new_map = new LinkedHashMap<>();
|
| | | if (CollectionUtils.isNotEmpty(listMap)) {
|
| | | for (Map<String, Object> map : listMap) {
|
| | | new_map.put("时间", map.get("time"));
|
| | | for (String key : map.keySet()) {
|
| | | for (Sensor sensor : sensors) {
|
| | | if (sensor.getSensorKey().equals(key)) {
|
| | | if("e79".equals(key)||"e80".equals(key)||"e81".equals(key)){
|
| | | new_map.put(sensor.getDescription(), StringUtils.scientificCountingConversion(map.get(key).toString().replace("\"", "")));
|
| | | }else{
|
| | | new_map.put(sensor.getDescription(), map.get(key).toString().replace("\"", ""));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | listMapNew.add(new_map);
|
| | | new_map = new LinkedHashMap<>();
|
| | | }
|
| | | }
|
| | | return listMapNew;
|
| | | }
|
| | |
|
| | | }
|