于紫祥_1901
2020-06-23 235a2be052544e41cef217920d4e55fee730995e
净化率,收集率,无组织排放
8 files added
13 files modified
1126 ■■■■■ changed files
src/main/java/com/moral/controller/ScreenController.java 72 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/DeviceMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/HistoryHourlyMapper.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/MonitorPointMapper.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/DeviceService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/HistoryHourlyService.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/MonitorPointService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java 370 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/util/MyLatLng.java 27 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/util/mapUtils.java 73 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/DeviceMapper.xml 11 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/HistoryHourlyMapper.xml 10 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/MonitorPointMapper.xml 9 ●●●●● patch | view | raw | blame | history
src/main/webapp/img/company_01.png patch | view | raw | blame | history
src/main/webapp/img/company_02.png patch | view | raw | blame | history
src/main/webapp/img/company_03.png patch | view | raw | blame | history
src/main/webapp/view/pressureMap.jsp 118 ●●●●● patch | view | raw | blame | history
src/main/webapp/view/purityMap.jsp 119 ●●●●● patch | view | raw | blame | history
src/main/webapp/view/unorganizedMap.jsp 243 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java
@@ -1779,4 +1779,76 @@
            return model;
        }
    }
    @GetMapping("/purify")
    @ApiOperation(value = "获取厂区净化率", notes = "获取厂区净化率")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "monitorPointId", value = "公司Id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "sensorKey", value = "因子", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19-14)", required = true, paramType = "query", dataType = "String")})
    public ModelAndView PurificationRate(HttpServletRequest request,ModelAndView model){
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        String monitPointIdS= (String) parameters.get("monitorPointId");
        String sensor= (String) parameters.get("sensorKey");
        String time= (String) parameters.get("time");
        String YearAndDay = time.substring(0, time.lastIndexOf("-"));
        String Hour = time.substring(time.lastIndexOf("-") + 1);
        String Time = YearAndDay + " " + Hour + ":00:00";
        int monitPointId=Integer.parseInt(monitPointIdS);
        JSONObject params=monitorPointService.getMonitorPointById(monitPointId,Time,1,sensor);
        String paramsJson = params.toJSONString();
        model.addObject("mapParams", paramsJson);
        model.setViewName("purityMap");
        return model;
    }
    @GetMapping("/collection")
    @ApiOperation(value = "获取厂区收集率", notes = "获取厂区收集率")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "monitorPointId", value = "公司Id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19-14)", required = true, paramType = "query", dataType = "String")})
    public ModelAndView collectionRate(HttpServletRequest request,ModelAndView model){
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        String monitPointIdS= (String) parameters.get("monitorPointId");
        String sensor= "";
        String time= (String) parameters.get("time");
        String YearAndDay = time.substring(0, time.lastIndexOf("-"));
        String Hour = time.substring(time.lastIndexOf("-") + 1);
        String Time = YearAndDay + " " + Hour + ":00:00";
        int monitPointId=Integer.parseInt(monitPointIdS);
        //获取公司信息
        JSONObject params=monitorPointService.getMonitorPointById(monitPointId,Time,2,sensor);
        model.addObject("params",params);
        model.setViewName("pressureMap");
        return model;
    }
    @GetMapping("/unorganizedEmissions")
    @ApiOperation(value = "无组织排放", notes = "无组织排放")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "monitorPointId", value = "公司Id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "sensorKey", value = "因子", required = true, paramType = "query", dataType = "String"),
            // @ApiImplicitParam(name = "sensorKey", value = "传感器key,如有多个用逗号分隔", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19-14)", required = true, paramType = "query", dataType = "String")})
    public ModelAndView unorganizedEmissions(HttpServletRequest request,ModelAndView model){
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        String monitPointIdS= (String) parameters.get("monitorPointId");
        String sensor= (String) parameters.get("sensorKey");
        String time= (String) parameters.get("time");
        String YearAndDay = time.substring(0, time.lastIndexOf("-"));
        String Hour = time.substring(time.lastIndexOf("-") + 1);
        String Time = YearAndDay + " " + Hour + ":00:00";
        int monitPointId=Integer.parseInt(monitPointIdS);
        //获取公司信息
        JSONObject params=monitorPointService.getMonitorPointById(monitPointId,Time,3,sensor);
        model.addObject("params",params);
        model.setViewName("unorganizedMap");
        return model;
    }
}
src/main/java/com/moral/mapper/DeviceMapper.java
@@ -44,4 +44,11 @@
    String getLimitDataByDevice(Map<String, Object> parameters);
    List<String> getMacsByOrganizationId(@Param("organizationIdList") List<Object> organizationIdList);
    List<Device> getDeviceById1(@Param("id") int id);
    //获取厂界设备
    List<Device> getDeviceById2(@Param("id") int id);
    List<Device> getDeviceById3(@Param("id") int id);
}
src/main/java/com/moral/mapper/HistoryHourlyMapper.java
@@ -1,5 +1,7 @@
package com.moral.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
public interface HistoryHourlyMapper {
@@ -9,4 +11,10 @@
    Map<String, Object> getPollutionSourceDataByHour(Map<String, Object> parameters);
    Map<String, Object> getPollutionSourceDataAll(Map<String, Object> parameters);
    //获取TVOC浓度
    String getTVOCByMac(@Param("mac") String mac, @Param("time") String time, @Param("sensor") String sensor);
    //获取压强大小
    String getPressureByMac(@Param("mac") String mac,@Param("time") String time);
    //获取风向
    Map<String,Object> getDataByMac(@Param("mac") String mac,@Param("time") String time);
}
src/main/java/com/moral/mapper/MonitorPointMapper.java
@@ -3,6 +3,7 @@
import java.util.List;
import java.util.Map;
import com.moral.entity.Device;
import org.apache.ibatis.annotations.Param;
import com.moral.common.mapper.BaseMapper;
@@ -17,4 +18,8 @@
    List<Integer> selectVersionsById(int id);
    Map<String, Object> selectAllById(int id);
    List<Map<String, Object>> getIdByOrganizationId(@Param("organizationIdList") List<Object> organizationIdList);
    //通过monitorPointId获取该公司区域的所有设备
    List<Device> getDeviceList(@Param("id") int id);
    //获取公司信息,通过id
    MonitorPoint getMonitorPointById(@Param("id") int id);
}
src/main/java/com/moral/service/DeviceService.java
@@ -61,4 +61,11 @@
    Device getDeviceByLongitudeAsc(String mac);
    List<String> getMacsByOrganizationId(List<Object> organizationIdList);
    //获取烟道设备
    List<Device> getDeviceById1(int id);
    //获取厂界设备
    List<Device> getDeviceById2(int id);
    //获取车间设备
    List<Device> getDeviceById3(int id);
}
src/main/java/com/moral/service/HistoryHourlyService.java
@@ -12,4 +12,13 @@
    Map<String, Object> getPollutionSourceDataAll(Map<String, Object> parameters) throws Exception;
    Point getDirPoint(Map<String, Object> parameters) throws Exception;
    //获取TVOC浓度
    String getTVOCByMac(String mac,String time,String sensor);
    //获取压强大小
    String getPressureByMac(String mac,String time);
    //获取historyHourly的小时数据
    Map<String,Object> getDataByMac(String mac,String time);
}
src/main/java/com/moral/service/MonitorPointService.java
@@ -4,7 +4,9 @@
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.moral.common.bean.PageBean;
import com.moral.entity.Device;
import com.moral.entity.MonitorPoint;
public interface MonitorPointService {
@@ -41,4 +43,10 @@
    void isCompensateCalculation(Map<String, Object> parameters);
    
    Map<String, Object> selectAllById(String id);
    //通过monitorPointId获取该公司区域的所有设备
    List<Device> getDeviceList(int id);
    //获取公司信息,通过id
    JSONObject getMonitorPointById(int id, String Time, int i, String sensor);
}
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -635,4 +635,19 @@
    public List<String> getMacsByOrganizationId(List<Object> organizationIdList) {
        return deviceMapper.getMacsByOrganizationId(organizationIdList);
    }
    @Override
    public List<Device> getDeviceById1(int id) {
        return deviceMapper.getDeviceById1(id);
    }
    @Override
    public List<Device> getDeviceById2(int id) {
        return deviceMapper.getDeviceById2(id);
    }
    @Override
    public List<Device> getDeviceById3(int id) {
        return deviceMapper.getDeviceById3(id);
    }
}
src/main/java/com/moral/service/impl/HistoryHourlyServiceImpl.java
@@ -100,6 +100,21 @@
    }
    @Override
    public String getTVOCByMac(String mac,String time,String sensor) {
        return historyHourlyMapper.getTVOCByMac(mac,time,sensor);
    }
    @Override
    public String getPressureByMac(String mac, String time) {
        return historyHourlyMapper.getPressureByMac(mac,time);
    }
    @Override
    public Map<String,Object> getDataByMac(String mac, String time) {
        return historyHourlyMapper.getDataByMac(mac,time);
    }
    @Override
    public Point getDirPoint(Map<String, Object> parameters) throws Exception {
        Map<String, Object> pollutionSourceData = getPollutionSourceDataByHour(parameters);
        if (MapUtils.isEmpty(pollutionSourceData)) {
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
@@ -1,5 +1,6 @@
package com.moral.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -13,8 +14,14 @@
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.moral.mapper.DictionaryDataMapper;
import com.moral.mapper.OrganizationMapper;
import com.moral.service.HistoryHourlyService;
import com.moral.util.MyLatLng;
import com.moral.util.mapUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -56,6 +63,9 @@
    
    @Resource
    private OrganizationService organizationService;
    @Resource
    private HistoryHourlyService historyHourlyService;
    
    private static Class ENTITY_CLASS = MonitorPoint.class;
    @Override
@@ -364,4 +374,364 @@
        Map<String, Object> map = monitorPointMapper.selectAllById(id2);
        return map;
    }
    @Override
    public List<Device> getDeviceList(int id) {
        return monitorPointMapper.getDeviceList(id);
    }
    @Override
    public JSONObject getMonitorPointById(int id, String Time, int i, String sensor) {
        JSONObject params = new JSONObject();
        MonitorPoint monitorPoint = monitorPointMapper.getMonitorPointById(id);
        if (i == 1) {
            Double longitude = monitorPoint.getLongitude();
            Double latitude = monitorPoint.getLatitude();
            Double workshop = 0.0;
            Double flue = 0.0;
            //烟道设备
            List<Device> device1 = deviceService.getDeviceById1(id);
            //厂界设备
            List<Device> device2 = deviceService.getDeviceById2(id);
            //车间设备
            List<Device> device3 = deviceService.getDeviceById3(id);
            String purificationRate = null;//净化率
            if (device3.size() == 0) {
                purificationRate = "公司无车间设备,无法计算净化率";
                params.put("device2", device2);
                params.put("device1", device1);
            } else {
                params.put("device1", device1);
                params.put("device2", device2);
                params.put("device3", device3);
                for (Device device33 : device3) {
                    String mac3 = device33.getMac();
                    String tvoc = historyHourlyService.getTVOCByMac(mac3, Time,sensor);
                    if (tvoc != null) {
                        workshop = Double.parseDouble(tvoc);
                    } else {
                        workshop = 0.0;
                    }
                }
                if (device1.size() == 0) {
                    purificationRate = "公司无烟道设备,无法计算净化率";
                } else {
                    for (Device device11 : device1) {
                        String mac1 = device11.getMac();
                        flue = Double.parseDouble(historyHourlyService.getTVOCByMac(mac1, Time,sensor));
                        if (workshop == 0.0) {
                            purificationRate = "车间设备无数据浓度,无法计算浓度值";
                        } else {
                            if (flue == 0.0) {
                                purificationRate = "烟道设备无数据浓度,无法计算净化率";
                            } else {
                                BigDecimal b = new BigDecimal(((workshop - flue) / workshop) * 100);
                                double purity2 = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
                                purificationRate = (purity2) + "%";
                            }
                        }
                    }
                }
            }
            params.put("latitude", latitude);
            params.put("longitude", longitude);
            params.put("purificationRate", purificationRate);
        }
        if (i == 2) {
            Double longitude = monitorPoint.getLongitude();
            Double latitude = monitorPoint.getLatitude();
            //烟道设备
            List<Device> device1 = deviceService.getDeviceById1(id);
            //厂界设备
            List<Device> device2 = deviceService.getDeviceById2(id);
            //车间设备
            List<Device> device3 = deviceService.getDeviceById3(id);
            String collectionRate = null;//收集率
            Double pressure = 0.0;//平均压强
            List<Double> list1 = new ArrayList();
            if (device3.size() == 0) {
                collectionRate = "该公司车间无设备,无法计算收集率";
                params.put("device1", device1);
                params.put("device2", device2);
            } else {
                params.put("device3", device3);
                if (device2.size() == 0) {
                    collectionRate = "该公司厂界无设备,无法计算收集率";
                    params.put("device1", device1);
                } else {
                    params.put("device2", device2);
                    params.put("device1", device1);
                    Double sum = 0.0;
                    for (Device device22 : device2) {
                        String mac2 = device22.getMac();
                        String pressure2 = historyHourlyService.getPressureByMac(mac2, Time);
                        System.out.println("pressure2="+pressure2);
                        if (pressure2 != null) {
                            pressure = Double.parseDouble(pressure2);
                            list1.add(pressure);
                        }else {
                            collectionRate = "该公司厂界设备无数据浓度,无法计算收集率";
                        }
                    }
                    for (Double d : list1) {
                        sum = sum + d;
                    }
                    if (list1.size() != 0) {
                        pressure = sum / list1.size();
                    } else {
                        collectionRate = "该公司厂界设备无数据浓度,无法计算收集率";
                    }
                    System.out.println(list1);
                    Double pressure33 = 0.0;
                    for (Device device33 : device3) {
                        String mac3 = device33.getMac();
                        String pressure3 = historyHourlyService.getPressureByMac(mac3, Time);
                        if (pressure3 != null) {
                            pressure33 = Double.parseDouble(pressure3);
                            BigDecimal b = new BigDecimal((pressure - pressure33 + 3.5) * 20);//临时加2.5,有具体设备就不需要加
                            double collection = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
                            collectionRate = collection + "%";
                        }
                    }
                }
            }
            params.put("latitude", latitude);
            params.put("longitude", longitude);
            params.put("collectionRate", collectionRate);
        }
        if (i == 3) {
            Double longitudeCompany = monitorPoint.getLongitude();
            Double latitudeCompany = monitorPoint.getLatitude();
            Double longitude = 0.0;//每台设备的经纬度
            Double latitude = 0.0;//每台设备的经纬度
            List<Device> deviceList = deviceService.getDeviceById2(id);
            //List<Device> deviceList = monitorPointService.getDeviceList(id);
            List<Map> list = new ArrayList<Map>();//存放historyHourly的json数据
            String smac = "";//,每台设备的Mac号
            List<Map> windList = new ArrayList<Map>();//存放每台设备的风向和经纬度
            Map<String, Object> jsonMap = new HashMap<String, Object>();//每台设备的数据
            Map<String, Object> deviceMap = null;
            for (Device device : deviceList) {
                deviceMap = new HashMap<String, Object>();
                smac = device.getMac();
                latitude = device.getLatitude();
                longitude = device.getLongitude();
                jsonMap = historyHourlyService.getDataByMac(smac, Time);
                deviceMap.put("longitude", longitude);
                deviceMap.put("latitude", latitude);
                if (jsonMap != null) {
                    deviceMap.put("jsonMap", jsonMap);
                } else {
                    deviceMap.put("jsonMap", "该设备该时间点无数据");
                }
                list.add(deviceMap);
            }
            Map<String, Object> mapData = new HashMap<String, Object>();
            Map<String, Object> mapDevice;
            JSONArray windDir;
            for (Map<String, Object> objectMap : list) {
                mapDevice = new HashMap<String, Object>();
                Map<String, Object> map = null;
                if (!(objectMap.get("jsonMap") instanceof String)) {
                    mapData = (Map<String, Object>) objectMap.get("jsonMap");
                    map = (Map) JSON.parseObject((String) mapData.get("json"));
                    windDir = (JSONArray) JSONArray.toJSON(map.get("e23"));
                    JSONArray concentration = (JSONArray) JSONArray.toJSON(map.get(sensor));
                    BigDecimal bigDecimal1=new BigDecimal(0);
                    BigDecimal bigDecimal=new BigDecimal(0);
                    if (concentration!=null){
                        if (concentration.get(0) instanceof Integer){
                            bigDecimal1 =new BigDecimal(concentration.get(0).toString());
                        }else {
                            bigDecimal1= (BigDecimal) concentration.get(0);
                        }
                        if (windDir!=null){
                            if (windDir.get(0) instanceof Integer){
                                bigDecimal =new BigDecimal(windDir.get(0).toString());
                            }else {
                                bigDecimal=(BigDecimal) windDir.get(0);
                            }
                            mapDevice.put("e23", bigDecimal.doubleValue());
                            mapDevice.put("sensor", bigDecimal1.doubleValue());
                            mapDevice.put("longitude", objectMap.get("longitude"));
                            mapDevice.put("latitude", objectMap.get("latitude"));
                        }else {
                            mapDevice.put("noSensor", "无风向数据");
                            mapDevice.put("longitude", objectMap.get("longitude"));
                            mapDevice.put("latitude", objectMap.get("latitude"));
                        }
                    }
                } else {
                    mapDevice.put("info", objectMap.get("jsonMap"));
                    mapDevice.put("longitude", objectMap.get("longitude"));
                    mapDevice.put("latitude", objectMap.get("latitude"));
                }
                windList.add(mapDevice);
            }
            // if (windDir!=null){}
            Double differenceNum = 0.0;
            Map<String, Object> indexMap;
            List<Map> mapList = new ArrayList<>();
            for (int j = 0; j < windList.size(); j++) {
                for (int k = 0; k < windList.size(); k++) {
                    if (k != j) {
                        indexMap = new HashMap<String, Object>();
                        if (windList.get(k).containsKey("e23") && windList.get(j).containsKey("e23")) {
                            Double e23Numk = (Double) windList.get(k).get("e23");
                            Double e23Numj = (Double) windList.get(j).get("e23");
                            Double diff = e23Numk - e23Numj;
                            BigDecimal b = new BigDecimal(Math.abs(diff));
                            differenceNum = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
                            if (differenceNum > 180) {
                                differenceNum = 360 - differenceNum;
                            }
                            indexMap.put("k", k);
                            indexMap.put("j", j);
                            indexMap.put("diff", differenceNum);
                        } else {
                            indexMap.put("k", k);
                            indexMap.put("j", j);
                            indexMap.put("info", "设备无数据");
                        }
//                     indexMap.put("longitude",windList.get(k).get("longitude"));
//                     indexMap.put("latitude",windList.get(k).get("latitude"));
                        mapList.add(indexMap);
                    } else {
                        continue;
                    }
                }
            }
            Double min = 0.0;
            int indexMin = 0;
            if (mapList.size()>0){
                if (mapList.get(0).containsKey("diff")) {
                    min = (Double) mapList.get(0).get("diff");
                    for (int q = 1; q < mapList.size(); q++) {
                        if (mapList.get(q).containsKey("diff")) {
                            if (min > (Double) mapList.get(q).get("diff")) {
                                min = (Double) mapList.get(q).get("diff");
                                indexMin = q;
                            }
                        } else {
                            indexMin = q;
                        }
                    }
                }
            }
            Map twoDeviceMap = mapList.get(indexMin);
            List<Map> list1 = new ArrayList<Map>();           //存放风向夹角最小的两台设备的经纬度
            list1.add(windList.get((Integer) twoDeviceMap.get("k")));
            list1.add(windList.get((Integer) twoDeviceMap.get("j")));
            Double wind = 0.0;
            Double sum = 0.0;
            if (list1.get(0).containsKey("e23")) {
                if (Math.abs((Double) list1.get(0).get("e23") - (Double) list1.get(1).get("e23")) > 180) {
                    sum = (Double) list1.get(0).get("e23") + (Double) list1.get(1).get("e23");
                    wind = sum / 2 + 180;
                    if (wind > 360) {
                        wind = wind - 360;
                    }
                } else {
                    for (Map map : list1) {
                        sum += (Double) map.get("e23");
                    }
                    wind = sum / 2;
                }
            } else {
                wind = 0.0;
            }
            Map<String, Object> longAndLatiMap;
            List<Map> longAndLatiList = new ArrayList<>();//经纬度夹角集合,存放的是windList中两台设备的下标和两台设备夹角与风向角的差值
            List<Map> preAngleDeviceList = new ArrayList<Map>(); //角度减去风向最小的两台设备
            if (wind != 0.0) {
                for (int f = 0; f < windList.size(); f++) {
                    for (int h = 0; h < windList.size(); h++) {
                        if (f != h) {
                            longAndLatiMap = new HashMap<String, Object>();
                            longAndLatiMap.put("h", h);
                            longAndLatiMap.put("f", f);
                            Double angle = mapUtils.getAngle(
                                    new MyLatLng((Double) windList.get(h).get("longitude"),
                                            (Double) windList.get(h).get("latitude")),
                                    new MyLatLng((Double) windList.get(f).get("longitude"),
                                            (Double) windList.get(f).get("latitude")));
                            Double angleDiff = Math.abs(angle - wind);
                            longAndLatiMap.put("angle", angleDiff);
                            longAndLatiList.add(longAndLatiMap);
                        }
                    }
                }
                Double minAngle = (Double) longAndLatiList.get(0).get("angle");
                int indexAngle = 0;
                for (int j = 0; j < longAndLatiList.size(); j++) {
                    if (minAngle > (Double) longAndLatiList.get(j).get("angle")) {
                        minAngle = (Double) longAndLatiList.get(j).get("angle");
                        indexAngle = j;
                    }
                }
                //windList.get((Integer) longAndLatiList.get(indexAngle).get("f"))获得风向和经纬度
                preAngleDeviceList.add(windList.get((Integer) longAndLatiList.get(indexAngle).get("h")));
                preAngleDeviceList.add(windList.get((Integer) longAndLatiList.get(indexAngle).get("f")));
                Double length = mapUtils.getDistance((Double) preAngleDeviceList.get(0).get("longitude"), (Double) preAngleDeviceList.get(0).get("latitude"),
                        (Double) preAngleDeviceList.get(1).get("longitude"), (Double) preAngleDeviceList.get(1).get("latitude"));
                Double subLength = length / 5;
                Double angle = mapUtils.getAngle(
                        new MyLatLng((Double) preAngleDeviceList.get(0).get("longitude"),
                                (Double) preAngleDeviceList.get(0).get("latitude")),
                        new MyLatLng((Double) preAngleDeviceList.get(1).get("longitude"),
                                (Double) preAngleDeviceList.get(1).get("latitude")));
                params.put("preAngleDeviceList", preAngleDeviceList);
                params.put("angle", angle);
                List locationList = new ArrayList();
                String[] firstLocation = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, (Double) preAngleDeviceList.get(0).get("longitude"),
                        (Double) preAngleDeviceList.get(0).get("latitude"), subLength);
                String[] secondLoction = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(firstLocation[0]),
                        Double.parseDouble(firstLocation[1]), subLength);
                String[] thirdLocation = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(secondLoction[0]),
                        Double.parseDouble(secondLoction[1]), subLength);
                String[] fourthLoction = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(thirdLocation[0]),
                        Double.parseDouble(thirdLocation[1]), subLength);
                locationList.add(firstLocation);
                locationList.add(secondLoction);
                locationList.add(thirdLocation);
                locationList.add(fourthLoction);
                params.put("locationList", locationList);
                String preAngleDeviceString = JSON.toJSON(preAngleDeviceList).toString();
                params.put("preAngleDeviceString", preAngleDeviceString);//两台添加箭头的设备
            } else {
                params.put("preAngleDeviceString", "");
            }
            //String preAngleDeviceString=preAngleDeviceList.
            params.put("wind", wind);
            params.put("list1", list1);
            params.put("deviceList", deviceList);
            params.put("latitudeCompany", latitudeCompany);
            params.put("longitudeCompany", longitudeCompany);
        }
        return params;
    }
}
src/main/java/com/moral/util/MyLatLng.java
New file
@@ -0,0 +1,27 @@
package com.moral.util;
 public class MyLatLng {
    final static double Rc=6378137;
    final static double Rj=6356725;
    double m_LoDeg,m_LoMin,m_LoSec;
    double m_LaDeg,m_LaMin,m_LaSec;
    double m_Longitude,m_Latitude;
    double m_RadLo,m_RadLa;
    double Ec;
    double Ed;
    public MyLatLng(double longitude, double latitude){
        m_LoDeg=(int)longitude;
        m_LoMin=(int)((longitude-m_LoDeg)*60);
        m_LoSec=(longitude-m_LoDeg-m_LoMin/60.)*3600;
        m_LaDeg=(int)latitude;
        m_LaMin=(int)((latitude-m_LaDeg)*60);
        m_LaSec=(latitude-m_LaDeg-m_LaMin/60.)*3600;
        m_Longitude=longitude;
        m_Latitude=latitude;
        m_RadLo=longitude*Math.PI/180.;
        m_RadLa=latitude*Math.PI/180.;
        Ec=Rj+(Rc-Rj)*(90.-m_Latitude)/90.;
        Ed=Ec*Math.cos(m_RadLa);
}}
src/main/java/com/moral/util/mapUtils.java
New file
@@ -0,0 +1,73 @@
package com.moral.util;
import java.text.DecimalFormat;
public class mapUtils {
    /**
     * 获取AB连线与正北方向的角度
     * @param A  A点的经纬度
     * @param B  B点的经纬度
     * @return  AB连线与正北方向的角度(0~360)
     */
    /** 180° **/
    private static final DecimalFormat df = new DecimalFormat("0.000000");
    //地球平均半径
    private static final double EARTH_RADIUS = 6378137;
    //把经纬度转为度(°)
    private static double rad(double d){
        return d * Math.PI / 180.0;
    }
    public static double getDistance(double lng1, double lat1, double lng2, double lat2){
        double radLat1 = rad(lat1);
        double radLat2 = rad(lat2);
        double a = radLat1 - radLat2;
        double b = rad(lng1) - rad(lng2);
        double s = 2 * Math.asin(
                Math.sqrt(
                        Math.pow(Math.sin(a/2),2)
                                + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)
                )
        );
        s = s * EARTH_RADIUS;
        s = Math.round(s * 10000) / 10000;
        return s;
    }
    public  static double getAngle(MyLatLng A,MyLatLng B){
        double dx=(B.m_RadLo-A.m_RadLo)*A.Ed;
        double dy=(B.m_RadLa-A.m_RadLa)*A.Ec;
        double angle=0.0;
        angle=Math.atan(Math.abs(dx/dy))*180./Math.PI;
        double dLo=B.m_Longitude-A.m_Longitude;
        double dLa=B.m_Latitude-A.m_Latitude;
        if(dLo>0&&dLa<=0){
            angle=(90.-angle)+90;
        }
        else if(dLo<=0&&dLa<0){
            angle=angle+180.;
        }else if(dLo<0&&dLa>=0){
            angle= (90.-angle)+270;
        }
        return angle;
    }
    public static String[] calLocationByDistanceAndLocationAndDirection(double angle, double startLong,double startLat, double distance){
        String[] result = new String[2];
        //将距离转换成经度的计算公式
        double δ = distance/EARTH_RADIUS;
        // 转换为radian,否则结果会不正确
        angle = Math.toRadians(angle);
        startLong = Math.toRadians(startLong);
        startLat = Math.toRadians(startLat);
        double lat = Math.asin(Math.sin(startLat)*Math.cos(δ)+Math.cos(startLat)*Math.sin(δ)*Math.cos(angle));
        double lon = startLong + Math.atan2(Math.sin(angle)*Math.sin(δ)*Math.cos(startLat),Math.cos(δ)-Math.sin(startLat)*Math.sin(lat));
        // 转为正常的10进制经纬度
        lon = Math.toDegrees(lon);
        lat = Math.toDegrees(lat);
        result[0] = df.format(lon);
        result[1] = df.format(lat);
        return result;
    }
}
src/main/resources/mapper/DeviceMapper.xml
@@ -430,4 +430,15 @@
        AND d.is_delete = '0'
    </select>
    <select id="getDeviceById1" resultType="com.moral.entity.Device">
        SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp  where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=1 and d.monitor_point_id=#{id}
    </select>
    <select id="getDeviceById2" resultType="com.moral.entity.Device">
        SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp  where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=2 and d.monitor_point_id=#{id}
    </select>
    <select id="getDeviceById3" resultType="com.moral.entity.Device">
        SELECT d.* FROM `device` as d,monitor_point as mp,device_property as dp  where d.monitor_point_id=mp.id and d.id=dp.id and dp.device_tech=3 and d.monitor_point_id=#{id}
    </select>
</mapper>
src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -52,4 +52,14 @@
        order by time desc
        limit 0,1
    </select>
    <select id="getTVOCByMac" resultType="java.lang.String">
        select json->'$.${sensor}[0]' as e17 from history_hourly where mac=#{mac} and time=#{time}
    </select>
    <select id="getPressureByMac" resultType="java.lang.String">
        select json->'$.e28[0]' as e28 from history_hourly where mac=#{mac} and time=#{time}
    </select>
    <select id="getDataByMac" resultType="java.util.Map">
                select json  from history_hourly where mac=#{mac} and time=#{time}
    </select>
</mapper>
src/main/resources/mapper/MonitorPointMapper.xml
@@ -156,4 +156,13 @@
                    #{organizationId}  
                </foreach>
    </select>
    <select id="getDeviceList" resultType="com.moral.entity.Device">
        SELECT d.* FROM `device` as d,monitor_point as mp
        where d.monitor_point_id=mp.id
        and mp.id=#{id}
    </select>
    <select id="getMonitorPointById" resultType="com.moral.entity.MonitorPoint">
        select * from monitor_point where id=#{id}
    </select>
</mapper>
src/main/webapp/img/company_01.png
src/main/webapp/img/company_02.png
src/main/webapp/img/company_03.png
src/main/webapp/view/pressureMap.jsp
New file
@@ -0,0 +1,118 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }
        #box {
            width:300px;
            height:500px;
            top:80px;
            right:30px;
            position:absolute;
            z-index:1;
            border:2px solid red;
            background-color:gainsboro;
            opacity: 0.8;
        }
    </style>
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=2.0&ak=rER1sgBIcQxkfNSlm2wmBGZGgEERrooM"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/utils.js"></script>
    <script type="text/javascript">
        if (typeof (JSON) == 'undefined') {
            $.getScript("js/json2.js");
        }
    </script>
    <script type="text/javascript" src="/js/paging.js"></script>
    <title>地图展示</title>
</head>
<body>
<div id="allmap" style="z-index: 0" ;>
</div>
<div id="box">
    <p>
       <img src="/img/company_01.png" style="width: 30px;height: 30px;margin-left: 15px;"/> <span style="position: relative;top: -9px;">&nbsp;&nbsp;--->烟道</span>
    </p>
    <p>
        <img src="/img/company_02.png" style="width: 30px;height: 30px;margin-left: 15px;"/> <span style="position: relative;top: -9px;">&nbsp;&nbsp;--->厂界</span>
    </p>
    <p>
        <img src="/img/company_03.png" style="width: 30px;height: 30px;margin-left: 15px;"/> <span style="position: relative;top: -9px;">&nbsp;&nbsp;--->车间</span>
        <br/>
        <br/>
    </p>
    <div id="purify">
    </div>
</div>
<div id="mapParams" style="display: none;">
    ${requestScope.params}
</div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");    // 创建Map实例
    map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
    var params = $.parseJSON($("#mapParams").html());
    var longitude = params["longitude"];
    var latitude = params["latitude"];
    map.centerAndZoom(new BMap.Point(longitude, latitude), 17);  // 初始化地图,设置中心点坐标和地图级别
             // 将标注添加到地图中
    $("#purify").append("<p style='margin-left: 15px;'>收集率:" + params["collectionRate"] + "</p>");
   /* var infoWindow = new BMap.InfoWindow("<p style='font-size:14px;'>" + text + "</p>");
    mark4.addEventListener("click", function () {
        this.openInfoWindow(infoWindow);
    });*/
    var device1 = params["device1"];
    if (device1 != null) {
        for (var i = 0; i < device1.length; i++) {
            var icon1 = new BMap.Icon("/img/company_01.png", new BMap.Size(48, 48));
            var mark1 = new BMap.Marker(new BMap.Point(device1[i].longitude, device1[i].latitude), {icon: icon1});
            map.addOverlay(mark1);
        }
    }
    var device2 = params["device2"];
    if (device2 != null) {
        for (var i = 0; i < device2.length; i++) {
            var icon2 = new BMap.Icon("/img/company_02.png", new BMap.Size(48, 48));
            var mark2 = new BMap.Marker(new BMap.Point(device2[i].longitude, device2[i].latitude), {icon: icon2});
            map.addOverlay(mark2);
        }
    }
    var device3 = params["device3"];
    if (device3 != null) {
        for (var i = 0; i < device3.length; i++) {
            var icon3 = new BMap.Icon("/img/company_03.png", new BMap.Size(48, 48));
            var mark3 = new BMap.Marker(new BMap.Point(device3[i].longitude, device3[i].latitude), {icon: icon3});
            map.addOverlay(mark3);
        }
    }
    //添加地图类型控件
    map.addControl(new BMap.MapTypeControl({
        mapTypes: [
            BMAP_NORMAL_MAP,
            BMAP_HYBRID_MAP
        ]
    }));
</script>
src/main/webapp/view/purityMap.jsp
New file
@@ -0,0 +1,119 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }
        #box {
            width:300px;
            height:500px;
            top:80px;
            right:30px;
            position:absolute;
            z-index:1;
            border:2px solid red;
            background-color:gainsboro;
            opacity: 0.8;
        }
    </style>
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=2.0&ak=rER1sgBIcQxkfNSlm2wmBGZGgEERrooM"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/utils.js"></script>
    <script type="text/javascript">
        if (typeof (JSON) == 'undefined') {
            $.getScript("js/json2.js");
        }
    </script>
    <script type="text/javascript" src="/js/paging.js"></script>
    <title>地图展示</title>
</head>
<body>
<div id="allmap" style="z-index: 0" ;>
</div>
<div id="box">
    <p>
       <img src="/img/company_01.png" style="width: 30px;height: 30px;margin-left: 15px;"/> <span style="position: relative;top: -9px;">&nbsp;&nbsp;--->烟道</span>
    </p>
    <p>
        <img src="/img/company_02.png" style="width: 30px;height: 30px;margin-left: 15px;"/> <span style="position: relative;top: -9px;">&nbsp;&nbsp;--->厂界</span>
    </p>
    <p>
        <img src="/img/company_03.png" style="width: 30px;height: 30px;margin-left: 15px;"/> <span style="position: relative;top: -9px;">&nbsp;&nbsp;--->车间</span>
        <br/>
        <br/>
    </p>
    <div id="purify">
    </div>
    <p style="margin-left: 22px;margin-top: 130px; color: red;font-size: 14px"><--无组织排放废气收集效率需大于90%--></p>
</div>
<div id="mapParams" style="display: none;">
    ${requestScope.mapParams}
</div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");    // 创建Map实例
    map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
    var params = $.parseJSON($("#mapParams").html());
    var longitude = params["longitude"];
    var latitude = params["latitude"];
    map.centerAndZoom(new BMap.Point(longitude, latitude), 17);  // 初始化地图,设置中心点坐标和地图级别
             // 将标注添加到地图中
    $("#purify").append("<p style='margin-left: 15px;'>净化率:" + params["purificationRate"] + "</p>");
   /* var infoWindow = new BMap.InfoWindow("<p style='font-size:14px;'>" + text + "</p>");
    mark4.addEventListener("click", function () {
        this.openInfoWindow(infoWindow);
    });*/
    var device1 = params["device1"];
    if (device1 != null) {
        for (var i = 0; i < device1.length; i++) {
            var icon1 = new BMap.Icon("/img/company_01.png", new BMap.Size(48, 48));
            var mark1 = new BMap.Marker(new BMap.Point(device1[i].longitude, device1[i].latitude), {icon: icon1});
            map.addOverlay(mark1);
        }
    }
    var device2 = params["device2"];
    if (device2 != null) {
        for (var i = 0; i < device2.length; i++) {
            var icon2 = new BMap.Icon("/img/company_02.png", new BMap.Size(48, 48));
            var mark2 = new BMap.Marker(new BMap.Point(device2[i].longitude, device2[i].latitude), {icon: icon2});
            map.addOverlay(mark2);
        }
    }
    var device3 = params["device3"];
    if (device3 != null) {
        for (var i = 0; i < device3.length; i++) {
            var icon3 = new BMap.Icon("/img/company_03.png", new BMap.Size(48, 48));
            var mark3 = new BMap.Marker(new BMap.Point(device3[i].longitude, device3[i].latitude), {icon: icon3});
            map.addOverlay(mark3);
        }
    }
    //添加地图类型控件
    map.addControl(new BMap.MapTypeControl({
        mapTypes: [
            BMAP_NORMAL_MAP,
            BMAP_HYBRID_MAP
        ]
    }));
</script>
src/main/webapp/view/unorganizedMap.jsp
New file
@@ -0,0 +1,243 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }
        #box {
            width:300px;
            height:100px;
            top:80px;
            left:30px;
            position:absolute;
            z-index:1;
            border:0px solid red;
            background-color:#f5f3f0;
            opacity: 0.8;
        }
        #cpm {
            width: 300px;
            height: 100px;
            position: absolute;
            background-color: #ffffff;
            display: none;
            left: 50%;
            top: 50%;
            margin-left: -150px;
            margin-top: -50px;
            z-index: 11;
            color: #000000;
            border: 2px solid #FF7F50;
            font-size: 14px;
            line-height: 100px;
            text-align: center;
        }
    </style>
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=2.0&ak=rER1sgBIcQxkfNSlm2wmBGZGgEERrooM"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/utils.js"></script>
    <script type="text/javascript">
        if (typeof (JSON) == 'undefined') {
            $.getScript("js/json2.js");
        }
    </script>
    <script type="text/javascript" src="/js/paging.js"></script>
    <title>地图展示</title>
</head>
<body>
<div id="cpm">该时间存在设备掉线,数据不能作为参考</div>
<div id="allmap" style="z-index: 0" ;>
</div>
<div id="box">
    <p style="text-indent: 2em;line-height: 25px;color: red">注:方向箭头代表风向,箭头上的颜色变化代表该厂区内该时间点的因子浓度变化</p>
</div>
<div id="mapParams" style="display: none;">
    ${requestScope.params}
</div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap",{minZoom:14,maxZoom:19});    // 创建Map实例
    map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
    var params = $.parseJSON($("#mapParams").html());
    var longitude = params["longitudeCompany"];
    var latitude = params["latitudeCompany"];
    var point=new BMap.Point(longitude, latitude);
    map.centerAndZoom(point, 18.5);  // 初始化地图,设置中心点坐标和地图级别
    var device1 = params["deviceList"];
    var preAngleDeviceString = params["preAngleDeviceString"];
    var wind = params["wind"];
    var devices=[];
    var locationList=params["locationList"];
    var color;
    if (preAngleDeviceString!=""){
        var preAngleDeviceList=JSON.parse(preAngleDeviceString);
        var diff=preAngleDeviceList[0].sensor-preAngleDeviceList[1].sensor;
        if (diff>0){
            var polyline = new BMap.Polyline([
                new BMap.Point(preAngleDeviceList[0].longitude, preAngleDeviceList[0].latitude),
                new BMap.Point(locationList[0][0],locationList[0][1])
            ], {strokeColor:"red", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline);   //增加折线
            var polyline1 = new BMap.Polyline([
                new BMap.Point(locationList[0][0],locationList[0][1]),
                new BMap.Point(locationList[1][0],locationList[1][1])
            ], {strokeColor:"Tomato", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline1);   //增加折线
            var polyline2 = new BMap.Polyline([
                new BMap.Point(locationList[1][0],locationList[1][1]),
                new BMap.Point(locationList[2][0],locationList[2 ][1])
            ], {strokeColor:"Coral", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline2);   //增加折线
            var polyline3 = new BMap.Polyline([
                new BMap.Point(locationList[2][0],locationList[2][1]),
                new BMap.Point(locationList[3][0],locationList[3][1])
            ], {strokeColor:"Orange", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline3);   //增加折线
            var polyline4 = new BMap.Polyline([
                new BMap.Point(locationList[3][0],locationList[3][1]),
                new BMap.Point(preAngleDeviceList[1].longitude, preAngleDeviceList[1].latitude)
            ], {strokeColor:"Gold", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline4);   //增加折线
            var arrowLineList = new Array();//记录绘制的箭头线
            color="Gold";
            arrowLineList[arrowLineList.length] = addArrow(polyline4,30,Math.PI/7,color);//记录绘制的箭头线
        } else {
            var polyline = new BMap.Polyline([
                new BMap.Point(preAngleDeviceList[0].longitude, preAngleDeviceList[0].latitude),
                new BMap.Point(locationList[0][0],locationList[0][1])
            ], {strokeColor:"Gold", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline);   //增加折线
            var polyline1 = new BMap.Polyline([
                new BMap.Point(locationList[0][0],locationList[0][1]),
                new BMap.Point(locationList[1][0],locationList[1][1])
            ], {strokeColor:"Orange", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline1);   //增加折线
            var polyline2 = new BMap.Polyline([
                new BMap.Point(locationList[1][0],locationList[1][1]),
                new BMap.Point(locationList[2][0],locationList[2 ][1])
            ], {strokeColor:"Coral", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline2);   //增加折线
            var polyline3 = new BMap.Polyline([
                new BMap.Point(locationList[2][0],locationList[2][1]),
                new BMap.Point(locationList[3][0],locationList[3][1])
            ], {strokeColor:"Tomato", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline3);   //增加折线
            var polyline4 = new BMap.Polyline([
                new BMap.Point(locationList[3][0],locationList[3][1]),
                new BMap.Point(preAngleDeviceList[1].longitude, preAngleDeviceList[1].latitude)
            ], {strokeColor:"red", strokeWeight:8, strokeOpacity:0.5});   //创建折线
            map.addOverlay(polyline4);   //增加折线
            var arrowLineList = new Array();//记录绘制的箭头线
            color="red";
            arrowLineList[arrowLineList.length] = addArrow(polyline4,28,Math.PI/7,color);//记录绘制的箭头线
        }
    }else {
        document.getElementById("cpm").style.display = 'block';
    }
    if (device1 != null) {
        for (var i = 0; i < device1.length; i++) {
            var icon1 = new BMap.Icon("/img/ico_co00.png", new BMap.Size(48, 48));
            var mark1 = new BMap.Marker(new BMap.Point(device1[i].longitude, device1[i].latitude), {icon: icon1});
            devices.push( new BMap.Point(device1[i].longitude, device1[i].latitude));
            map.addOverlay(mark1);
        }
    }
       /* var polygon = new BMap.Polygon(devices, {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5});  //创建多边形
        map.addOverlay(polygon);   //增加多边形*/
    //添加地图类型控件
    map.addControl(new BMap.MapTypeControl({
        mapTypes: [
            BMAP_NORMAL_MAP,
            BMAP_HYBRID_MAP
        ]
    }));
    //arrowLineList[arrowLineList.length] = addArrow(polyline,18,Math.PI/7);//记录绘制的箭头线
    function addArrow(polyline,length,angleValue,color){ //绘制箭头的函数
        var linePoint=polyline.getPath();//线的坐标串
        var arrowCount=linePoint.length;
        for(var i =1;i<arrowCount;i++){ //在拐点处绘制箭头
            var pixelStart=map.pointToPixel(linePoint[i-1]);
            var pixelEnd=map.pointToPixel(linePoint[i]);
            var angle=angleValue;//箭头和主线的夹角
            var r=length; // r/Math.sin(angle)代表箭头长度
            var delta=0; //主线斜率,垂直时无斜率
            var param=0; //代码简洁考虑
            var pixelTemX,pixelTemY;//临时点坐标
            var pixelX,pixelY,pixelX1,pixelY1;//箭头两个点
            if(pixelEnd.x-pixelStart.x==0){ //斜率不存在是时
                pixelTemX=pixelEnd.x;
                if(pixelEnd.y>pixelStart.y)
                {
                    pixelTemY=pixelEnd.y-r;
                }
                else
                {
                    pixelTemY=pixelEnd.y+r;
                }
                //已知直角三角形两个点坐标及其中一个角,求另外一个点坐标算法
                pixelX=pixelTemX-r*Math.tan(angle);
                pixelX1=pixelTemX+r*Math.tan(angle);
                pixelY=pixelY1=pixelTemY;
            }
            else  //斜率存在时
            {
                delta=(pixelEnd.y-pixelStart.y)/(pixelEnd.x-pixelStart.x);
                param=Math.sqrt(delta*delta+1);
                if((pixelEnd.x-pixelStart.x)<0) //第二、三象限
                {
                    pixelTemX=pixelEnd.x+ r/param;
                    pixelTemY=pixelEnd.y+delta*r/param;
                }
                else//第一、四象限
                {
                    pixelTemX=pixelEnd.x- r/param;
                    pixelTemY=pixelEnd.y-delta*r/param;
                }
                //已知直角三角形两个点坐标及其中一个角,求另外一个点坐标算法
                pixelX=pixelTemX+ Math.tan(angle)*r*delta/param;
                pixelY=pixelTemY-Math.tan(angle)*r/param;
                pixelX1=pixelTemX- Math.tan(angle)*r*delta/param;
                pixelY1=pixelTemY+Math.tan(angle)*r/param;
            }
            var pointArrow=map.pixelToPoint(new BMap.Pixel(pixelX,pixelY));
            var pointArrow1=map.pixelToPoint(new BMap.Pixel(pixelX1,pixelY1));
            var Arrow = new BMap.Polyline([
                pointArrow,
                linePoint[i],
                pointArrow1
            ], {strokeColor: color, strokeWeight: 6, strokeOpacity: 0.5});
            map.addOverlay(Arrow);
            return Arrow;
        }
    }
</script>