Merge remote-tracking branch 'origin/master'

This commit is contained in:
wuweida 2022-05-10 09:03:29 +08:00
commit 5399a21056
9 changed files with 238 additions and 59 deletions

View File

@ -25,6 +25,7 @@
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.72</version> <version>1.2.72</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
@ -41,6 +42,11 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

View File

@ -6,11 +6,14 @@ import com.hisense.monitormanage.dto.ScenicCameraDto;
import com.hisense.monitormanage.entity.*; import com.hisense.monitormanage.entity.*;
import com.hisense.monitormanage.mapper.*; import com.hisense.monitormanage.mapper.*;
import com.hisense.monitormanage.service.MonitorService; import com.hisense.monitormanage.service.MonitorService;
import com.hisense.monitormanage.service.SedimentTrailService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.lang.reflect.Method;
import java.time.Clock; import java.time.Clock;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
@ -33,6 +36,9 @@ public class Controller {
@Autowired @Autowired
private MonitorService monitorService; private MonitorService monitorService;
@Autowired
private SedimentTrailService sedimentTrailService;
@Autowired @Autowired
private CameraChannelMapper cameraChannelMapper; private CameraChannelMapper cameraChannelMapper;
@ -213,58 +219,6 @@ public class Controller {
return monitorService.suggest(map); return monitorService.suggest(map);
} }
//根据用户已输入的文字请求匹配的地址信息
//singleLine:用户输入的文字性地名地址信息必填
//maxSuggestions最大建议数量0~10默认2
//magicKey:地名地址唯一ID,Suggest操作返回的JSON数组中包含的magicKey
//outSR:坐标系信息,包含"wkid"属性是表示空间参考的ID示例{ "wkid":4490 }
@RequestMapping("geocode")
public Result geocode(
@RequestParam(value="singleLine") String singleLine,
@RequestParam(value = "maxSuggestions",required = false,defaultValue = "2") Integer maxSuggestions,
@RequestParam(value = "magicKey",required = false,defaultValue = "") String magicKey,
@RequestParam(value = "outSR",required = false,defaultValue = "") String outSR
){
Map<String,Object> map = new HashMap<>();
map.put("SingleLine",singleLine);
map.put("maxSuggestions",maxSuggestions);
map.put("magicKey",magicKey);
map.put("outSR",outSR);
return monitorService.geocode(map);
}
//根据用户已输入的坐标请求附近的地址信息
//location:坐标,必填,请注意编码示例{"x":120.40632244540544,"y":36.08136665300961,"spatialReference":{"wkid":4490,"latestWkid":4490}}
@RequestMapping("reverseGeocode")
public Result reverseGeocode(
@RequestParam(value="location") String location
){
Map<String,Object> map = new HashMap<>();
map.put("location",location);
return monitorService.reverseGeocode(map);
}
//查询视频点播巡检结果只取异常的
@RequestMapping("listChannelPlayStates")
public Result listChannelPlayStates(
@RequestParam(value="page",required = false,defaultValue = "1") Integer page,
@RequestParam(value="pageSize",required = false,defaultValue = "20") String pageSize
){
Map<String,Object> condition = new HashMap<>();
LocalDateTime localDateTime = LocalDateTime.now(Clock.systemUTC());
LocalDateTime startTime = localDateTime.minusDays(7);
condition.put("checkStatus",0);
condition.put("startTime",startTime.toString());
condition.put("endTime",localDateTime.toString());
Map<String,Object> map = new HashMap<>();
map.put("condition",condition);
map.put("page",page);
map.put("pageSize",pageSize);
monitorService.listChannelPlayStates(map);
return null;
}
//道路统计数据与排名 //道路统计数据与排名
@RequestMapping("roadData") @RequestMapping("roadData")
@ -313,7 +267,23 @@ public class Controller {
return monitorService.resCatalogApplyHJWSRoad(); return monitorService.resCatalogApplyHJWSRoad();
} }
//获取渣土车轨迹并保存到t_trail_sediment
@RequestMapping(value = "saveResCatalogApplyZTYS")
public boolean resCatalogApplyZTYS(){
return sedimentTrailService.batchSaveSedimentTrail();
}
//根据输入的经纬度和查询的半径时间查询范围内的渣土车轨迹信息
@RequestMapping(value = "listSedimentTrailByPoints")
public List<SedimentTrail> listSedimentTrailByPoints(
@RequestParam(value="longitude") double longitude,
@RequestParam(value="latitude") double latitude,
@RequestParam(value="raidus") Integer raidus,
@RequestParam(value="start") String start,
@RequestParam(value = "end") String end
){
System.out.println("listSedimentTrailByPoints......");
return sedimentTrailService.listSedimentTrailByPoints(longitude,latitude,raidus,start,end);
}
} }

View File

@ -0,0 +1,41 @@
package com.hisense.monitormanage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author admin
* @version 1.0.0
* @ClassName SedimentTrail.java
* @Description 渣土车轨迹
* @createTime 2022年05月09日 13:47:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_trail_sediment")
public class SedimentTrail{
@TableId
private Integer id;
private double speed;
private String simCardNum;
private LocalDateTime uploadtime;
private double coordinateX;
private double coordinateY;
private double longitude;
private double latitude;
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime recordTime;
private double angle;
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime updateTime;
private String status;
private double fuel;
}

View File

@ -0,0 +1,18 @@
package com.hisense.monitormanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.monitormanage.entity.SedimentTrail;
import java.util.List;
import java.util.Map;
/**
* @author admin
* @version 1.0.0
* @ClassName sedimentTrailMapper.java
* @Description TODO
* @createTime 2022年05月09日 13:59:00
*/
public interface SedimentTrailMapper extends BaseMapper<SedimentTrail> {
public void batchaSave(List<Map> list);
}

View File

@ -582,15 +582,15 @@ public class MonitorService {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token); headers.add("Authorization", "Bearer " + token);
// Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
// JSONObject search = new JSONObject(); JSONObject search = new JSONObject();
// search.put("opt","LIKE"); search.put("opt","LIKE");
// search.put("key","updatetime"); search.put("key","updatetime");
// search.put("val",this.dateStr()); search.put("val",this.dateStr());
// search.put("opt","EQ"); // search.put("opt","EQ");
// search.put("key","SSDQ"); // search.put("key","SSDQ");
// search.put("val","西海岸新区"); // search.put("val","西海岸新区");
// map.put("json",search); map.put("json",search);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers); HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity; ResponseEntity<JSONObject> responseEntity;

View File

@ -0,0 +1,59 @@
package com.hisense.monitormanage.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.hisense.monitormanage.entity.SedimentTrail;
import com.hisense.monitormanage.mapper.SedimentTrailMapper;
import com.hisense.monitormanage.utils.LongLatUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
* @author admin
* @version 1.0.0
* @ClassName SedimentTrailService.java
* @Description TODO
* @createTime 2022年05月09日 14:01:00
*/
@Service
@Log4j2
public class SedimentTrailService {
@Autowired
private SedimentTrailMapper sedimentTrailMapper;
@Autowired
private MonitorService monitorService;
//获取渣土车轨迹并保存到表t_trail_sediment
@Transactional(rollbackFor = Exception.class)
public boolean batchSaveSedimentTrail(){
try{
List<Map> maps = monitorService.resCatalogApplyZTYS();
Lists.partition(maps,200).forEach(
item-> sedimentTrailMapper.batchaSave(item)
);
return true;
}catch (Exception e){
log.error("[batchSaveSedimentTrail] exception:{}",e.getMessage());
return false;
}
}
/**
* 根据输入的经纬度和查询的半径查询范围内的渣土车轨迹信息
* @param longitude经度 latitude纬度 raidus() start(时间) end(时间)
*
*/
public List<SedimentTrail> listSedimentTrailByPoints(double longitude, double latitude, Integer raidus,String start,String end){
double[] points = LongLatUtil.getAround(longitude,latitude,raidus);
QueryWrapper<SedimentTrail> wrapper = new QueryWrapper<>();
wrapper.between("update_time",start,end).between("longitude",points[0],points[2]).between("latitude",points[1],points[3]);
return sedimentTrailMapper.selectList(wrapper);
}
}

View File

@ -0,0 +1,63 @@
package com.hisense.monitormanage.utils;
/**
* @author admin
* @version 1.0.0
* @ClassName LongLatUtil.java
* @Description TODO
* @createTime 2022年05月09日 09:54:00
*/
public class LongLatUtil {
private static final double PI = 3.1415926;
/**
* 计算地球上任意两点(经纬度)距离
*
* @param long1 第一点经度
* @param lat1 第一点纬度
* @param long2 第二点经度
* @param lat2 第二点纬度
* @return 返回距离 单位
*/
public static double distanceByLongNLat(double long1, double lat1, double long2, double lat2) {
double a, b, R;
R = 6378137;//地球半径
lat1 = lat1 * Math.PI / 180.0;
lat2 = lat2 * Math.PI / 180.0;
a = lat1 - lat2;
b = (long1 - long2) * Math.PI / 180.0;
double d;
double sa2, sb2;
sa2 = Math.sin(a / 2.0);
sb2 = Math.sin(b / 2.0);
d = 2 * R * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1) * Math.cos(lat2) * sb2 * sb2));
return d;
}
/**
* 根据经纬度和半径计算经纬度范围
*
* @param raidus 单位米
* @return minLat, minLng, maxLat, maxLng
*/
public static double[] getAround(double lon,double lat, int raidus) {
Double latitude = lat;
Double longitude = lon;
Double degree = (24901 * 1609) / 360.0;
double raidusMile = raidus;
Double dpmLat = 1 / degree;
Double radiusLat = dpmLat * raidusMile;
Double minLat = latitude - radiusLat;
Double maxLat = latitude + radiusLat;
Double mpdLng = degree * Math.cos(latitude * (PI / 180));
Double dpmLng = 1 / mpdLng;
Double radiusLng = dpmLng * raidusMile;
Double minLng = longitude - radiusLng;
Double maxLng = longitude + radiusLng;
return new double[]{minLng,minLat, maxLng, maxLat};
}
}

View File

@ -10,12 +10,15 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# 数据源名称 # 数据源名称
spring.datasource.name=defaultDataSource spring.datasource.name=defaultDataSource
# 数据库连接地址 # 数据库连接地址
#spring.datasource.url=jdbc:mysql://15.72.183.91:3306/monitor_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
spring.datasource.url=jdbc:mysql://15.72.183.91:3306/monitor_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 spring.datasource.url=jdbc:mysql://15.72.183.91:3306/monitor_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# 数据库用户名&密码: # 数据库用户名&密码:
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=w@CmM1mBVQkPhdrc spring.datasource.password=w@CmM1mBVQkPhdrc
#spring.datasource.password=123456
hwx.file.work-path=/Users/huangweixiong/Downloads/ hwx.file.work-path=/Users/huangweixiong/Downloads/
hwx.file.pic-host=http://127.0.0.1:7009 hwx.file.pic-host=http://127.0.0.1:7009
spring.resources.static-locations=classpath:/static,classpath:/public,file:${hwx.file.work-path} spring.resources.static-locations=classpath:/static,classpath:/public,file:${hwx.file.work-path}
mybatis-plus.mapper-locations=classpath*:/mapper/*.xml

View File

@ -0,0 +1,19 @@
<?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.hisense.monitormanage.mapper.SedimentTrailMapper">
<insert id="batchaSave" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";" >
INSERT INTO t_trail_sediment
(speed,sim_card_num,uploadtime,coordinate_x,coordinate_y,
longitude,latitude,record_time,angle,update_time,status,fuel)
VALUES
(
#{item.SPEED},#{item.SIMCARDNUM},#{item.UPLOADTIME},#{item.COORDINATEX},#{item.COORDINATEY},
#{item.LONGITUDE},#{item.LATITUDE},#{item.RECORDTIME},#{item.ANGEL},#{item.updatetime},
#{item.STATUS},#{item.FUEL}
)
</foreach>
</insert>
</mapper>