|
@@ -172,7 +172,7 @@ public class DeviceService {
|
|
|
device.setUpdateTime(now);
|
|
device.setUpdateTime(now);
|
|
|
device.setMountainId(headerData.getCompanyId());
|
|
device.setMountainId(headerData.getCompanyId());
|
|
|
deviceMapper.insert(device);
|
|
deviceMapper.insert(device);
|
|
|
- //新增到数据表kws_device_relation
|
|
|
|
|
|
|
+ //新增到数据表kws_device_Integration
|
|
|
KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
|
|
KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
|
|
|
String[] temp;//接收分割后的数组
|
|
String[] temp;//接收分割后的数组
|
|
|
temp = deviceAdd.getIntegrationId().split(Global.COMMA);
|
|
temp = deviceAdd.getIntegrationId().split(Global.COMMA);
|
|
@@ -259,14 +259,54 @@ public class DeviceService {
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public HttpResult update(DeviceAdd deviceAdd, HttpServletRequest response) {
|
|
public HttpResult update(DeviceAdd deviceAdd, HttpServletRequest response) {
|
|
|
|
|
+
|
|
|
|
|
+ KwsDevice deviceHas = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
|
|
|
+ .eq(KwsDevice::getId, deviceAdd.getId()));
|
|
|
|
|
+ if (Objects.isNull(deviceHas)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_SN_EXISTS);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
KwsDevice device = new KwsDevice();
|
|
KwsDevice device = new KwsDevice();
|
|
|
BeanUtils.copyProperties(deviceAdd, device);
|
|
BeanUtils.copyProperties(deviceAdd, device);
|
|
|
device.setId(Long.parseLong(deviceAdd.getId()));
|
|
device.setId(Long.parseLong(deviceAdd.getId()));
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
- device.setUpdateBy(Long.parseLong(commonService.getHeaderData(response).getUpdateBy()));
|
|
|
|
|
|
|
+ HeaderData headerData = commonService.getHeaderData(response);
|
|
|
|
|
+ device.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
|
device.setUpdateTime(now);
|
|
device.setUpdateTime(now);
|
|
|
- deviceMapper.updateById(device);
|
|
|
|
|
- return HttpResult.ok();
|
|
|
|
|
|
|
+ Integer updateStatus = deviceMapper.updateById(device);
|
|
|
|
|
+ if(updateStatus == 1){
|
|
|
|
|
+ int update = deviceIntegrationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceIntegration>()
|
|
|
|
|
+ .eq(KwsDeviceIntegration::getDeviceId, deviceAdd.getId())
|
|
|
|
|
+ .set(KwsDeviceIntegration::getDelFlag, NumberConstant.ONE)
|
|
|
|
|
+ .set(KwsDeviceIntegration::getUpdateBy,Long.parseLong(headerData.getUpdateBy()) )
|
|
|
|
|
+ .set(KwsDeviceIntegration::getUpdateTime, now));
|
|
|
|
|
+ if (update < 1) {
|
|
|
|
|
+ throw new BusinessException("删除设备集成要素异常");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //新增到数据表kws_device_Integration
|
|
|
|
|
+ KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
|
|
|
|
|
+ String[] temp;//接收分割后的数组
|
|
|
|
|
+ temp = deviceAdd.getIntegrationId().split(Global.COMMA);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < temp.length; i++) {
|
|
|
|
|
+ long interId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
|
|
+ deIntergration.setId(interId);
|
|
|
|
|
+ deIntergration.setDeviceId(Long.parseLong(deviceAdd.getId()));
|
|
|
|
|
+ deIntergration.setMountainId(headerData.getCompanyId());
|
|
|
|
|
+ deIntergration.setIntegrationId(Long.parseLong(temp[i]));
|
|
|
|
|
+ deIntergration.setCreateBy(Long.parseLong(headerData.getCreateBy()));
|
|
|
|
|
+ deIntergration.setCreateTime(now);
|
|
|
|
|
+ deIntergration.setStatus(NumberConstant.ZERO);
|
|
|
|
|
+ deIntergration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
|
|
|
+ deIntergration.setUpdateTime(now);
|
|
|
|
|
+ deviceIntegrationMapper.insert(deIntergration);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ throw new BusinessException("更新异常");
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|