|
@@ -104,6 +104,32 @@ public class IotDeviceService {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改设备
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param iotDevicePara
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public Object update(IotDevicePara iotDevicePara) {
|
|
|
|
|
+ if (Objects.isNull(iotDevicePara.getId())) {
|
|
|
|
|
+ throw new BusinessException("id不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ //校验sn
|
|
|
|
|
+ checkDeviceSn(iotDevicePara.getSn());
|
|
|
|
|
+ //校验产品
|
|
|
|
|
+ checkProduct(iotDevicePara.getProductId());
|
|
|
|
|
+
|
|
|
|
|
+ IotDevice iotDevice = new IotDevice();
|
|
|
|
|
+ iotDevice.setId(iotDevicePara.getId());
|
|
|
|
|
+ iotDevice.setProductId(iotDevicePara.getProductId());
|
|
|
|
|
+ iotDevice.setName(iotDevicePara.getName());
|
|
|
|
|
+ iotDevice.setSn(iotDevicePara.getSn());
|
|
|
|
|
+ iotDevice.setSubtitle(iotDevicePara.getSubtitle());
|
|
|
|
|
+ iotDevice.setRemark(iotDevicePara.getRemark());
|
|
|
|
|
+ iotDeviceMapper.updateById(iotDevice);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 删除设备
|
|
* 删除设备
|
|
|
*
|
|
*
|
|
@@ -208,9 +234,7 @@ public class IotDeviceService {
|
|
|
}
|
|
}
|
|
|
//产品编码转换
|
|
//产品编码转换
|
|
|
for (DeviceImportExcelVo deviceImportExcelVo : list) {
|
|
for (DeviceImportExcelVo deviceImportExcelVo : list) {
|
|
|
- IotProduct iotProduct = iotProductMapper.selectOne(new LambdaQueryWrapper<IotProduct>()
|
|
|
|
|
- .eq(IotProduct::getCode, deviceImportExcelVo.getCode())
|
|
|
|
|
- .eq(IotProduct::getDelFlag, Global.UN_DEL).last("limit 1"));
|
|
|
|
|
|
|
+ IotProduct iotProduct = iotProductMapper.selectOne(new LambdaQueryWrapper<IotProduct>().eq(IotProduct::getCode, deviceImportExcelVo.getCode()).eq(IotProduct::getDelFlag, Global.UN_DEL).last("limit 1"));
|
|
|
if (Objects.isNull(iotProduct)) {
|
|
if (Objects.isNull(iotProduct)) {
|
|
|
throw new BusinessException("产品编码[" + deviceImportExcelVo.getCode() + "]产品不存在");
|
|
throw new BusinessException("产品编码[" + deviceImportExcelVo.getCode() + "]产品不存在");
|
|
|
}
|
|
}
|
|
@@ -257,8 +281,7 @@ public class IotDeviceService {
|
|
|
* @param sn
|
|
* @param sn
|
|
|
*/
|
|
*/
|
|
|
private void checkDeviceSn(String sn) {
|
|
private void checkDeviceSn(String sn) {
|
|
|
- IotDevice iotDevice = iotDeviceMapper.selectOne(new LambdaQueryWrapper<IotDevice>()
|
|
|
|
|
- .eq(IotDevice::getSn, sn).eq(IotDevice::getDelFlag, Global.UN_DEL).last("limit 1"));
|
|
|
|
|
|
|
+ IotDevice iotDevice = iotDeviceMapper.selectOne(new LambdaQueryWrapper<IotDevice>().eq(IotDevice::getSn, sn).eq(IotDevice::getDelFlag, Global.UN_DEL).last("limit 1"));
|
|
|
if (Objects.nonNull(iotDevice)) {
|
|
if (Objects.nonNull(iotDevice)) {
|
|
|
throw new BusinessException("当前设备【" + iotDevice.getSn() + "】已存在");
|
|
throw new BusinessException("当前设备【" + iotDevice.getSn() + "】已存在");
|
|
|
}
|
|
}
|
|
@@ -270,10 +293,11 @@ public class IotDeviceService {
|
|
|
* @param productId 产品id
|
|
* @param productId 产品id
|
|
|
*/
|
|
*/
|
|
|
private void checkProduct(Long productId) {
|
|
private void checkProduct(Long productId) {
|
|
|
- IotProduct iotProduct = iotProductMapper.selectOne(new LambdaQueryWrapper<IotProduct>()
|
|
|
|
|
- .eq(IotProduct::getId, productId).eq(IotProduct::getDelFlag, Global.UN_DEL).last("limit 1"));
|
|
|
|
|
|
|
+ IotProduct iotProduct = iotProductMapper.selectOne(new LambdaQueryWrapper<IotProduct>().eq(IotProduct::getId, productId).eq(IotProduct::getDelFlag, Global.UN_DEL).last("limit 1"));
|
|
|
if (Objects.isNull(iotProduct)) {
|
|
if (Objects.isNull(iotProduct)) {
|
|
|
throw new BusinessException("当前产品不存在");
|
|
throw new BusinessException("当前产品不存在");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|