Commit e8fe8c18 by 胡懿

修改设备信息获取方式,增加在线设备判断,修改设备规则判断逻辑

parent 4f6cc1ca
......@@ -4,8 +4,10 @@ import cn.gintone.controller.vo.DeviceReqConfListReqVO;
import cn.gintone.controller.vo.DeviceReqConfSaveReqVO;
import cn.gintone.dal.DeviceReqConfMapper;
import cn.gintone.entity.DeviceReqConfDO;
import cn.gintone.iotdbUtils.MyDateUtils;
import cn.gintone.service.DeviceReqConfService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.slf4j.Logger;
......@@ -17,6 +19,7 @@ import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
......@@ -101,9 +104,27 @@ public class PumpStationKafkaConsumer {
private void processMessageAsync(String message, String topic) {
CompletableFuture.runAsync(() -> {
try {
boolean b = false;
JSONObject msgJsonObject = JSON.parseObject(message);
String snCode = msgJsonObject.get("serialNo").toString();
JSONArray services = msgJsonObject.getJSONArray("services");
if (null != services) {
JSONObject paramsObject = services.getJSONObject(0).getJSONObject("params");
if (null != paramsObject) {
String ts = paramsObject.getString("ts");
if (null != ts) {
long l = MyDateUtils.stringToLong(ts);
if (new Date().getTime() - l < 24 * 60 * 60 * 1000) {
b = true;
}
}
}
}
if (!b) {
logger.info("异步处理完成, topic: {}, SN: {}", topic, snCode);
return;
}
DeviceReqConfListReqVO temDRCLRV = new DeviceReqConfListReqVO();
temDRCLRV.setSnCode(snCode);
List<DeviceReqConfDO> deviceReqConfList = deviceReqConfMapper.selectList(temDRCLRV);
......
......@@ -33,7 +33,7 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 设备类型")
@RestController
@RequestMapping("/gintone/device-type")
@RequestMapping("/admin-api/gintone/device-type")
@Validated
public class DeviceTypeController {
......
......@@ -20,7 +20,7 @@ public class DeviceReqConfRespVO {
@ExcelProperty("设备名称")
private String deviceName;
@Schema(description = "设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21048")
@Schema(description = "设备id", example = "21048")
@ExcelProperty("设备id")
private String deviceId;
......@@ -32,7 +32,7 @@ public class DeviceReqConfRespVO {
@ExcelProperty("父级id")
private Long parentId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
......
......@@ -16,7 +16,6 @@ public class DeviceReqConfSaveReqVO {
private String deviceName;
@Schema(description = "设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21048")
@NotEmpty(message = "设备id不能为空")
private String deviceId;
@Schema(description = "设备类型id", example = "24373")
......
......@@ -429,7 +429,6 @@ public class DeviceReqConfServiceImpl implements DeviceReqConfService {
deviceReqConf.setDeviceName(ptExportDevice.getDeviceName());
deviceReqConf.setAddress(ptExportDevice.getDescription());
deviceReqConf.setDeviceEn(modelCode);
deviceReqConf.setRegionName(ptExportDevice.getDescription());
deviceReqConfMapper.insert(deviceReqConf);
}
......
......@@ -54,7 +54,7 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
MyReadApplicationUtils.readApplication();
boolean b = false;
boolean b = true;
if (b) {
String pdToken = request.getHeader("pdToken");
StringBuffer requestURL = request.getRequestURL();
......
......@@ -121,8 +121,7 @@ spring:
rocketmq:
name-server: 127.0.0.1:9876 # RocketMQ Namesrv
spring:
# RabbitMQ 配置项,对应 RabbitProperties 配置类
# RabbitMQ 配置项,对应 RabbitProperties 配置类
# rabbitmq:
# host: 192.168.19.205
# host: 127.0.0.1
......@@ -131,16 +130,42 @@ spring:
# password: kalo
# virtual-host: /
# Kafka 配置项,对应 KafkaProperties 配置类
kafka:
bootstrap-servers: localhost:9092
kafka:
cluster1:
bootstrap-servers: 59.195.13.209:9092
# bootstrap-servers: 192.168.19.128:9092
producer:
retries: 3
timeout: 60000
request-timeout-ms: 60000
max-block-ms: 60000
key.serializer: org.apache.kafka.common.serialization.StringSerializer
value.serializer: org.apache.kafka.common.serialization.StringSerializer
consumer:
group-id: weblog_consumer_group
auto-offset-reset: earliest
enable-auto-commit: false
max-poll-interval-ms: 300000
admin:
auto-create: true
cluster2:
bootstrap-servers: 59.195.13.250:29400,59.195.13.250:29401,59.195.13.250:29402
properties:
security.protocol: PLAINTEXT
producer:
retries: 3
request-timeout-ms: 60000
max-block-ms: 60000
key.serializer: org.apache.kafka.common.serialization.StringSerializer
value.serializer: org.apache.kafka.common.serialization.StringSerializer
consumer:
group-id: pump_station_consumer_group
auto-offset-reset: earliest
enable-auto-commit: false
max-poll-interval-ms: 300000
# 添加消费者稳定性配置
session-timeout-ms: 30000
heartbeat-interval-ms: 10000
max-poll-records: 500
--- #################### 服务保障相关配置 ####################
# Lock4j 配置项
......
......@@ -3,8 +3,8 @@ spring:
name: yudao-server
profiles:
# active: local
active: dev
active: local
# active: dev
main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
......
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 to comment