Merge branch 'dev' of http://blit.7drlb.com:8888/r/moral into wb
1 files added
16 files modified
| | |
| | | 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; |
| | | |
| | | } |
| | |
| | | |
| | | 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); |
| | | |
| | | } |
| | |
| | | /*监测因子趋势图数据*/ |
| | | List<Map<String, Object>> getTrendChartData(Map<String, Object> params); |
| | | |
| | | List<Device> deviceList(@Param("organizationId") int organizationId,@Param("regionCode") int regionCode,@Param("region") String region); |
| | | 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); |
| | | |
| | | } |
| | |
| | | * @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) { |
| | | //取参 |
| | |
| | | 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(); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | String type = "$."+ sensorCode; |
| | | String region = null; |
| | | String endHourlyTime = null; |
| | | if (regionCode != null && organizationId!=24) { |
| | | region = RegionCodeUtils.regionCodeConvertToName(regionCode); |
| | | params.put("region",region); |
| | | params.put("regionCode",regionCode); |
| | | } |
| | | params.put("organizationId",organizationId); |
| | | 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<Device> devices = new ArrayList<>(); |
| | |
| | | |
| | | }*/ |
| | | //查询所有设备对应的数据 |
| | | List<Device> devices = deviceMapper.deviceList(organizationId,regionCode,region); |
| | | /*List<Device> devices = new ArrayList<>(); |
| | | List<DeviceAndFiveMinuteDataDTO> dtos = new ArrayList<>(); |
| | | if (form.getChooseTime().equals("true")) { |
| | | String time = form.getTime(); |
| | |
| | | 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) |
| | |
| | | <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" resultMap="BaseResultMap"> |
| | | <select id="deviceList" resultType="java.util.Map"> |
| | | SELECT |
| | | t.latitude, |
| | | t.longitude, |
| | | t.mac, |
| | | t.state |
| | | 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 |
| | | inner JOIN monitor_point p on p.id = t.monitor_point_id and p.is_delete = 0 |
| | | and p.organization_id in ( |
| | | SELECT t1.id FROM organization t1 |
| | | where t1.id = #{organizationId} or t1.parent_id = #{organizationId}) |
| | | 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 ${region} = #{regionCode} |
| | | 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> |
| | |
| | | /* |
| | | package com.moral.api.kafka.consumer; |
| | | |
| | | import com.moral.api.service.*; |
| | |
| | | } |
| | | } |
| | | } |
| | | */ |