| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereNewHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.AtmoFunctionCode; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.dao.bo.AirDataBo; |
| | | import com.sandu.ximon.dao.bo.AirDataNongGengBo; |
| | | import com.sandu.ximon.dao.domain.AirData; |
| | | import com.sandu.ximon.dao.domain.AirDataNongGeng; |
| | | import com.sandu.ximon.dao.domain.AirEquipment; |
| | | import com.sandu.ximon.dao.domain.AirEquipmentNongGeng; |
| | | import com.sandu.ximon.dao.mapper.AirDataNongGengMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | public boolean saveReportData(String deviceName, A5AtmosphereNewHeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) { |
| | | |
| | | AirDataNongGeng airDataNongGeng = new AirDataNongGeng(); |
| | | BeanUtils.copyProperties(heartBeatDataPackage, airDataNongGeng); |
| | | //("噪声") |
| | | airDataNongGeng.setNoise(heartBeatDataPackage.getNoise() == null ? null : heartBeatDataPackage.getNoise() + "dB"); |
| | | //("硫化氢") |
| | | airDataNongGeng.setHydrogenSulfide(heartBeatDataPackage.getHydrogenSulfide() == null ? null : heartBeatDataPackage.getHydrogenSulfide() + ""); |
| | | //("SO2 浓度") |
| | | airDataNongGeng.setSo2(heartBeatDataPackage.getSo2() == null ? null : heartBeatDataPackage.getSo2() + "ppb"); |
| | | //("NO2 浓度") |
| | | airDataNongGeng.setNo2(heartBeatDataPackage.getNo2() == null ? null : heartBeatDataPackage.getNo2() + "ppb"); |
| | | //("CO 浓度") |
| | | airDataNongGeng.setCo(heartBeatDataPackage.getCo() == null ? null : heartBeatDataPackage.getCo() + "ppb"); |
| | | //("O3 浓度") |
| | | airDataNongGeng.setO3(heartBeatDataPackage.getO3() == null ? null : heartBeatDataPackage.getO3() + "ppb"); |
| | | //("PM2.5 浓度") |
| | | airDataNongGeng.setPm2point5(heartBeatDataPackage.getPm2point5() == null ? null : heartBeatDataPackage.getPm2point5() + "ug/m³"); |
| | | //("PM10 浓度") |
| | | airDataNongGeng.setPm10(heartBeatDataPackage.getPm10() == null ? null : heartBeatDataPackage.getPm10() + "ug/m³"); |
| | | //("空气温度") |
| | | airDataNongGeng.setAirTemperature(heartBeatDataPackage.getAirTemperature() == null ? null : heartBeatDataPackage.getAirTemperature() + "℃"); |
| | | //("空气湿度") |
| | | airDataNongGeng.setAirHumidity(heartBeatDataPackage.getAirHumidity() == null ? null : heartBeatDataPackage.getAirHumidity() + "%"); |
| | | //("大气压强") |
| | | airDataNongGeng.setAirPressure(heartBeatDataPackage.getAirPressure() == null ? null : heartBeatDataPackage.getAirPressure() + "hPa"); |
| | | //("风速") |
| | | airDataNongGeng.setWindSpeed(heartBeatDataPackage.getWindSpeed() == null ? null : heartBeatDataPackage.getWindSpeed() + "m/s"); |
| | | //("风向") |
| | | airDataNongGeng.setWindDirection(heartBeatDataPackage.getWindDirection() == null ? null : heartBeatDataPackage.getWindDirection() + "°"); |
| | | //("10 分钟雨量") |
| | | airDataNongGeng.setTenRainfallMin(heartBeatDataPackage.getTenRainfallMin() == null ? null : heartBeatDataPackage.getTenRainfallMin() + "mm"); |
| | | //("辐射") |
| | | airDataNongGeng.setRadiation(heartBeatDataPackage.getRadiation() == null ? null : heartBeatDataPackage.getRadiation() + "0W/㎡"); |
| | | //("光照") |
| | | airDataNongGeng.setIllumination(heartBeatDataPackage.getIllumination() == null ? null : heartBeatDataPackage.getIllumination() + "Klux"); |
| | | //紫外指数 |
| | | airDataNongGeng.setUltraviolet(heartBeatDataPackage.getUltraviolet() == null ? null : heartBeatDataPackage.getUltraviolet() + ""); |
| | | //CO2 |
| | | airDataNongGeng.setCo2(heartBeatDataPackage.getCo2() == null ? null : heartBeatDataPackage.getCo2() + "0ppm"); |
| | | //负氧离子 |
| | | airDataNongGeng.setO2(heartBeatDataPackage.getO2() == null ? null : heartBeatDataPackage.getO2() + "个"); |
| | | |
| | | airDataNongGeng.setMac(deviceName); |
| | | |
| | | //将设备信息添加到大气设备表 |
| | |
| | | airEquipmentNongGengService.addAirEquipment(airEquipmentNongGeng); |
| | | |
| | | //存缓存 |
| | | RedisUtils.getBean().set(AtmoFunctionCode.AIR_HEARTBEAT_NONG_GENG.getCode() + deviceName, heartBeatDataPackage, 300L); |
| | | RedisUtils.getBean().set(AtmoFunctionCode.AIR_HEARTBEAT_NONG_GENG.getCode() + deviceName, heartBeatDataPackage); |
| | | RedisUtils.getBean().set(AtmoFunctionCode.AIR_HEARTBEAT_NONG_GENG_STATE.getCode() + deviceName, heartBeatDataPackage, 300L); |
| | | |
| | | return save(airDataNongGeng); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询大气数据(模糊查询) |
| | | */ |
| | | public List<AirDataNongGengBo> listAirDataByKeyword(BaseConditionVO baseConditionVO, String keyword) { |
| | | public List<AirDataNongGengBo> listAirDataByKeyword(BaseConditionVO baseConditionVO, String keyword, String type) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | List<Long> listAirId; |
| | | if (SecurityUtils.getClientId() == null) { |
| | | listAirId = baseMapper.listAirId(keyword, null); |
| | | listAirId = baseMapper.listAirId(keyword, null, type); |
| | | } else { |
| | | listAirId = baseMapper.listAirId(keyword, SecurityUtils.getUserId()); |
| | | listAirId = baseMapper.listAirId(keyword, SecurityUtils.getUserId(), type); |
| | | } |
| | | if (CollUtil.isEmpty(listAirId)) { |
| | | return CollUtil.newArrayList(); |
| | |
| | | return airDataBos; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 设备历史数据 |
| | | * |
| | | * @param baseConditionVO |
| | | * @param mac |
| | | * @return |
| | | */ |
| | | public List<AirDataNongGengBo> historyData(BaseConditionVO baseConditionVO, String mac) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | if (mac == null || mac.isEmpty()) { |
| | | throw new BusinessException("mac不能为空"); |
| | | } |
| | | List<AirDataNongGengBo> bos = baseMapper.historyData(mac); |
| | | return bos; |
| | | } |
| | | } |