设备型号版本功能完善
This commit is contained in:
parent
d525c321a7
commit
dff5c1cb8c
|
@ -39,6 +39,7 @@ import java.io.UnsupportedEncodingException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -280,14 +281,14 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
public int insertAsDevice(AsDevice asDevice)
|
public int insertAsDevice(AsDevice asDevice)
|
||||||
{
|
{
|
||||||
asDevice.setCreateTime(DateUtils.getNowDate());
|
asDevice.setCreateTime(DateUtils.getNowDate());
|
||||||
AsDevice device = setValue(asDevice);
|
AsDevice device = setDeviceValue(asDevice);
|
||||||
AsDevice vo = asDeviceMapper.selectAsDeviceByMac(asDevice.getMac());
|
AsDevice vo = asDeviceMapper.selectAsDeviceByMac(asDevice.getMac());
|
||||||
ServiceUtil.assertion(vo!=null,"该设备已存在,不允许重复!");
|
ServiceUtil.assertion(vo!=null,"该设备已存在,不允许重复!");
|
||||||
return asDeviceMapper.insertAsDevice(device);
|
return asDeviceMapper.insertAsDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AsDevice setValue(AsDevice asDevice){
|
public AsDevice setDeviceValue(AsDevice asDevice){
|
||||||
// 前缀校验
|
// 前缀校验
|
||||||
AsModel asModel = new AsModel();
|
AsModel asModel = new AsModel();
|
||||||
asModel.setPre(asDevice.getPre());
|
asModel.setPre(asDevice.getPre());
|
||||||
|
@ -506,34 +507,18 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean bandDevice(AsDevice asDevice) {
|
public Boolean bandDevice(AsDevice asDevice) {
|
||||||
AsDevice device = asDeviceMapper.selectAsDeviceByMac(asDevice.getMac());
|
int i = asDeviceMapper.insertAsDevice(asDevice);
|
||||||
/* 根据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);
|
|
||||||
ServiceUtil.assertion(i == 0, "绑定失败!");
|
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());
|
// toggleDevice(asDevice.getUserId(), asDevice.getDeviceId());
|
||||||
}
|
// return Boolean.TRUE;
|
||||||
logger.info("=================【绑定设备】成功==================");
|
// });
|
||||||
return Boolean.TRUE;
|
// if(Boolean.FALSE.equals(execute))throw new ServiceException("绑定失败");
|
||||||
});
|
|
||||||
if(Boolean.FALSE.equals(execute))throw new ServiceException("绑定失败");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,10 +679,6 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
{
|
{
|
||||||
throw new ServiceException(code+"-----"+ paramsObj.getString("msg"));
|
throw new ServiceException(code+"-----"+ paramsObj.getString("msg"));
|
||||||
}
|
}
|
||||||
int insert = asDeviceMapper.insert(asDevice);
|
|
||||||
if(insert==0){
|
|
||||||
throw new ServiceException("录入失败,插入数据失败!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user