jinpengyong
2024-06-20 d0b261f701c86f55dd04365c620fb6f79cbe5c62
fix:盐城热力图接口修改提交
4 files modified
162 ■■■■ changed files
screen-api/src/main/java/com/moral/api/controller/HeatMapController.java 6 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/DataDisplayService.java 2 ●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java 151 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/DeviceMapper.xml 3 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/HeatMapController.java
@@ -40,9 +40,9 @@
     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")
screen-api/src/main/java/com/moral/api/service/DataDisplayService.java
@@ -51,5 +51,5 @@
    List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form);
    List<HeatMapDTO> getHeatMapDataV2(Integer id, String startTime, String type, String form,Integer monitorId);
}
screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java
@@ -571,10 +571,11 @@
    }
    @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<>();
@@ -685,7 +686,125 @@
                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;
@@ -724,7 +843,7 @@
               }
               lat1 =lat1-0.0022;
           }
       }
       }*/
        return distrinList(rsHeatMap);
    }
@@ -743,21 +862,23 @@
            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();
screen-api/src/main/resources/mapper/DeviceMapper.xml
@@ -251,6 +251,9 @@
        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=",">