Commit a2daf2cf by 朱淼
parents b2f3388f 65cdaafa
package com.makeit.module.iot.service;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.makeit.module.iot.util.HttpRequest;
import com.makeit.module.iot.vo.DeviceInstanceEntity;
import com.makeit.module.iot.vo.ResponseMessage;
import com.makeit.utils.data.convert.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* iot产品设备相关接口
*/
@Component
@Slf4j
public class IotDevicePropertiesOperateService extends IotCommonService {
public static final String DEVICE_PREFIX_URL = "/device-instance/";
/**
* 把设备写入属性
*/
@Async
public List<DeviceInstanceEntity> deviceWrite(String deviceId, Integer radarMount, Integer radarMode, Integer radarHight) {
String url = iotUrl + DEVICE_PREFIX_URL + deviceId + "/property";
// 条件可以自己改
Map<String, Object> map = Maps.newHashMap();
if (radarMount != null) {
map.put("radarMount", radarMount);
}
if (radarMode != null) {
map.put("radarMode", radarMode);
}
if (radarHight != null) {
map.put("radarHight", radarHight);
}
String body = JsonUtil.toJson(map);
HttpRequest request = buildRequest(url, body);
try {
ResponseMessage responseMessage = sendPut(url, request);
log.error("写入设备属性信息:{}", responseMessage.getMessage());
} catch (IOException e) {
log.error("调用:{}接口异常:{}", url, e.getMessage());
}
return Lists.newArrayList();
}
}
...@@ -38,6 +38,8 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -38,6 +38,8 @@ public class IotProductDeviceService extends IotCommonService {
public static final String DEVICE_PREFIX_URL = "/device-instance/"; public static final String DEVICE_PREFIX_URL = "/device-instance/";
public static final String REPORT_PROPERTY = "reportProperty";
/** /**
* 获取设备信息 * 获取设备信息
*/ */
...@@ -92,7 +94,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -92,7 +94,7 @@ public class IotProductDeviceService extends IotCommonService {
} }
public DeviceInfoContentBreathe getLastDeviceLogBreathe(String deviceId, Integer ignoreDuration) {//秒 public DeviceInfoContentBreathe getLastDeviceLogBreathe(String deviceId, Integer ignoreDuration) {//秒
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, "reportProperty"); DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, REPORT_PROPERTY);
if (deviceOperationLogEntity == null) { if (deviceOperationLogEntity == null) {
return null; return null;
} }
...@@ -109,7 +111,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -109,7 +111,7 @@ public class IotProductDeviceService extends IotCommonService {
} }
public DeviceInfoContentSpace getLastDeviceLogSpace(String deviceId, Integer ignoreDuration) {//秒 public DeviceInfoContentSpace getLastDeviceLogSpace(String deviceId, Integer ignoreDuration) {//秒
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, "reportProperty"); DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, REPORT_PROPERTY);
if (deviceOperationLogEntity == null) { if (deviceOperationLogEntity == null) {
return null; return null;
} }
...@@ -128,7 +130,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -128,7 +130,7 @@ public class IotProductDeviceService extends IotCommonService {
public List<DeviceInfoContentBreathe> getDeviceLogByTimeRangeBreathe(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) { public List<DeviceInfoContentBreathe> getDeviceLogByTimeRangeBreathe(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "reportProperty", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime)); List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentBreathe> deviceInfoContentBreatheList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentBreathe.class)); List<DeviceInfoContentBreathe> deviceInfoContentBreatheList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentBreathe.class));
...@@ -138,7 +140,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -138,7 +140,7 @@ public class IotProductDeviceService extends IotCommonService {
public List<DeviceInfoContentSpace> getDeviceLogByTimeRangeSpace(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) { public List<DeviceInfoContentSpace> getDeviceLogByTimeRangeSpace(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "reportProperty", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime)); List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentSpace.class)); List<DeviceInfoContentSpace> deviceInfoContentSpaceList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentSpace.class));
...@@ -148,7 +150,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -148,7 +150,7 @@ public class IotProductDeviceService extends IotCommonService {
public List<DeviceInfoContentFall> getDeviceLogByTimeRangeFall(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) { public List<DeviceInfoContentFall> getDeviceLogByTimeRangeFall(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "reportProperty", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime)); List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentFall> deviceInfoContentFallList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentFall.class)); List<DeviceInfoContentFall> deviceInfoContentFallList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentFall.class));
...@@ -235,7 +237,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -235,7 +237,7 @@ public class IotProductDeviceService extends IotCommonService {
Term term3 = Term.builder() Term term3 = Term.builder()
.column("type") .column("type")
.termType("eq") .termType("eq")
.type(Term.Type.or) .type(Term.Type.and)
.value(typeValue) .value(typeValue)
.terms(Lists.newArrayList()) .terms(Lists.newArrayList())
.options(Lists.newArrayList()) .options(Lists.newArrayList())
......
...@@ -7,6 +7,7 @@ import com.makeit.common.page.PageVO; ...@@ -7,6 +7,7 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO; import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO; import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO; import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
...@@ -64,5 +65,12 @@ public class PlatDeviceWechatController { ...@@ -64,5 +65,12 @@ public class PlatDeviceWechatController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("编辑设备属性")
@PostMapping("editDeviceProperties")
public ApiResponseEntity<?> editDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
platDeviceService.editDeviceProperties(dto);
return ApiResponseUtils.success();
}
} }
package com.makeit.dto.wechat.device;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 设备
* </p>
*
* @author eugene young
* @since 2023-09-05
*/
@Data
@ApiModel(value = "PlatDeviceAttrWechatDTO对象", description = "设备属性")
public class PlatDeviceAttrWechatDTO {
@ApiModelProperty(value = "设备id")
private String deviceId;
@ApiModelProperty(value = "雷达安装方式 雷达安装方式")
private Integer radarMount;
@ApiModelProperty(value = "雷达功能模式 默认侧装轨迹\n" +
"侧装下\n" +
"0为存在模式,1为轨迹模式;\n" +
"顶装下\n" +
"0为存在模式,1为区块模式;")
private Integer radarMode;
@ApiModelProperty(value = "\"最小值\":200,\"最大值\":380,\"步\n" +
"进\":1,\"单位\":\"cm\"")
private Integer radarHight;
}
...@@ -7,6 +7,7 @@ import com.makeit.dto.platform.device.PlatDeviceDetailDTO; ...@@ -7,6 +7,7 @@ import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO; import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO; import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO; import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO; import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO; import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
...@@ -52,4 +53,6 @@ public interface PlatDeviceService extends IService<PlatDevice> { ...@@ -52,4 +53,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
PlatDeviceDetailDTO getDetailDTO(String deviceId); PlatDeviceDetailDTO getDetailDTO(String deviceId);
void saasEdit(PlatDeviceEditSaasDTO dto); void saasEdit(PlatDeviceEditSaasDTO dto);
void editDeviceProperties(PlatDeviceAttrWechatDTO dto);
} }
...@@ -12,6 +12,7 @@ import com.makeit.dto.platform.device.PlatDeviceDetailDTO; ...@@ -12,6 +12,7 @@ import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.platform.device.PlatDeviceEditDTO; import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO; import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO; import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO; import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO; import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
...@@ -20,6 +21,7 @@ import com.makeit.entity.platform.device.PlatDeviceOther; ...@@ -20,6 +21,7 @@ import com.makeit.entity.platform.device.PlatDeviceOther;
import com.makeit.enums.CodeMessageEnum; import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.device.PlatDeviceMapper; import com.makeit.mapper.platform.device.PlatDeviceMapper;
import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import com.makeit.service.platform.auth.PlatOrgService; import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.device.PlatDeviceOtherService; import com.makeit.service.platform.device.PlatDeviceOtherService;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
...@@ -56,6 +58,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -56,6 +58,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private PlatOrgService platOrgService; private PlatOrgService platOrgService;
@Autowired @Autowired
private DeviceCacheUtil deviceCacheUtil; private DeviceCacheUtil deviceCacheUtil;
@Autowired
private IotDevicePropertiesOperateService devicePropertiesOperateService;
@Override @Override
public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) { public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
...@@ -256,4 +260,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -256,4 +260,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
.orderByDesc(BaseEntity::getUpdateDate); .orderByDesc(BaseEntity::getUpdateDate);
} }
@Override
public void editDeviceProperties(PlatDeviceAttrWechatDTO dto) {
devicePropertiesOperateService.deviceWrite(dto.getDeviceId(),dto.getRadarMount(),dto.getRadarMode(),dto.getRadarHight());
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment