chen_xi
2023-06-28 95a6e4392acc0f559b78c7300fdb3e5155e89795
部分提交
4 files modified
90 ■■■■ changed files
screen-api/src/main/java/com/moral/api/controller/CruiserController.java 23 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java 3 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java 42 ●●●● patch | view | raw | blame | history
screen-api/src/main/resources/application-local.yml 22 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/CruiserController.java
@@ -77,17 +77,34 @@
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String")
            @ApiImplicitParam(name = "time1", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time2", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage carTrajectory(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac") || !params.containsKey("time1")|| !params.containsKey("time2")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<Map<String, Object>> response = specialDeviceService.carTrajectory(params);
        List<Map<String, Object>> response = specialDeviceService.carTrajectory(params,true);
        return ObjectUtils.isEmpty(response) ? ResultMessage.ok() : ResultMessage.ok(response);
    }
    @GetMapping("carTrajectoryNewAvg")
    @ApiOperation(value = "走航车轨迹均值", notes = "走航车轨迹均值")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time1", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time2", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "type", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage carTrajectoryNewAvg(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac") || !params.containsKey("time1")|| !params.containsKey("time2")|| !params.containsKey("type")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<Map<String, Object>> response = specialDeviceService.carTrajectory(params,false);
        return ObjectUtils.isEmpty(response) ? ResultMessage.ok() : ResultMessage.ok(response);
    }
    /**
     * 走航车日报
screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java
@@ -25,7 +25,8 @@
    List<Map<String, Object>> selectCruisers();
    //走航车轨迹
    List<Map<String, Object>> carTrajectory(Map<String, Object> params);
    List<Map<String, Object>> carTrajectory(Map<String, Object> params,boolean type);
    /**
    * @Description: 根据mac号获取无人机数据
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java
@@ -32,6 +32,7 @@
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
@@ -103,7 +104,7 @@
    }
    @Override
    public List<Map<String, Object>> carTrajectory(Map<String, Object> params) {
    public List<Map<String, Object>> carTrajectory(Map<String, Object> params,boolean type) {
        params.put("dateFormat", "%Y-%m-%d %H:%i:%s");
        Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo();
        Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization");
@@ -126,7 +127,12 @@
            if (lon < 70 || lon > 150 || lat < 20 || lat > 60) {
                return true;
            }
            if(type){
            o.putAll(value);
            }else {
            }
            return false;
        });
        /*for (Map<String, Object> map:data) {
@@ -142,7 +148,6 @@
        }*/
        return filterData(data);
    }
    @Override
    public SpecialDevice getSpecialDeviceMapByMac(String mac) {
        QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper();
@@ -182,7 +187,7 @@
        String time2 = params.get("time2").toString();
        String rsTime = getTime(time1, time2);
        list.add(rsTime);
        List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params);
        List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params,false);
        if (ObjectUtils.isEmpty(maps)){
            return null;
        }
@@ -194,7 +199,7 @@
            map.put("time1",time3);
            map.put("time2",time4);
            map.put("mac",mac);
            List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map);
            List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false);
            if (ObjectUtils.isEmpty(maps1)){
                return null;
            }
@@ -210,7 +215,7 @@
            map.put("time1",time5);
            map.put("time2",time6);
            map.put("mac",mac);
            List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map);
            List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false);
            if (ObjectUtils.isEmpty(maps1)){
                return null;
            }
@@ -495,6 +500,33 @@
                result.add(map);
            }
        }
        return result;
    }
    //范围取均值
    private List<Map<String, Object>> filterData(List<Map<String, Object>> data, List<Map<String, Object>> result) {
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String,List<Object>> map = new HashMap<>();
        result.forEach(it->map.put(it.get(Constants.SENSOR_CODE_LON).toString()+ "_"+Constants.SENSOR_CODE_LAT.toString(),Arrays.asList(it)));
        // 坐标在50 以内分组
        for (Map<String, Object> mapData : data) {
            for (Map.Entry<String, List<Object>> entry : map.entrySet()) {
                double lng1 = Double.parseDouble(mapData.get(Constants.SENSOR_CODE_LON).toString());
                double lat1 = Double.parseDouble(mapData.get(Constants.SENSOR_CODE_LAT).toString());
                String[] mapKey = entry.getKey().split("_");
                List<Object> mapValue = entry.getValue();
                double lng2 = Double.parseDouble(mapKey[0]);
                double lat2 = Double.parseDouble(mapKey[1]);
                double distance = GeodesyUtils.getDistance(lat1, lng1, lat2, lng2);
                if (distance < dis) {
                    mapValue.add(mapData);
                }
            }
        }
        return list;
    }
}
screen-api/src/main/resources/application-local.yml
@@ -13,8 +13,9 @@
spring:
  profiles:
    active: dev
    include: bulletin, specialCity, announcement
  application:
    name: screen-manage
    name: screen-api
  redis:
    host: r-bp1xdlb9wfc6zt0msppd.redis.rds.aliyuncs.com
    port: 6379
@@ -43,7 +44,6 @@
      max-wait: 30000
      max-idle: 64
      min-idle: 32
  datasource:
    minIdle: 1
    time-between-eviction-runs-millis: 60000
@@ -53,7 +53,7 @@
    filters: stat
    type: com.alibaba.druid.pool.DruidDataSource
    max-wait: 60000
    url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk8o.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk8o2.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: moral_123456
    test-on-borrow: false
@@ -64,6 +64,12 @@
    driver-class-name: com.mysql.cj.jdbc.Driver
    max-conn-lifetime-millis: 20
    test-on-return: false
  servlet:
    multipart:
      enabled: true
      max-file-size: 10MB
      max-request-size: 10MB
mybatis-plus:
  mapper-locations: classpath:mapper/*.xml
@@ -79,12 +85,15 @@
kafka:
  listener:
    # 自动提交关闭,需要设置手动消息确认
    ack-mode: manual_immediate
  consumer:
    auto:
      offset:
        reset: latest
    # 在侦听器容器中运行的线程数,一般设置为 机器数*分区数
    concurrency: 3
    # 是否自动提交偏移量,默认值是true,为了避免出现重复数据和数据丢失,可以把它设置为false,然后手动提交偏移量
    enable:
      auto:
        commit: false
@@ -99,8 +108,12 @@
    buffer:
      memory: 40960
    linger: 1
    # 发生错误后,消息重发的次数。
    retries: 0
    servers: 47.99.145.48:9092,47.111.116.38:9092,47.111.124.159:9092
  groupId:
    second-data: SecondsDataGroup1
    cruiser-data: cruiserDataGroup1
mvc:
  interceptor:
    exclude:
@@ -110,6 +123,9 @@
      - /swagger-ui.html/**
      - /webjars/**
      - /verificationCode/**
      - /static/**
      - /file/**
AES:
  KEY: