|
|
@@ -1,5 +1,6 @@
|
|
|
package com.xunmei.iot.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -19,10 +20,7 @@ import com.xunmei.common.core.utils.StringUtils;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.redis.utils.RedisUtils;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
-import com.xunmei.iot.dto.deviceInfo.AlarmHostDeviceInfoVo;
|
|
|
-import com.xunmei.iot.dto.deviceInfo.EditAlarmHostDeviceDto;
|
|
|
-import com.xunmei.iot.dto.deviceInfo.EditDvrHostDeviceDto;
|
|
|
-import com.xunmei.iot.dto.deviceInfo.IotDeviceInfoPageDto;
|
|
|
+import com.xunmei.iot.dto.deviceInfo.*;
|
|
|
import com.xunmei.iot.mapper.IotAlarmDefenceAreaMapper;
|
|
|
import com.xunmei.iot.mapper.IotAlarmSubsystemMapper;
|
|
|
import com.xunmei.iot.mapper.IotDeviceInfoMapper;
|
|
|
@@ -32,6 +30,7 @@ import com.xunmei.iot.service.IotDeviceInfoExtendService;
|
|
|
import com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo;
|
|
|
import com.xunmei.iot.vo.deviceInfo.DvrHostDeviceInfoVo;
|
|
|
import com.xunmei.iot.vo.deviceInfo.IotDeviceInfoPageVo;
|
|
|
+import com.xunmei.iot.vo.deviceInfo.NetHostDeviceInfoVo;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.domain.SysUser;
|
|
|
@@ -41,6 +40,7 @@ import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.Serializable;
|
|
|
@@ -158,8 +158,10 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
case Dvs:
|
|
|
return "PT_" + DateUtils.parseDateToStr("yyyyMMddHHmmssSSS", new Date());
|
|
|
case AlarmHost:
|
|
|
+ case Host_Talk:
|
|
|
+ case Host_Door:
|
|
|
//DaHuaAlarmHost1729673859287
|
|
|
- return jsb.getString("deviceProduct") + System.currentTimeMillis();
|
|
|
+ return jsb.getString("deviceProduct") + "_" + System.currentTimeMillis();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -193,6 +195,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Integer editDvrHostDevice(EditDvrHostDeviceDto req) {
|
|
|
Long deviceId = req.getId();
|
|
|
SysOrg sysOrg = orgService.selectOrgById(req.getOrgId(), SecurityConstants.INNER);
|
|
|
@@ -247,7 +250,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
resp.setModels(deviceInfo.getDeviceModel());
|
|
|
resp.setIotCode(deviceInfo.getIotToken());
|
|
|
IotDeviceInfoExtend extend = extendService.findByDeviceId(id);
|
|
|
- BeanUtils.copyProperties(extend, resp,"id");
|
|
|
+ BeanUtils.copyProperties(extend, resp, "id");
|
|
|
resp.setUserName(extend.getUserName());
|
|
|
resp.setPassword(extend.getPassword());
|
|
|
resp.setServerIp(extend.getNetAddress());
|
|
|
@@ -256,13 +259,13 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
final LambdaQueryWrapper<IotAlarmSubsystem> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(IotAlarmSubsystem::getAlarmHostCode, deviceInfo.getDeviceCode());
|
|
|
wrapper.eq(IotAlarmSubsystem::getDeleted, 0);
|
|
|
- wrapper.select(IotAlarmSubsystem::getEnable,IotAlarmSubsystem::getCode, IotAlarmSubsystem::getName);
|
|
|
+ wrapper.select(IotAlarmSubsystem::getEnable, IotAlarmSubsystem::getCode, IotAlarmSubsystem::getName);
|
|
|
final List<IotAlarmSubsystem> subSystems = subsystemMapper.selectList(wrapper);
|
|
|
- if (CollUtil.isEmpty(subSystems)){
|
|
|
+ if (CollUtil.isEmpty(subSystems)) {
|
|
|
return resp;
|
|
|
}
|
|
|
resp.setSubSystemNums(subSystems.size());
|
|
|
- resp.setSubSystemList(subSystems.stream().map(r->{
|
|
|
+ resp.setSubSystemList(subSystems.stream().map(r -> {
|
|
|
final AlarmHostDeviceInfoVo.SubSystemInfoVo vo = new AlarmHostDeviceInfoVo.SubSystemInfoVo();
|
|
|
vo.setSubSystemIndex(r.getCode());
|
|
|
vo.setSubSystemName(r.getName());
|
|
|
@@ -274,11 +277,11 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
defenceWrapper.eq(IotAlarmDefenceArea::getAlarmHostCode, deviceInfo.getDeviceCode());
|
|
|
defenceWrapper.eq(IotAlarmDefenceArea::getDeleted, 0);
|
|
|
final List<IotAlarmDefenceArea> defenceAreaList = defenceAreaMapper.selectList(defenceWrapper);
|
|
|
- if (CollUtil.isEmpty(defenceAreaList)){
|
|
|
+ if (CollUtil.isEmpty(defenceAreaList)) {
|
|
|
return resp;
|
|
|
}
|
|
|
resp.setInputSensorNums(defenceAreaList.size());
|
|
|
- resp.setInputSensorList(defenceAreaList.stream().map(r->{
|
|
|
+ resp.setInputSensorList(defenceAreaList.stream().map(r -> {
|
|
|
final AlarmHostDeviceInfoVo.InputSensorInfoVo vo = new AlarmHostDeviceInfoVo.InputSensorInfoVo();
|
|
|
vo.setInputSensorIndex(r.getDefenceAreaIndex());
|
|
|
vo.setInputSensorName(r.getDefenceAreaName());
|
|
|
@@ -293,6 +296,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Integer editAlarmHostDevice(EditAlarmHostDeviceDto req) {
|
|
|
Long deviceId = req.getId();
|
|
|
SysOrg sysOrg = orgService.selectOrgById(req.getOrgId(), SecurityConstants.INNER);
|
|
|
@@ -302,11 +306,11 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- updateAddAlarmHostDevice(req, sysOrg);
|
|
|
+ updateAddAlarmHostDevice(req);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- private void updateAddAlarmHostDevice(EditAlarmHostDeviceDto req, SysOrg sysOrg) {
|
|
|
+ private void updateAddAlarmHostDevice(EditAlarmHostDeviceDto req) {
|
|
|
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
|
|
|
IotDeviceInfo deviceInfo = getById(req.getId());
|
|
|
|
|
|
@@ -476,4 +480,65 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Integer editNetHostDevice(EditNetHostDeviceDto req) {
|
|
|
+ final SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
|
|
|
+ final SysOrg sysOrg = orgService.selectSysOrgById(req.getOrgId(), SecurityConstants.INNER);
|
|
|
+ IotDeviceInfo deviceInfo;
|
|
|
+ if (req.getId() == null) {
|
|
|
+ deviceInfo = new IotDeviceInfo();
|
|
|
+ deviceInfo.setCreateTime(new Date());
|
|
|
+ deviceInfo.setCreateBy(sysUser.getId().toString());
|
|
|
+ }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;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public NetHostDeviceInfoVo netHostDeviceInfo(Long id) {
|
|
|
+
|
|
|
+ final IotDeviceInfo deviceInfo = getById(id);
|
|
|
+ if (deviceInfo == null) {
|
|
|
+ throw new RuntimeException("设备不存在");
|
|
|
+ }
|
|
|
+ NetHostDeviceInfoVo resp=new NetHostDeviceInfoVo();
|
|
|
+ final IotDeviceInfoExtend extend = extendService.findByDeviceId(id);
|
|
|
+ BeanUtil.copyProperties(deviceInfo, resp);
|
|
|
+ resp.setIotCode(deviceInfo.getIotToken());
|
|
|
+ resp.setDeviceBrand(deviceInfo.getDeviceBrand());
|
|
|
+ resp.setServerIp(extend.getNetAddress());
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
}
|