Commit 34e75af8 authored by 赵啸非's avatar 赵啸非

修改接口修改设备

parent 82403c41
...@@ -354,25 +354,26 @@ public class DeviceApiController { ...@@ -354,25 +354,26 @@ public class DeviceApiController {
} }
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode()); DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode());
if (ObjectUtils.isEmpty(deviceEntity)) { if (ObjectUtils.isEmpty(deviceEntity)) {
//初始化新增基础设备,后续在线完善信息后再行注册添加 //初始化新增基础设备,后续在线完善信息后再行注册添加
deviceEntity = new DeviceEntity(); deviceEntity = new DeviceEntity();
deviceEntity.initAttrValue(); deviceEntity.initAttrValue();
saveOrUpdate(req, platformEntity, productEntity, deviceEntity); saveDevice(req, platformEntity, productEntity, deviceEntity);
deviceEntity.setCreateTime(new Date()); deviceEntity.setCreateTime(new Date());
deviceEntity.setCreateUserId(1L); deviceEntity.setCreateUserId(1L);
deviceService.save(deviceEntity, null); deviceService.save(deviceEntity, null);
} else { } else {
//更新 //更新
saveOrUpdate(req, platformEntity, productEntity, deviceEntity); updateDevice(req, platformEntity, productEntity, deviceEntity);
deviceEntity.setUpdateTime(new Date()); deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(1L); deviceEntity.setUpdateUserId(1L);
deviceService.update(deviceEntity, null); deviceService.update(deviceEntity, null);
} }
if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()) { /* if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()) {
throw new AppException(DEVICE_UNACTIVE, DEVICE_UNACTIVE_CONTENT); throw new AppException(DEVICE_UNACTIVE, DEVICE_UNACTIVE_CONTENT);
} }*/
DeviceQueueAuthInfo authInfo = new DeviceQueueAuthInfo(); DeviceQueueAuthInfo authInfo = new DeviceQueueAuthInfo();
authInfo.setHost(host); authInfo.setHost(host);
...@@ -471,7 +472,7 @@ public class DeviceApiController { ...@@ -471,7 +472,7 @@ public class DeviceApiController {
return JSON.toJSONString(rsp); return JSON.toJSONString(rsp);
} }
private void saveOrUpdate(DeviceReq req, PlatformEntity platformEntity, ProductEntity productEntity, DeviceEntity deviceEntity) { private void saveDevice(DeviceReq req, PlatformEntity platformEntity, ProductEntity productEntity, DeviceEntity deviceEntity) {
BeanUtils.copyProperties(req, deviceEntity, BeanUtil.getNullPropertyNames(req)); BeanUtils.copyProperties(req, deviceEntity, BeanUtil.getNullPropertyNames(req));
deviceEntity.setPlatformId(platformEntity.getId()); deviceEntity.setPlatformId(platformEntity.getId());
...@@ -489,9 +490,22 @@ public class DeviceApiController { ...@@ -489,9 +490,22 @@ public class DeviceApiController {
deviceEntity.setDeviceCode(req.getDeviceCode()); deviceEntity.setDeviceCode(req.getDeviceCode());
deviceEntity.setEnabled(YesNoEnum.YES.getValue()); deviceEntity.setEnabled(YesNoEnum.YES.getValue());
if (!ObjectUtils.isEmpty(req.getActive())) { deviceEntity.setDeviceStatus( DeviceStatusEnum.未激活.getValue());
deviceEntity.setDeviceStatus(req.getActive() == YesNoEnum.YES.getValue() ? DeviceStatusEnum.离线.getValue() : DeviceStatusEnum.未激活.getValue()); deviceEntity.setSource(req.getSource());
} }
private void updateDevice(DeviceReq req, PlatformEntity platformEntity, ProductEntity productEntity, DeviceEntity deviceEntity) {
deviceEntity.setPlatformId(platformEntity.getId());
deviceEntity.setPlatformName(platformEntity.getPlatformName());
deviceEntity.setProductId(productEntity.getId());
deviceEntity.setProductName(productEntity.getProductName());
deviceEntity.setProductCode(productEntity.getProductCode());
deviceEntity.setSiteId(req.getSiteId());
deviceEntity.setSiteCode(req.getSiteCode());
deviceEntity.setSiteName(req.getSiteName());
deviceEntity.setSource(req.getSource()); deviceEntity.setSource(req.getSource());
} }
......
...@@ -100,6 +100,17 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -100,6 +100,17 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Autowired @Autowired
private SiteService siteService; private SiteService siteService;
public void refresh() {
log.info("开始初始化系统参数...");
try {
super.removeAllCache();
super.loadCache();
log.info("系统参数初始化完成!");
} catch (Exception e) {
log.error("查询系统参数异常", e);
}
}
@Override @Override
protected String getExtKey(DeviceEntity data) { protected String getExtKey(DeviceEntity data) {
return data.getDeviceCode(); return data.getDeviceCode();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment