Merge branch 'feature-BOX一期' of http://47.99.132.106:10081/wulin/qiuguo-iot into feature-BOX一期
This commit is contained in:
commit
01eaf091e2
@ -0,0 +1,72 @@
|
||||
package com.qiuguo.iot.data.entity.user;
|
||||
import org.hswebframework.ezorm.rdb.mapping.annotation.Comment;
|
||||
import org.hswebframework.web.crud.annotation.EnableEntityEvent;
|
||||
import org.hswebframework.web.api.crud.entity.GenericEntity;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Table;import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* </p>*
|
||||
* @author wulin
|
||||
* @since 2023-09-25
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Comment("")
|
||||
@Table(name = "user_handling_device")
|
||||
@EnableEntityEvent
|
||||
public class UserHandlingDeviceEntity extends GenericEntity<Long> {
|
||||
@Comment("id")
|
||||
@Column(name = "id", length = 11, nullable = false, unique = true)
|
||||
private Long id;
|
||||
|
||||
@Comment("字段名")
|
||||
@Column(name = "code", length = 50, nullable = false)
|
||||
private String code;
|
||||
|
||||
@Comment("值")
|
||||
@Column(name = "value", length = 50)
|
||||
private String value;
|
||||
|
||||
@Comment("数据类型")
|
||||
@Column(name = "type", length = 20, nullable = false)
|
||||
private String type;
|
||||
|
||||
@Comment("最大值")
|
||||
@Column(name = "max")
|
||||
private Integer max;
|
||||
|
||||
@Comment("最小值")
|
||||
@Column(name = "min")
|
||||
private Integer min;
|
||||
|
||||
@Comment("步长")
|
||||
@Column(name = "step")
|
||||
private Integer step;
|
||||
|
||||
@Comment("匹配字段")
|
||||
@Column(name = "matching_fields", length = 200, nullable = false)
|
||||
private String matchingFields;
|
||||
|
||||
@Comment("分类字段名称")
|
||||
@Column(name = "category_code", length = 20, nullable = false)
|
||||
private String categoryCode;
|
||||
|
||||
@Comment("分类名称")
|
||||
@Column(name = "category_name", length = 20, nullable = false)
|
||||
private String categoryName;
|
||||
|
||||
@Comment("is_delete")
|
||||
@Column(name = "is_delete")
|
||||
private Integer isDelete;
|
||||
|
||||
@Comment("create_time")
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
@Comment("modify_time")
|
||||
@Column(name = "modify_time")
|
||||
private Date modifyTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package com.qiuguo.iot.data.request.user;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
*请求类
|
||||
* @author wulin
|
||||
* @since 2023-09-25
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
public class UserHandlingDeviceRequest implements java.io.Serializable {
|
||||
|
||||
private int currPage = 1;
|
||||
private int pageSize = 10;
|
||||
private String sort;
|
||||
private String order;
|
||||
//
|
||||
private Long id;
|
||||
//字段名
|
||||
private String code;
|
||||
//值
|
||||
private String value;
|
||||
//数据类型
|
||||
private String type;
|
||||
//最大值
|
||||
private Integer max;
|
||||
//最小值
|
||||
private Integer min;
|
||||
//步长
|
||||
private Integer step;
|
||||
//匹配字段
|
||||
private String matchingFields;
|
||||
//分类字段名称
|
||||
private String categoryCode;
|
||||
//分类名称
|
||||
private String categoryName;
|
||||
//
|
||||
private Integer isDelete;
|
||||
//
|
||||
private Date createTime;
|
||||
//搜索开始
|
||||
|
||||
private Date createTimeStart;
|
||||
|
||||
//搜索结束
|
||||
private Date createTimeEnd;
|
||||
//
|
||||
private Date modifyTime;
|
||||
//搜索开始
|
||||
|
||||
private Date modifyTimeStart;
|
||||
|
||||
//搜索结束
|
||||
private Date modifyTimeEnd;
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.qiuguo.iot.data.resp.user;
|
||||
import com.qiuguo.iot.data.entity.user.UserHandlingDeviceEntity;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* </p>*返回类
|
||||
* @author wulin
|
||||
* @since 2023-09-25
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class UserHandlingDeviceResp {
|
||||
public UserHandlingDeviceResp(){
|
||||
}
|
||||
public UserHandlingDeviceResp(UserHandlingDeviceEntity entity){
|
||||
id = entity.getId();
|
||||
code = entity.getCode();
|
||||
value = entity.getValue();
|
||||
type = entity.getType();
|
||||
max = entity.getMax();
|
||||
min = entity.getMin();
|
||||
step = entity.getStep();
|
||||
matchingFields = entity.getMatchingFields();
|
||||
categoryCode = entity.getCategoryCode();
|
||||
categoryName = entity.getCategoryName();
|
||||
createTime = entity.getCreateTime();
|
||||
modifyTime = entity.getModifyTime();
|
||||
}
|
||||
|
||||
//
|
||||
private Long id;
|
||||
//字段名
|
||||
private String code;
|
||||
//值
|
||||
private String value;
|
||||
//数据类型
|
||||
private String type;
|
||||
//最大值
|
||||
private Integer max;
|
||||
//最小值
|
||||
private Integer min;
|
||||
//步长
|
||||
private Integer step;
|
||||
//匹配字段
|
||||
private String matchingFields;
|
||||
//分类字段名称
|
||||
private String categoryCode;
|
||||
//分类名称
|
||||
private String categoryName;
|
||||
//
|
||||
private Date createTime;
|
||||
//
|
||||
private Date modifyTime;
|
||||
}
|
||||
@ -0,0 +1,240 @@
|
||||
package com.qiuguo.iot.data.service.user;
|
||||
|
||||
|
||||
|
||||
import com.qiuguo.iot.base.utils.StringUtils;
|
||||
import com.qiuguo.iot.data.entity.user.UserHandlingDeviceEntity;
|
||||
import com.qiuguo.iot.data.request.user.UserHandlingDeviceRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.Date;
|
||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveQuery;
|
||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate;
|
||||
import org.hswebframework.ezorm.rdb.operator.dml.query.SortOrder;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
||||
import org.hswebframework.web.crud.service.GenericReactiveCrudService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wulin
|
||||
* @since 2023-09-25
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UserHandlingDeviceService extends GenericReactiveCrudService<UserHandlingDeviceEntity, Long> {
|
||||
|
||||
|
||||
public Mono<UserHandlingDeviceEntity> selectUserHandlingDeviceByRequest(UserHandlingDeviceRequest request){
|
||||
ReactiveQuery<UserHandlingDeviceEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getId, request.getId());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getCode())){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getCode, request.getCode());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getValue())){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getValue, request.getValue());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getType())){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getType, request.getType());
|
||||
}
|
||||
if(request.getMax() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getMax, request.getMax());
|
||||
}
|
||||
if(request.getMin() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getMin, request.getMin());
|
||||
}
|
||||
if(request.getStep() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getStep, request.getStep());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getMatchingFields())){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getMatchingFields, request.getMatchingFields());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getCategoryCode())){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getCategoryCode, request.getCategoryCode());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getCategoryName())){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getCategoryName, request.getCategoryName());
|
||||
}
|
||||
if(request.getIsDelete() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getIsDelete, request.getIsDelete());
|
||||
}
|
||||
if(request.getCreateTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getCreateTime, request.getCreateTime());
|
||||
}
|
||||
if(request.getModifyTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getModifyTime, request.getModifyTime());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
sortOrder = SortOrder.desc(request.getOrder());
|
||||
}else{
|
||||
sortOrder = SortOrder.asc(request.getOrder());
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
return reactiveQuery.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<PagerResult<UserHandlingDeviceEntity>> selectUserHandlingDevicesByRequest(UserHandlingDeviceRequest request){
|
||||
ReactiveQuery<UserHandlingDeviceEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getId, request.getId());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getCode())){
|
||||
reactiveQuery = reactiveQuery.$like$(UserHandlingDeviceRequest::getCode, request.getCode());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getValue())){
|
||||
reactiveQuery = reactiveQuery.$like$(UserHandlingDeviceRequest::getValue, request.getValue());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getType())){
|
||||
reactiveQuery = reactiveQuery.$like$(UserHandlingDeviceRequest::getType, request.getType());
|
||||
}
|
||||
if(request.getMax() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getMax, request.getMax());
|
||||
}
|
||||
if(request.getMin() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getMin, request.getMin());
|
||||
}
|
||||
if(request.getStep() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getStep, request.getStep());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getMatchingFields())){
|
||||
reactiveQuery = reactiveQuery.$like$(UserHandlingDeviceRequest::getMatchingFields, request.getMatchingFields());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getCategoryCode())){
|
||||
reactiveQuery = reactiveQuery.$like$(UserHandlingDeviceRequest::getCategoryCode, request.getCategoryCode());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getCategoryName())){
|
||||
reactiveQuery = reactiveQuery.$like$(UserHandlingDeviceRequest::getCategoryName, request.getCategoryName());
|
||||
}
|
||||
if(request.getIsDelete() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getIsDelete, request.getIsDelete());
|
||||
}
|
||||
if(request.getCreateTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(UserHandlingDeviceRequest::getCreateTime, request.getCreateTimeStart());
|
||||
}
|
||||
if(request.getCreateTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(UserHandlingDeviceRequest::getCreateTime, request.getCreateTimeEnd());
|
||||
}
|
||||
if(request.getModifyTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(UserHandlingDeviceRequest::getModifyTime, request.getModifyTimeStart());
|
||||
}
|
||||
if(request.getModifyTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(UserHandlingDeviceRequest::getModifyTime, request.getModifyTimeEnd());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
sortOrder = SortOrder.desc(request.getOrder());
|
||||
}else{
|
||||
sortOrder = SortOrder.asc(request.getOrder());
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
||||
param.setPageIndex(request.getCurrPage());
|
||||
param.setPageSize(request.getPageSize());
|
||||
param.setPaging(true);
|
||||
param.setFirstPageIndex(1);
|
||||
return queryPager(param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<UserHandlingDeviceEntity> selectUserHandlingDeviceById(Long id){
|
||||
return createQuery()
|
||||
.and("is_delete", 0)
|
||||
.and("id", id)
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> insertUserHandlingDevice(UserHandlingDeviceEntity entity){
|
||||
entity.setId(null);
|
||||
entity.setCreateTime(null);
|
||||
entity.setModifyTime(null);
|
||||
return insert(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> updateUserHandlingDeviceById(UserHandlingDeviceEntity entity){
|
||||
ReactiveUpdate<UserHandlingDeviceEntity> update = createUpdate()
|
||||
.set(UserHandlingDeviceEntity::getModifyTime, new Date());
|
||||
if(StringUtils.isNotEmpty(entity.getCode())){
|
||||
update = update.set(UserHandlingDeviceEntity::getCode, entity.getCode());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getValue())){
|
||||
update = update.set(UserHandlingDeviceEntity::getValue, entity.getValue());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getType())){
|
||||
update = update.set(UserHandlingDeviceEntity::getType, entity.getType());
|
||||
}
|
||||
if(entity.getMax() != null){
|
||||
update = update.set(UserHandlingDeviceEntity::getMax, entity.getMax());
|
||||
}
|
||||
if(entity.getMin() != null){
|
||||
update = update.set(UserHandlingDeviceEntity::getMin, entity.getMin());
|
||||
}
|
||||
if(entity.getStep() != null){
|
||||
update = update.set(UserHandlingDeviceEntity::getStep, entity.getStep());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getMatchingFields())){
|
||||
update = update.set(UserHandlingDeviceEntity::getMatchingFields, entity.getMatchingFields());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getCategoryCode())){
|
||||
update = update.set(UserHandlingDeviceEntity::getCategoryCode, entity.getCategoryCode());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getCategoryName())){
|
||||
update = update.set(UserHandlingDeviceEntity::getCategoryName, entity.getCategoryName());
|
||||
}
|
||||
if(entity.getIsDelete() != null){
|
||||
update = update.set(UserHandlingDeviceEntity::getIsDelete, entity.getIsDelete());
|
||||
}
|
||||
return update.where(UserHandlingDeviceEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> updateCoverUserHandlingDeviceById(UserHandlingDeviceEntity entity){
|
||||
ReactiveUpdate<UserHandlingDeviceEntity> update = createUpdate()
|
||||
.set(UserHandlingDeviceEntity::getModifyTime, new Date());
|
||||
update = update.set(UserHandlingDeviceEntity::getCode, entity.getCode());
|
||||
update = update.set(UserHandlingDeviceEntity::getValue, entity.getValue());
|
||||
update = update.set(UserHandlingDeviceEntity::getType, entity.getType());
|
||||
update = update.set(UserHandlingDeviceEntity::getMax, entity.getMax());
|
||||
update = update.set(UserHandlingDeviceEntity::getMin, entity.getMin());
|
||||
update = update.set(UserHandlingDeviceEntity::getStep, entity.getStep());
|
||||
update = update.set(UserHandlingDeviceEntity::getMatchingFields, entity.getMatchingFields());
|
||||
update = update.set(UserHandlingDeviceEntity::getCategoryCode, entity.getCategoryCode());
|
||||
update = update.set(UserHandlingDeviceEntity::getCategoryName, entity.getCategoryName());
|
||||
update = update.set(UserHandlingDeviceEntity::getIsDelete, entity.getIsDelete());
|
||||
return update.where(UserHandlingDeviceEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> deleteUserHandlingDeviceById(Long id){
|
||||
return createUpdate()
|
||||
.set("is_delete", 1)
|
||||
.set("modify_time", new Date())
|
||||
.where("id", id)
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -15,6 +15,11 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tuya</groupId>
|
||||
<artifactId>tuya-spring-boot-starter</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package com.qiuguo.iot.third.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*
|
||||
* @author weiyachao
|
||||
* @since 2023/9/25 15:13
|
||||
*/
|
||||
@Data
|
||||
public class TuyaQuery {
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 指令表ID
|
||||
*/
|
||||
private Long userHandlingDeviceId;
|
||||
|
||||
/**
|
||||
* 控制值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +1,7 @@
|
||||
package com.qiuguo.iot.user.api.service;
|
||||
package com.qiuguo.iot.third.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.tuya.connector.api.annotations.Body;
|
||||
import com.tuya.connector.api.annotations.DELETE;
|
||||
import com.tuya.connector.api.annotations.GET;
|
||||
@ -37,7 +36,7 @@ public interface TuyaDeviceConnector {
|
||||
|
||||
// 控制设备动作
|
||||
@POST("/v1.0/iot-03/devices/{device_id}/commands")
|
||||
Object controlDevice(@Path("device_id") String deviceId, @Body JSONObject commands);
|
||||
Boolean controlDevice(@Path("device_id") String deviceId, @Body JSONObject commands);
|
||||
|
||||
// 创建空间
|
||||
@POST("/v2.0/cloud/space/creation")
|
||||
@ -0,0 +1,85 @@
|
||||
package com.qiuguo.iot.third.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.qiuguo.iot.data.entity.user.UserHandlingDeviceEntity;
|
||||
import com.qiuguo.iot.data.service.user.UserHandlingDeviceService;
|
||||
import com.qiuguo.iot.third.query.TuyaQuery;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*
|
||||
* @author weiyachao
|
||||
* @since 2023/9/19 15:13
|
||||
*/
|
||||
@Service
|
||||
public class TuyaDeviceService {
|
||||
|
||||
@Autowired
|
||||
private TuyaDeviceConnector tuyaDeviceConnector;
|
||||
|
||||
@Autowired
|
||||
private UserHandlingDeviceService userHandlingDeviceService;
|
||||
|
||||
// @Autowired
|
||||
// private
|
||||
|
||||
/**
|
||||
* 查询设备详情
|
||||
*/
|
||||
public Mono<JSONArray> getDeviceInfo(String deviceId) {
|
||||
return Mono.just(tuyaDeviceConnector.getByid(deviceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备分类code
|
||||
*/
|
||||
public Mono<String> getCateCode(String deviceId) {
|
||||
JSONArray byid = tuyaDeviceConnector.getByid(deviceId);
|
||||
if (ObjectUtils.isEmpty(byid)) {
|
||||
return Mono.empty();
|
||||
}
|
||||
return Mono.just(byid.getJSONObject(0).getString("category"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制设备
|
||||
*/
|
||||
public Mono<Boolean> controlDevice(TuyaQuery query) {
|
||||
Mono<UserHandlingDeviceEntity> userHandlingDeviceEntityMono = userHandlingDeviceService.selectUserHandlingDeviceById(
|
||||
query.getUserHandlingDeviceId());
|
||||
return userHandlingDeviceEntityMono.flatMap(data -> {
|
||||
JSONArray jsonArray = tuyaDeviceConnector.getByid(query.getDeviceId());
|
||||
if (ObjectUtils.isEmpty(jsonArray)) {
|
||||
return Mono.just(false);
|
||||
}
|
||||
JSONObject deviceInfo = jsonArray.getJSONObject(0);
|
||||
if (Objects.equals(deviceInfo.getBoolean("is_online"), false) && !Objects.equals(data.getMatchingFields(),
|
||||
"开关")) {
|
||||
return Mono.just(false);
|
||||
}
|
||||
JSONObject commands = new JSONObject();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String type = data.getType();
|
||||
jsonObject.put("code", data.getCode());
|
||||
if (type.equalsIgnoreCase("boolean")) {
|
||||
jsonObject.put("value", data.getValue());
|
||||
} else if (type.equalsIgnoreCase("Integer")) {
|
||||
jsonObject.put("value", Integer.parseInt(data.getValue()));
|
||||
} else if (type.equalsIgnoreCase("Enum")) {
|
||||
jsonObject.put("value", data.getValue());
|
||||
} else {
|
||||
jsonObject.put("value", data.getValue());
|
||||
}
|
||||
commands.put("commands", Arrays.asList(jsonObject));
|
||||
Boolean aBoolean = tuyaDeviceConnector.controlDevice(query.getDeviceId(), commands);
|
||||
return Mono.just(aBoolean);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.qiuguo.iot.gateway.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*
|
||||
* @author weiyachao
|
||||
* @since 2023/9/22 17:35
|
||||
*/
|
||||
@Configuration
|
||||
public class GatewayConfiguration {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,6 +1,9 @@
|
||||
server:
|
||||
port: 8080
|
||||
port: 8081
|
||||
spring:
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
application:
|
||||
name: qiuguo-iot-gateway
|
||||
|
||||
|
||||
@ -24,9 +24,9 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tuya</groupId>
|
||||
<artifactId>tuya-spring-boot-starter</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<groupId>com.qiuguo.iot</groupId>
|
||||
<artifactId>iot-third</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -35,7 +35,10 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -7,9 +7,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"com.qiuguo.iot.user.api", "com.qiuguo.iot.data.service"})
|
||||
@SpringBootApplication(scanBasePackages = {"com.qiuguo.iot.user.api", "com.qiuguo.iot.data.service","com.qiuguo.iot.third.service"})
|
||||
@EnableEasyormRepository(value = "com.qiuguo.iot.data.entity.*")
|
||||
@ConnectorScan(basePackages = "com.qiuguo.iot.user.api.service")
|
||||
@ConnectorScan(basePackages = "com.qiuguo.iot.third.service")
|
||||
@EnableAspectJAutoProxy
|
||||
@EnableDiscoveryClient
|
||||
public class IotBoxUserApiApplication {
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
package com.qiuguo.iot.user.api.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.qiuguo.iot.data.entity.user.UserRoomEntity;
|
||||
import com.qiuguo.iot.data.request.user.UserRoomRequest;
|
||||
import com.qiuguo.iot.data.service.user.UserRoomService;
|
||||
import com.qiuguo.iot.user.api.service.TuyaDeviceConnector;
|
||||
import com.qiuguo.iot.user.api.rabbit.MyProducer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -26,44 +25,28 @@ public class RoomAdminController {
|
||||
private UserRoomService roomService;
|
||||
|
||||
@Resource
|
||||
private TuyaDeviceConnector deviceConnector;
|
||||
private MyProducer myProducer;
|
||||
|
||||
//新增
|
||||
@PostMapping("/save/room")
|
||||
public Mono<Void> roomSave(@RequestBody JSONObject jsonObject) {
|
||||
if (ObjectUtil.isNull(jsonObject)){
|
||||
return null;
|
||||
}
|
||||
UserRoomEntity room = jsonObject.toJavaObject(UserRoomEntity.class);
|
||||
if (ObjectUtil.isNull(room)){
|
||||
//todo:解析json为空
|
||||
}
|
||||
public Mono<Void> roomSave(@RequestBody UserRoomEntity room) {
|
||||
room.setCreateTime(new Date());
|
||||
room.setIsDelete(1);
|
||||
room.setModifyTime(new Date());
|
||||
roomService.insertUserRoom(room);
|
||||
return Mono.empty();
|
||||
return roomService.insertUserRoom(room).thenEmpty(Mono.empty());
|
||||
}
|
||||
|
||||
//更新
|
||||
@PostMapping("/edit/room")
|
||||
public Mono<JSONObject> editRoom(@RequestBody JSONObject jsonObject) {
|
||||
if (ObjectUtil.isNull(jsonObject)){
|
||||
return null;
|
||||
}
|
||||
UserRoomEntity room = jsonObject.toJavaObject(UserRoomEntity.class);
|
||||
if (ObjectUtil.isNull(room)){
|
||||
//todo:解析json为空
|
||||
}
|
||||
roomService.updateUserRoomById(room);
|
||||
return Mono.empty();
|
||||
public Mono<Integer> editRoom(@RequestBody UserRoomEntity room) {
|
||||
return roomService.updateUserRoomById(room).map( integer -> integer);
|
||||
}
|
||||
|
||||
//删除
|
||||
@GetMapping("/del/room")
|
||||
public Mono<Integer> delFamily(@RequestParam Long id) {
|
||||
if (ObjectUtil.isNull(id)){
|
||||
//todo:为空
|
||||
throw new RuntimeException("传入id为空");
|
||||
}
|
||||
return roomService.deleteUserRoomById(id);
|
||||
}
|
||||
@ -72,12 +55,11 @@ public class RoomAdminController {
|
||||
@PostMapping("/get/room")
|
||||
public Mono<PagerResult<UserRoomEntity>> getFamily(@RequestBody UserRoomRequest resp) {
|
||||
return roomService.selectUserRoomsByRequest(resp);
|
||||
/**
|
||||
* 判空
|
||||
* 查询对应设备id
|
||||
* 调用TuyaDeviceConnector.getByid接口
|
||||
* 返回
|
||||
*/
|
||||
//return Mono.just(aa);
|
||||
}
|
||||
|
||||
@GetMapping("/text")
|
||||
public String text() {
|
||||
myProducer.sendMessage("hello world");
|
||||
return "hello world";
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,8 +10,8 @@ import com.qiuguo.iot.data.entity.device.DeviceInfoEntity;
|
||||
import com.qiuguo.iot.data.request.device.DeviceInfoRequest;
|
||||
import com.qiuguo.iot.data.service.device.DeviceBatchService;
|
||||
import com.qiuguo.iot.data.service.device.DeviceInfoService;
|
||||
import com.qiuguo.iot.third.service.TuyaDeviceConnector;
|
||||
import com.qiuguo.iot.user.api.resp.device.DeviceInitResp;
|
||||
import com.qiuguo.iot.user.api.service.TuyaDeviceConnector;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hswebframework.web.exception.BusinessException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package com.qiuguo.iot.user.api.rabbit;
|
||||
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MyConsumer {
|
||||
|
||||
@RabbitListener(queues = "my-queue")
|
||||
public void receiveMessage(String message) {
|
||||
// 处理接收到的消息
|
||||
System.out.println("Received message: " + message);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.qiuguo.iot.user.api.rabbit;
|
||||
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MyProducer {
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
public void sendMessage(String message) {
|
||||
//发送消息
|
||||
rabbitTemplate.convertAndSend("my-queue", message);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.qiuguo.iot.user.api.rabbit;
|
||||
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class RabbitMQConfig {
|
||||
|
||||
@Bean
|
||||
public Queue myQueue() {
|
||||
return new Queue("my-queue");
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.qiuguo.iot.user.api.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*
|
||||
* @author weiyachao
|
||||
* @since 2023/9/19 15:13
|
||||
*/
|
||||
@Service
|
||||
public class TuyaDeviceService {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,4 +1,10 @@
|
||||
spring:
|
||||
rabbitmq:
|
||||
host: 192.168.8.146
|
||||
port: 31043
|
||||
username: admin
|
||||
password: 123456
|
||||
|
||||
cloud:
|
||||
# config:
|
||||
# # 如果本地配置优先级高,那么 override-none 设置为 true,包括系统环境变量、本地配置文件等配置
|
||||
|
||||
118
iot-modules/iot-box-user-api/src/test/java/UserTest.java
Normal file
118
iot-modules/iot-box-user-api/src/test/java/UserTest.java
Normal file
@ -0,0 +1,118 @@
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.qiuguo.iot.third.service.TuyaDeviceConnector;
|
||||
import com.qiuguo.iot.user.api.IotBoxUserApiApplication;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*
|
||||
* @author weiyachao
|
||||
* @since 2023/9/5 16:03
|
||||
*/
|
||||
@SpringBootTest(classes = IotBoxUserApiApplication.class)
|
||||
@Slf4j
|
||||
public class UserTest {
|
||||
|
||||
public String deviceId = "6c41ec425b5af5b81bxgas";
|
||||
|
||||
public String spaceId = "163208675";
|
||||
|
||||
@Autowired
|
||||
private TuyaDeviceConnector tuyaDeviceConnector;
|
||||
|
||||
@Test
|
||||
public void 查询所有分类() {
|
||||
String key = "dj";
|
||||
JSONArray aa = tuyaDeviceConnector.categories();
|
||||
for (Object o : aa) {
|
||||
JSONObject jsonObject = (JSONObject) o;
|
||||
if (Objects.equals(jsonObject.getString("code"), key)) {
|
||||
System.out.println(jsonObject.getString("name"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 转移设备() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("space_id", spaceId);
|
||||
Boolean aBoolean = tuyaDeviceConnector.transferDevice(deviceId, jsonObject);
|
||||
System.out.println(aBoolean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 获取设备支持的指令集() {
|
||||
Object functions = tuyaDeviceConnector.getFunctions(deviceId);
|
||||
System.out.println(functions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 修改空间() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", "testname");
|
||||
Boolean jsonObject1 = tuyaDeviceConnector.updateSpace(spaceId, jsonObject);
|
||||
System.out.println(jsonObject1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 查询空间() {
|
||||
//40001900
|
||||
JSONObject spaceInfo = tuyaDeviceConnector.getSpaceInfo("163208675");
|
||||
System.out.println(spaceInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 删除空间() {
|
||||
//40001900
|
||||
Boolean jsonObject = tuyaDeviceConnector.deleteSpace("163258893");
|
||||
System.out.println(jsonObject);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 创建空间() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", "space1_2");
|
||||
jsonObject.put("description", "space1_2的空间描述");
|
||||
Long jsonObject1 = tuyaDeviceConnector.creatSpace(jsonObject);
|
||||
System.out.println(jsonObject1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 控制设备动作() {
|
||||
JSONObject commands = new JSONObject();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", "switch_led");
|
||||
jsonObject.put("value", false);
|
||||
JSONObject js2 = new JSONObject();
|
||||
js2.put("code", "work_mode");
|
||||
js2.put("value", "colour");
|
||||
JSONObject js3 = new JSONObject();
|
||||
js3.put("code", "bright_value_v2");
|
||||
js3.put("value", 10);
|
||||
commands.put("commands", Arrays.asList( jsonObject));
|
||||
|
||||
Object controlDevice = tuyaDeviceConnector.controlDevice(deviceId,commands);
|
||||
System.out.println(controlDevice);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 查询空间下设备列表() {
|
||||
JSONArray devicesBySpaceIds = tuyaDeviceConnector.getDevicesBySpaceIds("163257138", 20);
|
||||
System.out.println(devicesBySpaceIds);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 查询设备信息() {
|
||||
JSONArray byid = tuyaDeviceConnector.getByid(deviceId);
|
||||
System.out.println(byid);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
package com.admin.service.impl;
|
||||
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* 设备信息Controller类
|
||||
* </p>
|
||||
*
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/DeviceInfo")
|
||||
public class DeviceInfoController{
|
||||
|
||||
|
||||
@Autowired
|
||||
private DeviceInfoService deviceInfoService;
|
||||
@PostMapping("/info")
|
||||
public Mono<DeviceInfoResp> selectDeviceInfoByRequest(@RequestBody DeviceInfoRequest request){
|
||||
return deviceInfoService.selectDeviceInfoByRequest(request).map(d -> {return new DeviceInfoResp(d);});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<PagerResult<DeviceInfoResp>> selectDeviceInfosByRequest(@RequestBody DeviceInfoRequest request){
|
||||
return deviceInfoService.selectDeviceInfosByRequest(request).map(d -> {
|
||||
PagerResult<DeviceInfoResp> result = new PagerResult<>();
|
||||
result.setPageIndex(d.getPageIndex());
|
||||
result.setPageSize(d.getPageSize());
|
||||
result.setTotal(d.getTotal());
|
||||
List<DeviceInfoResp> ds = d.getData().stream().map(new Function<DeviceInfoEntity, DeviceInfoResp>() {
|
||||
@Override
|
||||
public DeviceInfoResp apply(DeviceInfoEntity entity) {
|
||||
return new DeviceInfoResp(entity);
|
||||
}
|
||||
}
|
||||
|
||||
).collect(Collectors.toList());
|
||||
result.setData(ds);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/id")
|
||||
public Mono<DeviceInfoResp> selectDeviceInfoById(@RequestParam Long id){
|
||||
return deviceInfoService.selectDeviceInfoById(id).map(d -> {return new DeviceInfoResp(d);});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/save")
|
||||
public Mono<Integer> insertDeviceInfo(@RequestBody DeviceInfoEntity entity){
|
||||
return deviceInfoService.insertDeviceInfo(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/update")
|
||||
public Mono<Integer> updateDeviceInfoById(@RequestBody DeviceInfoEntity entity){
|
||||
return deviceInfoService.updateDeviceInfoById(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/updateCover")
|
||||
public Mono<Integer> updateCoverDeviceInfoById(@RequestBody DeviceInfoEntity entity){
|
||||
return deviceInfoService.updateCoverDeviceInfoById(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Mono<Integer> deleteDeviceInfoById(@RequestParam Long id){
|
||||
return deviceInfoService.deleteDeviceInfoById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,108 +0,0 @@
|
||||
package com.qiuguo.iot.data.entity;
|
||||
import org.hswebframework.ezorm.rdb.mapping.annotation.Comment;
|
||||
import org.hswebframework.web.crud.annotation.EnableEntityEvent;
|
||||
import org.hswebframework.web.api.crud.entity.GenericEntity;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Table;import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* </p>*设备信息表
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Comment("设备信息表")
|
||||
@Table(name = "device_info")
|
||||
@EnableEntityEvent
|
||||
public class DeviceInfoEntity extends GenericEntity<Long> {
|
||||
@Comment("id")
|
||||
@Column(name = "id", length = 11, nullable = false, unique = true)
|
||||
private Long id;
|
||||
|
||||
@Comment("是否删除:0 否 1 删除")
|
||||
@Column(name = "is_delete", nullable = false)
|
||||
private Integer isDelete;
|
||||
|
||||
@Comment("创建时间")
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
@Comment("修改时间")
|
||||
@Column(name = "modify_time")
|
||||
private Date modifyTime;
|
||||
|
||||
@Comment("批次号")
|
||||
@Column(name = "batch_id", nullable = false)
|
||||
private Long batchId;
|
||||
|
||||
@Comment("设备名称")
|
||||
@Column(name = "name", length = 100, nullable = false)
|
||||
private String name;
|
||||
|
||||
@Comment("设备序列号")
|
||||
@Column(name = "sn", length = 100, nullable = false)
|
||||
private String sn;
|
||||
|
||||
@Comment("设备密钥,用于验签")
|
||||
@Column(name = "key", length = 100)
|
||||
private String key;
|
||||
|
||||
@Comment("蓝牙地址")
|
||||
@Column(name = "bt_mac", length = 50)
|
||||
private String btMac;
|
||||
|
||||
@Comment("wifi地址")
|
||||
@Column(name = "wifi_mac", length = 50)
|
||||
private String wifiMac;
|
||||
|
||||
@Comment("当前固件版本")
|
||||
@Column(name = "firmware_version", length = 10)
|
||||
private String firmwareVersion;
|
||||
|
||||
@Comment("设备类型:0 果Box 1智能插座 2智能大灯 3智能窗帘驱动 4智能窗户关闭 5智能台灯 6智能桌子 7智能椅子 8智能风扇 9智能空调(遥控器) 10智能冰箱 11智能洗碗机 12智能电热水器 13温度传感器 14空气质量传感器 15光线传感器 16雨量传感器 17闭门器")
|
||||
@Column(name = "device_type", nullable = false)
|
||||
private Integer deviceType;
|
||||
|
||||
@Comment("设备状态:0:开启,1待机、关闭(在线)")
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
|
||||
@Comment("是否在线 0:不在线 1在线")
|
||||
@Column(name = "on_line")
|
||||
private Integer onLine;
|
||||
|
||||
@Comment("最后一次上线时间")
|
||||
@Column(name = "last_on_line_time")
|
||||
private Date lastOnLineTime;
|
||||
|
||||
@Comment("通讯协议类型:0:WebSocket 1:MQTT 2:TCP 3:UDP 4:HTTP")
|
||||
@Column(name = "protocol_type", nullable = false)
|
||||
private Integer protocolType;
|
||||
|
||||
@Comment("运行模式id")
|
||||
@Column(name = "operating_mode_id", nullable = false)
|
||||
private Long operatingModeId;
|
||||
|
||||
@Comment("升级模式:0 无模式 1 自动升级")
|
||||
@Column(name = "ota_type", nullable = false)
|
||||
private Integer otaType;
|
||||
|
||||
@Comment("自动升级开始时间段")
|
||||
@Column(name = "ota_start_time")
|
||||
private Date otaStartTime;
|
||||
|
||||
@Comment("自动升级结束时间段")
|
||||
@Column(name = "ota_end_time")
|
||||
private Date otaEndTime;
|
||||
|
||||
@Comment("生产时间")
|
||||
@Column(name = "factory_time")
|
||||
private Date factoryTime;
|
||||
|
||||
@Comment("销售时间")
|
||||
@Column(name = "sale_time")
|
||||
private Date saleTime;
|
||||
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
package com.qiuguo.iot.data.entity;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
*设备信息请求类
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
public class DeviceInfoRequest implements java.io.Serializable {
|
||||
|
||||
private int currPage = 1;
|
||||
private int pageSize = 10;
|
||||
private String sort;
|
||||
private String order;
|
||||
//
|
||||
private Long id;
|
||||
//是否删除:0 否 1 删除
|
||||
private Integer isDelete;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
//创建时间搜索开始
|
||||
|
||||
private Date createTimeStart;
|
||||
|
||||
//创建时间搜索结束
|
||||
private Date createTimeEnd;
|
||||
//修改时间
|
||||
private Date modifyTime;
|
||||
//修改时间搜索开始
|
||||
|
||||
private Date modifyTimeStart;
|
||||
|
||||
//修改时间搜索结束
|
||||
private Date modifyTimeEnd;
|
||||
//批次号
|
||||
private Long batchId;
|
||||
//设备名称
|
||||
private String name;
|
||||
//设备序列号
|
||||
private String sn;
|
||||
//设备密钥,用于验签
|
||||
private String key;
|
||||
//蓝牙地址
|
||||
private String btMac;
|
||||
//wifi地址
|
||||
private String wifiMac;
|
||||
//当前固件版本
|
||||
private String firmwareVersion;
|
||||
//设备类型:0 果Box 1智能插座 2智能大灯 3智能窗帘驱动 4智能窗户关闭 5智能台灯 6智能桌子 7智能椅子 8智能风扇 9智能空调(遥控器) 10智能冰箱 11智能洗碗机 12智能电热水器 13温度传感器 14空气质量传感器 15光线传感器 16雨量传感器 17闭门器
|
||||
private Integer deviceType;
|
||||
//设备状态:0:开启,1待机、关闭(在线)
|
||||
private Integer status;
|
||||
//是否在线 0:不在线 1在线
|
||||
private Integer onLine;
|
||||
//最后一次上线时间
|
||||
private Date lastOnLineTime;
|
||||
//最后一次上线时间搜索开始
|
||||
|
||||
private Date lastOnLineTimeStart;
|
||||
|
||||
//最后一次上线时间搜索结束
|
||||
private Date lastOnLineTimeEnd;
|
||||
//通讯协议类型:0:WebSocket 1:MQTT 2:TCP 3:UDP 4:HTTP
|
||||
private Integer protocolType;
|
||||
//运行模式id
|
||||
private Long operatingModeId;
|
||||
//升级模式:0 无模式 1 自动升级
|
||||
private Integer otaType;
|
||||
//自动升级开始时间段
|
||||
private Date otaStartTime;
|
||||
//自动升级开始时间段搜索开始
|
||||
|
||||
private Date otaStartTimeStart;
|
||||
|
||||
//自动升级开始时间段搜索结束
|
||||
private Date otaStartTimeEnd;
|
||||
//自动升级结束时间段
|
||||
private Date otaEndTime;
|
||||
//自动升级结束时间段搜索开始
|
||||
|
||||
private Date otaEndTimeStart;
|
||||
|
||||
//自动升级结束时间段搜索结束
|
||||
private Date otaEndTimeEnd;
|
||||
//生产时间
|
||||
private Date factoryTime;
|
||||
//生产时间搜索开始
|
||||
|
||||
private Date factoryTimeStart;
|
||||
|
||||
//生产时间搜索结束
|
||||
private Date factoryTimeEnd;
|
||||
//销售时间
|
||||
private Date saleTime;
|
||||
//销售时间搜索开始
|
||||
|
||||
private Date saleTimeStart;
|
||||
|
||||
//销售时间搜索结束
|
||||
private Date saleTimeEnd;
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
package com.qiuguo.iot.data.entity;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* </p>*设备信息返回类
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DeviceInfoResp {
|
||||
public DeviceInfoResp(){
|
||||
}
|
||||
public DeviceInfoResp(DeviceInfoEntity entity){
|
||||
id = entity.getId();
|
||||
createTime = entity.getCreateTime();
|
||||
modifyTime = entity.getModifyTime();
|
||||
batchId = entity.getBatchId();
|
||||
name = entity.getName();
|
||||
sn = entity.getSn();
|
||||
key = entity.getKey();
|
||||
btMac = entity.getBtMac();
|
||||
wifiMac = entity.getWifiMac();
|
||||
firmwareVersion = entity.getFirmwareVersion();
|
||||
deviceType = entity.getDeviceType();
|
||||
status = entity.getStatus();
|
||||
onLine = entity.getOnLine();
|
||||
lastOnLineTime = entity.getLastOnLineTime();
|
||||
protocolType = entity.getProtocolType();
|
||||
operatingModeId = entity.getOperatingModeId();
|
||||
otaType = entity.getOtaType();
|
||||
otaStartTime = entity.getOtaStartTime();
|
||||
otaEndTime = entity.getOtaEndTime();
|
||||
factoryTime = entity.getFactoryTime();
|
||||
saleTime = entity.getSaleTime();
|
||||
}
|
||||
|
||||
//
|
||||
private Long id;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
//修改时间
|
||||
private Date modifyTime;
|
||||
//批次号
|
||||
private Long batchId;
|
||||
//设备名称
|
||||
private String name;
|
||||
//设备序列号
|
||||
private String sn;
|
||||
//设备密钥,用于验签
|
||||
private String key;
|
||||
//蓝牙地址
|
||||
private String btMac;
|
||||
//wifi地址
|
||||
private String wifiMac;
|
||||
//当前固件版本
|
||||
private String firmwareVersion;
|
||||
//设备类型:0 果Box 1智能插座 2智能大灯 3智能窗帘驱动 4智能窗户关闭 5智能台灯 6智能桌子 7智能椅子 8智能风扇 9智能空调(遥控器) 10智能冰箱 11智能洗碗机 12智能电热水器 13温度传感器 14空气质量传感器 15光线传感器 16雨量传感器 17闭门器
|
||||
private Integer deviceType;
|
||||
//设备状态:0:开启,1待机、关闭(在线)
|
||||
private Integer status;
|
||||
//是否在线 0:不在线 1在线
|
||||
private Integer onLine;
|
||||
//最后一次上线时间
|
||||
private Date lastOnLineTime;
|
||||
//通讯协议类型:0:WebSocket 1:MQTT 2:TCP 3:UDP 4:HTTP
|
||||
private Integer protocolType;
|
||||
//运行模式id
|
||||
private Long operatingModeId;
|
||||
//升级模式:0 无模式 1 自动升级
|
||||
private Integer otaType;
|
||||
//自动升级开始时间段
|
||||
private Date otaStartTime;
|
||||
//自动升级结束时间段
|
||||
private Date otaEndTime;
|
||||
//生产时间
|
||||
private Date factoryTime;
|
||||
//销售时间
|
||||
private Date saleTime;
|
||||
}
|
||||
@ -1,333 +0,0 @@
|
||||
package com.admin.service.impl;
|
||||
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* 设备信息服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DeviceInfoService extends GenericReactiveCrudService<DeviceInfoEntity, Long> {
|
||||
|
||||
|
||||
public Mono<DeviceInfoEntity> selectDeviceInfoByRequest(DeviceInfoRequest request){
|
||||
ReactiveQuery<DeviceInfoEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getId, request.getId());
|
||||
}
|
||||
if(request.getIsDelete() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getIsDelete, request.getIsDelete());
|
||||
}
|
||||
if(request.getCreateTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getCreateTime, request.getCreateTime());
|
||||
}
|
||||
if(request.getModifyTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getModifyTime, request.getModifyTime());
|
||||
}
|
||||
if(request.getBatchId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getBatchId, request.getBatchId());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getName())){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getName, request.getName());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getSn())){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getSn, request.getSn());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getKey())){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getKey, request.getKey());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getBtMac())){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getBtMac, request.getBtMac());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getWifiMac())){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getWifiMac, request.getWifiMac());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getFirmwareVersion())){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getFirmwareVersion, request.getFirmwareVersion());
|
||||
}
|
||||
if(request.getDeviceType() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getDeviceType, request.getDeviceType());
|
||||
}
|
||||
if(request.getStatus() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getStatus, request.getStatus());
|
||||
}
|
||||
if(request.getOnLine() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getOnLine, request.getOnLine());
|
||||
}
|
||||
if(request.getLastOnLineTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getLastOnLineTime, request.getLastOnLineTime());
|
||||
}
|
||||
if(request.getProtocolType() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getProtocolType, request.getProtocolType());
|
||||
}
|
||||
if(request.getOperatingModeId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getOperatingModeId, request.getOperatingModeId());
|
||||
}
|
||||
if(request.getOtaType() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getOtaType, request.getOtaType());
|
||||
}
|
||||
if(request.getOtaStartTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getOtaStartTime, request.getOtaStartTime());
|
||||
}
|
||||
if(request.getOtaEndTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getOtaEndTime, request.getOtaEndTime());
|
||||
}
|
||||
if(request.getFactoryTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getFactoryTime, request.getFactoryTime());
|
||||
}
|
||||
if(request.getSaleTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getSaleTime, request.getSaleTime());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
sortOrder = SortOrder.desc(request.getOrder());
|
||||
}else{
|
||||
sortOrder = SortOrder.asc(request.getOrder());
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
return reactiveQuery.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<PagerResult<DeviceInfoEntity> selectDeviceInfosByRequest(DeviceInfoRequest request){
|
||||
ReactiveQuery<DeviceInfoEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getId, request.getId());
|
||||
}
|
||||
if(request.getIsDelete() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getIsDelete, request.getIsDelete());
|
||||
}
|
||||
if(request.getCreateTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(DeviceInfoRequest::getCreateTime, request.getCreateTimeStart());
|
||||
}
|
||||
if(request.getCreateTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(DeviceInfoRequest::getCreateTime, request.getCreateTimeEnd());
|
||||
}
|
||||
if(request.getModifyTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(DeviceInfoRequest::getModifyTime, request.getModifyTimeStart());
|
||||
}
|
||||
if(request.getModifyTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(DeviceInfoRequest::getModifyTime, request.getModifyTimeEnd());
|
||||
}
|
||||
if(request.getBatchId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getBatchId, request.getBatchId());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getName())){
|
||||
reactiveQuery = reactiveQuery.$like$(DeviceInfoRequest::getName, request.getName());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getSn())){
|
||||
reactiveQuery = reactiveQuery.$like$(DeviceInfoRequest::getSn, request.getSn());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getKey())){
|
||||
reactiveQuery = reactiveQuery.$like$(DeviceInfoRequest::getKey, request.getKey());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getBtMac())){
|
||||
reactiveQuery = reactiveQuery.$like$(DeviceInfoRequest::getBtMac, request.getBtMac());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getWifiMac())){
|
||||
reactiveQuery = reactiveQuery.$like$(DeviceInfoRequest::getWifiMac, request.getWifiMac());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getFirmwareVersion())){
|
||||
reactiveQuery = reactiveQuery.$like$(DeviceInfoRequest::getFirmwareVersion, request.getFirmwareVersion());
|
||||
}
|
||||
if(request.getDeviceType() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getDeviceType, request.getDeviceType());
|
||||
}
|
||||
if(request.getStatus() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getStatus, request.getStatus());
|
||||
}
|
||||
if(request.getOnLine() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getOnLine, request.getOnLine());
|
||||
}
|
||||
if(request.getLastOnLineTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(DeviceInfoRequest::getLastOnLineTime, request.getLastOnLineTimeStart());
|
||||
}
|
||||
if(request.getLastOnLineTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(DeviceInfoRequest::getLastOnLineTime, request.getLastOnLineTimeEnd());
|
||||
}
|
||||
if(request.getProtocolType() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getProtocolType, request.getProtocolType());
|
||||
}
|
||||
if(request.getOperatingModeId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getOperatingModeId, request.getOperatingModeId());
|
||||
}
|
||||
if(request.getOtaType() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceInfoRequest::getOtaType, request.getOtaType());
|
||||
}
|
||||
if(request.getOtaStartTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(DeviceInfoRequest::getOtaStartTime, request.getOtaStartTimeStart());
|
||||
}
|
||||
if(request.getOtaStartTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(DeviceInfoRequest::getOtaStartTime, request.getOtaStartTimeEnd());
|
||||
}
|
||||
if(request.getOtaEndTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(DeviceInfoRequest::getOtaEndTime, request.getOtaEndTimeStart());
|
||||
}
|
||||
if(request.getOtaEndTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(DeviceInfoRequest::getOtaEndTime, request.getOtaEndTimeEnd());
|
||||
}
|
||||
if(request.getFactoryTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(DeviceInfoRequest::getFactoryTime, request.getFactoryTimeStart());
|
||||
}
|
||||
if(request.getFactoryTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(DeviceInfoRequest::getFactoryTime, request.getFactoryTimeEnd());
|
||||
}
|
||||
if(request.getSaleTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(DeviceInfoRequest::getSaleTime, request.getSaleTimeStart());
|
||||
}
|
||||
if(request.getSaleTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(DeviceInfoRequest::getSaleTime, request.getSaleTimeEnd());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
sortOrder = SortOrder.desc(request.getOrder());
|
||||
}else{
|
||||
sortOrder = SortOrder.asc(request.getOrder());
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
||||
param.setPageIndex(request.getCurrPage());
|
||||
param.setPageSize(request.getPageSize());
|
||||
param.setPaging(true);
|
||||
param.setFirstPageIndex(1);
|
||||
return queryPager(param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<DeviceInfoEntity> selectDeviceInfoById(Long id){
|
||||
return createQuery()
|
||||
.and("is_delete", 0)
|
||||
.and("id", id)
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> insertDeviceInfo(DeviceInfoEntity entity){
|
||||
entity.setId(null);
|
||||
entity.setCreateTime(null);
|
||||
entity.setModifyTime(null);
|
||||
return insert(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> updateDeviceInfoById(DeviceInfoEntity entity){
|
||||
ReactiveUpdate<DeviceInfoEntity> update = createUpdate()
|
||||
.set(DeviceInfoEntity::getModifyTime, new Date());
|
||||
if(entity.getIsDelete() != null){
|
||||
update = update.set(DeviceInfoEntity::getIsDelete, entity.getIsDelete());
|
||||
}
|
||||
if(entity.getBatchId() != null){
|
||||
update = update.set(DeviceInfoEntity::getBatchId, entity.getBatchId());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getName())){
|
||||
update = update.set(DeviceInfoEntity::getName, entity.getName());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getSn())){
|
||||
update = update.set(DeviceInfoEntity::getSn, entity.getSn());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getKey())){
|
||||
update = update.set(DeviceInfoEntity::getKey, entity.getKey());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getBtMac())){
|
||||
update = update.set(DeviceInfoEntity::getBtMac, entity.getBtMac());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getWifiMac())){
|
||||
update = update.set(DeviceInfoEntity::getWifiMac, entity.getWifiMac());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getFirmwareVersion())){
|
||||
update = update.set(DeviceInfoEntity::getFirmwareVersion, entity.getFirmwareVersion());
|
||||
}
|
||||
if(entity.getDeviceType() != null){
|
||||
update = update.set(DeviceInfoEntity::getDeviceType, entity.getDeviceType());
|
||||
}
|
||||
if(entity.getStatus() != null){
|
||||
update = update.set(DeviceInfoEntity::getStatus, entity.getStatus());
|
||||
}
|
||||
if(entity.getOnLine() != null){
|
||||
update = update.set(DeviceInfoEntity::getOnLine, entity.getOnLine());
|
||||
}
|
||||
if(entity.getLastOnLineTime() != null){
|
||||
update = update.set(DeviceInfoEntity::getLastOnLineTime, entity.getLastOnLineTime());
|
||||
}
|
||||
if(entity.getProtocolType() != null){
|
||||
update = update.set(DeviceInfoEntity::getProtocolType, entity.getProtocolType());
|
||||
}
|
||||
if(entity.getOperatingModeId() != null){
|
||||
update = update.set(DeviceInfoEntity::getOperatingModeId, entity.getOperatingModeId());
|
||||
}
|
||||
if(entity.getOtaType() != null){
|
||||
update = update.set(DeviceInfoEntity::getOtaType, entity.getOtaType());
|
||||
}
|
||||
if(entity.getOtaStartTime() != null){
|
||||
update = update.set(DeviceInfoEntity::getOtaStartTime, entity.getOtaStartTime());
|
||||
}
|
||||
if(entity.getOtaEndTime() != null){
|
||||
update = update.set(DeviceInfoEntity::getOtaEndTime, entity.getOtaEndTime());
|
||||
}
|
||||
if(entity.getFactoryTime() != null){
|
||||
update = update.set(DeviceInfoEntity::getFactoryTime, entity.getFactoryTime());
|
||||
}
|
||||
if(entity.getSaleTime() != null){
|
||||
update = update.set(DeviceInfoEntity::getSaleTime, entity.getSaleTime());
|
||||
}
|
||||
return update.where(DeviceInfoEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> updateCoverDeviceInfoById(DeviceInfoEntity entity){
|
||||
ReactiveUpdate<DeviceInfoEntity> update = createUpdate()
|
||||
.set(DeviceInfoEntity::getModifyTime, new Date());
|
||||
update = update.set(DeviceInfoEntity::getIsDelete, entity.getIsDelete());
|
||||
update = update.set(DeviceInfoEntity::getBatchId, entity.getBatchId());
|
||||
update = update.set(DeviceInfoEntity::getName, entity.getName());
|
||||
update = update.set(DeviceInfoEntity::getSn, entity.getSn());
|
||||
update = update.set(DeviceInfoEntity::getKey, entity.getKey());
|
||||
update = update.set(DeviceInfoEntity::getBtMac, entity.getBtMac());
|
||||
update = update.set(DeviceInfoEntity::getWifiMac, entity.getWifiMac());
|
||||
update = update.set(DeviceInfoEntity::getFirmwareVersion, entity.getFirmwareVersion());
|
||||
update = update.set(DeviceInfoEntity::getDeviceType, entity.getDeviceType());
|
||||
update = update.set(DeviceInfoEntity::getStatus, entity.getStatus());
|
||||
update = update.set(DeviceInfoEntity::getOnLine, entity.getOnLine());
|
||||
update = update.set(DeviceInfoEntity::getLastOnLineTime, entity.getLastOnLineTime());
|
||||
update = update.set(DeviceInfoEntity::getProtocolType, entity.getProtocolType());
|
||||
update = update.set(DeviceInfoEntity::getOperatingModeId, entity.getOperatingModeId());
|
||||
update = update.set(DeviceInfoEntity::getOtaType, entity.getOtaType());
|
||||
update = update.set(DeviceInfoEntity::getOtaStartTime, entity.getOtaStartTime());
|
||||
update = update.set(DeviceInfoEntity::getOtaEndTime, entity.getOtaEndTime());
|
||||
update = update.set(DeviceInfoEntity::getFactoryTime, entity.getFactoryTime());
|
||||
update = update.set(DeviceInfoEntity::getSaleTime, entity.getSaleTime());
|
||||
return update.where(DeviceInfoEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> deleteDeviceInfoById(Long id){
|
||||
return createUpdate()
|
||||
.set("is_delete", 1)
|
||||
.set("modify_time", new Date())
|
||||
.where("id", id)
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
package com.admin.service.impl;
|
||||
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* 用户房间Controller类
|
||||
* </p>
|
||||
*
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/UserRoom")
|
||||
public class UserRoomController{
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserRoomService userRoomService;
|
||||
@PostMapping("/info")
|
||||
public Mono<UserRoomResp> selectUserRoomByRequest(@RequestBody UserRoomRequest request){
|
||||
return userRoomService.selectUserRoomByRequest(request).map(d -> {return new UserRoomResp(d);});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
public Mono<PagerResult<UserRoomResp>> selectUserRoomsByRequest(@RequestBody UserRoomRequest request){
|
||||
return userRoomService.selectDeviceInfosByRequest(request).map(d -> {
|
||||
PagerResult<UserRoomResp> result = new PagerResult<>();
|
||||
result.setPageIndex(d.getPageIndex());
|
||||
result.setPageSize(d.getPageSize());
|
||||
result.setTotal(d.getTotal());
|
||||
List<UserRoomResp> ds = d.getData().stream().map(new Function<UserRoomEntity, UserRoomResp>() {
|
||||
@Override
|
||||
public DeviceInfoResp apply(UserRoomEntity entity) {
|
||||
return new UserRoomResp(entity);
|
||||
}
|
||||
}
|
||||
|
||||
).collect(Collectors.toList());
|
||||
result.setData(ds);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/id")
|
||||
public Mono<UserRoomResp> selectUserRoomById(@RequestParam Long id){
|
||||
return userRoomService.selectUserRoomById(id).map(d -> {return new UserRoomResp(d);});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/save")
|
||||
public Mono<Integer> insertUserRoom(@RequestBody UserRoomEntity entity){
|
||||
return userRoomService.insertUserRoom(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/update")
|
||||
public Mono<Integer> updateUserRoomById(@RequestBody UserRoomEntity entity){
|
||||
return userRoomService.updateUserRoomById(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/updateCover")
|
||||
public Mono<Integer> updateCoverUserRoomById(@RequestBody UserRoomEntity entity){
|
||||
return userRoomService.updateCoverUserRoomById(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Mono<Integer> deleteUserRoomById(@RequestParam Long id){
|
||||
return userRoomService.deleteUserRoomById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package com.qiuguo.iot.data.entity;
|
||||
import org.hswebframework.ezorm.rdb.mapping.annotation.Comment;
|
||||
import org.hswebframework.web.crud.annotation.EnableEntityEvent;
|
||||
import org.hswebframework.web.api.crud.entity.GenericEntity;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Table;import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* </p>*用户房间表
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Comment("用户房间表")
|
||||
@Table(name = "user_room")
|
||||
@EnableEntityEvent
|
||||
public class UserRoomEntity extends GenericEntity<Long> {
|
||||
@Comment("id")
|
||||
@Column(name = "id", length = 11, nullable = false, unique = true)
|
||||
private Long id;
|
||||
|
||||
@Comment("家庭id")
|
||||
@Column(name = "home_id", nullable = false)
|
||||
private Long homeId;
|
||||
|
||||
@Comment("房间名称")
|
||||
@Column(name = "room_name", length = 100)
|
||||
private String roomName;
|
||||
|
||||
@Comment("涂鸦空间id")
|
||||
@Column(name = "space_id", length = 100)
|
||||
private Long spaceId;
|
||||
|
||||
@Comment("is_delete")
|
||||
@Column(name = "is_delete")
|
||||
private Integer isDelete;
|
||||
|
||||
@Comment("create_time")
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
@Comment("modify_time")
|
||||
@Column(name = "modify_time")
|
||||
private Date modifyTime;
|
||||
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
package com.qiuguo.iot.data.entity;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
*用户房间请求类
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
public class UserRoomRequest implements java.io.Serializable {
|
||||
|
||||
private int currPage = 1;
|
||||
private int pageSize = 10;
|
||||
private String sort;
|
||||
private String order;
|
||||
//
|
||||
private Long id;
|
||||
//家庭id
|
||||
private Long homeId;
|
||||
//房间名称
|
||||
private String roomName;
|
||||
//涂鸦空间id
|
||||
private Long spaceId;
|
||||
//
|
||||
private Integer isDelete;
|
||||
//
|
||||
private Date createTime;
|
||||
//搜索开始
|
||||
|
||||
private Date createTimeStart;
|
||||
|
||||
//搜索结束
|
||||
private Date createTimeEnd;
|
||||
//
|
||||
private Date modifyTime;
|
||||
//搜索开始
|
||||
|
||||
private Date modifyTimeStart;
|
||||
|
||||
//搜索结束
|
||||
private Date modifyTimeEnd;
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package com.qiuguo.iot.data.entity;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* </p>*用户房间返回类
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class UserRoomResp {
|
||||
public UserRoomResp(){
|
||||
}
|
||||
public UserRoomResp(UserRoomEntity entity){
|
||||
id = entity.getId();
|
||||
homeId = entity.getHomeId();
|
||||
roomName = entity.getRoomName();
|
||||
spaceId = entity.getSpaceId();
|
||||
createTime = entity.getCreateTime();
|
||||
modifyTime = entity.getModifyTime();
|
||||
}
|
||||
|
||||
//
|
||||
private Long id;
|
||||
//家庭id
|
||||
private Long homeId;
|
||||
//房间名称
|
||||
private String roomName;
|
||||
//涂鸦空间id
|
||||
private Long spaceId;
|
||||
//
|
||||
private Date createTime;
|
||||
//
|
||||
private Date modifyTime;
|
||||
}
|
||||
@ -1,168 +0,0 @@
|
||||
package com.admin.service.impl;
|
||||
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
* 用户房间服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wulin
|
||||
* @since 2023-09-21
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UserRoomService extends GenericReactiveCrudService<UserRoomEntity, Long> {
|
||||
|
||||
|
||||
public Mono<UserRoomEntity> selectUserRoomByRequest(UserRoomRequest request){
|
||||
ReactiveQuery<UserRoomEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getId, request.getId());
|
||||
}
|
||||
if(request.getHomeId() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getHomeId, request.getHomeId());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getRoomName())){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getRoomName, request.getRoomName());
|
||||
}
|
||||
if(request.getSpaceId() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getSpaceId, request.getSpaceId());
|
||||
}
|
||||
if(request.getIsDelete() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getIsDelete, request.getIsDelete());
|
||||
}
|
||||
if(request.getCreateTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getCreateTime, request.getCreateTime());
|
||||
}
|
||||
if(request.getModifyTime() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getModifyTime, request.getModifyTime());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
sortOrder = SortOrder.desc(request.getOrder());
|
||||
}else{
|
||||
sortOrder = SortOrder.asc(request.getOrder());
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
return reactiveQuery.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<PagerResult<UserRoomEntity> selectUserRoomsByRequest(UserRoomRequest request){
|
||||
ReactiveQuery<UserRoomEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getId, request.getId());
|
||||
}
|
||||
if(request.getHomeId() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getHomeId, request.getHomeId());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getRoomName())){
|
||||
reactiveQuery = reactiveQuery.$like$(UserRoomRequest::getRoomName, request.getRoomName());
|
||||
}
|
||||
if(request.getSpaceId() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getSpaceId, request.getSpaceId());
|
||||
}
|
||||
if(request.getIsDelete() != null){
|
||||
reactiveQuery = reactiveQuery.and(UserRoomRequest::getIsDelete, request.getIsDelete());
|
||||
}
|
||||
if(request.getCreateTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(UserRoomRequest::getCreateTime, request.getCreateTimeStart());
|
||||
}
|
||||
if(request.getCreateTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(UserRoomRequest::getCreateTime, request.getCreateTimeEnd());
|
||||
}
|
||||
if(request.getModifyTimeStart() != null){
|
||||
reactiveQuery = reactiveQuery.gte(UserRoomRequest::getModifyTime, request.getModifyTimeStart());
|
||||
}
|
||||
if(request.getModifyTimeEnd() != null){
|
||||
reactiveQuery = reactiveQuery.lte(UserRoomRequest::getModifyTime, request.getModifyTimeEnd());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
sortOrder = SortOrder.desc(request.getOrder());
|
||||
}else{
|
||||
sortOrder = SortOrder.asc(request.getOrder());
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
||||
param.setPageIndex(request.getCurrPage());
|
||||
param.setPageSize(request.getPageSize());
|
||||
param.setPaging(true);
|
||||
param.setFirstPageIndex(1);
|
||||
return queryPager(param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<UserRoomEntity> selectUserRoomById(Long id){
|
||||
return createQuery()
|
||||
.and("is_delete", 0)
|
||||
.and("id", id)
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> insertUserRoom(UserRoomEntity entity){
|
||||
entity.setId(null);
|
||||
entity.setCreateTime(null);
|
||||
entity.setModifyTime(null);
|
||||
return insert(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> updateUserRoomById(UserRoomEntity entity){
|
||||
ReactiveUpdate<UserRoomEntity> update = createUpdate()
|
||||
.set(UserRoomEntity::getModifyTime, new Date());
|
||||
if(entity.getHomeId() != null){
|
||||
update = update.set(UserRoomEntity::getHomeId, entity.getHomeId());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(entity.getRoomName())){
|
||||
update = update.set(UserRoomEntity::getRoomName, entity.getRoomName());
|
||||
}
|
||||
if(entity.getSpaceId() != null){
|
||||
update = update.set(UserRoomEntity::getSpaceId, entity.getSpaceId());
|
||||
}
|
||||
if(entity.getIsDelete() != null){
|
||||
update = update.set(UserRoomEntity::getIsDelete, entity.getIsDelete());
|
||||
}
|
||||
return update.where(UserRoomEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> updateCoverUserRoomById(UserRoomEntity entity){
|
||||
ReactiveUpdate<UserRoomEntity> update = createUpdate()
|
||||
.set(UserRoomEntity::getModifyTime, new Date());
|
||||
update = update.set(UserRoomEntity::getHomeId, entity.getHomeId());
|
||||
update = update.set(UserRoomEntity::getRoomName, entity.getRoomName());
|
||||
update = update.set(UserRoomEntity::getSpaceId, entity.getSpaceId());
|
||||
update = update.set(UserRoomEntity::getIsDelete, entity.getIsDelete());
|
||||
return update.where(UserRoomEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Mono<Integer> deleteUserRoomById(Long id){
|
||||
return createUpdate()
|
||||
.set("is_delete", 1)
|
||||
.set("modify_time", new Date())
|
||||
.where("id", id)
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user