fix: 调整客流计数器上报数据返回(含调整配置周期1min/次)
All checks were successful
iot-test-platform CI/CD / build-and-deploy (push) Successful in 32s

This commit is contained in:
lzh
2025-12-18 10:12:29 +08:00
parent 492cca36ed
commit 4fe7083891
2 changed files with 67 additions and 32 deletions

View File

@@ -2,6 +2,7 @@ package com.iot.transport.jt808.controller;
import com.iot.transport.jt808.common.CommonResult;
import com.iot.transport.jt808.entity.dto.LocationDto;
import com.iot.transport.jt808.entity.response.DeviceUploadResp;
import com.iot.transport.jt808.service.ApiLogService;
import com.iot.transport.jt808.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
@@ -10,6 +11,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Map;
import java.util.List;
@@ -60,18 +63,18 @@ public class DeviceController {
}
break;
case "workmode":
if (params != null && params.size() >= 2) {
commandStr = CommandBuilder.setWorkMode(Integer.parseInt(params.get(0)), Integer.parseInt(params.get(1)));
}
break;
if (params != null && params.size() >= 2) {
commandStr = CommandBuilder.setWorkMode(Integer.parseInt(params.get(0)), Integer.parseInt(params.get(1)));
}
break;
case "realtime":
if (params != null && params.size() >= 2) {
commandStr = CommandBuilder.setRealtimeMode(Integer.parseInt(params.get(0)), Integer.parseInt(params.get(1)));
}
break;
if (params != null && params.size() >= 2) {
commandStr = CommandBuilder.setRealtimeMode(Integer.parseInt(params.get(0)), Integer.parseInt(params.get(1)));
}
break;
case "custom": // 自定义指令内容
commandStr = (String) payload.get("raw");
break;
commandStr = (String) payload.get("raw");
break;
default:
return CommonResult.failed("Unknown command type: " + cmdType);
}
@@ -90,8 +93,8 @@ public class DeviceController {
*/
@PostMapping("/command/text")
public CommonResult<String> sendTextCommand(@RequestParam String phone,
@RequestParam String content,
@RequestParam(defaultValue = "1") int flag) { // 默认为1(紧急)
@RequestParam String content,
@RequestParam(defaultValue = "1") int flag) { // 默认为1(紧急)
try {
Session session = findSessionByPhone(phone);
if (session == null) {
@@ -162,11 +165,26 @@ public class DeviceController {
* 2. 推送到前端页面
*/
@PostMapping("/upload")
public CommonResult<String> receiveDeviceData(@RequestBody Map<String, Object> payload) {
public DeviceUploadResp receiveDeviceData(@RequestBody Map<String, Object> payload) {
// 广播日志(同时会记录到服务器日志文件)
apiLogService.broadcastLog("API", payload);
return CommonResult.success("设备数据接收成功");
// 2. 组装设备响应
DeviceUploadResp resp = new DeviceUploadResp();
resp.setStatusCode(0);
resp.setTime(
LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
);
resp.setOpen("0800");
resp.setClose("2300");
resp.setSaveCycle(1);
resp.setUpCycle(1);
resp.setLicense("0");
resp.setDirection("twoWay");
resp.setUpgradeUrl("http://op.foorir.com/upgrade/2023120.bin");
return resp;
}
/**

View File

@@ -0,0 +1,17 @@
package com.iot.transport.jt808.entity.response;
import lombok.Data;
@Data
public class DeviceUploadResp {
private Integer statusCode; // 0 正常 1 未绑定平台 2 解析 json 出错
private String time; // yyyyMMddHHmmss
private String open; // 营业开始时间
private String close; // 营业结束时间
private Integer saveCycle; // 存储周期
private Integer upCycle; // 上报周期
private String license; // 0 正常 1 证书到期
private String direction; // twoWay / onlyIn / onlyOut / exchange
private String upgradeUrl; // 升级地址(无升级可为空)
}