于紫祥_1901
2020-08-24 53217a560fecddcf8ff5b7583532f49381b14d80
风场图update
4 files modified
159 ■■■■■ changed files
src/main/java/com/moral/mapper/DeviceMapper.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 126 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/DeviceMapper.xml 24 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/MonitorPointMapper.xml 3 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/DeviceMapper.java
@@ -65,10 +65,12 @@
    DeviceAndWind getDeviceAndWindByMac(@Param("mac") String mac,@Param("time") String time,
                                        @Param("table") String table);
    List<DeviceAndWind> byMonitorIdGetDeviceAndWind(@Param("id") int id,@Param("time") String time,
                                                    @Param("table") String table);
    List<DeviceAndWind> byMonitorIdGetDeviceAndWind(@Param("id") int id,@Param("time") String time, @Param("table") String table);
    DeviceAndWind byMacGetDeviceAndWind(@Param("mac") String mac,@Param("time") String time, @Param("table") String table);
    List<Device> getDeviceListByMonitorPointIds(List<Integer> list);
    Map<String, Object> selectAllFieldByMac(Map<String, Object> params);
    List getDeviceByCode(Map<String, Object> params);
}
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -720,12 +720,10 @@
    @Override
    public List byMonitorIdGetDeviceAndWind(String id,String time,String tab) {
        List<DeviceAndWind> deviceAndWinds=deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id),time,tab);
        System.out.println(time);
        List loList=new ArrayList();
        List laList=new ArrayList();
        Double U=0.0;
        Double V=0.0;
        log.info(deviceAndWinds.size());
        List list=new ArrayList();
        for (DeviceAndWind andWind : deviceAndWinds) {
            Double lo=andWind.getLongitude();
@@ -869,7 +867,6 @@
        List transList= LatLngTransformation.Convert_BD09_To_GCJ02(monitorLa,monitorLo);
        Double transLo=(Double) transList.get(0);
        Double transLa=(Double) transList.get(1);
        list.add(jsonArray);
        list.add(transLo);
        list.add(transLa);
@@ -879,25 +876,63 @@
    @Override
    public List byMonitorIdGetDeviceAndWindSpecial(String id, String time, String tab) {
        List<DeviceAndWind> deviceAndWinds=deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id),time,tab);
        MonitorPoint monitorPoint=monitorPointMapper.byIdGetMonitorPoint(Integer.parseInt(id));
        Integer areaCode=monitorPoint.getAreaCode();
        String townCode= monitorPoint.getTownCode()+"";
        Map<String, Object> parm=new HashMap<>();
        List<DeviceAndWind> deviceAndWinds=new ArrayList<>();
        Double  loma= 0.0;
        Double  lomi= 0.0;
        Double  lama= 0.0;
        Double  lami= 0.0;
        int length=1;
        int perdlen=1;
        if (areaCode==320581){
            parm.put("areaCode",areaCode);
            List<Device> deviceList=deviceMapper.getDeviceByCode(parm);
            for (Device d : deviceList) {
                String mac=d.getMac();
                 DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac,time,tab);
                 if (deviceAndWind!=null){
                     deviceAndWinds.add(deviceAndWind);
                 }
            }
            length=8000;
            perdlen=2200;
        }else if ((areaCode == 320583) && (townCode.equals("320583108000"))){
            parm.put("townCode",townCode);
            List<Device> deviceList=deviceMapper.getDeviceByCode(parm);
            for (Device d : deviceList) {
                String mac=d.getMac();
                DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac,time,tab);
                if (deviceAndWind!=null){
                    deviceAndWinds.add(deviceAndWind);
                }
            }
            length=2000;
            perdlen=280;
        }else {
            deviceAndWinds=deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id),time,tab);
            length=2000;
            perdlen=80;
        }
        List loList=new ArrayList();
        List laList=new ArrayList();
        Double U=0.0;
        Double V=0.0;
        List list=new ArrayList();
        for (DeviceAndWind andWind : deviceAndWinds) {
            Double lo=andWind.getLongitude();
            Double la=andWind.getLatitude();
            List tranlist= LatLngTransformation.Convert_BD09_To_GCJ02(la,lo);
            Double transLo=(Double) tranlist.get(0);
            Double transLa=(Double) tranlist.get(1);
            loList.add(transLo);
            laList.add(transLa);
                Double lo=andWind.getLongitude();
                Double la=andWind.getLatitude();
                List tranlist= LatLngTransformation.Convert_BD09_To_GCJ02(la,lo);
                Double transLo=(Double) tranlist.get(0);
                Double transLa=(Double) tranlist.get(1);
                loList.add(transLo);
                laList.add(transLa);
        }
        Double  loma= 0.0;
        Double  lomi= 0.0;
        Double  lama= 0.0;
        Double  lami= 0.0;
        if (loList.size()>0){
            loma= (Double) Collections.max(loList);
            lomi= (Double) Collections.min(loList);
@@ -912,17 +947,15 @@
        laLaMap.put("maxLa",lama);
        laLaMap.put("minLa",lami);
        Double lo1=lomi-2000*0.00001141;
        Double lo2=loma+2000*0.00001141;
        Double la2=lami-2000*0.00000899;
        Double la1=lama+2000*0.00000899;
        Double lo1=lomi-length*0.00001141;
        Double lo2=loma+length*0.00001141;
        Double la2=lami-length*0.00000899;
        Double la1=lama+length*0.00000899;
        Double dx=0.00001141*70;
        Double dy=0.00000899*70;
        Double dx=0.00001141*perdlen;
        Double dy=0.00000899*perdlen;
        int nx=(int) Math.floor((lo2-lo1)/dx);
        int ny=(int) Math.floor((la1-la2)/dy);
        System.out.println(nx+"----"+ny);
        String header1 = "\"" + "header" + "\"" + ": " + "{" + "\"" + "parameterUnit" + "\"" + ": " + "\"" + "m/s" + "\"" + ", " + "\"" + "parameterNumber" + "\"" + ": " + 2 +
                ", " + "\"" + "dx" + "\"" + ": " + dx + ", " + "\"" + "dy" + "\"" + ": " + dy +
                ", " + "\"" + "parameterNumberName" + "\"" + ": " + "\"" + "eastward_wind" + "\"" + ", " + "\"" + "la1" + "\"" + ": " + la1 + ", " + "\"" + "la2" + "\"" + ": " + la2 +
@@ -942,31 +975,30 @@
        List<Map> mapList=new ArrayList<Map>();
        for (int j = 0; j <deviceAndWinds.size() ; j++) {
            Map<String,Double> map=new HashMap<String,Double> ();
            Double windDir= deviceAndWinds.get(j).getWindDir();
                Map<String,Double> map=new HashMap<String,Double> ();
                Double windDir= deviceAndWinds.get(j).getWindDir();
                Double windSpeed=deviceAndWinds.get(j).getWindSpeed();
                if (windDir==null){
                    windDir=0.0;
                    windSpeed=0.0;
                }
                Double tvoc=deviceAndWinds.get(j).getTVoc();
            Double windSpeed=deviceAndWinds.get(j).getWindSpeed();
            if (windDir==null){
                windDir=0.0;
                windSpeed=0.0;
            }
            Double tvoc=deviceAndWinds.get(j).getTVoc();
                List tranlist= LatLngTransformation.Convert_BD09_To_GCJ02(deviceAndWinds.get(j).getLatitude(),deviceAndWinds.get(j).getLongitude());
                Double transLo=(Double) tranlist.get(0);
                Double transLa=(Double) tranlist.get(1);
                if (tvoc==null){
                    tvoc=0.0;
                }
                Double dir = (270.0 - windDir * Math.PI / 180.0);
            List tranlist= LatLngTransformation.Convert_BD09_To_GCJ02(deviceAndWinds.get(j).getLatitude(),deviceAndWinds.get(j).getLongitude());
            Double transLo=(Double) tranlist.get(0);
            Double transLa=(Double) tranlist.get(1);
            if (tvoc==null){
                tvoc=0.0;
            }
            Double dir = (270.0 - windDir * Math.PI / 180.0);
            U = windSpeed * Math.cos(dir);
            V = windSpeed * Math.sin(dir);
            map.put("lo",transLo);
            map.put("la",transLa);
            map.put("U",U);
            map.put("V",V);
            mapList.add(map);
                U = windSpeed * Math.cos(dir);
                V = windSpeed * Math.sin(dir);
                map.put("lo",transLo);
                map.put("la",transLa);
                map.put("U",U);
                map.put("V",V);
                mapList.add(map);
        }
        for (int i = 0; i <mapList.size() ; i++) {
            Double lo= (Double) mapList.get(i).get("lo");
@@ -1023,7 +1055,7 @@
        String vData = "\"" + "data" + "\"" + ": " + vList;
        String s1 = "[" + "{" + header1 + ", " + uData + "}" + ", " + "{" + header2 + ", " + vData + "}" + "]";
        JSONArray jsonArray = JSONArray.parseArray(s1);
        MonitorPoint monitorPoint=monitorPointMapper.byIdGetMonitorPoint(Integer.parseInt(id));
        Double monitorLo=monitorPoint.getLongitude();
        Double monitorLa=monitorPoint.getLatitude();
        List transList= LatLngTransformation.Convert_BD09_To_GCJ02(monitorLa,monitorLo);
src/main/resources/mapper/DeviceMapper.xml
@@ -524,4 +524,28 @@
            FROM device
            WHERE mac = #{mac}
    </select>
    <select id="getDeviceByCode" resultType="java.util.List" resultMap="BaseResultMap">
        select d.* from monitor_point as m,device as d where m.id=d.monitor_point_id
        and m.id
        in
        (SELECT m.id where state!=4
        <if test="areaCode != null">
            and area_code = #{areaCode}
        </if>
        <if test="townCode != null">
            and town_code = #{townCode}
        </if>
        )
    </select>
    <select id="byMacGetDeviceAndWind" resultType="com.moral.entity.DeviceAndWind">
         select d.longitude as longitude,d.latitude as latitude,
            case when h.json->"$.e18[0]"=0 then 0.1 else h.json->"$.e18[0]" end
            as windSpeed, h.json->"$.e23[0]" as windDir,
            h.json->"$.e17[0]" as tVoc
            from ${table} as h ,`device` as d
            where d.mac=h.mac and h.time=#{time}
            and d.mac=#{mac}
    </select>
</mapper>
src/main/resources/mapper/MonitorPointMapper.xml
@@ -9,6 +9,7 @@
        <result column="province_code" jdbcType="INTEGER" property="provinceCode"/>
        <result column="city_code" jdbcType="INTEGER" property="cityCode"/>
        <result column="area_code" jdbcType="INTEGER" property="areaCode"/>
        <result column="town_code" jdbcType="INTEGER" property="townCode"/>
        <result column="organization_id" jdbcType="INTEGER" property="organizationId"/>
        <result column="address" jdbcType="VARCHAR" property="address"/>
        <result column="is_delete" jdbcType="CHAR" property="isDelete"/>
@@ -172,7 +173,7 @@
        and o.id=mp.organization_id
        and a.id=#{id};
    </select>
    <select id="byIdGetMonitorPoint" resultType="com.moral.entity.MonitorPoint">
    <select id="byIdGetMonitorPoint" resultType="com.moral.entity.MonitorPoint" resultMap="BaseResultMap">
        SELECT * FROM `monitor_point` where id=#{id}
    </select>