Merge remote-tracking branch 'origin/dev' into cjl
29 files added
11 files modified
| | |
| | | import com.deepoove.poi.data.RowRenderData; |
| | | import com.deepoove.poi.policy.HackLoopTableRenderPolicy; |
| | | import com.moral.api.entity.Dustld; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | import com.moral.api.exception.BusinessException; |
| | | import com.moral.api.pojo.bo.ExcelBO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.poi.xwpf.usermodel.XWPFDocument; |
| | |
| | | |
| | | } |
| | | |
| | | @GetMapping("sort") |
| | | @ApiOperation("路段排序") |
| | | public ResultMessage sectionRanking(@RequestParam @ApiParam(value = "mac",name = "mac号") String mac, |
| | | @RequestParam @ApiParam(value = "startTime",name = "开始时间") String startTime, |
| | | @RequestParam @ApiParam(value = "endTime",name = "结束时间") String endTime){ |
| | | |
| | | List<SecondCruiserSort> sort = dustldService.sort(mac, startTime, endTime); |
| | | return ResultMessage.ok(sort); |
| | | } |
| | | |
| | | |
| | | |
| | | public static void downloadWord(String fileName, Map<String, Object> params, HttpServletResponse response, String newFileName) { |
| | |
| | | public ResultMessage getHeatMap(@RequestParam @ApiParam(value = "organizationId",name = "组织id") Integer id, |
| | | @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.getHeatMapDataV2(id, startTime, type, form); |
| | | @RequestParam @ApiParam(value = "form",name= "时间类型") String form, |
| | | @RequestParam @ApiParam(value = "monitorId",name= "站点id") Integer monitorId){ |
| | | List<HeatMapDTO> heatMapData = dataDisplayService.getHeatMapDataV2(id, startTime, type, form,monitorId); |
| | | return ResultMessage.ok(ObjectUtils.isEmpty(heatMapData)?"0":heatMapData); |
| | | } |
| | | @GetMapping("queryTime") |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName SecondCruiserSort |
| | | * @date 2024.06.25 15:29 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SecondCruiserSort extends Model<SecondCruiserSort> { |
| | | |
| | | /** |
| | | * 路段名称 |
| | | */ |
| | | private String road; |
| | | |
| | | /** |
| | | * 数据 |
| | | */ |
| | | private Double value; |
| | | |
| | | /** |
| | | * mac号 |
| | | */ |
| | | private String mac; |
| | | /** |
| | | * 组织Id |
| | | */ |
| | | private Integer organizationId; |
| | | |
| | | /** |
| | | * 时间 |
| | | */ |
| | | private String time; |
| | | |
| | | /** |
| | | * 平均值 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Double avg; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import io.lettuce.core.dynamic.annotation.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | |
| | | public interface SecondCruiserSortMapper extends BaseMapper<SecondCruiserSort> { |
| | | |
| | | List<SecondCruiserSort> getSort(@Param("mac") String mac, @Param("startTime") String startTime,@Param("endTime") String endTime); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form); |
| | | List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form,Integer monitorId); |
| | | } |
| | |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.entity.Dustld; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | |
| | | |
| | | public interface DustldService { |
| | | |
| | |
| | | |
| | | List<Dustld> selectAll(Map<String, Object> params); |
| | | |
| | | |
| | | //路段排序 |
| | | List<SecondCruiserSort> sort(String mac, String startTime, String endTime); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | |
| | | public interface SecondCruiserSortService extends IService<SecondCruiserSort> { |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form) { |
| | | public List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form,Integer monitorId) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("start",startTime); |
| | | map.put("type","$."+ type); |
| | | map.put("monitorId",monitorId); |
| | | ArrayList<Integer> list = new ArrayList<>(); |
| | | list.add(id); |
| | | ArrayList<HeatMapDTO> rsHeatMap = new ArrayList<>(); |
| | |
| | | rsHeatMap.add(heatMapDTO); |
| | | } |
| | | } |
| | | if (id==73){ |
| | | |
| | | if (!ObjectUtils.isEmpty(monitorId)){ |
| | | if (monitorId==117){ |
| | | double lat =33.35001; |
| | | double lng =120.142939; |
| | | for (int i = 0; i <24 ; i++) { |
| | | for (int j = 0; j < 20; j++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | heatMapDTO.setLat(lat); |
| | | heatMapDTO.setLng(lng); |
| | | heatMapDTO.setName("1"); |
| | | heatMapDTO.setMac(i+"10"+j); |
| | | rsHeatMap.add(heatMapDTO); |
| | | lng=lng+0.0021; |
| | | if (j==19){ |
| | | lng=120.142939; |
| | | } |
| | | } |
| | | lat =lat-0.0011; |
| | | } |
| | | } else if (monitorId==118){ |
| | | double lat =33.375618; |
| | | double lng =120.14271; |
| | | for (int i = 0; i <24 ; i++) { |
| | | for (int j = 0; j < 17; j++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | heatMapDTO.setLat(lat); |
| | | heatMapDTO.setLng(lng); |
| | | heatMapDTO.setName("1"); |
| | | heatMapDTO.setMac(i+"10"+j); |
| | | rsHeatMap.add(heatMapDTO); |
| | | lng=lng+0.0021; |
| | | if (j==16){ |
| | | lng=120.14271; |
| | | } |
| | | } |
| | | lat =lat-0.0011; |
| | | } |
| | | } else if (monitorId==120){ |
| | | double lat =33.410581; |
| | | double lng =120.108739; |
| | | for (int i = 0; i <21 ; i++) { |
| | | for (int j = 0; j < 15; j++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | heatMapDTO.setLat(lat); |
| | | heatMapDTO.setLng(lng); |
| | | heatMapDTO.setName("1"); |
| | | heatMapDTO.setMac(i+"10"+j); |
| | | rsHeatMap.add(heatMapDTO); |
| | | lng=lng+0.0021; |
| | | if (j==14){ |
| | | lng=120.108739; |
| | | } |
| | | } |
| | | lat =lat-0.001; |
| | | } |
| | | }else if (monitorId==121){ |
| | | double lat =33.398466; |
| | | double lng =120.153462; |
| | | for (int i = 0; i <13 ; i++) { |
| | | for (int j = 0; j < 16; j++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | heatMapDTO.setLat(lat); |
| | | heatMapDTO.setLng(lng); |
| | | heatMapDTO.setName("1"); |
| | | heatMapDTO.setMac(i+"10"+j); |
| | | rsHeatMap.add(heatMapDTO); |
| | | lng=lng+0.00085; |
| | | if (j==15){ |
| | | lng=120.153462; |
| | | } |
| | | } |
| | | lat =lat-0.001; |
| | | } |
| | | }else if (monitorId==122){ |
| | | double lat =33.210894; |
| | | double lng =120.424509; |
| | | for (int i = 0; i <15 ; i++) { |
| | | for (int j = 0; j < 9; j++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | heatMapDTO.setLat(lat); |
| | | heatMapDTO.setLng(lng); |
| | | heatMapDTO.setName("1"); |
| | | heatMapDTO.setMac(i+"10"+j); |
| | | rsHeatMap.add(heatMapDTO); |
| | | lng=lng+0.0021; |
| | | if (j==8){ |
| | | lng=120.424509; |
| | | } |
| | | } |
| | | lat =lat-0.001; |
| | | } |
| | | }else if (monitorId==119){ |
| | | double lat =33.384755; |
| | | double lng =120.20625; |
| | | for (int i = 0; i <14 ; i++) { |
| | | for (int j = 0; j < 12; j++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | heatMapDTO.setLat(lat); |
| | | heatMapDTO.setLng(lng); |
| | | heatMapDTO.setName("1"); |
| | | heatMapDTO.setMac(i+"10"+j); |
| | | rsHeatMap.add(heatMapDTO); |
| | | lng=lng+0.0021; |
| | | if (j==11){ |
| | | lng=120.20625; |
| | | } |
| | | } |
| | | lat =lat-0.001; |
| | | } |
| | | } |
| | | } |
| | | /* if (id==73){ |
| | | //亭湖区 |
| | | double lat =33.414538; |
| | | double lng =120.066616; |
| | |
| | | } |
| | | lat1 =lat1-0.0022; |
| | | } |
| | | } |
| | | }*/ |
| | | return distrinList(rsHeatMap); |
| | | } |
| | | |
| | |
| | | ArrayList<Double> doubleArrayList = new ArrayList<>(); |
| | | ArrayList<GeoCoordinate> geoCoordinates = new ArrayList<>(); |
| | | List<HeatMapDTO> heatMapDTOS = collect.get(integer); |
| | | for (HeatMapDTO heatMapDTO : heatMapDTOS) { |
| | | GeoCoordinate geoCoordinate = new GeoCoordinate(); |
| | | doubleArrayList.add(heatMapDTO.getCount()); |
| | | if (heatMapDTOS.size()>1){ |
| | | for (HeatMapDTO heatMapDTO : heatMapDTOS) { |
| | | GeoCoordinate geoCoordinate = new GeoCoordinate(); |
| | | doubleArrayList.add(heatMapDTO.getCount()); |
| | | // heatMapDTO.setCount(heatMapDTO.getCount()); |
| | | if (type.equals("a21026")){ |
| | | heatMapDTO.setCount(1.0); |
| | | }else { |
| | | heatMapDTO.setCount(0.0); |
| | | } |
| | | if (type.equals("a21026")){ |
| | | heatMapDTO.setCount(1.0); |
| | | }else { |
| | | heatMapDTO.setCount(0.0); |
| | | } |
| | | |
| | | geoCoordinate.setLongitude(heatMapDTO.getLng()); |
| | | geoCoordinate.setLatitude(heatMapDTO.getLat()); |
| | | geoCoordinates.add(geoCoordinate); |
| | | geoCoordinate.setLongitude(heatMapDTO.getLng()); |
| | | geoCoordinate.setLatitude(heatMapDTO.getLat()); |
| | | geoCoordinates.add(geoCoordinate); |
| | | } |
| | | } |
| | | if (!ObjectUtils.isEmpty(doubleArrayList)){ |
| | | if (!ObjectUtils.isEmpty(doubleArrayList) &&doubleArrayList.size()>1){ |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | //计算均值集合 |
| | | double asDouble = doubleArrayList.stream().mapToDouble(Double::valueOf).max().getAsDouble(); |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.moral.api.config.Interceptor.UserHelper; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | import com.moral.api.entity.SysDictData; |
| | | import com.moral.api.exception.BusinessException; |
| | | import com.moral.api.mapper.*; |
| | |
| | | |
| | | @Autowired |
| | | private DustldMapper dustldMapper; |
| | | |
| | | @Autowired |
| | | private SecondCruiserSortMapper secondCruiserSortMapper; |
| | | |
| | | /** |
| | | * 保存日报信息 |
| | |
| | | return dustlds; |
| | | } |
| | | |
| | | /** |
| | | * 路段排序 |
| | | * @param mac |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SecondCruiserSort> sort(String mac, String startTime, String endTime) { |
| | | SysDictData list = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER.getValue(),"dustld"); |
| | | List<SecondCruiserSort> secondCruiserSorts = secondCruiserSortMapper.getSort(mac, startTime, endTime); |
| | | |
| | | //校准尘负荷 |
| | | if (!ObjectUtils.isEmpty(secondCruiserSorts)){ |
| | | for (SecondCruiserSort secondCruiserSort : secondCruiserSorts) { |
| | | if(list.getDataValue().contains(",")){ |
| | | List<String> resultStr = Arrays.asList(list.getDataValue().split(",")); |
| | | if(resultStr.size() % 2 ==0){ |
| | | // secondCruiserSort.setAvg(numAvg(resultStr,BigDecimal.valueOf(secondCruiserSort.getAvg())).doubleValue()); |
| | | secondCruiserSort.setAvg((double) Math.round(numAvg(resultStr, BigDecimal.valueOf(secondCruiserSort.getAvg())).doubleValue())); |
| | | } |
| | | }else { |
| | | BigDecimal dataValue = Objects.nonNull(list.getDataValue())?BigDecimal.valueOf(Double.parseDouble(list.getDataValue())):BigDecimal.ZERO; |
| | | // secondCruiserSort.setAvg(BigDecimal.valueOf(secondCruiserSort.getAvg()).add(dataValue).doubleValue()); |
| | | secondCruiserSort.setAvg((double) Math.round(BigDecimal.valueOf(secondCruiserSort.getAvg()).add(dataValue).doubleValue())); |
| | | } |
| | | } |
| | | } |
| | | return secondCruiserSorts; |
| | | } |
| | | |
| | | |
| | | //获取图片地址 |
| | | private String getList(String path, List<MultipartFile> files1) { |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | import com.moral.api.mapper.SecondCruiserSortMapper; |
| | | import com.moral.api.service.SecondCruiserSortService; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName SecondCruiserSortServiceImpl |
| | | * @date 2024.06.28 09:14 |
| | | */ |
| | | @Service |
| | | public class SecondCruiserSortServiceImpl extends ServiceImpl<SecondCruiserSortMapper, SecondCruiserSort> implements SecondCruiserSortService { |
| | | } |
| | |
| | | FROM |
| | | device as d |
| | | inner JOIN organization o on o.id = d.organization_id and o.is_delete = 0 |
| | | <if test="monitorId !=null and monitorId !=''"> |
| | | and monitor_point_id =#{monitorId} |
| | | </if> |
| | | <if test="organizationIds != null and organizationIds.size !=0"> |
| | | and organization_id in |
| | | <foreach collection="organizationIds" item="id" index="index" open="(" close=")" separator=","> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.SecondCruiserSortMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.SecondCruiserSort"> |
| | | <result column="road" property="road"/> |
| | | <result column="time" property="time"/> |
| | | <result column="value" property="value"/> |
| | | <result column="mac" property="mac"/> |
| | | <result column="organization_id" property="organizationId"/> |
| | | </resultMap> |
| | | |
| | | <select id="getSort" resultType="com.moral.api.entity.SecondCruiserSort"> |
| | | select road,avg(value) as "avg",time,mac from second_cruiser_sort |
| | | where mac =#{mac} and time BETWEEN #{startTime} and #{endTime} GROUP BY road ORDER BY avg DESC |
| | | |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private ManageCoordinateDetailService manageCoordinateDetailService; |
| | | |
| | | @Autowired |
| | | private HistorySecondCruiserService historySecondCruiserService; |
| | | |
| | | private final EmailSpringUtil emailSpringUtil; |
| | | private final CityWeatherForecastService cityWeatherForecastService; |
| | | |
| | |
| | | return new ResultMessage(); |
| | | } |
| | | |
| | | @GetMapping("secondCruiserSort") |
| | | @ApiOperation(value = "走航车排名", notes = "走航车排名") |
| | | public ResultMessage secondCruiserSort() { |
| | | String startTime ="2024-06-06 00:07:01"; |
| | | String endTime ="2024-06-06 23:07:01"; |
| | | historySecondCruiserService.sort(startTime,endTime); |
| | | return new ResultMessage(); |
| | | } |
| | | |
| | | @GetMapping("insertCoordinateDetail") |
| | | @ApiOperation(value = "路段录入", notes = "路段录入") |
| | | public ResultMessage insertCoordinateDetail() { |
| | | String startTime ="2024-06-06 00:07:01"; |
| | | String endTime ="2024-06-06 23:07:01"; |
| | | manageCoordinateDetailService.insertCoordinateDetail(startTime,endTime); |
| | | return new ResultMessage(); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | String host = "https://pair.market.alicloudapi.com"; |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName CruiserDTO |
| | | * @date 2024.06.19 09:15 |
| | | */ |
| | | @Data |
| | | public class CruiserDTO { |
| | | |
| | | |
| | | /** |
| | | * 数据时间 |
| | | */ |
| | | private String time; |
| | | |
| | | /** |
| | | * 纬度 |
| | | */ |
| | | @JsonProperty(value = "flylat") |
| | | private Double flyLat; |
| | | |
| | | /** |
| | | * 经度 |
| | | */ |
| | | @JsonProperty(value = "flylon") |
| | | private Double flyLon; |
| | | |
| | | |
| | | private String data; |
| | | |
| | | |
| | | private String state; |
| | | |
| | | |
| | | public CruiserDTO() { |
| | | this.state = "1"; // 设置state字段默认值为1 |
| | | } |
| | | |
| | | @Override |
| | | public boolean equals(Object o) { |
| | | if (this == o) return true; |
| | | if (o == null || getClass() != o.getClass()) return false; |
| | | CruiserDTO cruiser = (CruiserDTO) o; |
| | | //当type、color 内容都相等的时候,才返回true |
| | | return Objects.equals(flyLat, cruiser.flyLat) && |
| | | Objects.equals(flyLon, cruiser.flyLon); |
| | | } |
| | | @Override |
| | | public int hashCode() { |
| | | return Objects.hash(flyLat, flyLon); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName DustldDTO |
| | | * @date 2024.06.25 14:25 |
| | | */ |
| | | @Data |
| | | public class DustldDTO { |
| | | |
| | | |
| | | private String name; |
| | | //纬度 |
| | | private String flyLat; |
| | | //经度 |
| | | private String flyLon; |
| | | |
| | | //尘负荷 |
| | | private Double data; |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName HistorySecondCruiser |
| | | * @date 2024.06.25 14:33 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class HistorySecondCruiser extends Model<HistorySecondCruiser> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 设备mac |
| | | */ |
| | | private String mac; |
| | | |
| | | /** |
| | | * 数据时间 |
| | | */ |
| | | private Date time; |
| | | |
| | | /** |
| | | * 数据 |
| | | */ |
| | | private String value; |
| | | |
| | | /** |
| | | * 此数据所属组织id |
| | | */ |
| | | private Integer organizationId; |
| | | |
| | | /** |
| | | * 数据批次 |
| | | */ |
| | | private Date batch; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName ManageCoordinate |
| | | * @date 2024.06.19 09:13 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class ManageCoordinate extends Model<ManageCoordinate> { |
| | | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 路段id |
| | | */ |
| | | @TableId(value = "coordinate_id", type = IdType.AUTO) |
| | | private Integer coordinateId; |
| | | /** |
| | | * 起点名称 |
| | | */ |
| | | private String startPoint; |
| | | /** |
| | | * 终点名称 |
| | | */ |
| | | private String endPoint; |
| | | /** |
| | | *是否删除 |
| | | */ |
| | | private Integer isDel; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 修改人id |
| | | * |
| | | */ |
| | | private Integer updateUserId; |
| | | /** |
| | | * 修改人名称 |
| | | */ |
| | | private String updayeUserName; |
| | | |
| | | |
| | | private Integer organizationId; |
| | | |
| | | /** |
| | | * 经纬度点位 |
| | | */ |
| | | private String value; |
| | | |
| | | |
| | | /** |
| | | * 百度经纬度点位 |
| | | */ |
| | | private String bdValue; |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName ManageCoordinateDetail |
| | | * @date 2024.06.19 09:21 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class ManageCoordinateDetail extends Model<ManageCoordinateDetail> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | /** |
| | | * 经纬度id |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 路段id |
| | | */ |
| | | private Integer coordinateId; |
| | | /** |
| | | * 经度 |
| | | */ |
| | | private Double longitude; |
| | | /** |
| | | *纬度 |
| | | */ |
| | | private Double latitude; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 修改人id |
| | | * |
| | | */ |
| | | private Integer updateUserId; |
| | | /** |
| | | * 修改人名称 |
| | | */ |
| | | private String updayeUserName; |
| | | |
| | | |
| | | private String state; |
| | | |
| | | |
| | | @TableField(exist = false) |
| | | private String code; |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName SecondCruiserSort |
| | | * @date 2024.06.25 15:29 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SecondCruiserSort extends Model<SecondCruiserSort> { |
| | | |
| | | /** |
| | | * 路段名称 |
| | | */ |
| | | private String road; |
| | | |
| | | /** |
| | | * 数据 |
| | | */ |
| | | private Double value; |
| | | |
| | | /** |
| | | * mac号 |
| | | */ |
| | | private String mac; |
| | | /** |
| | | * 组织Id |
| | | */ |
| | | private Integer organizationId; |
| | | |
| | | /** |
| | | * 时间 |
| | | */ |
| | | private String time; |
| | | |
| | | |
| | | /* public SecondCruiserSort() { |
| | | this.time =DateUtils.getDateStringOfDay(-1,"yyyy-MM-dd HH:00:00"); // 构造函数中设置默认值 |
| | | }*/ |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName SysDictData |
| | | * @date 2024.06.25 14:01 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SysDictData extends Model<SysDictData> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 序号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 数据类型Id |
| | | */ |
| | | private Integer dictTypeId; |
| | | |
| | | /** |
| | | * 数据编码 |
| | | */ |
| | | @TableField("dataKey") |
| | | private String dataKey; |
| | | |
| | | /** |
| | | * 数据值 |
| | | */ |
| | | @TableField("dataValue") |
| | | private String dataValue; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 是否删除 |
| | | */ |
| | | private String isDelete; |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName SysDictType |
| | | * @date 2024.06.25 14:05 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class SysDictType extends Model<SysDictType> { |
| | | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 序号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 类型 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 描述 |
| | | */ |
| | | private String desc; |
| | | |
| | | /** |
| | | * 系统内置 无法更改 |
| | | */ |
| | | private Integer system; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 是否删除 |
| | | */ |
| | | private String isDelete; |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | |
| | | public interface HistorySecondCruiserMapper extends BaseMapper<HistorySecondCruiser> { |
| | | |
| | | List<Map<String,Object>> getDusts(Map<String,Object> params); |
| | | |
| | | List<HistorySecondCruiser> getResult(String startTime,String endTime); |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.entity.CruiserDTO; |
| | | import com.moral.api.entity.DustldDTO; |
| | | import com.moral.api.entity.ManageCoordinate; |
| | | import com.moral.api.entity.ManageCoordinateDetail; |
| | | |
| | | public interface ManageCoordinateDetailMapper extends BaseMapper<ManageCoordinateDetail> { |
| | | |
| | | List<ManageCoordinate> selectCoordinate(); |
| | | |
| | | List<CruiserDTO> getCruiserInfo(Map<String,Object> params); |
| | | |
| | | List<DustldDTO> CompareTo(Integer orgId); |
| | | } |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.moral.api.entity.Organization; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | |
| | | */ |
| | | public interface OrganizationMapper extends BaseMapper<Organization> { |
| | | |
| | | List<Integer> orgIdSpecialDevList(@Param("organizationId") Integer organizationId, @Param("mac") String mac); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | |
| | | public interface SecondCruiserSortMapper extends BaseMapper<SecondCruiserSort> { |
| | | |
| | | void insertAll(List<SecondCruiserSort> list); |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.entity.SysDictData; |
| | | import com.moral.api.entity.SysDictType; |
| | | |
| | | public interface SysDictTypeMapper extends BaseMapper<SysDictType> { |
| | | |
| | | List<SysDictData> selectCodeList(@Param("code") String code, @Param("id") String id); |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | |
| | | /** |
| | | * <p> |
| | | * 走航车秒数据表 服务类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-13 |
| | | */ |
| | | public interface HistorySecondCruiserService extends IService<HistorySecondCruiser> { |
| | | |
| | | void sort(String startTime,String endTime); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.entity.ManageCoordinateDetail; |
| | | |
| | | public interface ManageCoordinateDetailService extends IService<ManageCoordinateDetail> { |
| | | |
| | | /** |
| | | * 路段信息录入 |
| | | */ |
| | | void insertCoordinateDetail(String startTime,String endTime); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | |
| | | public interface SecondCruiserSortService extends IService<SecondCruiserSort> { |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.entity.SysDictData; |
| | | import com.moral.api.entity.SysDictType; |
| | | |
| | | public interface SysDictTypeService extends IService<SysDictType> { |
| | | |
| | | SysDictData listOne(String code, String dataKey); |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.DustldDTO; |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | | import com.moral.api.mapper.ManageCoordinateDetailMapper; |
| | | import com.moral.api.mapper.OrganizationMapper; |
| | | import com.moral.api.mapper.SecondCruiserSortMapper; |
| | | import com.moral.api.service.HistorySecondCruiserService; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName HistorySecondCruiserServiceImpl |
| | | * @date 2024.06.25 14:41 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class HistorySecondCruiserServiceImpl extends ServiceImpl<HistorySecondCruiserMapper, HistorySecondCruiser> implements HistorySecondCruiserService { |
| | | |
| | | @Autowired |
| | | private HistorySecondCruiserMapper historySecondCruiserMapper; |
| | | @Autowired |
| | | private OrganizationMapper organizationMapper; |
| | | @Autowired |
| | | private ManageCoordinateDetailMapper manageCoordinateDetailMapper; |
| | | @Autowired |
| | | private SecondCruiserSortMapper secondCruiserSortMapper; |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void sort(String startTime, String endTime) { |
| | | |
| | | if (ObjectUtils.isEmpty(startTime)&&ObjectUtils.isEmpty(endTime)){ |
| | | //当前时间的前一个小时 |
| | | startTime = DateUtils.getDateStringOfHour(-2, "yyyy-MM-dd HH:00:00"); |
| | | |
| | | //获取当前时间 |
| | | endTime = DateUtils.getCurDate("yyyy-MM-dd HH:00:00"); |
| | | } |
| | | List<HistorySecondCruiser> result = historySecondCruiserMapper.getResult(startTime, endTime); |
| | | |
| | | // |
| | | ArrayList<SecondCruiserSort> list1 = new ArrayList<>(); |
| | | if (!ObjectUtils.isEmpty(result)){ |
| | | for (HistorySecondCruiser historySecondCruiser : result) { |
| | | String mac = historySecondCruiser.getMac(); |
| | | Integer organizationId = historySecondCruiser.getOrganizationId(); |
| | | List<Integer> orgList = organizationMapper.orgIdSpecialDevList(organizationId, mac); |
| | | if(CollectionUtils.isEmpty(orgList)){ |
| | | return; |
| | | } |
| | | |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | params.put("mac",mac); |
| | | params.put("startTime",startTime); |
| | | params.put("endTime",endTime); |
| | | List<Map<String, Object>> dusts = historySecondCruiserMapper.getDusts(params); |
| | | Map<String, List<DustldDTO>> collect = manageCoordinateDetailMapper.CompareTo(orgList.get(0)).stream().collect(Collectors.groupingBy(o -> o.getName())); |
| | | if (ObjectUtils.isEmpty(dusts) || ObjectUtils.isEmpty(collect)){ |
| | | return; |
| | | } |
| | | Set<String> strings = collect.keySet(); |
| | | for (String string : strings) { |
| | | SecondCruiserSort secondCruiserSort = new SecondCruiserSort(); |
| | | ArrayList<Double> doubleArrayList = new ArrayList<>(); |
| | | List<DustldDTO> dustldDTOS = collect.get(string); |
| | | for (DustldDTO dustldDTO : dustldDTOS) { |
| | | String flyLat = dustldDTO.getFlyLat(); |
| | | String flyLon = dustldDTO.getFlyLon(); |
| | | if (flyLon==null && flyLat==null){ |
| | | continue; |
| | | } |
| | | double latDouble1 = Double.parseDouble(flyLat); |
| | | double lonDouble1 = Double.parseDouble(flyLon); |
| | | for (Map<String, Object> dust : dusts) { |
| | | String flyLat1 = Objects.nonNull(dust.get("flyLat")) ? dust.get("flyLat").toString() :"0"; |
| | | String flyLon1 = Objects.nonNull(dust.get("flyLon")) ? dust.get("flyLon").toString() :"0"; |
| | | double latDouble = Double.parseDouble(flyLat1); |
| | | double lonDouble = Double.parseDouble(flyLon1); |
| | | // String flyLon1 = dust.get("flyLon").toString(); |
| | | if (latDouble1==latDouble && lonDouble1==lonDouble){ |
| | | Double dustld = Objects.nonNull(dust.get("dustld"))?Double.parseDouble(dust.get("dustld").toString()):0d; |
| | | doubleArrayList.add(dustld); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (ObjectUtils.isEmpty(doubleArrayList)){ |
| | | continue; |
| | | } |
| | | Double ListAva = doubleArrayList.stream() .collect(Collectors.averagingDouble(Double::doubleValue)); |
| | | double rsAvg = new BigDecimal(ListAva).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | secondCruiserSort.setRoad(string); |
| | | secondCruiserSort.setValue(rsAvg); |
| | | secondCruiserSort.setMac(mac); |
| | | secondCruiserSort.setOrganizationId(organizationId); |
| | | secondCruiserSort.setTime(endTime); |
| | | list1.add(secondCruiserSort); |
| | | } |
| | | } |
| | | } |
| | | if (!ObjectUtils.isEmpty(list1)){ |
| | | // log.info(list1.size()+""); |
| | | secondCruiserSortMapper.insertAll(list1); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.awt.geom.Point2D; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.CruiserDTO; |
| | | import com.moral.api.entity.ManageCoordinate; |
| | | import com.moral.api.entity.ManageCoordinateDetail; |
| | | import com.moral.api.mapper.ManageCoordinateDetailMapper; |
| | | import com.moral.api.service.ManageCoordinateDetailService; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName ManageCoordinateDetailServiceImpl |
| | | * @date 2024.06.19 09:23 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ManageCoordinateDetailServiceImpl extends ServiceImpl<ManageCoordinateDetailMapper, ManageCoordinateDetail> implements ManageCoordinateDetailService { |
| | | |
| | | |
| | | @Autowired |
| | | private ManageCoordinateDetailMapper manageCoordinateDetailMapper; |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void insertCoordinateDetail(String startTime,String endTime) { |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | |
| | | if (ObjectUtils.isEmpty(startTime)&&ObjectUtils.isEmpty(endTime)){ |
| | | //当前时间的前一天 |
| | | startTime = DateUtils.getDateStringOfDay(-1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | //获取当前时间 |
| | | endTime = DateUtils.getCurDate(DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | } |
| | | params.put("startTime",startTime); |
| | | params.put("endTime",endTime); |
| | | |
| | | //获取路段信息 |
| | | List<ManageCoordinate> coordinates = manageCoordinateDetailMapper.selectCoordinate(); |
| | | //获取走航车数据 |
| | | List<CruiserDTO> cruiserInfo = manageCoordinateDetailMapper.getCruiserInfo(params); |
| | | cruiserInfo = cruiserInfo.stream().distinct().collect(Collectors.toList()); |
| | | List<ManageCoordinateDetail> result = new ArrayList<>(); |
| | | for (ManageCoordinate coordinate : coordinates) { |
| | | String value = coordinate.getValue(); |
| | | if (!ObjectUtils.isEmpty(value)){ |
| | | List<Map<String, Object>> parse = (List<Map<String, Object>>) JSONArray.parse(value); |
| | | |
| | | for (int i = 0; i < cruiserInfo.size(); i++) { |
| | | CruiserDTO cruiserDTO = cruiserInfo.get(i); |
| | | if (ObjectUtils.isEmpty(cruiserDTO)){ |
| | | continue; |
| | | } |
| | | Double flyLat = cruiserDTO.getFlyLat(); |
| | | Double flyLon = cruiserDTO.getFlyLon(); |
| | | if (ObjectUtils.isEmpty(flyLat)||ObjectUtils.isEmpty(flyLon)){ |
| | | continue; |
| | | } |
| | | boolean inPolygon = isInPolygon(flyLon, flyLat, parse); |
| | | if (inPolygon){ |
| | | LambdaQueryWrapper<ManageCoordinateDetail> wr = new LambdaQueryWrapper<>(); |
| | | wr.eq(ManageCoordinateDetail::getLongitude,flyLon); |
| | | wr.eq(ManageCoordinateDetail::getLatitude,flyLat); |
| | | List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(wr); |
| | | if (ObjectUtils.isEmpty(manageCoordinateDetails)){ |
| | | ManageCoordinateDetail rsDTO = new ManageCoordinateDetail(); |
| | | rsDTO.setLatitude(flyLat); |
| | | rsDTO.setLongitude(flyLon); |
| | | rsDTO.setState("2"); |
| | | rsDTO.setCreateTime(new Date()); |
| | | rsDTO.setUpdateTime(new Date()); |
| | | rsDTO.setCoordinateId(coordinate.getCoordinateId()); |
| | | result.add(rsDTO); |
| | | cruiserInfo.remove(i); |
| | | i--; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(result)){ |
| | | this.saveBatch(result); |
| | | // log.info(result.size()+""); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断当前位置是否在多边形区域内 |
| | | * @param |
| | | * @param mapList 区域顶点 |
| | | * @return |
| | | */ |
| | | public static boolean isInPolygon(Double X,Double Y,List<Map<String, Object>> mapList){ |
| | | |
| | | |
| | | Point2D.Double point = new Point2D.Double(X, Y); |
| | | List<Point2D.Double> pointList= new ArrayList<Point2D.Double>(); |
| | | |
| | | for (Map<String, Object> param : mapList) { |
| | | //纬度 |
| | | String lat = param.get("lat").toString(); |
| | | //经度 |
| | | String lng = param.get("lng").toString(); |
| | | Point2D.Double polygonPoint = new Point2D.Double(Double.parseDouble(lng),Double.parseDouble(lat)); |
| | | pointList.add(polygonPoint); |
| | | } |
| | | return IsPtInPoly(point,pointList); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 判断点是否在多边形内,如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true |
| | | * @param point 检测点 |
| | | * @param pts 多边形的顶点 |
| | | * @return 点在多边形内返回true,否则返回false |
| | | */ |
| | | public static boolean IsPtInPoly(Point2D.Double point, List<Point2D.Double> pts){ |
| | | |
| | | int N = pts.size(); |
| | | boolean boundOrVertex = true; //如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true |
| | | int intersectCount = 0;//cross points count of x |
| | | double precision = 2e-10; //浮点类型计算时候与0比较时候的容差 |
| | | Point2D.Double p1, p2;//neighbour bound vertices |
| | | Point2D.Double p = point; //当前点 |
| | | |
| | | p1 = pts.get(0);//left vertex |
| | | for(int i = 1; i <= N; ++i){//check all rays |
| | | if(p.equals(p1)){ |
| | | return boundOrVertex;//p is an vertex |
| | | } |
| | | |
| | | p2 = pts.get(i % N); |
| | | if(p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)){ |
| | | p1 = p2; |
| | | continue; |
| | | } |
| | | |
| | | if(p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)){ |
| | | if(p.y <= Math.max(p1.y, p2.y)){ |
| | | if(p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)){ |
| | | return boundOrVertex; |
| | | } |
| | | |
| | | if(p1.y == p2.y){ |
| | | if(p1.y == p.y){ |
| | | return boundOrVertex; |
| | | }else{//before ray |
| | | ++intersectCount; |
| | | } |
| | | }else{ |
| | | double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y; |
| | | if(Math.abs(p.y - xinters) < precision){ |
| | | return boundOrVertex; |
| | | } |
| | | |
| | | if(p.y < xinters){ |
| | | ++intersectCount; |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | if(p.x == p2.x && p.y <= p2.y){ |
| | | Point2D.Double p3 = pts.get((i+1) % N); |
| | | if(p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)){ |
| | | ++intersectCount; |
| | | }else{ |
| | | intersectCount += 2; |
| | | } |
| | | } |
| | | } |
| | | p1 = p2; |
| | | } |
| | | |
| | | if(intersectCount % 2 == 0){//偶数在多边形外 |
| | | return false; |
| | | } else { //奇数在多边形内 |
| | | return true; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.SecondCruiserSort; |
| | | import com.moral.api.mapper.SecondCruiserSortMapper; |
| | | import com.moral.api.service.SecondCruiserSortService; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName SecondCruiserSortServiceImpl |
| | | * @date 2024.06.26 14:29 |
| | | */ |
| | | @Service |
| | | public class SecondCruiserSortServiceImpl extends ServiceImpl<SecondCruiserSortMapper, SecondCruiserSort> implements SecondCruiserSortService { |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.SysDictData; |
| | | import com.moral.api.entity.SysDictType; |
| | | import com.moral.api.mapper.SysDictTypeMapper; |
| | | import com.moral.api.service.SysDictTypeService; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName SysDictTypeServiceImpl |
| | | * @date 2024.06.25 14:10 |
| | | */ |
| | | @Service |
| | | public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService { |
| | | |
| | | |
| | | @Override |
| | | public SysDictData listOne(String code, String dataKey) { |
| | | List<SysDictData> list = this.baseMapper.selectCodeList(code,dataKey); |
| | | SysDictData sysDictData = new SysDictData(); |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | return list.get(0); |
| | | } |
| | | sysDictData.setDataValue("0"); |
| | | return sysDictData; |
| | | |
| | | } |
| | | } |
| | |
| | | import com.moral.api.service.HistoryFiveMinutelyService; |
| | | import com.moral.api.service.HistoryHourlyService; |
| | | import com.moral.api.service.HistoryMonthlyService; |
| | | import com.moral.api.service.HistorySecondCruiserService; |
| | | import com.moral.api.service.HistoryWeeklyService; |
| | | import com.moral.api.service.ManageCoordinateDetailService; |
| | | import com.moral.api.service.impl.HistorySecondCruiserServiceImpl; |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.context.XxlJobHelper; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | |
| | | |
| | | @Autowired |
| | | private HistoryMonthlyService historyMonthlyService; |
| | | |
| | | |
| | | @Autowired |
| | | private ManageCoordinateDetailService manageCoordinateDetailService; |
| | | |
| | | |
| | | @Autowired |
| | | private HistorySecondCruiserService historySecondCruiserService; |
| | | |
| | | //5分钟数据统计 |
| | | @XxlJob("insertHistoryFiveMinutely") |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 路段信息录入 |
| | | * @return |
| | | */ |
| | | @XxlJob("manageCoordinateDetail") |
| | | public ReturnT manageCoordinateDetail(){ |
| | | try { |
| | | manageCoordinateDetailService.insertCoordinateDetail(null,null); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return new ReturnT(ReturnT.FAIL_CODE, e.getMessage()); |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 走航车路段排名 |
| | | * @return |
| | | */ |
| | | @XxlJob("secondCruiserSort") |
| | | public ReturnT secondCruiserSort(){ |
| | | try { |
| | | historySecondCruiserService.sort(null,null); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return new ReturnT(ReturnT.FAIL_CODE, e.getMessage()); |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.HistorySecondCruiserMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.HistorySecondCruiser"> |
| | | <result column="mac" property="mac"/> |
| | | <result column="time" property="time"/> |
| | | <result column="value" property="value"/> |
| | | <result column="organization_id" property="organizationId"/> |
| | | <result column="batch" property="batch"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="getDusts" resultType="java.util.Map"> |
| | | SELECT |
| | | value ->>'$.flylat' as flyLat,value ->>'$.flylon' as flyLon,value ->>'$.dustld' as dustld, |
| | | `time` |
| | | FROM `history_second_cruiser` |
| | | WHERE mac = #{mac} |
| | | AND `time` <![CDATA[>=]]> #{startTime} |
| | | AND `time` <![CDATA[<]]> #{endTime} |
| | | </select> |
| | | |
| | | <select id="getResult" resultType="com.moral.api.entity.HistorySecondCruiser"> |
| | | SELECT |
| | | distinct mac,organization_id |
| | | FROM `history_second_cruiser` |
| | | WHERE |
| | | `time` <![CDATA[>=]]> #{startTime} |
| | | AND `time` <![CDATA[<=]]> #{endTime} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.ManageCoordinateDetailMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.ManageCoordinateDetail"> |
| | | <id column="id" property="id" /> |
| | | <result column="coordinate_id" property="coordinateId" /> |
| | | <result column="longitude" property="longitude" /> |
| | | <result column="latitude" property="latitude" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="update_user_id" property="updateUserId" /> |
| | | <result column="updaye_user_name" property="updayeUserName" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="selectCoordinate" resultType="com.moral.api.entity.ManageCoordinate"> |
| | | SELECT * FROM manage_coordinate WHERE is_del =0 |
| | | </select> |
| | | |
| | | <select id="getCruiserInfo" resultType="com.moral.api.entity.CruiserDTO"> |
| | | select DATE_FORMAT(`time`, #{dateFormat}) AS time,value ->>'$.flylat' as flyLat,value ->>'$.flylon' as flyLon |
| | | from history_second_cruiser |
| | | WHERE |
| | | `time` <![CDATA[>=]]> #{startTime} |
| | | AND `time` <![CDATA[<=]]> #{endTime} |
| | | order by time |
| | | </select> |
| | | |
| | | <select id="CompareTo" resultType="com.moral.api.entity.DustldDTO"> |
| | | SELECT |
| | | mc.start_point as name , |
| | | md.longitude as flyLon, |
| | | md.latitude as flyLat |
| | | FROM |
| | | manage_coordinate AS mc |
| | | LEFT JOIN manage_coordinate_detail AS md ON mc.coordinate_id = md.coordinate_id |
| | | WHERE |
| | | mc.is_del =0 |
| | | and mc.organization_id=#{orgId} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <result column="is_delete" property="isDelete" /> |
| | | </resultMap> |
| | | |
| | | <select id="orgIdSpecialDevList" resultType="java.lang.Integer"> |
| | | select organization_id from special_device where 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 ) and mac = #{mac} and is_delete = 0 |
| | | |
| | | |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.SecondCruiserSortMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.SecondCruiserSort"> |
| | | <result column="road" property="road"/> |
| | | <result column="time" property="time"/> |
| | | <result column="value" property="value"/> |
| | | <result column="mac" property="mac"/> |
| | | <result column="organization_id" property="organizationId"/> |
| | | </resultMap> |
| | | |
| | | <insert id="insertAll"> |
| | | INSERT INTO second_cruiser_sort (road,time,value,mac,organization_id) |
| | | VALUES |
| | | <foreach collection="list" item="item" separator=","> |
| | | (#{item.road},#{item.time},#{item.value},#{item.mac},#{item.organizationId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.SysDictTypeMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.SysDictType"> |
| | | <id column="id" property="id" /> |
| | | <result column="name" property="name" /> |
| | | <result column="desc" property="desc" /> |
| | | <result column="system" property="system" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="is_delete" property="isDelete" /> |
| | | </resultMap> |
| | | <select id="selectCodeList" resultType="com.moral.api.entity.SysDictData"> |
| | | select t1.id,t1.dict_type_id,t1.dataKey,t1.dataValue from sys_dict_type t |
| | | left join sys_dict_data t1 on t1.dict_type_id = t.id |
| | | where t.is_delete = 0 and t.name = #{code} and t1.dataKey = #{id} and t1.is_delete = 0 |
| | | order by t1.create_time desc |
| | | </select> |
| | | |
| | | |
| | | </mapper> |