add:添加ota上报入库
parent
7fe2c4b337
commit
1f34bb5aed
|
@ -0,0 +1,23 @@
|
|||
package cc.iotkit.model.ota;
|
||||
|
||||
import cc.iotkit.model.Id;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @Author: 石恒
|
||||
* @Date: 2023/6/15 22:00
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceOtaInfo implements Id<String> {
|
||||
private String id;
|
||||
private Integer step;
|
||||
private String desc;
|
||||
private String version;
|
||||
private String module;
|
||||
private String deviceId;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package cc.iotkit.model.ota;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: 石恒
|
||||
* @Date: 2023/6/15 22:54
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class OtaInfo implements Serializable {
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package cc.iotkit.data.manager;
|
||||
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.ota.DeviceOtaInfo;
|
||||
|
||||
/**
|
||||
* @Author: 石恒
|
||||
* @Date: 2023/6/15 22:14
|
||||
* @Description:
|
||||
*/
|
||||
public interface IDeviceOtaInfoData extends ICommonData<DeviceOtaInfo, String> {
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package cc.iotkit.data.dao;
|
||||
|
||||
import cc.iotkit.data.model.TbDeviceOtaInfo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||
|
||||
/**
|
||||
* @Author: 石恒
|
||||
* @Date: 2023/6/15 22:21
|
||||
* @Description:
|
||||
*/
|
||||
public interface DeviceOtaInfoRepository extends JpaRepository<TbDeviceOtaInfo, String>, QuerydslPredicateExecutor<TbDeviceOtaInfo> {
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cc.iotkit.data.model;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @Author: 石恒
|
||||
* @Date: 2023/6/15 22:22
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "device_ota_info")
|
||||
@ApiModel(value = "设备信息")
|
||||
@AutoMapper(target = TbDeviceOtaInfo.class)
|
||||
public class TbDeviceOtaInfo {
|
||||
@Id
|
||||
@GeneratedValue(generator = "SnowflakeIdGenerator")
|
||||
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
|
||||
private String id;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.data.dao.DeviceOtaInfoRepository;
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.manager.IDeviceOtaInfoData;
|
||||
import cc.iotkit.data.model.TbDeviceOtaInfo;
|
||||
import cc.iotkit.model.ota.DeviceOtaInfo;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: 石恒
|
||||
* @Date: 2023/6/15 22:19
|
||||
* @Description:
|
||||
*/
|
||||
@Primary
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceOtaInfoDataImpl implements IDeviceOtaInfoData, IJPACommData<DeviceOtaInfo, String> {
|
||||
|
||||
private DeviceOtaInfoRepository deviceOtaInfoRepository;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
@Override
|
||||
public JpaRepository getBaseRepository() {
|
||||
return deviceOtaInfoRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getJpaRepositoryClass() {
|
||||
return TbDeviceOtaInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return DeviceOtaInfo.class;
|
||||
}
|
||||
}
|
|
@ -189,7 +189,7 @@ public class DeviceMessageHandler implements IMessageHandler {
|
|||
|
||||
private void doOta(DeviceMessage message) {
|
||||
ThingModelMessage thingModelMessage = converter.decode(message);
|
||||
deviceBehaviourService.reportMessage(thingModelMessage);
|
||||
deviceBehaviourService.deviceOta(thingModelMessage);
|
||||
}
|
||||
|
||||
private void doReport(DeviceMessage message) {
|
||||
|
|
|
@ -18,10 +18,12 @@ import cc.iotkit.common.utils.UniqueIdUtil;
|
|||
import cc.iotkit.comp.model.DeviceState;
|
||||
import cc.iotkit.comp.model.RegisterInfo;
|
||||
import cc.iotkit.data.manager.IDeviceInfoData;
|
||||
import cc.iotkit.data.manager.IDeviceOtaInfoData;
|
||||
import cc.iotkit.data.manager.IProductData;
|
||||
import cc.iotkit.data.manager.IProductModelData;
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.model.ota.DeviceOtaInfo;
|
||||
import cc.iotkit.model.product.Product;
|
||||
import cc.iotkit.model.product.ProductModel;
|
||||
import cc.iotkit.mq.MqProducer;
|
||||
|
@ -41,6 +43,9 @@ public class DeviceBehaviourService {
|
|||
|
||||
@Autowired
|
||||
private IProductModelData productModelData;
|
||||
@Autowired
|
||||
private IDeviceOtaInfoData deviceOtaInfoData;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("deviceInfoDataCache")
|
||||
private IDeviceInfoData deviceInfoData;
|
||||
|
@ -267,4 +272,10 @@ public class DeviceBehaviourService {
|
|||
ThingModelMessage message = JsonUtils.parseObject(jsonMsg, ThingModelMessage.class);
|
||||
reportMessage(message);
|
||||
}
|
||||
|
||||
public void deviceOta(ThingModelMessage message) {
|
||||
DeviceOtaInfo otaInfo = (DeviceOtaInfo)message.getData();
|
||||
otaInfo.setDeviceId(message.getDeviceId());
|
||||
deviceOtaInfoData.save(otaInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,6 +212,7 @@ function disconnect(clientId) {
|
|||
}
|
||||
|
||||
function ota(head, payload) {
|
||||
payload = JSON.parse(payload);
|
||||
var topic = head.topic;
|
||||
var arr = topic.split('/');
|
||||
if (arr.length < 6) {
|
||||
|
|
Loading…
Reference in New Issue