ZhuDongming
2020-07-06 f145f5ca0b1beef1300ef73ed1393af63413779d
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -23,6 +23,7 @@
import com.moral.common.util.ValidateUtil;
import com.moral.entity.Device;
import com.moral.entity.DeviceProperty;
import com.moral.entity.MonitorPoint;
import com.moral.mapper.DeviceMapper;
import com.moral.mapper.DevicePropertyMapper;
import com.moral.mapper.DeviceVersionMapper;
@@ -206,6 +207,7 @@
     */
    @Override
    public List<Device> query(Map<String, Object> params) {
        List<Integer> dv = deviceMapper.getHasWindDirAndWindSpeedDeviceVersion();
        Object orgIdObj = params.get("orgId");
        List<Device> deviceList = null;
        if (orgIdObj != null) {
@@ -214,6 +216,31 @@
            params.put("orgIds", orgIds);
            deviceList = deviceMapper.selectByMap(params);
            // loadDeviceState(deviceList);
        }
        Example deviceExample = new Example(Device.class);//实例化
        Example.Criteria deviceCriteria = deviceExample.createCriteria();
        deviceCriteria.orEqualTo("isDelete", Constants.IS_DELETE_FALSE);
        List<Device> devicesInfo = deviceMapper.selectByExample(deviceExample);
        Example monitorExample = new Example(MonitorPoint.class);//实例化
        Example.Criteria monitorCriteria = monitorExample.createCriteria();
        monitorCriteria.orEqualTo("isDelete", Constants.IS_DELETE_FALSE);
        List<MonitorPoint> monitorsInfo = monitorPointMapper.selectByExample(monitorExample);
        for (Device d : deviceList) {
            if (dv.contains(d.getDeviceVersionId())) {
                d.setHasWindInfo(true);
            } else {
                d.setHasWindInfo(false);
            }
            for (Device temp : devicesInfo) {
                if (d.getId().equals(temp.getId())) {
                    d.setState(temp.getState());
                }
            }
            for (MonitorPoint mp : monitorsInfo) {
                if (d.getMonitorPointId().equals(mp.getId())) {
                    d.setMonitorPoint(mp);
                }
            }
        }
        return deviceList;
    }
@@ -635,4 +662,39 @@
    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);
    }
    @Override
    public List<Device> queryDevice(Map<String, Object> params) {
        List<Integer> dv = deviceMapper.getHasWindDirAndWindSpeedDeviceVersion();
        Object orgIdObj = params.get("orgId");
        List<Device> deviceList = null;
        if (orgIdObj != null) {
            Integer orgId = Integer.parseInt(orgIdObj.toString());
            List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
            params.put("orgIds", orgIds);
            deviceList = deviceMapper.selectDevicesAll(params);
        }
        List<Device> deviceListHasWind=new ArrayList<>();
        for (Device d : deviceList) {
            if (dv.contains(d.getDeviceVersionId())) {
                deviceListHasWind.add(d);
            }
        }
        return deviceListHasWind;
    }
}