|
@@ -14,6 +14,7 @@ import com.yunfeiyun.agmp.iot.common.enums.IotDeviceconnTypeEnum;
|
|
|
import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
import com.yunfeiyun.agmp.iotm.device.domain.IotDevconnConfigInfoVo;
|
|
import com.yunfeiyun.agmp.iotm.device.domain.IotDevconnConfigInfoVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.domain.reqvo.IotDeviceconnAddReqVo;
|
|
import com.yunfeiyun.agmp.iotm.device.domain.reqvo.IotDeviceconnAddReqVo;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.device.domain.reqvo.IotDeviceconnEditReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.domain.reqvo.IotDeviceconnListReqVo;
|
|
import com.yunfeiyun.agmp.iotm.device.domain.reqvo.IotDeviceconnListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.domain.resvo.IotDeviceconnInfoResVo;
|
|
import com.yunfeiyun.agmp.iotm.device.domain.resvo.IotDeviceconnInfoResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.domain.resvo.IotDeviceconnListResVo;
|
|
import com.yunfeiyun.agmp.iotm.device.domain.resvo.IotDeviceconnListResVo;
|
|
@@ -38,88 +39,10 @@ public class IotDeviceconnServiceImpl implements IIotDeviceconnService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ITosDevicetypeService tosDevicetypeService;
|
|
private ITosDevicetypeService tosDevicetypeService;
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 查询设备连接配置
|
|
|
|
|
- *
|
|
|
|
|
- * @param id 设备连接配置主键
|
|
|
|
|
- * @return 设备连接配置
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public IotDeviceconn selectIotDeviceconnById(Long id)
|
|
|
|
|
- {
|
|
|
|
|
- return iotDeviceconnMapper.selectIotDeviceconnById(id);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 查询设备连接配置列表
|
|
|
|
|
- *
|
|
|
|
|
- * @param iotDeviceconn 设备连接配置
|
|
|
|
|
- * @return 设备连接配置
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public List<IotDeviceconn> selectIotDeviceconnList(IotDeviceconn iotDeviceconn)
|
|
|
|
|
- {
|
|
|
|
|
- iotDeviceconn.setTid(SecurityUtils.getTid());
|
|
|
|
|
- return iotDeviceconnMapper.selectIotDeviceconnList(iotDeviceconn);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 新增设备连接配置
|
|
|
|
|
- *
|
|
|
|
|
- * @param iotDeviceconn 设备连接配置
|
|
|
|
|
- * @return 结果
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public int insertIotDeviceconn(IotDeviceconn iotDeviceconn)
|
|
|
|
|
- {
|
|
|
|
|
- iotDeviceconn.setTid(SecurityUtils.getTid());
|
|
|
|
|
- return iotDeviceconnMapper.insertIotDeviceconn(iotDeviceconn);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 修改设备连接配置
|
|
|
|
|
- *
|
|
|
|
|
- * @param iotDeviceconn 设备连接配置
|
|
|
|
|
- * @return 结果
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public int updateIotDeviceconn(IotDeviceconn iotDeviceconn)
|
|
|
|
|
- {
|
|
|
|
|
- return iotDeviceconnMapper.updateIotDeviceconn(iotDeviceconn);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 批量删除设备连接配置
|
|
|
|
|
- *
|
|
|
|
|
- * @param ids 需要删除的设备连接配置主键
|
|
|
|
|
- * @return 结果
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public int deleteIotDeviceconnByIds(Long[] ids)
|
|
|
|
|
- {
|
|
|
|
|
- return iotDeviceconnMapper.deleteIotDeviceconnByIds(ids);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 删除设备连接配置信息
|
|
|
|
|
- *
|
|
|
|
|
- * @param id 设备连接配置主键
|
|
|
|
|
- * @return 结果
|
|
|
|
|
- */
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public int deleteIotDeviceconnById(Long id)
|
|
|
|
|
- {
|
|
|
|
|
- return iotDeviceconnMapper.deleteIotDeviceconnById(id);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public int addDeviceconn(IotDeviceconnAddReqVo reqVo) {
|
|
|
|
|
|
|
+ public int addDeviceconn(IotDeviceconnAddReqVo reqVo, boolean isCreateConnect) {
|
|
|
String devconnType = reqVo.getDevconnType();
|
|
String devconnType = reqVo.getDevconnType();
|
|
|
String devtypeBid = reqVo.getDevtypeBid();
|
|
String devtypeBid = reqVo.getDevtypeBid();
|
|
|
- List<IotDevconnConfigInfoVo> devconnConfigList = reqVo.getDevconnConfigList();
|
|
|
|
|
- if(devconnConfigList == null || devconnConfigList.isEmpty()){
|
|
|
|
|
- throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"连接配置不能为空");
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
TosDevicetype tosDevicetype = tosDevicetypeService.selectTosDevicetypeByDevtypeBid(devtypeBid);
|
|
TosDevicetype tosDevicetype = tosDevicetypeService.selectTosDevicetypeByDevtypeBid(devtypeBid);
|
|
|
if(tosDevicetype == null){
|
|
if(tosDevicetype == null){
|
|
@@ -147,6 +70,10 @@ public class IotDeviceconnServiceImpl implements IIotDeviceconnService
|
|
|
|
|
|
|
|
insertIotDeviceconnList.add(iotDeviceconn);
|
|
insertIotDeviceconnList.add(iotDeviceconn);
|
|
|
}else{
|
|
}else{
|
|
|
|
|
+ List<IotDevconnConfigInfoVo> devconnConfigList = reqVo.getDevconnConfigList();
|
|
|
|
|
+ if(devconnConfigList == null || devconnConfigList.isEmpty()){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"连接配置不能为空");
|
|
|
|
|
+ }
|
|
|
String diffName = "";
|
|
String diffName = "";
|
|
|
for(IotDevconnConfigInfoVo devconnConfigInfo : devconnConfigList){
|
|
for(IotDevconnConfigInfoVo devconnConfigInfo : devconnConfigList){
|
|
|
String devconnName = devconnConfigInfo.getDevconnName();
|
|
String devconnName = devconnConfigInfo.getDevconnName();
|
|
@@ -185,11 +112,17 @@ public class IotDeviceconnServiceImpl implements IIotDeviceconnService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int status = insertIotDeviceconnByBatch(insertIotDeviceconnList);
|
|
int status = insertIotDeviceconnByBatch(insertIotDeviceconnList);
|
|
|
-
|
|
|
|
|
- // Todo 发送消息,创建设备连接
|
|
|
|
|
|
|
+ if(isCreateConnect) {
|
|
|
|
|
+ // Todo 发送消息,创建设备连接
|
|
|
|
|
+ }
|
|
|
return status;
|
|
return status;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int addDeviceconn(IotDeviceconnAddReqVo reqVo) {
|
|
|
|
|
+ return addDeviceconn(reqVo, true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询设备连接配置列表
|
|
* 查询设备连接配置列表
|
|
|
*
|
|
*
|
|
@@ -202,20 +135,6 @@ public class IotDeviceconnServiceImpl implements IIotDeviceconnService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 批量新增设备连接配置
|
|
|
|
|
- *
|
|
|
|
|
- * @param iotDeviceconnList 设备连接配置列表
|
|
|
|
|
- * @return 结果
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public int insertIotDeviceconnByBatch(List<IotDeviceconn> iotDeviceconnList) {
|
|
|
|
|
- for (IotDeviceconn iotDeviceconn : iotDeviceconnList) {
|
|
|
|
|
- iotDeviceconn.setTid(SecurityUtils.getTid());
|
|
|
|
|
- }
|
|
|
|
|
- return iotDeviceconnMapper.insertIotDeviceconnByBatch(iotDeviceconnList);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
* 获取设备连接配置详细信息
|
|
* 获取设备连接配置详细信息
|
|
|
*
|
|
*
|
|
|
* @param devtypeBid 设备连接配置主键
|
|
* @param devtypeBid 设备连接配置主键
|
|
@@ -250,4 +169,128 @@ public class IotDeviceconnServiceImpl implements IIotDeviceconnService
|
|
|
}
|
|
}
|
|
|
return iotDeviceconnInfoResVo;
|
|
return iotDeviceconnInfoResVo;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改设备连接配置
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param reqVo@return 结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int editIotDeviceconn(IotDeviceconnEditReqVo reqVo) {
|
|
|
|
|
+ String devconnType = reqVo.getDevconnType();
|
|
|
|
|
+ String oldDevtypeBid = reqVo.getOldDevtypeBid();
|
|
|
|
|
+ String newDevtypeBid = reqVo.getNewDevtypeBid();
|
|
|
|
|
+
|
|
|
|
|
+ IotDeviceconn selectIotDeviceconn = new IotDeviceconn();
|
|
|
|
|
+ selectIotDeviceconn.setDevtypeBid(oldDevtypeBid);
|
|
|
|
|
+ List<IotDeviceconn> iotDeviceconnList = selectIotDeviceconnList(selectIotDeviceconn);
|
|
|
|
|
+ if(iotDeviceconnList == null || iotDeviceconnList.isEmpty()){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"连接配置不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ TosDevicetype tosDevicetype = tosDevicetypeService.selectTosDevicetypeByDevtypeBid(newDevtypeBid);
|
|
|
|
|
+ if(tosDevicetype == null){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"设备型号不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<String> devconnBids = new ArrayList<>();
|
|
|
|
|
+ for(IotDeviceconn iotDeviceconn : iotDeviceconnList){
|
|
|
|
|
+ devconnBids.add(iotDeviceconn.getDevconnBid());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ deleteIotDeviceconnByBids(devconnBids.toArray(new String[0]), false);
|
|
|
|
|
+
|
|
|
|
|
+ IotDeviceconnAddReqVo addReqVo = new IotDeviceconnAddReqVo();
|
|
|
|
|
+ addReqVo.setDevtypeBid(newDevtypeBid);
|
|
|
|
|
+ addReqVo.setDevconnType(devconnType);
|
|
|
|
|
+ addReqVo.setDevconnConfigList(reqVo.getDevconnConfigList());
|
|
|
|
|
+
|
|
|
|
|
+ int status = addDeviceconn(addReqVo, false);
|
|
|
|
|
+ // Todo 发送消息,删除设备连接
|
|
|
|
|
+ // Todo 发送消息,更新设备连接
|
|
|
|
|
+
|
|
|
|
|
+ return status;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除设备连接配置信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param devtypeBid 设备连接配置主键
|
|
|
|
|
+ * @return 设备连接配置
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int deleteIotDeviceconn(String devtypeBid) {
|
|
|
|
|
+ if(StringUtils.isEmpty(devtypeBid)){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"参数不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ IotDeviceconn selectIotDeviceconn = new IotDeviceconn();
|
|
|
|
|
+ selectIotDeviceconn.setDevtypeBid(devtypeBid);
|
|
|
|
|
+ List<IotDeviceconn> iotDeviceconnList = selectIotDeviceconnList(selectIotDeviceconn);
|
|
|
|
|
+ if(iotDeviceconnList == null || iotDeviceconnList.isEmpty()){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"连接配置不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ // Todo 检测设备是否引用此连接配置,如果有则不允许删除
|
|
|
|
|
+ List<String> devconnBids = new ArrayList<>();
|
|
|
|
|
+ for(IotDeviceconn iotDeviceconn : iotDeviceconnList){
|
|
|
|
|
+ devconnBids.add(iotDeviceconn.getDevconnBid());
|
|
|
|
|
+ }
|
|
|
|
|
+ return deleteIotDeviceconnByBids(devconnBids.toArray(new String[0]));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量删除设备连接配置
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param devconnBids 需要删除的数据主键集合
|
|
|
|
|
+ * @return 结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int deleteIotDeviceconnByBids(String[] devconnBids, boolean isDeleteConnect) {
|
|
|
|
|
+ int status = iotDeviceconnMapper.deleteIotDeviceconnByBids(devconnBids);
|
|
|
|
|
+ if(isDeleteConnect) {
|
|
|
|
|
+ // 删除设备连接配置
|
|
|
|
|
+ }
|
|
|
|
|
+ return status;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量删除设备连接配置
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param devconnBids 需要删除的数据主键集合
|
|
|
|
|
+ * @param
|
|
|
|
|
+ * @return 结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int deleteIotDeviceconnByBids(String[] devconnBids) {
|
|
|
|
|
+ return deleteIotDeviceconnByBids(devconnBids, true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询设备连接配置列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param iotDeviceconn 设备连接配置
|
|
|
|
|
+ * @return 设备连接配置
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<IotDeviceconn> selectIotDeviceconnList(IotDeviceconn iotDeviceconn)
|
|
|
|
|
+ {
|
|
|
|
|
+ iotDeviceconn.setTid(SecurityUtils.getTid());
|
|
|
|
|
+ return iotDeviceconnMapper.selectIotDeviceconnList(iotDeviceconn);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量新增设备连接配置
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param iotDeviceconnList 设备连接配置列表
|
|
|
|
|
+ * @return 结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int insertIotDeviceconnByBatch(List<IotDeviceconn> iotDeviceconnList) {
|
|
|
|
|
+ for (IotDeviceconn iotDeviceconn : iotDeviceconnList) {
|
|
|
|
|
+ iotDeviceconn.setTid(SecurityUtils.getTid());
|
|
|
|
|
+ }
|
|
|
|
|
+ return iotDeviceconnMapper.insertIotDeviceconnByBatch(iotDeviceconnList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|