Merge remote-tracking branch 'origin/wb_21' into qa
1 files added
32 files modified
| | |
| | | package com.moral.api.config.websocket; |
| | | |
| | | import com.moral.api.websocket.CruiserWebSocketServer; |
| | | |
| | | import com.moral.api.websocket.SingleDeviceServer; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | |
| | | //处理查询业务 |
| | | List<DeviceAndFiveMinuteDataDTO> dto = historyFiveMinutelyService.queryDeviceAndFiveMinuteData(form); |
| | | |
| | | List<Map<String, Object>> dto = historyFiveMinutelyService.queryDeviceAndFiveMinuteData(form); |
| | | Map<String,List<Map<String, Object>>> dtoResult = new HashMap<>(); |
| | | dtoResult.put("devices",dto); |
| | | //转换前端参数 |
| | | DeviceAndFiveMinuteDataVO vo = DeviceAndFiveMinuteDataVO.convert(dto); |
| | | //DeviceAndFiveMinuteDataVO vo = DeviceAndFiveMinuteDataVO.convert(dto); |
| | | |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo); |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), dtoResult); |
| | | } |
| | | |
| | | /** |
New file |
| | |
| | | package com.moral.api.dto; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @ClassName CityAqiDailyListDTO |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-08-22 15:19 |
| | | * @Version 1.0 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class CityAqiDailyListDTO { |
| | | |
| | | private String cityCode; |
| | | |
| | | private BigDecimal aqi; |
| | | |
| | | private BigDecimal comp; |
| | | |
| | | private BigDecimal nums; |
| | | |
| | | } |
| | |
| | | /* |
| | | |
| | | package com.moral.api.exception.consumer; |
| | | |
| | |
| | | import com.moral.constant.KafkaConstants; |
| | | |
| | | |
| | | /* |
| | | * 走航车数据消费者 |
| | | * |
| | | */ |
| | | /* * 走航车数据消费者 |
| | | **//* |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | */ |
| | |
| | | /* |
| | | |
| | | package com.moral.api.exception.consumer; |
| | | |
| | |
| | | import java.util.concurrent.CopyOnWriteArraySet; |
| | | |
| | | |
| | | */ |
| | | /* |
| | | * |
| | | /** |
| | | * @ClassName SecondsDataConsumer1 |
| | | * @Description TODO |
| | | * @Author 陈凯裕 |
| | | * @Date 2021/6/15 14:49 |
| | | * @Version TODO |
| | | * |
| | | *//* |
| | | **/ |
| | | |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | */ |
| | |
| | | |
| | | import com.moral.api.entity.AlarmInfo; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import io.lettuce.core.dynamic.annotation.Param; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | List<Map<String,Object>> selectNewestData(Map<String, Object> map); |
| | | |
| | | int numNews(@Param("organizationId") int organizationId); |
| | | |
| | | } |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import com.moral.api.dto.CityAqiDailyListDTO; |
| | | import com.moral.api.entity.CityAqiDaily; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface CityAqiDailyMapper extends BaseMapper<CityAqiDaily> { |
| | | |
| | | |
| | | /** |
| | | * 查询指定省份得api 和 综合指数 |
| | | * */ |
| | | List<CityAqiDailyListDTO> CityAqiDailyMap(Map<String, Object> params); |
| | | } |
| | |
| | | |
| | | import com.moral.api.entity.CityAqi; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import io.lettuce.core.dynamic.annotation.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface CityAqiMapper extends BaseMapper<CityAqi> { |
| | | |
| | | /** |
| | | * |
| | | *查询24小时城市api |
| | | * */ |
| | | List<CityAqi> listCity(@Param("cityCode") Integer cityCode); |
| | | |
| | | } |
| | |
| | | |
| | | import com.moral.api.entity.Device; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import io.lettuce.core.dynamic.annotation.Param; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | /*监测因子趋势图数据*/ |
| | | List<Map<String, Object>> getTrendChartData(Map<String, Object> params); |
| | | |
| | | List<Map<String, Object>> deviceList(@Param("organizationId") int organizationId, |
| | | @Param("regionCode") int regionCode, |
| | | @Param("region") String region, |
| | | @Param("type") String type, |
| | | @Param("sensorCode") String sensorCode, |
| | | @Param("times") String times, |
| | | @Param("endHourlyTime") String endHourlyTime); |
| | | |
| | | List<Integer> deviceIdList(@Param("organizationId") int organizationId); |
| | | |
| | | List<Integer> deviceOrgIdList(@Param("organizationId") int organizationId); |
| | | |
| | | } |
| | |
| | | //根据站点id获取设备列表 |
| | | List<Device> getDevicesByMonitorPointId(Integer monitorPointId); |
| | | |
| | | List<Device> getDevicesByMonitorPointId(List<Integer> monitorPointId); |
| | | |
| | | //根据macs获取公有因子信息 |
| | | Map<String, Object> getSensorsByMac(Map<String,Object> params); |
| | | |
| | |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/7/16 |
| | | */ |
| | | List<DeviceAndFiveMinuteDataDTO> queryDeviceAndFiveMinuteData(QueryDeviceAndFiveMinuteDataForm form); |
| | | List<Map<String, Object>> queryDeviceAndFiveMinuteData(QueryDeviceAndFiveMinuteDataForm form); |
| | | |
| | | /** |
| | | * @Description: 查询一个设备最新的五分钟数据 |
| | |
| | | public Map<String, Object> getDataByConditionWithoutPage(Map<String, Object> parameters) { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | int orgId = Integer.parseInt(parameters.get("organization_id").toString()); |
| | | //定义一个集合,存放所有id |
| | | /* //定义一个集合,存放所有id |
| | | List<Integer> allOrgId = new ArrayList<>(); |
| | | allOrgId.add(orgId); |
| | | //循环集合 |
| | |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | }*/ |
| | | List<Integer> deviceIdList = deviceMapper.deviceIdList(orgId); |
| | | if (deviceIdList.size()>0){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | QueryWrapper<AlarmInfo> alarmInfoQueryWrapper = new QueryWrapper<>(); |
| | |
| | | public Map<String, Object> alarmReminder(Map<String, Object> parameters) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | int orgId = Integer.parseInt(parameters.get("organization_id").toString()); |
| | | //定义一个集合,存放所有id |
| | | /*//定义一个集合,存放所有id |
| | | List<Integer> allOrgId = new ArrayList<>(); |
| | | allOrgId.add(orgId); |
| | | //循环集合 |
| | |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | if (deviceIdList.size()>0){ |
| | | }*/ |
| | | // if (deviceIdList.size()>0){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("deviceIds",deviceIdList); |
| | | //map.put("deviceIds",deviceIdList); |
| | | int size = Integer.parseInt(parameters.get("size").toString()); |
| | | map.put("size",size); |
| | | map.put("orgId",orgId); |
| | | List<Map<String, Object>> resultList = alarmInfoMapper.selectNewestData(map); |
| | | SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (Map<String, Object> alarmInfo:resultList) { |
| | |
| | | alarmInfo.put("alarm_time",alarm_time); |
| | | } |
| | | resultMap.put("alarmInfors",resultList); |
| | | QueryWrapper<AlarmInfo> alarmInfoQueryWrapper = new QueryWrapper<>(); |
| | | Integer totalNumber = alarmInfoMapper.numNews(orgId); |
| | | /*QueryWrapper<AlarmInfo> alarmInfoQueryWrapper = new QueryWrapper<>(); |
| | | alarmInfoQueryWrapper.in("device_id",deviceIdList); |
| | | Integer totalNumber = alarmInfoMapper.selectCount(alarmInfoQueryWrapper); |
| | | Integer totalNumber = alarmInfoMapper.selectCount(alarmInfoQueryWrapper);*/ |
| | | resultMap.put("totalNumber",totalNumber); |
| | | return resultMap; |
| | | } |
| | | return null; |
| | | // } |
| | | // return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.config.properties.SpecialCitiesProperties; |
| | | import com.moral.api.dto.CityAqiDailyListDTO; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.CityAqiMapper; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.ForecastMapper; |
| | | import com.moral.api.mapper.SysAreaMapper; |
| | | import com.moral.api.mapper.*; |
| | | import com.moral.api.pojo.dto.cityAQI.CityPollutionLevel; |
| | | import com.moral.api.pojo.dto.cityAQI.ConcentrationAndPercent; |
| | | import com.moral.api.pojo.form.aqi.AirQualityComparisonForm; |
| | |
| | | |
| | | import com.moral.util.MathUtils; |
| | | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private CityAqiMapper cityAqiMapper; |
| | | @Autowired |
| | | private CityAqiDailyMapper cityAqiDailyMapper; |
| | | |
| | | @Autowired |
| | | private ForecastMapper forecastMapper; |
| | |
| | | @Override |
| | | public Map<String, Object> query24HoursAqiByRegionCode(Integer regionCode) { |
| | | //查询最新一条数据,用于获取最新的时间 |
| | | QueryWrapper<CityAqi> lastDataWrapper = new QueryWrapper<>(); |
| | | /*QueryWrapper<CityAqi> lastDataWrapper = new QueryWrapper<>(); |
| | | lastDataWrapper.eq("city_code", regionCode); |
| | | lastDataWrapper.orderByDesc("time"); |
| | | lastDataWrapper.last(true, "limit 1"); |
| | |
| | | //查询数据 |
| | | QueryWrapper<CityAqi> wrapper = new QueryWrapper<>(); |
| | | wrapper.between("time", startDate, endDate); |
| | | wrapper.eq("city_code", regionCode); |
| | | List<CityAqi> cityAqis = cityAqiMapper.selectList(wrapper); |
| | | wrapper.eq("city_code", regionCode);*/ |
| | | List<CityAqi> cityAqis = cityAqiMapper.listCity(regionCode); |
| | | //如果数据不足24小时则补全 |
| | | if (cityAqis.size() != 24) { |
| | | Map<Date, CityAqi> dateCityAqiMap = new HashMap<>(); |
| | | cityAqis.forEach(value -> dateCityAqiMap.put(value.getTime(), value)); |
| | | if(CollectionUtils.isEmpty(cityAqis)){ |
| | | return new HashMap<>(); |
| | | } |
| | | Date startDate = cityAqis.get(0).getTime(); |
| | | if(cityAqis.size()<24){ |
| | | for (int i = 0; i < 24; i++) { |
| | | Date date = DateUtils.addHours(startDate, i); |
| | | CityAqi cityAqi1 = dateCityAqiMap.get(date); |
| | | if (cityAqi1 == null) { |
| | | Date dateTime = DateUtils.addHours(startDate, i); |
| | | if(cityAqis.size()-1 <i){ |
| | | CityAqi newCityAqi = new CityAqi(); |
| | | newCityAqi.setTime(date); |
| | | newCityAqi.setTime(dateTime); |
| | | newCityAqi.setValue("0"); |
| | | cityAqis.add(newCityAqi); |
| | | continue; |
| | | } |
| | | } |
| | | //按照时间进行排序 |
| | | cityAqis.sort(Comparator.comparing(CityAqi::getTime)); |
| | | } |
| | | //按照时间进行排序 |
| | | cityAqis.sort(Comparator.comparing(CityAqi::getTime)); |
| | | |
| | | //封装返回数据,map的key为yyyy-MM-dd HH:mm格式的时间,value为aqi的数值 |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | for (CityAqi aqi : cityAqis) { |
| | | String key = DateUtils.dateToDateString(aqi.getTime(), "yyyy-MM-dd HH:mm"); |
| | | String allDataJson = aqi.getValue(); |
| | | if (allDataJson == null) { |
| | | result.put(key, ""); |
| | | continue; |
| | | } |
| | | Map<String, Object> allDataMap = JSON.parseObject(allDataJson, Map.class); |
| | | Object aqiData = allDataMap.get("AQI"); |
| | | if (aqiData == null) |
| | | result.put(key, ""); |
| | | else |
| | | result.put(key, aqiData); |
| | | result.put(key,aqi.getValue()); |
| | | } |
| | | return result; |
| | | } |
| | |
| | | |
| | | Date now = new Date(); |
| | | //昨日 |
| | | Date yesterday = DateUtils.dataToTimeStampTime(DateUtils.getDateOfDay(now, -1), DateUtils.yyyy_MM_dd_EN); |
| | | String dateString = DateUtils.dateToDateString(yesterday, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | Date yesterday = DateUtils.dataToTimeStampTime(DateUtils.getDateOfDay(now, 0), DateUtils.yyyy_MM_dd_EN); |
| | | String dateString = DateUtils.dateToDateString(yesterday, DateUtils.yyyy_MM_dd_EN); |
| | | |
| | | String s = String.valueOf(regionCode); |
| | | //获取省,市code |
| | | Integer provinceCode = Integer.parseInt(s.substring(0, 2) + "0000"); |
| | | Integer cityCode = Integer.parseInt(s.substring(0, 4) + "00"); |
| | | //获取省内所有city_code |
| | | Map<String,Object> params = new HashMap<>(); |
| | | params.put("cityCode",provinceCode); |
| | | params.put("start",dateString); |
| | | params.put("end",dateString); |
| | | params.put("type",1); |
| | | List<CityAqiDailyListDTO> dayList = cityAqiDailyMapper.CityAqiDailyMap(params); |
| | | String start = DateUtils.dateToDateString(DateUtils.addMonths(DateUtils.getFirstDayOfLastMonth(), 1)); |
| | | params.put("start",start); |
| | | params.put("type",2); |
| | | List<CityAqiDailyListDTO> monList = cityAqiDailyMapper.CityAqiDailyMap(params); |
| | | start =DateUtils.dateToDateString(now, DateUtils.yyyy); |
| | | params.put("start",start); |
| | | params.put("end",start); |
| | | params.put("type",3); |
| | | List<CityAqiDailyListDTO> yearList = cityAqiDailyMapper.CityAqiDailyMap(params); |
| | | int indexDay = dayList.stream().map(CityAqiDailyListDTO::getCityCode).collect(Collectors.toList()).indexOf(cityCode.toString()); |
| | | int indexMon = monList.stream().map(CityAqiDailyListDTO::getCityCode).collect(Collectors.toList()).indexOf(cityCode.toString()); |
| | | int indexYear = yearList.stream().map(CityAqiDailyListDTO::getCityCode).collect(Collectors.toList()).indexOf(cityCode.toString()); |
| | | result.put("day",mapResult(dayList,indexDay)); |
| | | result.put("month",mapResult(monList,indexMon)); |
| | | result.put("year",mapResult(yearList,indexYear)); |
| | | /* //获取省内所有city_code |
| | | QueryWrapper<SysArea> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("area_code").eq("parent_code", provinceCode); |
| | | List<Object> cityCodes = sysAreaService.listObjs(wrapper); |
| | |
| | | yearMap.put("size", null); |
| | | } |
| | | yearMap.put("compositeIndex", yearMap.remove("value")); |
| | | result.put("year", yearMap); |
| | | result.put("year", yearMap);*/ |
| | | |
| | | //时间,昨日 |
| | | result.put("time", DateUtils.dateToDateString(yesterday, DateUtils.yyyy_MM_dd_EN)); |
| | | return result; |
| | | } |
| | | |
| | | private Map<String,Object> mapResult(List<CityAqiDailyListDTO> list, int length){ |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("AQI",CollectionUtils.isNotEmpty(list)&&length>0&&Objects.nonNull(list.get(length-1))?list.get(length-1).getAqi():0); |
| | | map.put("rank",CollectionUtils.isNotEmpty(list)&&length>0?length:0); |
| | | map.put("size",CollectionUtils.isNotEmpty(list)&&length>0?list.size():0); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<AirQualityComparisonVO> queryAirQualityComparison(AirQualityComparisonForm form) { |
| | | //取参 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Device> getDevicesByMonitorPointId(List<Integer> monitorPointId) { |
| | | QueryWrapper<Device> wrapper = new QueryWrapper(); |
| | | wrapper.in("monitor_point_id", monitorPointId); |
| | | wrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | wrapper.orderByAsc("dev_num"); |
| | | return deviceMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getSensorsByMac(Map<String, Object> params) { |
| | | List<String> sensorCodes = Arrays.asList(Constants.SENSOR_CODE_PM25 |
| | | , Constants.SENSOR_CODE_PM10 |
| | |
| | | Map<String,Object> historyHourlyMap = new HashMap<>(); |
| | | historyHourlyMap.put("mac",mac); |
| | | JSONObject value = JSONObject.parseObject(historyFiveMinutely.getValue()); |
| | | Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); |
| | | historyHourlyMap.put(sensorCode,sensorValue); |
| | | if (value.get(sensorCode)==null){ |
| | | historyHourlyMap.put(sensorCode,0.0); |
| | | }else { |
| | | Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); |
| | | historyHourlyMap.put(sensorCode,sensorValue); |
| | | } |
| | | // Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); |
| | | // historyHourlyMap.put(sensorCode,sensorValue); |
| | | Date time = historyFiveMinutely.getTime(); |
| | | String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | historyHourlyMap.put("time",timeStr); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.config.mybatis.MybatisPlusConfig; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.HistoryFiveMinutelyMapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.mapper.HistoryHourlyMapper; |
| | |
| | | import com.moral.constant.SeparateTableType; |
| | | import com.moral.util.DateUtils; |
| | | import com.moral.util.MybatisPLUSUtils; |
| | | import com.moral.util.RegionCodeUtils; |
| | | import io.lettuce.core.GeoCoordinates; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | HistoryHourlyMapper historyHourlyMapper; |
| | | @Autowired |
| | | DeviceService deviceService; |
| | | @Autowired |
| | | DeviceMapper deviceMapper; |
| | | |
| | | @Override |
| | | public List<DeviceAndFiveMinuteDataDTO> queryDeviceAndFiveMinuteData(QueryDeviceAndFiveMinuteDataForm form) { |
| | | public List<Map<String, Object>> queryDeviceAndFiveMinuteData(QueryDeviceAndFiveMinuteDataForm form) { |
| | | //取参 |
| | | String times = DateUtils.dateToDateString(new Date(),DateUtils.yyyyMM_EN); |
| | | Integer organizationId = form.getOrganizationId(); |
| | | Integer regionCode = form.getRegionCode(); |
| | | String sensorCode = form.getSensorCode(); |
| | | String type = "$."+ sensorCode; |
| | | String region = null; |
| | | String endHourlyTime = null; |
| | | if (regionCode != null && organizationId!=24) { |
| | | region = RegionCodeUtils.regionCodeConvertToName(regionCode); |
| | | } |
| | | if (form.getChooseTime().equals("true")) { |
| | | endHourlyTime = form.getTime(); |
| | | } |
| | | List<Map<String, Object>> listAll = deviceMapper.deviceList(organizationId,regionCode,region,type,sensorCode,times,endHourlyTime); |
| | | //查询组织在对应地区下的站点以及设备 |
| | | List<MonitorPoint> monitorPoints = monitorPointService.queryByOrgIdAndRegionCode(new MonitorPointQueryForm(organizationId, regionCode)); |
| | | /*List<MonitorPoint> monitorPoints = monitorPointService.queryByOrgIdAndRegionCode(new MonitorPointQueryForm(organizationId, regionCode)); |
| | | List<Device> devices = new ArrayList<>(); |
| | | for (MonitorPoint monitorPoint : monitorPoints) { |
| | | List<Device> monitorPointDevices = monitorPoint.getDevices(); |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | }*/ |
| | | //查询所有设备对应的数据 |
| | | /*List<Device> devices = new ArrayList<>(); |
| | | List<DeviceAndFiveMinuteDataDTO> dtos = new ArrayList<>(); |
| | | if (form.getChooseTime().equals("true")) { |
| | | String time = form.getTime(); |
| | |
| | | } |
| | | return dtos; |
| | | } |
| | | //List<Map<String, Object>> sensorValuess = (List<Map<String, Object>>) redisTemplate.opsForValue().multiGet(Arrays.asList("data_five_minutes:p5dnd7a0245400","data_five_minutes:p5dnd7a0245412")); |
| | | for (Device device : devices) { |
| | | DeviceAndFiveMinuteDataDTO dto = new DeviceAndFiveMinuteDataDTO(); |
| | | String mac = device.getMac(); |
| | | Map<String, Object> sensorValues = queryLastDataByMac(mac); |
| | | |
| | | String dbDataStr = JSON.toJSONString(sensorValues); |
| | | sensorValues = JSON.parseObject(dbDataStr, HashMap.class); |
| | | Map<String, Object> sensorValue = new HashMap<>(); |
| | |
| | | dto.setDevice(device); |
| | | dto.setSensorValue(sensorValue); |
| | | dtos.add(dto); |
| | | } |
| | | return dtos; |
| | | }*/ |
| | | return listAll; |
| | | } |
| | | |
| | | @Override |
| | |
| | | // region = RegionCodeUtils.regionCodeConvertToName(regionCode); |
| | | // } |
| | | |
| | | //查询子组织 |
| | | /* //查询子组织 |
| | | List<Organization> childrenOrganization = organizationService.getChildrenOrganizationsById(organizationId); |
| | | List<Integer> organizationIds = new ArrayList<>(); |
| | | |
| | | for (Organization organization : childrenOrganization) { |
| | | organizationIds.add(organization.getId()); |
| | | } |
| | | organizationIds.add(organizationId); |
| | | organizationIds.add(organizationId);*/ |
| | | //查询站点 |
| | | QueryWrapper<MonitorPoint> queryMonitorPointsWrapper = new QueryWrapper<>(); |
| | | |
| | | //如果region不为空,就查询当前组织,所选城市下所有站点及设备信息 |
| | | //如果region为空,则查询当前组织下所有的站点和设备 |
| | | List<Integer> organizationIds = deviceMapper.deviceOrgIdList(organizationId); |
| | | if (region != null){ |
| | | queryMonitorPointsWrapper.eq(region, regionCode); |
| | | } |
| | |
| | | import com.moral.api.entity.MonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.SysArea; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.MonitorPointMapper; |
| | | import com.moral.api.mapper.SysAreaMapper; |
| | | import com.moral.api.service.OrganizationService; |
| | |
| | | |
| | | @Autowired |
| | | private OrganizationService organizationService; |
| | | @Autowired |
| | | private DeviceMapper deviceMapper; |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getMapPath(Integer orgId) { |
| | | //获取组织下所有子组织 |
| | | List<Organization> organizations = organizationService.getChildrenOrganizationsById(orgId); |
| | | /*List<Organization> organizations = organizationService.getChildrenOrganizationsById(orgId); |
| | | List<Integer> orgIds = organizations.stream().map(Organization::getId).collect(Collectors.toList()); |
| | | orgIds.add(orgId); |
| | | orgIds.add(orgId);*/ |
| | | List<Integer> orgIds = deviceMapper.deviceOrgIdList(orgId); |
| | | QueryWrapper<MonitorPoint> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("province_code", "city_code", "area_code") |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | |
| | | * @Date 2021/6/15 13:56 |
| | | * @Version TODO |
| | | **/ |
| | | |
| | | @ServerEndpoint("/singleDevice/{mac}") |
| | | @Component |
| | | @Data |
| | |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | redis: |
| | | host: r-bp1xdlb9wfc6zt0msp05.redis.rds.aliyuncs.com |
| | | host: r-bp1xdlb9wfc6zt0msp18.redis.rds.aliyuncs.com |
| | | port: 6379 |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | timeout: 30000 |
| | | jedis: |
| | | pool: |
| | |
| | | max-wait: 30000 |
| | | min-idle: 32 |
| | | tokenRedis: |
| | | host: r-bp1xdlb9wfc6zt0msp05.redis.rds.aliyuncs.com |
| | | host: r-bp1xdlb9wfc6zt0msp18.redis.rds.aliyuncs.com |
| | | port: 6379 |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | timeout: 30000 |
| | | database: 15 |
| | | pool: |
| | |
| | | filters: stat |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | max-wait: 60000 |
| | | url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk05.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk18.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: moral_qx |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | test-on-borrow: false |
| | | sql-script-encoding: utf-8 |
| | | pool-prepared-statements: true |
| | |
| | | <select id="selectNewestData" resultType="java.util.Map"> |
| | | select ai.id alarmInfoId,ai.alarm_time,ai.index,ai.alarm_type,ai.alarm_information,d.id deviceId,d.name deviceName,d.longitude,d.latitude |
| | | from alarm_info ai, device d |
| | | where ai.device_id in |
| | | <foreach collection="deviceIds" item="deviceId" index="index" open="(" close=")" separator=","> |
| | | #{deviceId} |
| | | </foreach> |
| | | and d.id = ai.device_id |
| | | ORDER by ai.create_time DESC |
| | | limit 0,#{size} |
| | | where ai.alarm_time = (SELECT max(alarm_time) from alarm_info limit 1) and d.id = ai.device_id and ai.device_id in |
| | | (select t.id from device t |
| | | inner JOIN monitor_point p on p.id = t.monitor_point_id and p.is_delete = 0 |
| | | |
| | | and p.organization_id in ( SELECT id FROM ( |
| | | SELECT id, parent_id, name FROM organization WHERE id = #{orgId} |
| | | UNION ALL |
| | | SELECT i.id, i.parent_id, i.name |
| | | FROM organization i |
| | | INNER JOIN ( |
| | | SELECT * FROM ( |
| | | SELECT id, parent_id, name FROM organization WHERE id = #{orgId} |
| | | UNION ALL |
| | | SELECT id, parent_id, name FROM organization WHERE parent_id = #{orgId} |
| | | ) t1 |
| | | ) t2 ON i.parent_id = t2.id |
| | | where i.is_delete = 0 |
| | | ) t3) |
| | | WHERE |
| | | t.is_delete = 0 |
| | | ) |
| | | ORDER by ai.id DESC |
| | | limit #{size} |
| | | </select> |
| | | <select id="numNews" resultType="java.lang.Integer"> |
| | | select count(1) from alarm_info |
| | | where alarm_time >= date_format(NOW(),'%Y-%m-%d') |
| | | and device_id in (SELECT |
| | | t.id |
| | | FROM |
| | | device t |
| | | INNER JOIN monitor_point p ON p.id = t.monitor_point_id |
| | | AND p.is_delete = 0 |
| | | AND p.organization_id IN ( |
| | | SELECT |
| | | id |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | id = #{organizationId} UNION ALL |
| | | SELECT |
| | | i.id, |
| | | i.parent_id, |
| | | i.NAME |
| | | FROM |
| | | organization i |
| | | INNER JOIN ( |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | id = #{organizationId} UNION ALL |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | parent_id = #{organizationId} |
| | | ) t1 |
| | | ) t2 ON i.parent_id = t2.id |
| | | WHERE |
| | | i.is_delete = 0 |
| | | ) t3 |
| | | ) |
| | | WHERE |
| | | t.is_delete = 0 ) |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <result column="value" property="value"/> |
| | | </resultMap> |
| | | |
| | | <select id="CityAqiDailyMap" resultType="com.moral.api.dto.CityAqiDailyListDTO"> |
| | | SELECT c.city_code, avg(c.value ->'$.AQI')as aqi,avg(c.value ->'$.compositeIndex') |
| | | as comp,sum(c.value ->'$.compositeIndex') as nums FROM city_aqi_daily c |
| | | INNER JOIN sys_area s on s.area_code = c.city_code and parent_code = #{cityCode} |
| | | where 1 =1 |
| | | <if test="type == 1"> |
| | | and c.time <![CDATA[=]]> #{start} |
| | | GROUP BY c.city_code order by aqi |
| | | </if> |
| | | <if test=" type == 2 "> |
| | | and c.time <![CDATA[>=]]> #{start} and c.time <![CDATA[<=]]> #{end} |
| | | GROUP BY c.city_code order by nums |
| | | </if> |
| | | <if test="type == 3 "> |
| | | and c.time <![CDATA[>=]]> #{start} |
| | | GROUP BY c.city_code order by nums |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | <result column="time" property="time"/> |
| | | <result column="value" property="value"/> |
| | | </resultMap> |
| | | |
| | | <select id="listCity" resultMap="BaseResultMap"> |
| | | SELECT |
| | | time,value ->> '$.AQI' as value |
| | | FROM |
| | | `city_aqi` |
| | | WHERE |
| | | time >= DATE_SUB( date_format(NOW(),'%Y-%m-%d %H'), INTERVAL 1 DAY ) |
| | | AND city_code = #{cityCode} |
| | | ORDER BY |
| | | time |
| | | </select> |
| | | </mapper> |
| | |
| | | AND `time` <![CDATA[<]]> #{end} |
| | | ORDER BY `time` |
| | | </select> |
| | | <select id="deviceList" resultType="java.util.Map"> |
| | | SELECT |
| | | t.latitude as latitude, |
| | | t.longitude as longitude, |
| | | t.mac as mac, |
| | | t.state,(hf.value ->> #{type} )+0 as ${sensorCode} |
| | | FROM |
| | | device t |
| | | inner JOIN monitor_point p on p.id = t.monitor_point_id and p.is_delete = 0 |
| | | and p.organization_id in ( |
| | | SELECT id FROM ( |
| | | SELECT id, parent_id, name FROM organization WHERE id = #{organizationId} |
| | | UNION ALL |
| | | SELECT i.id, i.parent_id, i.name |
| | | FROM organization i |
| | | INNER JOIN ( |
| | | SELECT * FROM ( |
| | | SELECT id, parent_id, name FROM organization WHERE id = #{organizationId} |
| | | UNION ALL |
| | | SELECT id, parent_id, name FROM organization WHERE parent_id = #{organizationId} |
| | | ) t1 |
| | | ) t2 ON i.parent_id = t2.id |
| | | where i.is_delete = 0 |
| | | ) t3 |
| | | ) |
| | | <if test="region != null"> |
| | | and p.${region} = #{regionCode} |
| | | </if> |
| | | <if test="endHourlyTime !=null and endHourlyTime != ''"> |
| | | left join history_hourly_${times} hf on hf.time =#{endHourlyTime} and t.mac = hf.mac |
| | | </if> |
| | | <if test="endHourlyTime ==null"> |
| | | left join history_five_minutely_${times} hf on hf.time = (select max(time) from history_five_minutely_${times} LIMIT 1 |
| | | ) and t.mac = hf.mac |
| | | </if> |
| | | |
| | | |
| | | WHERE |
| | | t.state <![CDATA[ <> ]]> '0' and t.is_delete = 0 |
| | | order by t.id desc |
| | | </select> |
| | | |
| | | <select id="deviceIdList" resultType="java.lang.Integer"> |
| | | SELECT |
| | | t.id |
| | | FROM |
| | | device t |
| | | INNER JOIN monitor_point p ON p.id = t.monitor_point_id |
| | | AND p.is_delete = 0 |
| | | AND p.organization_id IN ( |
| | | SELECT |
| | | id |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | id = #{organizationId} UNION ALL |
| | | SELECT |
| | | i.id, |
| | | i.parent_id, |
| | | i.NAME |
| | | FROM |
| | | organization i |
| | | INNER JOIN ( |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | id = #{organizationId} UNION ALL |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | parent_id = #{organizationId} |
| | | ) t1 |
| | | ) t2 ON i.parent_id = t2.id |
| | | WHERE |
| | | i.is_delete = 0 |
| | | ) t3 |
| | | ) |
| | | WHERE |
| | | t.is_delete = 0 |
| | | </select> |
| | | |
| | | <select id="deviceOrgIdList" resultType="java.lang.Integer"> |
| | | SELECT |
| | | id |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | id = #{organizationId} UNION ALL |
| | | SELECT |
| | | i.id, |
| | | i.parent_id, |
| | | i.NAME |
| | | FROM |
| | | organization i |
| | | INNER JOIN ( |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | id = #{organizationId} UNION ALL |
| | | SELECT |
| | | id, |
| | | parent_id, |
| | | NAME |
| | | FROM |
| | | organization |
| | | WHERE |
| | | parent_id = #{organizationId} |
| | | ) t1 |
| | | ) t2 ON i.parent_id = t2.id |
| | | WHERE |
| | | i.is_delete = 0 |
| | | ) t3 |
| | | </select> |
| | | </mapper> |
| | |
| | | return new ResultMessage(); |
| | | } |
| | | |
| | | @GetMapping("insertHCHistoryAqi") |
| | | @ApiOperation(value = "海城省控", notes = "海城省控") |
| | | public ResultMessage insertHCHistoryAqi() { |
| | | historyAqiService.insertHCHistoryAqi(); |
| | | return new ResultMessage(); |
| | | } |
| | | @GetMapping("dateToChangShu") |
| | | @ApiOperation(value = "常熟小时数据", notes = "常熟小时数据") |
| | | public ResultMessage dateToChangShu() { |
| | |
| | | //获取最新history_aqi数据 |
| | | List<HistoryAqi> getHistoryAqi(); |
| | | |
| | | |
| | | void insertHCHistoryAqi(); |
| | | |
| | | } |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | |
| | | import com.moral.api.service.GovMonitorPointService; |
| | | import com.moral.api.service.HistoryAqiService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.util.HttpUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.DateUtils; |
| | | import com.xxl.job.core.context.XxlJobHelper; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import net.sf.jsqlparser.expression.DoubleValue; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.client.CookieStore; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.client.protocol.HttpClientContext; |
| | | import org.apache.http.impl.client.BasicCookieStore; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.impl.cookie.BasicClientCookie; |
| | | import org.apache.http.protocol.BasicHttpContext; |
| | | import org.apache.http.protocol.HttpContext; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.http.*; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.client.RestClientException; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.OutputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | queryWrapper.eq("time", time); |
| | | return historyAqiMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void insertHCHistoryAqi() { |
| | | Date endTime = DateUtils.dataToTimeStampTime(new Date(), "yyyy/MM/dd HH:mm"); |
| | | Date startTime = DateUtils.addHours(endTime,-8); |
| | | String endTimeStr = DateUtils.dateToDateString(endTime, "yyyy/MM/dd HH")+":00"; |
| | | String startStr = DateUtils.dateToDateString(startTime, "yyyy/MM/dd HH")+":00"; |
| | | cityHc(startStr,endTimeStr); |
| | | } |
| | | public void cityHc(String startTime , String endTime){ |
| | | String guid = "494942fc-707d-4997-8ada-02cf03a48ca8"; |
| | | //String cook ="ASP.NET_SessionId=u1wknnkdq4qjq2rgtdx23jxg; __RequestVerificationToken=Goi78jPi7W5n6rXeetyuDY6meazKED4bLSHbuMiDdJgDH8j5iCW_Dq1hqmTYGKiseHIslQOa9lhOEgGzcFhHxpnYVoC-1fkYp9olbgRyVSfSwGx53EQWZwTqL5X8XszfDTJhuWMcK7qONpSHIBfzzA2; Captcha=A7B9FB; .ASPXAUTH=06E9FA83AFFAD6D023922A9814118F0D3E97B16AF1D814CAAFED4E2E64416E5F4A17649F8C71180BCFE30DD72EB8EDFE6A997B204BF3C6F361C47F650301820CC35C0E9DEC3F22F52F9919EA38A8AFDA294CE107C2F477A4AD5B397268943AE6E7FEB1998DA4A6F6F067B8ABF0C4C8F2C8A6DD337B491D8458B4EA5A9C215549"; |
| | | String cook = redisTemplate.opsForHash().get("hc","cook").toString(); |
| | | String host = "http://218.60.150.228:8008"; |
| | | String path = "//Layui/GetTableData"; |
| | | String method = "POST"; |
| | | Map<String, String> headers = new HashMap<String, String>(); |
| | | headers.put("Cookie", cook); |
| | | Map<String, String> querys = new HashMap<String, String>(); |
| | | querys.put("StationId","9efce5f9-f5d0-43e8-83ef-9aa7421efe63"); |
| | | querys.put("StationId_Text","海城北顺城路"); |
| | | querys.put("MItemId","5780ec98-a292-4727-9db2-d48c23fe5df5%2C262c4695-a376-4d3c-b122-2551897c1f8f%2Cca3ca54d-6525-4087-8fe5-bbdd77790317%2Cdb38b109-aeed-4888-bb2d-7cff951fd8c6%2Cbc3d741f-89b5-486d-aa25-b0e6a8ea8d2f%2C05e1dc49-5f09-45bc-8214-ceeb79b723d4%2Cba36afa5-2af8-4eb8-a52e-e8e653ce480a%2C9422b004-9761-4ca2-a725-4e998e5bb194%2Cdc3e1cf6-0771-4202-976b-199a3c0d66f5%2Cf02e3db5-5a42-4e1e-9bf2-94f8ee506e08%2Cbc39097e-4623-4076-8b5c-41c5b11d4b9b%2C2bcf2b6d-1588-43be-a2a6-ec4d5d52b707%2Cba20e1eb-23f7-44ea-8159-3e165a50c47c%2C06293d01-fb29-4e36-8dfa-763ef917a071%2C34f2e0e3-7230-45f5-aeac-f7da85f0b8a6%2C33f81201-5c25-459f-96ef-89e66e39d518%2C24173325-a890-4326-a909-1fc92da8d905"); |
| | | querys.put("sdtDate",startTime); |
| | | querys.put("edtDate",endTime); |
| | | querys.put("WorkCondition","2"); |
| | | querys.put("_CTRL_ID","MonValueTable"); |
| | | querys.put("_PAGE_ID","MonValue"); |
| | | try { |
| | | HttpResponse response = HttpUtils.doPost(host, path, method, headers, new HashMap<>(),querys); |
| | | System.out.println(response.toString()); |
| | | //获取response的body |
| | | String msg = EntityUtils.toString(response.getEntity()); |
| | | Map<String, Object> data = JSON.parseObject(msg, Map.class); |
| | | String mac = data.get("Data").toString(); |
| | | JSONArray jsonArray = JSONArray.parseArray(mac); |
| | | if(jsonArray.size()>0){ |
| | | JSONObject object = jsonArray.getJSONObject(jsonArray.size()-1); |
| | | String pm2_5 = object.get("262c4695-a376-4d3c-b122-2551897c1f8f_15e1b93e-3827-407f-9121-081555a512c5").toString(); |
| | | String pm10 = object.get("ca3ca54d-6525-4087-8fe5-bbdd77790317_15e1b93e-3827-407f-9121-081555a512c5").toString(); |
| | | String so2 = object.get("db38b109-aeed-4888-bb2d-7cff951fd8c6_15e1b93e-3827-407f-9121-081555a512c5").toString(); |
| | | String no2 = object.get("bc3d741f-89b5-486d-aa25-b0e6a8ea8d2f_15e1b93e-3827-407f-9121-081555a512c5").toString(); |
| | | String no = object.get("05e1dc49-5f09-45bc-8214-ceeb79b723d4_15e1b93e-3827-407f-9121-081555a512c5").toString(); |
| | | String nox = object.get("ba36afa5-2af8-4eb8-a52e-e8e653ce480a_15e1b93e-3827-407f-9121-081555a512c5").toString(); |
| | | String co = object.get("9422b004-9761-4ca2-a725-4e998e5bb194_15e1b93e-3827-407f-9121-081555a512c5").toString(); |
| | | String o3 = object.get("dc3e1cf6-0771-4202-976b-199a3c0d66f5_15e1b93e-3827-407f-9121-081555a512c5").toString(); |
| | | String pubtime = object.get("DistrictId").toString(); |
| | | String station = object.get("TimePoint").toString(); |
| | | String city = object.get("CityId").toString(); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("pm2_5", StringUtils.isNotEmpty(pm2_5)? Double.parseDouble(pm2_5):0d); |
| | | map.put("pm10", StringUtils.isNotEmpty(pm10)? Double.parseDouble(pm10):0d); |
| | | map.put("so2", StringUtils.isNotEmpty(so2)? Double.parseDouble(so2):0d); |
| | | map.put("no2", StringUtils.isNotEmpty(no2)? Double.parseDouble(no2):0d); |
| | | map.put("no", StringUtils.isNotEmpty(no)? Double.parseDouble(no):0d); |
| | | map.put("co", StringUtils.isNotEmpty(co)? Double.parseDouble(co):0d); |
| | | map.put("o3", StringUtils.isNotEmpty(o3)? Double.parseDouble(o3):0d); |
| | | map.put("pubtime", pubtime); |
| | | map.put("station", station); |
| | | map.put("city", city); |
| | | HistoryAqi historyAqi = new HistoryAqi(); |
| | | historyAqi.setValue(JSONObject.toJSONString(map)); |
| | | historyAqi.setGuid(guid); |
| | | Date time = DateUtils.getDate(object.get("TimePoint").toString(), DateUtils.yyyy_MM_dd_HH_EN); |
| | | historyAqi.setTime(DateUtils.addHours(time,-1)); |
| | | Map<String, Object> value = new HashMap<>(); |
| | | if (StringUtils.isNotEmpty(pm2_5)) { |
| | | value.put(Constants.SENSOR_CODE_PM25, Double.parseDouble(pm2_5)); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(pm10)) { |
| | | value.put(Constants.SENSOR_CODE_PM10, Double.parseDouble(pm10)); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(so2)) { |
| | | value.put(Constants.SENSOR_CODE_SO2, Double.parseDouble(so2)); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(no2)) { |
| | | value.put(Constants.SENSOR_CODE_NO2, Double.parseDouble(no2)); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(co)) { |
| | | value.put(Constants.SENSOR_CODE_CO, Double.parseDouble(co.toString())); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(o3)) { |
| | | value.put(Constants.SENSOR_CODE_O3, Double.parseDouble(o3)); |
| | | } |
| | | //aqi数据存入redis |
| | | redisTemplate.opsForHash().put(RedisConstants.AQI_DATA, guid, value); |
| | | historyAqiMapper.insertHistoryAqi(Arrays.asList(historyAqi)); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | @XxlJob("insertHCHistoryAqi") |
| | | public ReturnT insertHCHistoryAqi() { |
| | | try { |
| | | historyAqiService.insertHCHistoryAqi(); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return new ReturnT(ReturnT.FAIL_CODE, e.getMessage()); |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | //城市aqi小时数据接入 |
| | | @XxlJob("insertCityAqi") |
| | | public ReturnT insertCityAqi() { |
| | |
| | | application: |
| | | name: screen-job |
| | | redis: |
| | | host: r-bp1xdlb9wfc6zt0msp05.redis.rds.aliyuncs.com |
| | | host: r-bp1xdlb9wfc6zt0msp18.redis.rds.aliyuncs.com |
| | | port: 6379 |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | timeout: 30000 |
| | | jedis: |
| | | pool: |
| | |
| | | max-wait: 30000 |
| | | min-idle: 32 |
| | | tokenRedis: |
| | | host: r-bp1xdlb9wfc6zt0msp05.redis.rds.aliyuncs.com |
| | | host: r-bp1xdlb9wfc6zt0msp18.redis.rds.aliyuncs.com |
| | | port: 6379 |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | timeout: 30000 |
| | | database: 14 |
| | | pool: |
| | |
| | | filters: stat |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | max-wait: 60000 |
| | | url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk05.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk18.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: moral_qx |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | test-on-borrow: false |
| | | sql-script-encoding: utf-8 |
| | | pool-prepared-statements: true |
| | |
| | | import com.moral.api.service.SysDictDataService; |
| | | import com.moral.api.service.TestService; |
| | | import com.moral.api.service.impl.SensorServiceImpl; |
| | | import com.moral.api.util.AdjustDataUtils; |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.api.util.CompareFieldUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.KafkaConstants; |
| | | import com.moral.constant.RedisConstants; |
| | |
| | | private SensorService sensorService; |
| | | @Autowired |
| | | SysDictDataMapper sysDictDataMapper; |
| | | @Autowired |
| | | private AdjustDataUtils adjustDataUtils; |
| | | |
| | | @ApiOperation(value = "因子测试", notes = "因子测试") |
| | | @ApiImplicitParams({ |
| | |
| | | }) |
| | | @RequestMapping(value = "getSensor", method = RequestMethod.GET) |
| | | public void getSensor() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("time","1692364996898"); |
| | | map.put("mac","p5dnd7a0391986"); |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | HashMap<String, Object> map2 = new HashMap<>(); |
| | | Map<String, Object> adjust = adjustDataUtils.adjust(map, map1, map2, "2"); |
| | | QueryWrapper<Sensor> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("code").eq("is_delete", Constants.NOT_DELETE); |
| | | List<Object> list = sensorService.listObjs(queryWrapper); |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | |
| | | } |
| | | |
| | | //数据过滤 |
| | | // data.remove("time"); |
| | | data.remove("time"); |
| | | data.remove("entryTime"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String format = dateFormat.format(new Date().getTime()); |
| | | //获取年份 |
| | | String substring = format.substring(0, 4); |
| | | |
| | | String substring1 = time.toString().substring(0, 4); |
| | | |
| | | String replace = time.toString().replace(substring1, substring); |
| | | |
| | | data.put("DataTime",replace); |
| | | |
| | | Iterator<Map.Entry<String, Object>> iterator = data.entrySet().iterator(); |
| | | Map<String, Object> newMap = new HashMap<>(); |
| | | Map.Entry<String, Object> next; |
| | |
| | | Map<String, Object> versionInfo = (Map<String, Object>) deviceInfo.get("version"); |
| | | Integer version = (Integer) versionInfo.get("id"); |
| | | //获取时间戳 |
| | | String time1 = data.get("time").toString(); |
| | | long l = Long.parseLong(time1); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); |
| | | String format1 = dateFormat.format(l); |
| | | Date time = DateUtils.getDate(format1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | // String time1 = data.get("time").toString(); |
| | | // long l = Long.parseLong(time1); |
| | | // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); |
| | | // String format1 = dateFormat.format(l); |
| | | // Date time = DateUtils.getDate(format1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | |
| | | |
| | | // Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN); |
| | | Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN); |
| | | String yearAndMonth = DateUtils.dateToDateString(DateUtils.addHours(time, -1), DateUtils.yyyyMM_EN); |
| | | |
| | | result.put("mac", mac); |
| | |
| | | if (ObjectUtils.isEmpty(map)){ |
| | | return deviceData; |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a21005"))){ |
| | | JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a21005 = jsonObject.get("a21005").toString(); |
| | | deviceData.put("a21005",Double.parseDouble(a21005)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a21026"))){ |
| | | JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a21026 = jsonObject.get("a21026").toString(); |
| | | deviceData.put("a21026",Double.parseDouble(a21026)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a21004"))){ |
| | | JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a21004 = jsonObject.get("a21004").toString(); |
| | | deviceData.put("a21004",Double.parseDouble(a21004)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a34002"))){ |
| | | JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a34002 = jsonObject.get("a34002").toString(); |
| | | deviceData.put("a34002",Double.parseDouble(a34002)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a34004"))){ |
| | | JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a34004 = jsonObject.get("a34004").toString(); |
| | | deviceData.put("a34004",Double.parseDouble(a34004)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a05024"))){ |
| | | JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a05024 = jsonObject.get("a05024").toString(); |
| | | deviceData.put("a05024",Double.parseDouble(a05024)); |
| | | JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | if (ObjectUtils.isEmpty(aqiMap)){ |
| | | deviceData.put("a21005",Double.parseDouble(jsonObject.get("a21005").toString())); |
| | | deviceData.put("a21026",Double.parseDouble(jsonObject.get("a21026").toString())); |
| | | deviceData.put("a21004",Double.parseDouble(jsonObject.get("a21004").toString())); |
| | | deviceData.put("a34002",Double.parseDouble(jsonObject.get("a34002").toString())); |
| | | deviceData.put("a34004",Double.parseDouble(jsonObject.get("a34004").toString())); |
| | | deviceData.put("a05024",Double.parseDouble(jsonObject.get("a05024").toString())); |
| | | }else { |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a21005"))){ |
| | | |
| | | String a21005 = jsonObject.get("a21005").toString(); |
| | | deviceData.put("a21005",Double.parseDouble(a21005)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a21026"))){ |
| | | // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a21026 = jsonObject.get("a21026").toString(); |
| | | deviceData.put("a21026",Double.parseDouble(a21026)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a21004"))){ |
| | | // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a21004 = jsonObject.get("a21004").toString(); |
| | | deviceData.put("a21004",Double.parseDouble(a21004)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a34002"))){ |
| | | // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a34002 = jsonObject.get("a34002").toString(); |
| | | deviceData.put("a34002",Double.parseDouble(a34002)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a34004"))){ |
| | | // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a34004 = jsonObject.get("a34004").toString(); |
| | | deviceData.put("a34004",Double.parseDouble(a34004)); |
| | | } |
| | | if (ObjectUtils.isEmpty(aqiMap.get("a05024"))){ |
| | | // JSONObject jsonObject = JSONObject.parseObject(map.get("value").toString()); |
| | | String a05024 = jsonObject.get("a05024").toString(); |
| | | deviceData.put("a05024",Double.parseDouble(a05024)); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | application: |
| | | name: screen-manage |
| | | redis: |
| | | host: r-bp1xdlb9wfc6zt0msp05.redis.rds.aliyuncs.com |
| | | host: r-bp1xdlb9wfc6zt0msp18.redis.rds.aliyuncs.com |
| | | port: 6379 |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | timeout: 30000 |
| | | jedis: |
| | | pool: |
| | |
| | | max-wait: 30000 |
| | | min-idle: 32 |
| | | tokenRedis: |
| | | host: r-bp1xdlb9wfc6zt0msp05.redis.rds.aliyuncs.com |
| | | host: r-bp1xdlb9wfc6zt0msp18.redis.rds.aliyuncs.com |
| | | port: 6379 |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | timeout: 30000 |
| | | database: 14 |
| | | pool: |
| | |
| | | filters: stat |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | max-wait: 60000 |
| | | url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk05.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk18.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: moral_qx |
| | | password: QX_moral_2023 |
| | | password: QxPcRedis_moarl_2320 |
| | | test-on-borrow: false |
| | | sql-script-encoding: utf-8 |
| | | pool-prepared-statements: true |