| | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.common.util.MyBatisBaseMapUtil; |
| | | import com.moral.entity.Device; |
| | |
| | | import com.moral.service.MonitorPointService; |
| | | import com.moral.service.SensorService; |
| | | |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import tk.mybatis.mapper.entity.Example; |
| | | |
| | | @Service |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getSensorByDId(String id) { |
| | | List<Map<String, Object>> list = sensorMapper.getSensorByDId(id); |
| | | return list; |
| | | } |
| | | @Override |
| | | public List<Map<String, Object>> getSensorByMonitorPointId(String monitor_point_id) { |
| | | List<Map<String, Object>> list = sensorMapper.getSensorByMonitorPointId(monitor_point_id); |
| | | return list; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, String>> getSensorsAllMap() { |
| | | List<Sensor> sensors = sensorMapper.selectAll(); |
| | | Map<String, String> sensorsDescriptionMap = new HashMap<>(); |
| | | for (Sensor sensor : sensors) { |
| | | sensorsDescriptionMap.put(sensor.getSensorKey(), sensor.getDescription()); |
| | | } |
| | | Map<String, String> sensorsUnitMap = new HashMap<>(); |
| | | for (Sensor sensor : sensors) { |
| | | sensorsUnitMap.put(sensor.getSensorKey(), sensor.getUnit()); |
| | | } |
| | | List<Map<String, String>> sensorsMapList = new ArrayList<>(); |
| | | sensorsMapList.add(sensorsDescriptionMap); |
| | | sensorsMapList.add(sensorsUnitMap); |
| | | return sensorsMapList; |
| | | } |
| | | |
| | | @Override |
| | | public List<Sensor> selectSenosrsByOrgId(Map<String, Object> parameters) { |
| | | List<String> macList = new ArrayList<>(); |
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(parameters); |
| | |
| | | return sensors; |
| | | } |
| | | |
| | | @Override |
| | | public List<List<String>> listSensorInfos(String[] sensorsResult) { |
| | | List<String> sensorKeys = new ArrayList<>(); |
| | | List<String> sensorKeysNames = new ArrayList<>(); |
| | | List<String> sensorKeysUnits = new ArrayList<>(); |
| | | List<List<String>> sensorInfos = new ArrayList<>(); |
| | | for (int index = 0; index < sensorsResult.length; index++) { |
| | | String[] split = sensorsResult[index].split("-"); |
| | | String key = split[0].replace("\"", ""); |
| | | String name = split[1].replace("\"", ""); |
| | | String Unit = split[2].replace("\"", ""); |
| | | sensorKeys.add(key); |
| | | sensorKeysNames.add(name); |
| | | sensorKeysUnits.add(Unit); |
| | | } |
| | | sensorInfos.add(sensorKeys); |
| | | sensorInfos.add(sensorKeysNames); |
| | | sensorInfos.add(sensorKeysUnits); |
| | | return sensorInfos; |
| | | } |
| | | |
| | | @Override |
| | | public List<List<Map<String, Object>>> listExcelDatas(List<List<String>> sensorInfos, List<Map<String, Object>> list) { |
| | | List<List<Map<String, Object>>> sheets = new ArrayList<>(); |
| | | for (int i = 0; i < sensorInfos.get(0).size(); i++) { |
| | | List<Map<String, Object>> sheet = new ArrayList<>(); |
| | | for (int j = 0; j < list.size(); j++) { |
| | | Map<String, Object> data = new LinkedHashMap<>(); |
| | | for (Map.Entry<String, Object> kv : list.get(j).entrySet()) { |
| | | if ("monitorPointName".equals(kv.getKey())) { |
| | | if ("null".equals(sensorInfos.get(2).get(i))) { |
| | | data.put("站点名称(单位:)", kv.getValue()); |
| | | } else { |
| | | data.put("站点名称(单位:" + sensorInfos.get(2).get(i) + ")", kv.getValue()); |
| | | } |
| | | } else if ("name".equals(kv.getKey())) { |
| | | data.put("设备名称", kv.getValue()); |
| | | } else { |
| | | String sensorsValue = kv.getValue().toString(); |
| | | JSONObject jsonObject = JSONObject.parseObject(sensorsValue); |
| | | if (jsonObject != null) { |
| | | List<Object> sensorsValueList = (List<Object>) jsonObject.get(sensorInfos.get(0).get(i)); |
| | | if (sensorsValueList != null) { |
| | | data.put(kv.getKey(), sensorsValueList.get(0)); |
| | | } else { |
| | | data.put(kv.getKey(), ""); |
| | | } |
| | | } else { |
| | | data.put(kv.getKey(), ""); |
| | | } |
| | | } |
| | | } |
| | | sheet.add(data); |
| | | } |
| | | sheets.add(sheet); |
| | | } |
| | | return sheets; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getSensorKeys() { |
| | | return sensorMapper.getSensorKeys(); |
| | | } |
| | | |
| | | } |