kaiyu
2020-11-16 cd264145f9b4107f1430da46269dd306d26f3116
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -29,6 +29,7 @@
import com.moral.mapper.OrganizationMapper;
import com.moral.service.AccountService;
import com.moral.service.DeviceService;
import com.moral.service.MonitorPointService;
import com.moral.util.LatLngTransformation;
import com.moral.util.TkMybatisUtils;
@@ -39,6 +40,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import tk.mybatis.mapper.entity.Example;
@Service
@@ -78,6 +80,8 @@
    OrganizationMapper organizationMapper;
    @Resource
    DictionaryDataMapper dictionaryDataMapper;
    @Resource
    private MonitorPointService monitorPointService ;
    @Override
    public Map<String, Object> getDeviceStatesByAccount(Map<String, Object> parameters) {
@@ -207,13 +211,39 @@
    public List<Device> query(Map<String, Object> params) {
        List<Integer> dv = deviceMapper.getHasWindDirAndWindSpeedDeviceVersion();
        Object orgIdObj = params.get("orgId");
        String regionCode = params.get("regionCode").toString();
        List<Device> deviceList = null;
        if (orgIdObj != null) {
            Integer orgId = Integer.parseInt(orgIdObj.toString());
            List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
            params.put("orgIds", orgIds);
            System.out.println(params);
            //剔除沧州地图页面非公司设备图标
            if (regionCode.startsWith("1309")&&orgIdObj.toString().equals("5")) {
                orgIds = new ArrayList<>();
                Collections.addAll(orgIds, 60, 65, 159, 165, 166);
            deviceList = deviceMapper.selectByMap(params);
                Iterator<Device> iter = deviceList.iterator();
                while (iter.hasNext()) {
                    Device device = iter.next();
                    Integer mpId = device.getMonitorPointId();
                    Integer oid = monitorPointService.byIdGetMonitorPoint(mpId).getOrganizationId();
                    if (!orgIds.contains(oid)) {
                        iter.remove();
                    } else {
                        if (orgId == 60) {
                            if (mpId != 56) {
                                iter.remove();
                            }
                        } else if (orgId == 65) {
                            if (mpId != 83 && mpId != 84) {
                                iter.remove();
                            }
                        }
                    }
                }
            }else {
                params.put("orgIds", orgIds);
                deviceList = deviceMapper.selectByMap(params);
            }
            // loadDeviceState(deviceList);
        }
        Example deviceExample = new Example(Device.class);//实例化
@@ -719,8 +749,8 @@
    }
    @Override
    public List byMonitorIdGetDeviceAndWind(String id,String time,String tab) {
        List<DeviceAndWind> deviceAndWinds=deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id),time,tab);
    public List byMonitorIdGetDeviceAndWind(String id, String tab) {
        List<DeviceAndWind> deviceAndWinds = deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id), tab);
        List loList=new ArrayList();
        List laList=new ArrayList();
        Double U=0.0;
@@ -876,7 +906,7 @@
    }
    @Override
    public List byMonitorIdGetDeviceAndWindSpecial(String id, String time, String tab) {
    public List byMonitorIdGetDeviceAndWindSpecial(String id, String tab) {
        MonitorPoint monitorPoint=monitorPointMapper.byIdGetMonitorPoint(Integer.parseInt(id));
        Integer areaCode=monitorPoint.getAreaCode();
        String townCode= monitorPoint.getTownCode()+"";
@@ -895,7 +925,7 @@
            List<Device> deviceList=deviceMapper.getDeviceByCode(parm);
            for (Device d : deviceList) {
                String mac=d.getMac();
                 DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac,time,tab);
                DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac, tab);
                 if (deviceAndWind!=null){
                     deviceAndWinds.add(deviceAndWind);
                 }
@@ -907,7 +937,7 @@
            List<Device> deviceList=deviceMapper.getDeviceByCode(parm);
            for (Device d : deviceList) {
                String mac=d.getMac();
                DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac,time,tab);
                DeviceAndWind deviceAndWind = deviceMapper.byMacGetDeviceAndWind(mac, tab);
                if (deviceAndWind!=null){
                    deviceAndWinds.add(deviceAndWind);
                }
@@ -915,15 +945,15 @@
            length=2000;
            perdlen=280;
        }else if(monitorPointId==35){
         DeviceAndWind deviceAndWind=deviceMapper.getDeviceAndWindByMac("898607b0101730392253",time,tab);
         DeviceAndWind deviceAndWind1=deviceMapper.getDeviceAndWindByMac("p5dnd7a0392083",time,tab);
            DeviceAndWind deviceAndWind = deviceMapper.getDeviceAndWindByMac("898607b0101730392253", tab);
            DeviceAndWind deviceAndWind1 = deviceMapper.getDeviceAndWindByMac("p5dnd7a0392083", tab);
         deviceAndWinds.add(deviceAndWind);
         deviceAndWinds.add(deviceAndWind1);
            length=2000;
            perdlen=50;
        }else {
            deviceAndWinds=deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id),time,tab);
            deviceAndWinds = deviceMapper.byMonitorIdGetDeviceAndWind(Integer.parseInt(id), tab);
            length=2000;
            perdlen=80;
        }
@@ -999,7 +1029,7 @@
                if (tvoc==null){
                    tvoc=0.0;
                }
                Double dir = (270.0 + windDir * Math.PI / 180.0);
            Double dir = (270.0 - windDir * Math.PI / 180.0);
                U = windSpeed * Math.cos(dir);
                V = windSpeed * Math.sin(dir);
@@ -1088,4 +1118,14 @@
        return deviceMapper.byMacGetOrgId(mac);
    }
    @Override
    public List<Device> getDevice(String macOrName) {
        return deviceMapper.getDevice(macOrName);
    }
    @Override
    public List<Device> getDeviceByCode() {
        return deviceMapper.getDeviceByCityCode();
    }
}