|
@@ -3,17 +3,26 @@ package com.yunfeiyun.agmp.iotm.web.service.impl;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
|
|
+import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.SecurityUtils;
|
|
import com.yunfeiyun.agmp.common.utils.SecurityUtils;
|
|
|
|
|
+import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotDeviceconn;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.enums.IotDeviceDelStatusEnum;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.enums.IotDeviceStatusTypeEnum;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
import com.yunfeiyun.agmp.iot.common.service.TypeCacheService;
|
|
import com.yunfeiyun.agmp.iot.common.service.TypeCacheService;
|
|
|
import com.yunfeiyun.agmp.iotm.common.service.IotDeviceBaseService;
|
|
import com.yunfeiyun.agmp.iotm.common.service.IotDeviceBaseService;
|
|
|
|
|
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceAddReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.mapper.IotDeviceMapper;
|
|
import com.yunfeiyun.agmp.iotm.web.mapper.IotDeviceMapper;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
|
|
|
|
|
|
import com.yunfeiyun.agmp.iotm.mq.service.SendToTosMsgService;
|
|
import com.yunfeiyun.agmp.iotm.mq.service.SendToTosMsgService;
|
|
|
|
|
|
|
|
import com.yunfeiyun.agmp.iotm.mq.service.SendToIotsMsgService;
|
|
import com.yunfeiyun.agmp.iotm.mq.service.SendToIotsMsgService;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceconnService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -34,11 +43,65 @@ public class IotDeviceServiceImpl implements IIotDeviceService
|
|
|
private SendToTosMsgService sendToTosMsgService;
|
|
private SendToTosMsgService sendToTosMsgService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private SendToIotsMsgService sendToIotsMsgService;
|
|
private SendToIotsMsgService sendToIotsMsgService;
|
|
|
- @Resource
|
|
|
|
|
|
|
+// @Resource
|
|
|
private Map<String, IotDeviceBaseService> iotDeviceBaseServiceMap;
|
|
private Map<String, IotDeviceBaseService> iotDeviceBaseServiceMap;
|
|
|
@Resource
|
|
@Resource
|
|
|
private TypeCacheService typeCacheService;
|
|
private TypeCacheService typeCacheService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIotDeviceconnService iotDeviceconnService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增设备基础
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param reqVo@return 结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int addIotDevice(IotDeviceAddReqVo reqVo) {
|
|
|
|
|
+ String devconnBid = reqVo.getDevconnBid();
|
|
|
|
|
+ String devCode = reqVo.getDevCode();
|
|
|
|
|
+ String devName = reqVo.getDevName();
|
|
|
|
|
+
|
|
|
|
|
+ if(StringUtils.isEmpty(devCode) || StringUtils.isEmpty(devName) ){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"设备编码或设备名称不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ IotDeviceconn selectDeviceconn = new IotDeviceconn();
|
|
|
|
|
+ selectDeviceconn.setDevconnBid(devconnBid);
|
|
|
|
|
+ List<IotDeviceconn> iotDeviceconnList = iotDeviceconnService.selectIotDeviceconnList(selectDeviceconn);
|
|
|
|
|
+ if(iotDeviceconnList == null || iotDeviceconnList.isEmpty()){
|
|
|
|
|
+ throw new RuntimeException("设备连接不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IotDeviceconn iotDeviceconn = iotDeviceconnList.get(0);
|
|
|
|
|
+
|
|
|
|
|
+ String firmBid = iotDeviceconn.getFirmBid();
|
|
|
|
|
+ String devtypeBid = iotDeviceconn.getDevtypeBid();
|
|
|
|
|
+
|
|
|
|
|
+ IotDevice selectIotDevice = new IotDevice();
|
|
|
|
|
+ selectIotDevice.setDevCode(devCode);
|
|
|
|
|
+ selectIotDevice.setFirmBid(firmBid);
|
|
|
|
|
+ selectIotDevice.setDevtypeBid(devtypeBid);
|
|
|
|
|
+
|
|
|
|
|
+ List<IotDevice> iotDeviceList = selectIotDeviceList(selectIotDevice);
|
|
|
|
|
+ if(iotDeviceList != null && !iotDeviceList.isEmpty()){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"该设备已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IotDevice iotDevice = new IotDevice();
|
|
|
|
|
+ iotDevice.setDevBid(iotDeviceconn.getUUId());
|
|
|
|
|
+ iotDevice.setDevtypeBid(devtypeBid);
|
|
|
|
|
+ iotDevice.setDevclassBid(iotDeviceconn.getDevclassBid());
|
|
|
|
|
+ iotDevice.setFirmBid(firmBid);
|
|
|
|
|
+ iotDevice.setDevconnBid(devconnBid);
|
|
|
|
|
+ iotDevice.setDevCode(devCode);
|
|
|
|
|
+ iotDevice.setDevName(devName);
|
|
|
|
|
+ iotDevice.setDevStatus(IotDeviceStatusTypeEnum.WAIT_ACTIVATE.getCode());
|
|
|
|
|
+ iotDevice.setDevCreator(SecurityUtils.getUserId());
|
|
|
|
|
+ iotDevice.setDevCreateddate(DateUtils.dateTimeNow());
|
|
|
|
|
+ iotDevice.setDevDelstatus(IotDeviceDelStatusEnum.NOT_DELETE.getCode());
|
|
|
|
|
+
|
|
|
|
|
+ return insertIotDevice(iotDevice);
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* 查询设备基础
|
|
* 查询设备基础
|
|
|
*
|
|
*
|
|
@@ -59,6 +122,7 @@ public class IotDeviceServiceImpl implements IIotDeviceService
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public List<IotDevice> selectIotDeviceList(IotDevice iotDevice) {
|
|
public List<IotDevice> selectIotDeviceList(IotDevice iotDevice) {
|
|
|
|
|
+ iotDevice.setTid(SecurityUtils.getTid());
|
|
|
return iotDeviceMapper.selectIotDeviceList(iotDevice);
|
|
return iotDeviceMapper.selectIotDeviceList(iotDevice);
|
|
|
}
|
|
}
|
|
|
|
|
|