Merge remote-tracking branch 'origin/dev' into cjl
	
		
		9 files added
	
		
		13 files modified
	
	
 
	
	
	
	
	
	
	
	
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import io.swagger.annotations.ApiParam; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.collections4.CollectionUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestParam; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import java.time.LocalDate; | 
|---|
|  |  |  | import java.time.temporal.ChronoUnit; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.dataDisplay.HeatMapDTO; | 
|---|
|  |  |  | import com.moral.api.service.DataDisplayService; | 
|---|
|  |  |  | import com.moral.api.vo.HeatMapVo; | 
|---|
|  |  |  | import com.moral.api.vo.TimeHourVo; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import com.moral.util.DateUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Description //todo | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author swb | 
|---|
|  |  |  | * @ClassName HeatMapController | 
|---|
|  |  |  | * @date 2023.12.11 15:20 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"区域热力图"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/heatMap") | 
|---|
|  |  |  | public class HeatMapController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DataDisplayService dataDisplayService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("query") | 
|---|
|  |  |  | @ApiOperation("热力图显示") | 
|---|
|  |  |  | public ResultMessage  getHeatMap(@RequestParam @ApiParam(value = "code",name = "区域码") String code, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "startTime",name = "开始时间") String startTime, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "type",name= "因子类型") String type, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "form",name= "时间类型") String form){ | 
|---|
|  |  |  | List<HeatMapDTO> heatMapData = dataDisplayService.getHeatMapData(code, startTime, type, form); | 
|---|
|  |  |  | return ResultMessage.ok(ObjectUtils.isEmpty(heatMapData)?"0":heatMapData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @GetMapping("queryTime") | 
|---|
|  |  |  | @ApiOperation("查询时间") | 
|---|
|  |  |  | public ResultMessage  getHeatMap(@RequestParam @ApiParam(value = "startTime",name = "开始时间") String startTime, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "endTime",name= "结束类型") String endTime, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "type",name= "时间类型") String type){ | 
|---|
|  |  |  | ArrayList<HeatMapVo> heatMapVos = new ArrayList<>(); | 
|---|
|  |  |  | if (type.equals("day")){ | 
|---|
|  |  |  | ArrayList<TimeHourVo> timeHourVos = new ArrayList<>(); | 
|---|
|  |  |  | String[] splitStart = startTime.split("-"); | 
|---|
|  |  |  | String[] splitEnd = endTime.split("-"); | 
|---|
|  |  |  | LocalDate startDate = LocalDate.of(Integer.parseInt(splitStart[0]), Integer.parseInt(splitStart[1]), Integer.parseInt(splitStart[2])); | 
|---|
|  |  |  | LocalDate endDate = LocalDate.of(Integer.parseInt(splitEnd[0]), Integer.parseInt(splitEnd[1]), Integer.parseInt(splitEnd[2])); | 
|---|
|  |  |  | long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); | 
|---|
|  |  |  | for (int i = 0; i <= daysBetween; i++) { | 
|---|
|  |  |  | HeatMapVo heatMapVo = new HeatMapVo(); | 
|---|
|  |  |  | LocalDate date = startDate.plusDays(i); | 
|---|
|  |  |  | heatMapVo.setId(i); | 
|---|
|  |  |  | heatMapVo.setName(date.toString()); | 
|---|
|  |  |  | heatMapVo.setHourListTime(timeHourVos); | 
|---|
|  |  |  | heatMapVos.add(heatMapVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if (type.equals("month")){ | 
|---|
|  |  |  | ArrayList<TimeHourVo> timeHourVos = new ArrayList<>(); | 
|---|
|  |  |  | String[] splitStart = startTime.split("-"); | 
|---|
|  |  |  | String[] splitEnd = endTime.split("-"); | 
|---|
|  |  |  | //结束时间月份的天数 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int monthDay = DateUtils.getMonthDay(DateUtils.getDate(endTime,DateUtils.yyyy_MM_EN)); | 
|---|
|  |  |  | LocalDate startDate = LocalDate.of(Integer.parseInt(splitStart[0]), Integer.parseInt(splitStart[1]),1); | 
|---|
|  |  |  | LocalDate endDate = LocalDate.of(Integer.parseInt(splitEnd[0]), Integer.parseInt(splitEnd[1]),monthDay); | 
|---|
|  |  |  | long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); | 
|---|
|  |  |  | for (int i = 0; i <= daysBetween; i++) { | 
|---|
|  |  |  | HeatMapVo heatMapVo = new HeatMapVo(); | 
|---|
|  |  |  | LocalDate date = startDate.plusDays(i); | 
|---|
|  |  |  | heatMapVo.setId(i); | 
|---|
|  |  |  | heatMapVo.setName(date.toString()); | 
|---|
|  |  |  | heatMapVo.setHourListTime(timeHourVos); | 
|---|
|  |  |  | heatMapVos.add(heatMapVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | int id = 0; | 
|---|
|  |  |  | int idHour = -1; | 
|---|
|  |  |  | Date ks = DateUtils.getDate(startTime,"yyyy-MM-dd HH"); | 
|---|
|  |  |  | Date js = DateUtils.getDateAddHour(DateUtils.getDate(endTime,"yyyy-MM-dd HH"),1); | 
|---|
|  |  |  | String name =  DateUtils.dateToDateString(ks,DateUtils.yyyy_MM_dd_EN); | 
|---|
|  |  |  | List<TimeHourVo> hourListTime = new ArrayList<>(); | 
|---|
|  |  |  | while (DateUtils.isTimeBefor(js,ks)){ | 
|---|
|  |  |  | idHour++; | 
|---|
|  |  |  | HeatMapVo heatMapVo = new HeatMapVo(); | 
|---|
|  |  |  | String nameEndTime =  DateUtils.dateToDateString(ks,DateUtils.yyyy_MM_dd_EN); | 
|---|
|  |  |  | String time =  DateUtils.dateToDateString(ks,"HH"); | 
|---|
|  |  |  | String ksTime =  DateUtils.dateToDateString(ks,"yyyy-MM-dd HH"); | 
|---|
|  |  |  | TimeHourVo hourVo = new TimeHourVo(); | 
|---|
|  |  |  | heatMapVo.setName(name); | 
|---|
|  |  |  | heatMapVo.setId(id); | 
|---|
|  |  |  | if(name.equals(nameEndTime)){ | 
|---|
|  |  |  | heatMapVo.setId(id); | 
|---|
|  |  |  | heatMapVo.setName(name); | 
|---|
|  |  |  | hourVo.setName(time); | 
|---|
|  |  |  | hourVo.setId(idHour); | 
|---|
|  |  |  | hourListTime.add(hourVo); | 
|---|
|  |  |  | if(ksTime.equals(endTime)){ | 
|---|
|  |  |  | heatMapVo.setHourListTime(hourListTime); | 
|---|
|  |  |  | heatMapVos.add(heatMapVo); | 
|---|
|  |  |  | idHour++; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | id++; | 
|---|
|  |  |  | if(ksTime.equals(endTime)){ | 
|---|
|  |  |  | heatMapVo.setHourListTime(hourListTime); | 
|---|
|  |  |  | heatMapVos.add(heatMapVo); | 
|---|
|  |  |  | hourListTime = new ArrayList<>(); | 
|---|
|  |  |  | hourVo = new TimeHourVo(); | 
|---|
|  |  |  | heatMapVo = new HeatMapVo(); | 
|---|
|  |  |  | hourVo.setName("00"); | 
|---|
|  |  |  | hourVo.setId(idHour++); | 
|---|
|  |  |  | hourListTime.add(hourVo); | 
|---|
|  |  |  | heatMapVo.setId(id); | 
|---|
|  |  |  | heatMapVo.setName(nameEndTime); | 
|---|
|  |  |  | heatMapVo.setHourListTime(hourListTime); | 
|---|
|  |  |  | heatMapVos.add(heatMapVo); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | name = nameEndTime; | 
|---|
|  |  |  | heatMapVo.setHourListTime(hourListTime); | 
|---|
|  |  |  | heatMapVos.add(heatMapVo); | 
|---|
|  |  |  | hourListTime = new ArrayList<>(); | 
|---|
|  |  |  | hourVo.setName(time); | 
|---|
|  |  |  | hourVo.setId(idHour); | 
|---|
|  |  |  | hourListTime.add(hourVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ks = DateUtils.getDateAddHour(ks,1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(heatMapVos)){ | 
|---|
|  |  |  | heatMapVos.get(0).setIdLength(idHour); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /*            String[] splitStart = startTime.split("-"); | 
|---|
|  |  |  | String[] s1 = splitStart[2].split(" "); | 
|---|
|  |  |  | String[] splitEnd = endTime.split("-"); | 
|---|
|  |  |  | String[] s2 = splitEnd[2].split(" "); | 
|---|
|  |  |  | //获取天时间 | 
|---|
|  |  |  | LocalDate startDate = LocalDate.of(Integer.parseInt(splitStart[0]), Integer.parseInt(splitStart[1]),Integer.parseInt(s1[0])); | 
|---|
|  |  |  | LocalDate endDate = LocalDate.of(Integer.parseInt(splitEnd[0]), Integer.parseInt(splitEnd[1]),Integer.parseInt(s2[0])); | 
|---|
|  |  |  | long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); | 
|---|
|  |  |  | //获取小时 | 
|---|
|  |  |  | LocalDateTime startDateTime = LocalDateTime.of(Integer.parseInt(splitStart[0]), Integer.parseInt(splitStart[1]), Integer.parseInt(s1[0]), Integer.parseInt(s1[1]), 0); | 
|---|
|  |  |  | LocalDateTime endDateTime = LocalDateTime.of(Integer.parseInt(splitEnd[0]), Integer.parseInt(splitEnd[1]), Integer.parseInt(s2[0]), Integer.parseInt(s2[1]), 0); | 
|---|
|  |  |  | List<String> hourList = new ArrayList<>(); | 
|---|
|  |  |  | LocalDateTime currentDateTime = startDateTime; | 
|---|
|  |  |  | while (currentDateTime.isBefore(endDateTime) || currentDateTime.equals(endDateTime)) { | 
|---|
|  |  |  | hourList.add(currentDateTime.toString()); | 
|---|
|  |  |  | currentDateTime = currentDateTime.plusHours(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int length=0; | 
|---|
|  |  |  | for (int i = 0; i <= daysBetween; i++) { | 
|---|
|  |  |  | ArrayList<TimeHourVo> timeHourVos = new ArrayList<>(); | 
|---|
|  |  |  | HeatMapVo heatMapVo = new HeatMapVo(); | 
|---|
|  |  |  | LocalDate date = startDate.plusDays(i); | 
|---|
|  |  |  | heatMapVo.setId(i); | 
|---|
|  |  |  | heatMapVo.setName(date.toString()); | 
|---|
|  |  |  | for (int i1 = 0; i1 < hourList.size(); i1++) { | 
|---|
|  |  |  | if (hourList.get(i1).contains(date.toString())){ | 
|---|
|  |  |  | TimeHourVo hourVo = new TimeHourVo(); | 
|---|
|  |  |  | hourVo.setName(hourList.get(i1).substring(11,13)); | 
|---|
|  |  |  | hourVo.setId(length); | 
|---|
|  |  |  | timeHourVos.add(hourVo); | 
|---|
|  |  |  | hourList.remove(i1); | 
|---|
|  |  |  | i1--; | 
|---|
|  |  |  | length++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | heatMapVo.setHourListTime(timeHourVos); | 
|---|
|  |  |  | heatMapVos.add(heatMapVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | heatMapVos.get(0).setIdLength(length);*/ | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ResultMessage.ok(ObjectUtils.isEmpty(heatMapVos)?"0":heatMapVos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.mapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.Device; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.dataDisplay.HeatMapDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.device.AppDeviceVo; | 
|---|
|  |  |  | import io.lettuce.core.dynamic.annotation.Param; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<AppDeviceVo> getDevices(@Param("mac") String mac,@Param("organizationId") Integer organizationId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<HeatMapDTO> getHeatMap(HashMap<String,Object> params); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.pojo.dto.dataDisplay; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Description //todo | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author swb | 
|---|
|  |  |  | * @ClassName HeatMapDTO | 
|---|
|  |  |  | * @date 2023.12.11 16:11 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class HeatMapDTO { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 数据时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String time; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 纬度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Double lat; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 经度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Double lng; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 数据 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Double count; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private  String mac; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private  String name; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Double getCount(){ | 
|---|
|  |  |  | Double count = this.count; | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(count)){ | 
|---|
|  |  |  | count= 0.0; | 
|---|
|  |  |  | return count; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return count; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.pojo.dto.dataDisplay.HeatMapDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.dataDisplay.MonitorPointDataDisplayDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.dataDisplay.SensorComparisonDisplayDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.form.dataDisplay.MonitorPointDataDisplayForm; | 
|---|
|  |  |  | import com.moral.api.pojo.form.dataDisplay.SensorComparisonDisplayForm; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @Date: 2022/09/26 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | List<SensorComparisonDisplayDTO> getSensorComparisonDisplayDataV2(Map<String, Object> params); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<HeatMapDTO> getHeatMapData(String code, String startTime, String type, String form); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.moral.api.entity.*; | 
|---|
|  |  |  | import com.moral.api.mapper.DeviceMapper; | 
|---|
|  |  |  | import com.moral.api.mapper.HistoryMonthlyMapper; | 
|---|
|  |  |  | import com.moral.api.mapper.OrganizationMapper; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.dataDisplay.HeatMapDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.dataDisplay.MonitorPointDataDisplayDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.dataDisplay.SensorComparisonDisplayDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.form.dataDisplay.MonitorPointDataDisplayForm; | 
|---|
|  |  |  | import com.moral.api.pojo.form.dataDisplay.SensorComparisonDisplayForm; | 
|---|
|  |  |  | import com.moral.api.service.*; | 
|---|
|  |  |  | import com.moral.constant.Constants; | 
|---|
|  |  |  | import com.moral.constant.SeparateTableType; | 
|---|
|  |  |  | import com.moral.pojo.AQI; | 
|---|
|  |  |  | import com.moral.util.*; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import static com.moral.util.DateUtils.dateToDateString; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @ClassName DataDisplayServiceImpl | 
|---|
|  |  |  | 
|---|
|  |  |  | * @Version TODO | 
|---|
|  |  |  | **/ | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class DataDisplayServiceImpl implements DataDisplayService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | HistoryWeeklyService historyWeeklyService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | HistoryMonthlyService historyMonthlyService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | OrganizationMapper organizationMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | DeviceMapper deviceMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 热力图显示 | 
|---|
|  |  |  | * @param code | 
|---|
|  |  |  | * @param startTime | 
|---|
|  |  |  | * @param type | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<HeatMapDTO> getHeatMapData(String code, String startTime, String type, String form) { | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("start",startTime); | 
|---|
|  |  |  | map.put("type","$."+ type); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取用户信息 | 
|---|
|  |  |  | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); | 
|---|
|  |  |  | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); | 
|---|
|  |  |  | Integer organizationId = (Integer) orgInfo.get("id"); | 
|---|
|  |  |  | //大账号 | 
|---|
|  |  |  | ArrayList<Integer> list = new ArrayList<>(); | 
|---|
|  |  |  | if (organizationId==24){ | 
|---|
|  |  |  | LambdaQueryWrapper<Organization> wrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | wrapper.eq(Organization::getIsDelete,Constants.NOT_DELETE); | 
|---|
|  |  |  | wrapper.eq(Organization::getCityCode,code); | 
|---|
|  |  |  | List<Organization> organizations = organizationMapper.selectList(wrapper); | 
|---|
|  |  |  | List<Integer> collect = organizations.stream().map(organization -> organization.getId()).collect(Collectors.toList()); | 
|---|
|  |  |  | list.addAll(collect); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | list.add(organizationId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        ArrayList<Map<String, Object>> rsHeatMap = new ArrayList<>(); | 
|---|
|  |  |  | ArrayList<HeatMapDTO> rsHeatMap = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (form.equals("hour")){ //小时 | 
|---|
|  |  |  | Date date1 = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_EN); | 
|---|
|  |  |  | List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(date1, date1, SeparateTableType.MONTH); | 
|---|
|  |  |  | //                for (Integer integer : list) { | 
|---|
|  |  |  | map.put("organizationIds",list); | 
|---|
|  |  |  | map.put("tableName",tableNames.get(0)); | 
|---|
|  |  |  | //                    List<Map<String, Object>> heatMap = deviceMapper.getHeatMap(map); | 
|---|
|  |  |  | List<HeatMapDTO> heatMap = deviceMapper.getHeatMap(map); | 
|---|
|  |  |  | rsHeatMap.addAll(heatMap); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else { //天 | 
|---|
|  |  |  | //            for (Integer integer : list) { | 
|---|
|  |  |  | map.put("organizationIds",list); | 
|---|
|  |  |  | //                List<Map<String, Object>> heatMap = deviceMapper.getHeatMap(map); | 
|---|
|  |  |  | List<HeatMapDTO> heatMap = deviceMapper.getHeatMap(map); | 
|---|
|  |  |  | rsHeatMap.addAll(heatMap); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return distrinList(rsHeatMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 字段去重 | 
|---|
|  |  |  | * @param responseList | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private List<HeatMapDTO> distrinList(List<HeatMapDTO> responseList){ | 
|---|
|  |  |  | List<HeatMapDTO> rsMap = new ArrayList<>(); | 
|---|
|  |  |  | Set<String> keysSet = new HashSet<String>(); | 
|---|
|  |  |  | for (HeatMapDTO heatMapDTO : responseList) { | 
|---|
|  |  |  | String keys = String.valueOf(heatMapDTO.getMac()); | 
|---|
|  |  |  | int beforeSize = keysSet.size(); | 
|---|
|  |  |  | keysSet.add(keys); | 
|---|
|  |  |  | int afterSize = keysSet.size(); | 
|---|
|  |  |  | if(afterSize == beforeSize + 1){ | 
|---|
|  |  |  | rsMap.add(heatMapDTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info(responseList.size()+""); | 
|---|
|  |  |  | log.info(rsMap.size()+""); | 
|---|
|  |  |  | return rsMap; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Description: 根据时间进行排序 | 
|---|
|  |  |  | * @Param: [timeValueMap, reportType] | 
|---|
|  |  |  | * @return: java.util.Map<java.lang.String               ,               java.lang.String> | 
|---|
|  |  |  | 
|---|
|  |  |  | StringBuilder builder = new StringBuilder(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int i = 1; | 
|---|
|  |  |  | long timestamp = System.currentTimeMillis(); | 
|---|
|  |  |  | for (String string : strings) { | 
|---|
|  |  |  | DustForm dustForm = new DustForm(); | 
|---|
|  |  |  | ArrayList<Double> doubleArrayList = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | long timestamp2 = System.currentTimeMillis(); | 
|---|
|  |  |  | log.info(timestamp2-timestamp+""); | 
|---|
|  |  |  | //排序 | 
|---|
|  |  |  | list1.sort(Comparator.comparing(DustForm::getValue).reversed()); | 
|---|
|  |  |  | rsMap.put("list1",list1); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String str = new DecimalFormat("#.######").format(Double.parseDouble(result.get("a21005").toString())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | QueryFiveDataByMacVO queryFiveDataByMacVO = new QueryFiveDataByMacVO(); | 
|---|
|  |  |  | queryFiveDataByMacVO.setName(device.getName()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setDataTime(datas.get("dataTime").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA34004(result.get("a34004").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA34002(result.get("a34002").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA21026(result.get("a21026").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA21004(result.get("a21004").toString()); | 
|---|
|  |  |  | if (!ObjectUtils.isEmpty(result.get("a21005"))){ | 
|---|
|  |  |  | String str = new DecimalFormat("#.######").format(Double.parseDouble(result.get("a21005").toString())); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA21005(str); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA05024(result.get("a05024").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA01008(result.get("a01008").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA01007(result.get("a01007").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA99054(result.get("a99054").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        queryFiveDataByMacVO.setA34004(result.get("a34004").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA34004(ObjectUtils.isEmpty(result.get("a34004"))?null:result.get("a34004").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA34002(ObjectUtils.isEmpty(result.get("a34002"))?null:result.get("a34002").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA21026(ObjectUtils.isEmpty(result.get("a21026"))?null:result.get("a21026").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA21004(ObjectUtils.isEmpty(result.get("a21004"))?null:result.get("a21004").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA05024(ObjectUtils.isEmpty(result.get("a05024"))?null:result.get("a05024").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA01008(ObjectUtils.isEmpty(result.get("a01008"))?null:result.get("a01008").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA01007(ObjectUtils.isEmpty(result.get("a01007"))?null:result.get("a01007").toString()); | 
|---|
|  |  |  | queryFiveDataByMacVO.setA99054(ObjectUtils.isEmpty(result.get("a99054"))?null:result.get("a99054").toString()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return queryFiveDataByMacVO; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private double getDivisor(String code,double num){ | 
|---|
|  |  |  | double rs = 0.0; | 
|---|
|  |  |  | if (code.contains("-")){ | 
|---|
|  |  |  | String data = code.substring(1); | 
|---|
|  |  |  | rs = num - Double.parseDouble(data); | 
|---|
|  |  |  | } else if (code.contains("*")){ | 
|---|
|  |  |  | String data = code.substring(1); | 
|---|
|  |  |  | rs = num * Double.parseDouble(data); | 
|---|
|  |  |  | } else if (code.contains("/")){ | 
|---|
|  |  |  | String data = code.substring(1); | 
|---|
|  |  |  | rs = num / Double.parseDouble(data); | 
|---|
|  |  |  | } else if (code.contains(",")){ | 
|---|
|  |  |  | String[] split = code.split(","); | 
|---|
|  |  |  | for (String s : split) { | 
|---|
|  |  |  | String[] split1 = s.split("<"); | 
|---|
|  |  |  | double sp1 = Double.parseDouble(split1[0]); | 
|---|
|  |  |  | double sp2 = Double.parseDouble(split1[1]); | 
|---|
|  |  |  | double sp3 = Double.parseDouble(split1[2]); | 
|---|
|  |  |  | if (num>=sp1 && num<=sp2){ | 
|---|
|  |  |  | rs = num + sp3; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | rs = num + Double.parseDouble(code); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rs; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.vo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Description //todo | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author swb | 
|---|
|  |  |  | * @ClassName HeatMapVo | 
|---|
|  |  |  | * @date 2023.12.13 12:44 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class HeatMapVo { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private  Integer id ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String name; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    private List<Map<String,Object>> hourList; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<TimeHourVo> hourListTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private  Integer idLength; | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.vo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Description //todo | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author swb | 
|---|
|  |  |  | * @ClassName HeatMapVo | 
|---|
|  |  |  | * @date 2023.12.13 12:44 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class TimeHourVo { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String name; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Integer id; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | and mac LIKE "%"#{mac}"%" AND is_delete = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getHeatMap" resultType="com.moral.api.pojo.dto.dataDisplay.HeatMapDTO"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | d.mac as mac, | 
|---|
|  |  |  | d.latitude as lat, | 
|---|
|  |  |  | d.longitude as lng, | 
|---|
|  |  |  | d.name as name, | 
|---|
|  |  |  | (hd.value ->> '$.a34002' )+0 as count, | 
|---|
|  |  |  | hd.time | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | device as d | 
|---|
|  |  |  | inner JOIN organization o on o.id = d.organization_id and o.is_delete = 0 | 
|---|
|  |  |  | <if test="organizationIds != null and organizationIds.size !=0"> | 
|---|
|  |  |  | and organization_id in | 
|---|
|  |  |  | <foreach collection="organizationIds" item="id" index="index" open="(" close=")" separator=","> | 
|---|
|  |  |  | #{id} | 
|---|
|  |  |  | </foreach> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="tableName !=null"> | 
|---|
|  |  |  | RIGHT join history_hourly${tableName} hd on hd.time = #{start}  and d.mac = hd.mac | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="tableName ==null "> | 
|---|
|  |  |  | RIGHT join history_daily hd on hd.time = #{start}   and d.mac = hd.mac | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | d.is_delete = 0 | 
|---|
|  |  |  | order by d.mac | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|
|  |  |  | 
|---|
|  |  |  | return new ResultMessage(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("dateInsertHistoryHourlyJKAvg") | 
|---|
|  |  |  | @ApiOperation(value = "小时数据", notes = "小时数据") | 
|---|
|  |  |  | public ResultMessage dateInsertHistoryHourlyJKAvg(String start, String end) { | 
|---|
|  |  |  | String format = DateUtils.yyyy_MM_dd_HH_mm_EN; | 
|---|
|  |  |  | //        String start ="2023-11-19 09:00"; | 
|---|
|  |  |  | //        String end ="2023-11-19 10:00"; | 
|---|
|  |  |  | //        Date start = DateUtils.getDate(s,format); | 
|---|
|  |  |  | //        Date end = DateUtils.getDate(s1,format); | 
|---|
|  |  |  | historyHourlyService.dateInsertHistoryHourlyJKAvg(start, end); | 
|---|
|  |  |  | return new ResultMessage(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("FiveMinutelyTest") | 
|---|
|  |  |  | @ApiOperation(value = "5分钟数据1", notes = "5分钟数据1") | 
|---|
|  |  |  | public ResultMessage FiveMinutelyTest(String yz,String mac) { | 
|---|
|  |  |  | 
|---|
|  |  |  | //计算海城市的小数数据 | 
|---|
|  |  |  | void dateInsertHistoryHourlyAvg(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //计算疾控中心的小时数据 | 
|---|
|  |  |  | void dateInsertHistoryHourlyJKAvg(String start,String end); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.moral.constant.SeparateTableType; | 
|---|
|  |  |  | import com.moral.util.AmendUtils; | 
|---|
|  |  |  | import com.moral.util.DateUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.util.MybatisPLUSUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.httpclient.HttpClient; | 
|---|
|  |  |  | import org.apache.commons.httpclient.methods.PostMethod; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.data.redis.core.RedisTemplate; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.*; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.net.InetAddress; | 
|---|
|  |  |  | import java.net.InetSocketAddress; | 
|---|
|  |  |  | import java.net.Socket; | 
|---|
|  |  |  | import java.net.SocketAddress; | 
|---|
|  |  |  | import java.nio.charset.StandardCharsets; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.concurrent.atomic.AtomicInteger; | 
|---|
|  |  |  | import java.util.function.Supplier; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 计算疾控中心的小时数据 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void dateInsertHistoryHourlyJKAvg(String start,String end) { | 
|---|
|  |  |  | QueryWrapper<Device> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | wrapper.select("mac"); | 
|---|
|  |  |  | wrapper.eq("organization_id",72); | 
|---|
|  |  |  | wrapper.eq("is_delete",Constants.NOT_DELETE); | 
|---|
|  |  |  | List<Device> devices = deviceMapper.selectList(wrapper); | 
|---|
|  |  |  | ArrayList<String> macs = new ArrayList<>(); | 
|---|
|  |  |  | for (Device device : devices) { | 
|---|
|  |  |  | macs.add(device.getMac()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //从数据库获取数据参数 | 
|---|
|  |  |  | Map<String, Object> params = new HashMap<>(); | 
|---|
|  |  |  | Date startTime=null; | 
|---|
|  |  |  | Date endTime=null; | 
|---|
|  |  |  | if (!ObjectUtils.isEmpty(start) || !ObjectUtils.isEmpty(end)){ | 
|---|
|  |  |  | startTime = DateUtils.getDate(start, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); | 
|---|
|  |  |  | endTime = DateUtils.getDate(end, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | //时间格式化:yyyy-MM-dd HH:mm | 
|---|
|  |  |  | String format = DateUtils.yyyy_MM_dd_HH_EN; | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | //开始时间 | 
|---|
|  |  |  | startTime = DateUtils.dataToTimeStampTime(DateUtils.addHours(now, -1), format); | 
|---|
|  |  |  | //结束时间 | 
|---|
|  |  |  | endTime = DateUtils.dataToTimeStampTime(now, format); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | params.put("start", startTime); | 
|---|
|  |  |  | params.put("end", endTime); | 
|---|
|  |  |  | params.put("macs",macs); | 
|---|
|  |  |  | //获取数据的分钟表后缀 | 
|---|
|  |  |  | String timeUnits = DateUtils.dateToDateString(startTime, DateUtils.yyyyMM_EN); | 
|---|
|  |  |  | params.put("timeUnits", timeUnits); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //因子 | 
|---|
|  |  |  | QueryWrapper<Sensor> sensorQueryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | sensorQueryWrapper.select("code", "lower", "upper").eq("is_delete", Constants.NOT_DELETE); | 
|---|
|  |  |  | List<Sensor> sensors = sensorService.list(sensorQueryWrapper); | 
|---|
|  |  |  | // 获取疾控中心设备的一小时内分钟的数据 | 
|---|
|  |  |  | List<Map<String, Object>> hourlyData = historyMinutelyMapper.getHistoryMinutelyData(params); | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(hourlyData)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //按mac分组 | 
|---|
|  |  |  | Map<String, List<Map<String, Object>>> data = hourlyData.parallelStream() | 
|---|
|  |  |  | .collect(Collectors.groupingBy(o -> (String) o.get("mac"))); | 
|---|
|  |  |  | //存入数据库的结果集 | 
|---|
|  |  |  | List<Map<String, Object>> insertData = new ArrayList<>(); | 
|---|
|  |  |  | data.forEach((key, value) -> { | 
|---|
|  |  |  | Map<String, Object> historyHourly = new HashMap<>(); | 
|---|
|  |  |  | historyHourly.put("mac", key); | 
|---|
|  |  |  | historyHourly.put("time",start); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> jsonMap = new HashMap<>(); | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("data", value); | 
|---|
|  |  |  | map.put("type", "hour"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (Sensor sensor : sensors) { | 
|---|
|  |  |  | String sensorCode = sensor.getCode(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //风向上下限 | 
|---|
|  |  |  | if (sensorCode.equals(Constants.SENSOR_CODE_WIND_DIR)) { | 
|---|
|  |  |  | if (sensor.getUpper() != null) { | 
|---|
|  |  |  | map.put("windDirUpper", sensor.getUpper()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (sensor.getLower() != null) { | 
|---|
|  |  |  | map.put("windDirLower", sensor.getLower()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //风速上下限 | 
|---|
|  |  |  | if (sensorCode.equals(Constants.SENSOR_CODE_WIND_SPEED)) { | 
|---|
|  |  |  | if (sensor.getUpper() != null) { | 
|---|
|  |  |  | map.put("windSpeedUpper", sensor.getUpper()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (sensor.getLower() != null) { | 
|---|
|  |  |  | map.put("windSpeedLower", sensor.getLower()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //风向均值计算并修约 | 
|---|
|  |  |  | Map<String, Object> windDirAvg = AmendUtils.getWindDirAvg(map); | 
|---|
|  |  |  | if (!ObjectUtils.isEmpty(windDirAvg)) { | 
|---|
|  |  |  | jsonMap.putAll(windDirAvg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //除风向外其他因子均值计算 | 
|---|
|  |  |  | sensors.forEach(sensor -> { | 
|---|
|  |  |  | String sensorCode = sensor.getCode(); | 
|---|
|  |  |  | Double upper = sensor.getUpper(); | 
|---|
|  |  |  | Double lower = sensor.getLower(); | 
|---|
|  |  |  | AtomicInteger size = new AtomicInteger(); | 
|---|
|  |  |  | DoubleStream optionalDouble = value.parallelStream() | 
|---|
|  |  |  | .flatMapToDouble(v -> { | 
|---|
|  |  |  | Map<String, Object> dataValue = JSONObject.parseObject((String) v.get("value"), Map.class); | 
|---|
|  |  |  | Object sensorValue = dataValue.get(sensorCode); | 
|---|
|  |  |  | //数据有效性标记位 | 
|---|
|  |  |  | Object flag = dataValue.get(sensorCode + "-" + Constants.MARKER_BIT_KEY); | 
|---|
|  |  |  | if (!Constants.MARKER_BIT_TRUE.equals(flag)) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(sensorValue)) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //风向单独计算 | 
|---|
|  |  |  | if (Constants.SENSOR_CODE_WIND_DIR.equals(sensorCode)) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //剔除数据超过上下限的数据 | 
|---|
|  |  |  | double aDouble = Double.parseDouble(sensorValue.toString()); | 
|---|
|  |  |  | if (!ObjectUtils.isEmpty(upper)) { | 
|---|
|  |  |  | if (aDouble < upper) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!ObjectUtils.isEmpty(lower)) { | 
|---|
|  |  |  | if (aDouble > lower) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | size.getAndIncrement(); | 
|---|
|  |  |  | return DoubleStream.of(aDouble); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | OptionalDouble average = optionalDouble.average(); | 
|---|
|  |  |  | if (average.isPresent()) { | 
|---|
|  |  |  | //银行家算法修约 | 
|---|
|  |  |  | double sciCal = AmendUtils.sciCal(average.getAsDouble(), 4); | 
|---|
|  |  |  | jsonMap.put(sensorCode, sciCal); | 
|---|
|  |  |  | //标志位 | 
|---|
|  |  |  | if (size.get() >= 45) { | 
|---|
|  |  |  | jsonMap.put(sensorCode + "-" + Constants.MARKER_BIT_KEY, Constants.MARKER_BIT_TRUE); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | jsonMap.put(sensorCode + "-" + Constants.MARKER_BIT_KEY, Constants.MARKER_BIT_FALSE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | historyHourly.put("version", value.get(0).get("version")); | 
|---|
|  |  |  | historyHourly.put("value", JSONObject.toJSONString(jsonMap)); | 
|---|
|  |  |  | insertData.add(historyHourly); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //存入数据库 | 
|---|
|  |  |  | historyHourlyMapper.insertHistoryHourlyAvg(insertData,timeUnits); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String strList(String startTime,String mn,String msg){ | 
|---|
|  |  |  | String qn = "QN="+ startTime + "001;ST=22;CN=2061;PW=123456;MN="+mn.toUpperCase()+";CP=&&DataTime="+startTime+";"; | 
|---|
|  |  |  | Map<String, Object> data = JSON.parseObject(msg, Map.class); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //疾控中心小时数据统计 | 
|---|
|  |  |  | @XxlJob("dateInsertHistoryHourlyJKAvg") | 
|---|
|  |  |  | public ReturnT dateInsertHistoryHourlyJKAvg(){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | historyHourlyService.dateInsertHistoryHourlyJKAvg(null,null); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return new ReturnT(ReturnT.FAIL_CODE, e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ReturnT.SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import io.swagger.annotations.ApiParam; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestParam; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.validation.Valid; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.moral.api.entity.Divisor; | 
|---|
|  |  |  | import com.moral.api.mapper.DivisorMapper; | 
|---|
|  |  |  | import com.moral.api.service.DivisorService; | 
|---|
|  |  |  | import com.moral.constant.Constants; | 
|---|
|  |  |  | import com.moral.constant.ResponseCodeEnum; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Description //todo | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author swb | 
|---|
|  |  |  | * @ClassName DivisorController | 
|---|
|  |  |  | * @date 2023.12.06 14:15 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"因子配置"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping(value = "/divisor") | 
|---|
|  |  |  | public class DivisorController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DivisorService divisorService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("insert") | 
|---|
|  |  |  | @ApiOperation("新增") | 
|---|
|  |  |  | public ResultMessage  insert(@Valid @RequestBody Divisor divisor){ | 
|---|
|  |  |  | QueryWrapper<Divisor> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.eq("organization_id", divisor.getOrganizationId()).eq("is_del", Constants.NOT_DELETE); | 
|---|
|  |  |  | if (divisorService.getOne(queryWrapper) != null) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.MAC_IS_EXIST.getCode(), ResponseCodeEnum.MAC_IS_EXIST.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | divisorService.insert(divisor); | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("update") | 
|---|
|  |  |  | @ApiOperation("修改") | 
|---|
|  |  |  | public ResultMessage  update(@Valid @RequestBody Divisor divisor){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | QueryWrapper<Divisor> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.eq("organization_id", divisor.getOrganizationId()).eq("is_del", Constants.NOT_DELETE); | 
|---|
|  |  |  | if (divisorService.getOne(queryWrapper) != null) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.MAC_IS_EXIST.getCode(), ResponseCodeEnum.MAC_IS_EXIST.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | divisorService.update(divisor); | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("delete") | 
|---|
|  |  |  | @ApiOperation("删除") | 
|---|
|  |  |  | public ResultMessage  delete(@RequestParam @ApiParam(value = "id",name = "主键id") Integer id){ | 
|---|
|  |  |  | divisorService.delete(id); | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("select") | 
|---|
|  |  |  | @ApiOperation("详情") | 
|---|
|  |  |  | public ResultMessage  select(@RequestParam @ApiParam(value = "id",name = "主键id") Integer id){ | 
|---|
|  |  |  | Divisor divisor = divisorService.queryById(id); | 
|---|
|  |  |  | return ResultMessage.ok(ObjectUtils.isEmpty(divisor)?"0":divisor); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("page") | 
|---|
|  |  |  | @ApiOperation("分页") | 
|---|
|  |  |  | public ResultMessage page(@RequestParam @ApiParam(value = "mac",name = "mac号") String mac, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "page",name = "页码") String page, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "size",name = "条数") String size) { | 
|---|
|  |  |  | Map<String, Object> select = divisorService.select(mac, page, size); | 
|---|
|  |  |  | return ResultMessage.ok(ObjectUtils.isEmpty(select)?"0":select); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.entity; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.ApiModel; | 
|---|
|  |  |  | import io.swagger.annotations.ApiModelProperty; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  | import lombok.experimental.Accessors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Description //todo | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author swb | 
|---|
|  |  |  | * @ClassName Divisor | 
|---|
|  |  |  | * @date 2023.12.06 14:12 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @EqualsAndHashCode(callSuper = false) | 
|---|
|  |  |  | @Accessors(chain = true) | 
|---|
|  |  |  | @ApiModel(value="Divisor - Divisor对象", description="Divisor - Divisor对象") | 
|---|
|  |  |  | public class Divisor extends Model<Divisor> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final long serialVersionUID = 1L; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiModelProperty(value = "主键") | 
|---|
|  |  |  | private  Integer id; | 
|---|
|  |  |  | @ApiModelProperty(value = "区域") | 
|---|
|  |  |  | private  String organizationId; | 
|---|
|  |  |  | @ApiModelProperty(value = "pm2.5") | 
|---|
|  |  |  | private  String pm25; | 
|---|
|  |  |  | @ApiModelProperty(value = "PM10") | 
|---|
|  |  |  | private  String pm10; | 
|---|
|  |  |  | @ApiModelProperty(value = "二氧化硫") | 
|---|
|  |  |  | private  String so2; | 
|---|
|  |  |  | @ApiModelProperty(value = "二氧化氮") | 
|---|
|  |  |  | private  String no2; | 
|---|
|  |  |  | @ApiModelProperty(value = "一氧化钛") | 
|---|
|  |  |  | private  String co; | 
|---|
|  |  |  | @ApiModelProperty(value = "tvoc") | 
|---|
|  |  |  | private  String tvoc; | 
|---|
|  |  |  | @ApiModelProperty(value = "臭氧") | 
|---|
|  |  |  | private  String o3; | 
|---|
|  |  |  | @ApiModelProperty(value = "尘负荷") | 
|---|
|  |  |  | private String dustld; | 
|---|
|  |  |  | @ApiModelProperty(value = "是否删除") | 
|---|
|  |  |  | private  String isDel; | 
|---|
|  |  |  | @ApiModelProperty(value = "创建时间") | 
|---|
|  |  |  | private  Date createTime; | 
|---|
|  |  |  | @ApiModelProperty(value = "修改时间") | 
|---|
|  |  |  | private  Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private  String createName; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private  String updateName; | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.mapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
|---|
|  |  |  | import com.moral.api.entity.Divisor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public interface DivisorMapper extends BaseMapper<Divisor> { | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.IService; | 
|---|
|  |  |  | import com.moral.api.entity.Divisor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public interface DivisorService extends IService<Divisor> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 新增 | 
|---|
|  |  |  | * @param divisor | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | void insert(Divisor divisor); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 修改 | 
|---|
|  |  |  | * @param divisor | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | void update(Divisor divisor); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 删除 | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | void  delete(Integer id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 详情 | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | Divisor  queryById(Integer id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分页查询 | 
|---|
|  |  |  | * @param mac | 
|---|
|  |  |  | * @param page | 
|---|
|  |  |  | * @param size | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | Map<String,Object> select(String mac,String page,String size); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  | import org.springframework.web.context.request.RequestContextHolder; | 
|---|
|  |  |  | import org.springframework.web.context.request.ServletRequestAttributes; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.moral.api.entity.Divisor; | 
|---|
|  |  |  | import com.moral.api.entity.ManageAccount; | 
|---|
|  |  |  | import com.moral.api.mapper.DivisorMapper; | 
|---|
|  |  |  | import com.moral.api.pojo.redisBean.AccountInfoDTO; | 
|---|
|  |  |  | import com.moral.api.service.DivisorService; | 
|---|
|  |  |  | import com.moral.api.util.LogUtils; | 
|---|
|  |  |  | import com.moral.constant.Constants; | 
|---|
|  |  |  | import com.moral.util.TokenUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Description //todo | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author swb | 
|---|
|  |  |  | * @ClassName DivisorServiceimpl | 
|---|
|  |  |  | * @date 2023.12.06 14:18 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class DivisorServiceImpl extends ServiceImpl<DivisorMapper, Divisor> implements DivisorService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private  DivisorMapper divisorMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 新增 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param divisor | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void insert(Divisor divisor) { | 
|---|
|  |  |  | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); | 
|---|
|  |  |  | ManageAccount manageAccount = accountInfoDTO.getAccount(); | 
|---|
|  |  |  | divisor.setIsDel(Constants.NOT_DELETE); | 
|---|
|  |  |  | divisor.setCreateTime(new Date()); | 
|---|
|  |  |  | divisor.setUpdateTime(new Date()); | 
|---|
|  |  |  | divisor.setCreateName(manageAccount.getUserName()); | 
|---|
|  |  |  | divisorMapper.insert(divisor); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 修改 | 
|---|
|  |  |  | * @param divisor | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void update(Divisor divisor) { | 
|---|
|  |  |  | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); | 
|---|
|  |  |  | ManageAccount manageAccount = accountInfoDTO.getAccount(); | 
|---|
|  |  |  | Divisor divisor1 = divisorMapper.selectById(divisor.getId()); | 
|---|
|  |  |  | divisor.setUpdateTime(new Date()); | 
|---|
|  |  |  | divisor.setUpdateName(manageAccount.getUserName()); | 
|---|
|  |  |  | divisorMapper.updateById(divisor); | 
|---|
|  |  |  | //操作日志记录 | 
|---|
|  |  |  | StringBuilder content = new StringBuilder(); | 
|---|
|  |  |  | content.append("修改了"+divisor1.getOrganizationId()+"走航车高值范围"); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getDustld())?",尘负荷==>null":",尘负荷==>"+divisor.getDustld()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getCo())?",co==>null":",co==>"+divisor.getCo()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getSo2())?",so2==>null":",so2==>"+divisor.getSo2()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getNo2())?",no2==>null":",no2==>"+divisor.getNo2()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getPm25())?",pm2.5==>null":",pm2.5==>"+divisor.getPm25()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getPm10())?",pm10==>null":",pm10==>"+divisor.getPm10()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getTvoc())?",tvoc==>null":",tvoc==>"+divisor.getTvoc()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getO3())?",o3==>null":",o3==>"+divisor.getO3()); | 
|---|
|  |  |  | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 删除 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void delete(Integer id) { | 
|---|
|  |  |  | Divisor divisor = divisorMapper.selectById(id); | 
|---|
|  |  |  | divisor.setIsDel(Constants.DELETE); | 
|---|
|  |  |  | divisorMapper.updateById(divisor); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 详情 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Divisor queryById(Integer id) { | 
|---|
|  |  |  | Divisor divisor = divisorMapper.selectById(id); | 
|---|
|  |  |  | return divisor; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分页查询 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param mac | 
|---|
|  |  |  | * @param page | 
|---|
|  |  |  | * @param size | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> select(String mac, String page, String size) { | 
|---|
|  |  |  | HashMap<String, Object> result = new HashMap<>(); | 
|---|
|  |  |  | LambdaQueryWrapper<Divisor> wrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | wrapper.eq(Divisor::getIsDel,Constants.NOT_DELETE); | 
|---|
|  |  |  | //        if (!ObjectUtils.isEmpty(mac)){ | 
|---|
|  |  |  | //            wrapper.like(Divisor::getMac,mac); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | Page<Divisor> PageList = new Page<>(Integer.parseInt(page), Integer.parseInt(size)); | 
|---|
|  |  |  | Page<Divisor> divisorPage = divisorMapper.selectPage(PageList, wrapper); | 
|---|
|  |  |  | result.put("total", PageList.getTotal()); | 
|---|
|  |  |  | result.put("totalPage", PageList.getPages()); | 
|---|
|  |  |  | result.put("current", PageList.getCurrent()); | 
|---|
|  |  |  | result.put("pageSize", PageList.getSize()); | 
|---|
|  |  |  | result.put("item", divisorPage.getRecords()); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | for (CruiserDTO cruiserDTO : cruiserInfo) { | 
|---|
|  |  |  | Double flyLat = cruiserDTO.getFlyLat(); | 
|---|
|  |  |  | Double flyLon = cruiserDTO.getFlyLon(); | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(flyLat) || ObjectUtils.isEmpty(flyLon)){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ManageCoordinateDetail rsDTO = new ManageCoordinateDetail(); | 
|---|
|  |  |  | rsDTO.setLatitude(flyLat); | 
|---|
|  |  |  | rsDTO.setLongitude(flyLon); | 
|---|
|  |  |  | 
|---|
|  |  |  | public Map<String, Object> selectUnit(Map<String, Object> parameters) { | 
|---|
|  |  |  | QueryWrapper<ResponsibilityUnit> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | wrapper.eq("is_del",Constants.NOT_DELETE); | 
|---|
|  |  |  | wrapper.eq("is_invalid",0); | 
|---|
|  |  |  | //        wrapper.eq("is_invalid",0); | 
|---|
|  |  |  | int page = Integer.parseInt(parameters.get("page").toString()); | 
|---|
|  |  |  | int size = Integer.parseInt(parameters.get("size").toString()); | 
|---|
|  |  |  | Object parentName1 = parameters.get("parentCode"); | 
|---|