|
|
@@ -206,9 +206,6 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
if (deviceId == null) {
|
|
|
IotDeviceInfo deviceInfo = new IotDeviceInfo();
|
|
|
buildDeviceInfo(deviceInfo, req, sysOrg);
|
|
|
- deviceInfo.setId(IdWorker.getId());
|
|
|
- deviceInfo.setCreateTime(new Date());
|
|
|
- deviceInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getId().toString());
|
|
|
effect = baseMapper.insert(deviceInfo);
|
|
|
deviceId = deviceInfo.getId();
|
|
|
} else {
|
|
|
@@ -227,24 +224,29 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
deviceInfo.setDeviceName(req.getDeviceName());
|
|
|
deviceInfo.setDeviceType(BaseDeviceTypeEnum.Dvs.getCode());
|
|
|
deviceInfo.setDeviceProduct(req.getDeviceProduct());
|
|
|
- if (ObjectUtil.isEmpty(deviceInfo.getDeviceCode())) {
|
|
|
- deviceInfo.setDeviceCode(generalDeviceCode(BaseDeviceTypeEnum.Dvs, null));
|
|
|
- }
|
|
|
IotServerProduct product = baseMapper.selectProduct(req.getDeviceProduct());
|
|
|
SysMultiLayerDictionary dictionary = baseMapper.selectMultiLayerDictionaryByName(product.getProducer());
|
|
|
if (dictionary!=null){
|
|
|
deviceInfo.setDeviceBrand(dictionary.getId());
|
|
|
}
|
|
|
deviceInfo.setDeviceModel(req.getModels());
|
|
|
- deviceInfo.setIotToken(req.getIotCode());
|
|
|
- deviceInfo.setOrgId(req.getOrgId());
|
|
|
deviceInfo.setEnable(req.getEnable());
|
|
|
deviceInfo.setDeleted(0);
|
|
|
- deviceInfo.setNetStatus("0");
|
|
|
+ if (deviceInfo.getId()==null){
|
|
|
+ deviceInfo.setOrgId(req.getOrgId());
|
|
|
+ deviceInfo.setOrgName(sysOrg.getShortName());
|
|
|
+ deviceInfo.setOrgPath(sysOrg.getPath());
|
|
|
+ deviceInfo.setNetStatus("0");
|
|
|
+ deviceInfo.setSyncStatus(0);
|
|
|
+ deviceInfo.setIotToken(req.getIotCode());
|
|
|
+ deviceInfo.setDeviceCode(generalDeviceCode(BaseDeviceTypeEnum.Dvs, null));
|
|
|
+ deviceInfo.setCreateTime(new Date());
|
|
|
+ deviceInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getId().toString());
|
|
|
+ deviceInfo.setId(IdWorker.getId());
|
|
|
+ }
|
|
|
deviceInfo.setUpdateTime(new Date());
|
|
|
deviceInfo.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getName());
|
|
|
- deviceInfo.setOrgName(sysOrg.getShortName());
|
|
|
- deviceInfo.setOrgPath(sysOrg.getPath());
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -418,6 +420,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
deviceInfo.setIotToken(req.getIotCode());
|
|
|
deviceInfo.setOrgId(req.getOrgId());
|
|
|
deviceInfo.setEnable(req.getEnable());
|
|
|
+ deviceInfo.setSyncStatus(0);
|
|
|
deviceInfo.setDeleted(0);
|
|
|
deviceInfo.setCreateTime(new Date());
|
|
|
deviceInfo.setUpdateTime(new Date());
|
|
|
@@ -496,39 +499,36 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
final SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
|
|
|
final SysOrg sysOrg = orgService.selectSysOrgById(req.getOrgId(), SecurityConstants.INNER);
|
|
|
IotDeviceInfo deviceInfo;
|
|
|
+ final BaseDeviceTypeEnum typeEnum = BaseDeviceTypeEnum.getEnumByCode(req.getDeviceType());
|
|
|
+ JSONObject JSB = new JSONObject();
|
|
|
if (req.getId() == null) {
|
|
|
deviceInfo = new IotDeviceInfo();
|
|
|
deviceInfo.setCreateTime(new Date());
|
|
|
deviceInfo.setCreateBy(sysUser.getId().toString());
|
|
|
+ deviceInfo.setIotToken(req.getIotCode()); deviceInfo.setOrgId(sysOrg.getId());
|
|
|
+ deviceInfo.setOrgName(sysOrg.getShortName());
|
|
|
+ deviceInfo.setOrgPath(sysOrg.getPath());
|
|
|
+ deviceInfo.setDeleted(0);
|
|
|
+ switch (typeEnum) {
|
|
|
+ case Host_Talk:
|
|
|
+ deviceInfo.setDeviceProduct("TALK_HOST");
|
|
|
+ JSB.put("deviceProduct", deviceInfo.getDeviceProduct());
|
|
|
+ deviceInfo.setDeviceCode(generalDeviceCode(BaseDeviceTypeEnum.Host_Talk, JSB));
|
|
|
+ break;
|
|
|
+ case Host_Door:
|
|
|
+ deviceInfo.setDeviceProduct("DOOR_HOST");
|
|
|
+ JSB.put("deviceProduct", deviceInfo.getDeviceProduct());
|
|
|
+ deviceInfo.setDeviceCode(generalDeviceCode(BaseDeviceTypeEnum.Host_Door, JSB));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
} else {
|
|
|
deviceInfo = getById(req.getId());
|
|
|
}
|
|
|
BeanUtil.copyProperties(req, deviceInfo);
|
|
|
- deviceInfo.setIotToken(req.getIotCode());
|
|
|
- final BaseDeviceTypeEnum typeEnum = BaseDeviceTypeEnum.getEnumByCode(req.getDeviceType());
|
|
|
- JSONObject JSB = new JSONObject();
|
|
|
- switch (typeEnum) {
|
|
|
- case Host_Talk:
|
|
|
- deviceInfo.setDeviceProduct("TALK_HOST");
|
|
|
- JSB.put("deviceProduct", deviceInfo.getDeviceProduct());
|
|
|
- deviceInfo.setDeviceCode(generalDeviceCode(BaseDeviceTypeEnum.Host_Talk, JSB));
|
|
|
-
|
|
|
- break;
|
|
|
- case Host_Door:
|
|
|
- deviceInfo.setDeviceProduct("DOOR_HOST");
|
|
|
- JSB.put("deviceProduct", deviceInfo.getDeviceProduct());
|
|
|
- deviceInfo.setDeviceCode(generalDeviceCode(BaseDeviceTypeEnum.Host_Door, JSB));
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
deviceInfo.setUpdateTime(new Date());
|
|
|
deviceInfo.setUpdateBy(sysUser.getId().toString());
|
|
|
- deviceInfo.setOrgId(sysOrg.getId());
|
|
|
- deviceInfo.setOrgName(sysOrg.getShortName());
|
|
|
- deviceInfo.setOrgPath(sysOrg.getPath());
|
|
|
- deviceInfo.setDeleted(0);
|
|
|
saveOrUpdate(deviceInfo);
|
|
|
extendService.updateNetHostExtendByDeviceId(deviceInfo.getId(), req);
|
|
|
return 1;
|