设备型号版本功能完善
This commit is contained in:
parent
d525c321a7
commit
dff5c1cb8c
|
@ -39,6 +39,7 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -280,14 +281,14 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
public int insertAsDevice(AsDevice asDevice)
|
||||
{
|
||||
asDevice.setCreateTime(DateUtils.getNowDate());
|
||||
AsDevice device = setValue(asDevice);
|
||||
AsDevice device = setDeviceValue(asDevice);
|
||||
AsDevice vo = asDeviceMapper.selectAsDeviceByMac(asDevice.getMac());
|
||||
ServiceUtil.assertion(vo!=null,"该设备已存在,不允许重复!");
|
||||
return asDeviceMapper.insertAsDevice(device);
|
||||
}
|
||||
|
||||
|
||||
public AsDevice setValue(AsDevice asDevice){
|
||||
public AsDevice setDeviceValue(AsDevice asDevice){
|
||||
// 前缀校验
|
||||
AsModel asModel = new AsModel();
|
||||
asModel.setPre(asDevice.getPre());
|
||||
|
@ -506,34 +507,18 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
*/
|
||||
@Override
|
||||
public Boolean bandDevice(AsDevice asDevice) {
|
||||
AsDevice device = asDeviceMapper.selectAsDeviceByMac(asDevice.getMac());
|
||||
/* 根据mac号获取到设备详情*/
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
if(ObjectUtils.isEmpty(device)){
|
||||
asDevice.setDeviceName(defaultName);
|
||||
int i = bandSn(asDevice);
|
||||
ServiceUtil.assertion(i == 0, "录入失败!");
|
||||
}else{
|
||||
if(ObjectUtils.isNotEmpty(device.getUserId()) && device.getUserId()>0){
|
||||
throw new ServiceException("该设备已经绑定用户,请先解绑!");
|
||||
}
|
||||
device.setUserId(asDevice.getUserId());
|
||||
AsUser asUser = asUserService.selectUserById(asDevice.getUserId());
|
||||
ServiceUtil.assertion(ObjectUtils.isEmpty(asUser), "用户不存在!");
|
||||
device.setUserName(asUser.getUserName());
|
||||
device.setBluetoothId(asDevice.getBluetoothId());
|
||||
device.setBluetoothName(asDevice.getBluetoothName());
|
||||
device.setPre(asDevice.getPre());
|
||||
int i = asDeviceMapper.updateAsDevice(device);
|
||||
int i = asDeviceMapper.insertAsDevice(asDevice);
|
||||
ServiceUtil.assertion(i == 0, "绑定失败!");
|
||||
|
||||
// Boolean execute = transactionTemplate.execute(e -> {
|
||||
// asDevice.setDeviceName(defaultName);
|
||||
// int i = bandSn(asDevice);
|
||||
// ServiceUtil.assertion(i == 0, "录入失败!");
|
||||
// setDeviceValue(asDevice);
|
||||
// 切换默认设备
|
||||
toggleDevice(asDevice.getUserId(), device.getDeviceId());
|
||||
}
|
||||
logger.info("=================【绑定设备】成功==================");
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
if(Boolean.FALSE.equals(execute))throw new ServiceException("绑定失败");
|
||||
// toggleDevice(asDevice.getUserId(), asDevice.getDeviceId());
|
||||
// return Boolean.TRUE;
|
||||
// });
|
||||
// if(Boolean.FALSE.equals(execute))throw new ServiceException("绑定失败");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -694,10 +679,6 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
{
|
||||
throw new ServiceException(code+"-----"+ paramsObj.getString("msg"));
|
||||
}
|
||||
int insert = asDeviceMapper.insert(asDevice);
|
||||
if(insert==0){
|
||||
throw new ServiceException("录入失败,插入数据失败!");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user