cjl
2024-04-23 65b70cf13a2ec91013d876771be878c165cae3a4
screen-api/src/main/java/com/moral/api/service/impl/HandDeviceServiceImpl.java
@@ -18,6 +18,7 @@
import com.moral.api.entity.HandDevice;
import com.moral.api.entity.HistoryFiveMinutely;
import com.moral.api.entity.HistoryHourly;
import com.moral.api.entity.HistoryMinutely;
import com.moral.api.mapper.DeviceMapper;
import com.moral.api.mapper.HandDeviceMapper;
import com.moral.api.pojo.query.handdevice.HandDevicePageCond;
@@ -64,6 +65,7 @@
     */
    @Override
    public Page<HandDevice> page(HandDevicePageCond handDevicePageCond) {
        Page<HandDevice> page = handDeviceMapper.Page(handDevicePageCond.getPage().convertPage(),
                                                    handDevicePageCond.getMac(),
                                                    handDevicePageCond.getName(),
@@ -95,14 +97,17 @@
     */
    @Override
    public HandDevice update(HandDevice handDevice) {
        QxUser currentUser = UserHelper.getCurrentUser();
        String state = handDevice.getState();
        if (state.equals("0")){
            HandDevice handDevice1 = getHand(handDevice);
            handDevice1.setCreateName(currentUser.getUserName());
            handDeviceMapper.insert(handDevice1);
            return handDevice1;
        }else {
            handDevice.setEndTime(new Date());
            handDevice.setState("0");
            handDevice.setUpdateName(currentUser.getUserName());
            handDeviceMapper.updateById(handDevice);
            return handDevice;
        }
@@ -140,7 +145,10 @@
        Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_mm_EN);
        Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_mm_EN);
        List<Map<String, Object>> rsMap = new ArrayList<>();
        if (ObjectUtils.isEmpty(endTime)){
             endDate = new Date();
        }
        if (type.equals("hour")){
            List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(mac, startDate, endDate);
            for (HistoryHourly historyHourly : valueByMacAndTime) {
@@ -151,7 +159,17 @@
                map.put("a21028",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028"));
                rsMap.add(map);
            }
        }else {
        }else if (type.equals("minute")){
            List<HistoryMinutely> historyMinutelys = historyHourlyService.getHistoryMinutely(mac, startDate, endDate);
            for (HistoryMinutely historyMinutely : historyMinutelys) {
                String value = historyMinutely.getValue();
                Map map = JSON.parseObject(value, Map.class);
                map.put("time",DateUtils.dateToDateString(historyMinutely.getTime()));
                map.put("a21001",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001"));
                map.put("a21028",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028"));
                rsMap.add(map);
            }
        }else if (type.equals("minutely")){
            List<HistoryFiveMinutely> historyFiveMinutelies = historyFiveMinutelyService.queryFiveMinutely(mac, startDate, endDate);
            for (HistoryFiveMinutely historyFiveMinutely : historyFiveMinutelies) {
                String value = historyFiveMinutely.getValue();
@@ -175,9 +193,15 @@
    public List<Map<String, Object>> detailsExecl(Map<String, Object> params) {
        String type = params.get("type").toString();
        String mac = params.get("mac").toString();
        Object endTime = params.get("endTime");
        Date startDate = DateUtils.getDate(params.get("startTime").toString(),DateUtils.yyyy_MM_dd_HH_mm_EN);
        Date endDate = DateUtils.getDate(params.get("endTime").toString(),DateUtils.yyyy_MM_dd_HH_mm_EN);
        Date endDate;
        List<Map<String, Object>> rsMap = new ArrayList<>();
        if (ObjectUtils.isEmpty(endTime)){
             endDate = new Date();
        }else {
             endDate = DateUtils.getDate(endTime.toString(),DateUtils.yyyy_MM_dd_HH_mm_EN);
        }
        if (type.equals("hour")){
            List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(mac, startDate, endDate);
            for (HistoryHourly historyHourly : valueByMacAndTime) {
@@ -185,18 +209,18 @@
                String value = historyHourly.getValue();
                Map map = JSON.parseObject(value, Map.class);
                map1.put("时间",DateUtils.dateToDateString(historyHourly.getTime()));
                map1.put("pm25",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004"));
                map1.put("pm10",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002"));
                map1.put("二氧化氮",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004"));
                map1.put("二氧化硫",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026"));
                map1.put("一氧化碳",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005"));
                map1.put("气压",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006"));
                map1.put("温度",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001"));
                map1.put("湿度",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002"));
                map1.put("tvoc",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054"));
                map1.put("甲醛",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001"));
                map1.put("硫化氢",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028"));
                map1.put("氨气",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001"));
                map1.put("pm25ug/m³",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004"));
                map1.put("pm10ug/m³",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002"));
                map1.put("二氧化氮ug/m³",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004"));
                map1.put("二氧化硫ug/m³",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026"));
                map1.put("一氧化碳ug/m³",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005"));
                map1.put("气压hpa",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006"));
                map1.put("温度℃",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001"));
                map1.put("湿度%",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002"));
                map1.put("tvocmg/m³",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054"));
                map1.put("甲醛mg/m³",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001"));
                map1.put("硫化氢ppm",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028"));
                map1.put("氨气ug/m³",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001"));
                rsMap.add(map1);
            }
        }else {
@@ -206,18 +230,18 @@
                String value = historyFiveMinutely.getValue();
                Map map = JSON.parseObject(value, Map.class);
                map1.put("时间",DateUtils.dateToDateString(historyFiveMinutely.getTime()));
                map1.put("pm25",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004"));
                map1.put("pm10",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002"));
                map1.put("二氧化氮",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004"));
                map1.put("二氧化硫",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026"));
                map1.put("一氧化碳",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005"));
                map1.put("气压",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006"));
                map1.put("温度",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001"));
                map1.put("湿度",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002"));
                map1.put("tvoc",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054"));
                map1.put("甲醛",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001"));
                map1.put("硫化氢",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028"));
                map1.put("氨气",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001"));
                map1.put("pm25ug/m³",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004"));
                map1.put("pm10ug/m³",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002"));
                map1.put("二氧化氮ug/m³",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004"));
                map1.put("二氧化硫ug/m³",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026"));
                map1.put("一氧化碳ug/m³",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005"));
                map1.put("气压hpa",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006"));
                map1.put("温度℃",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001"));
                map1.put("湿度%",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002"));
                map1.put("tvocmg/m³",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054"));
                map1.put("甲醛ug/m³",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001"));
                map1.put("硫化氢ppm",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028"));
                map1.put("氨气ug/m³",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001"));
                rsMap.add(map1);
            }
        }
@@ -226,7 +250,6 @@
    private HandDevice getHand(HandDevice handDevice){
        QxUser currentUser = UserHelper.getCurrentUser();
        HandDevice rsHandDevice = new HandDevice();
        rsHandDevice.setName(handDevice.getName());
        rsHandDevice.setMac(handDevice.getMac());
@@ -234,7 +257,6 @@
        rsHandDevice.setLatitude(handDevice.getLatitude());
        rsHandDevice.setLongitude(handDevice.getLongitude());
        rsHandDevice.setIsDelete(Constants.NOT_DELETE);
        rsHandDevice.setUpdateName(currentUser.getUserName());
        rsHandDevice.setStartTime(new Date());
        rsHandDevice.setUpdateTime(new Date());
        rsHandDevice.setCreateTime(new Date());