fengxiang
2018-06-14 bde2512a915e394ab6f3939833469516c473ee0e
EquDeviceAdapter 更新
1 files modified
15 ■■■■ changed files
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 15 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -376,18 +376,27 @@
    }
    @Override
    @Transactional
    public void addOrModify(Device device){
        try{
            //mac 转小写
            if(!StringUtils.isBlank(device.getMac())){
                device.setMac(device.getMac().toLowerCase());
            }
            if(device.getId()==null){
            if(device.getId()!=null){
                deviceMapper.updateByPrimaryKeySelective(device);
            }else{
                Device deviceQuery = new Device();
                deviceQuery.setMac(device.getMac());
                Device deviceResult = deviceMapper.selectOne(deviceQuery);
                if(deviceResult !=null){
                    device.setId(deviceResult.getId());
                    deviceMapper.updateByPrimaryKeySelective(device);
                }else {
                device.setState(Constants.DEVICE_STATE_OFFLINE);
                device.setIsDelete(Constants.IS_DELETE_FALSE);
                deviceMapper.insertSelective(device);
            }else{
                deviceMapper.updateByPrimaryKeySelective(device);
                }
            }
            //刷新redis里设备信息
            refreshDeviceInRedis(device.getMac());