电表设备信息
This commit is contained in:
parent
5015a5e870
commit
06a07462d9
|
@ -0,0 +1,30 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送设备信息实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("device_info")
|
||||||
|
public class DeviceInfoRecord {
|
||||||
|
private String gatewaySN;
|
||||||
|
private Integer deviceType;
|
||||||
|
private String deviceSN;
|
||||||
|
private String heartbeatTime;
|
||||||
|
private Integer isOnline;
|
||||||
|
private Integer isOpenAccount;
|
||||||
|
private Integer isOweMoney;
|
||||||
|
private BigDecimal totalMoney;
|
||||||
|
private Integer buyTimes;
|
||||||
|
private BigDecimal balance;
|
||||||
|
private String roomNo;
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
private Integer isSend;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("device_order_info")
|
||||||
|
public class DeviceOrderInfo {
|
||||||
|
private String deviceSN;
|
||||||
|
private Integer saleType;
|
||||||
|
private String buyTypeName;
|
||||||
|
private BigDecimal money;
|
||||||
|
private String saleDate;
|
||||||
|
private String ownerName;
|
||||||
|
private String roomNo;
|
||||||
|
private Integer isSend;
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description DeviceInfoDTO
|
||||||
|
* @Author lijingtong
|
||||||
|
* @Date 2025-07-09
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class DeviceInfoDTO {
|
||||||
|
@JSONField(name = "requestData")
|
||||||
|
private DeviceInfoDataDTO requestData;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description DeviceInfoDataDTO
|
||||||
|
* @Author lijingtong
|
||||||
|
* @Date 2025-07-09
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class DeviceInfoDataDTO {
|
||||||
|
@JSONField(name = "requestFlag")
|
||||||
|
private String requestFlag;
|
||||||
|
@JSONField(name = "requestDataList")
|
||||||
|
private List<DeviceInfoDataListDTO> requestDataList;
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description DeviceInfoDataListDTO
|
||||||
|
* @Author lijingtong
|
||||||
|
* @Date 2025-07-09
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class DeviceInfoDataListDTO {
|
||||||
|
// 多维网关设备SN
|
||||||
|
@JSONField(name = "gatewaySN")
|
||||||
|
private String gatewaySN;
|
||||||
|
// 设备类型
|
||||||
|
@JSONField(name = "deviceType")
|
||||||
|
private Integer deviceType;
|
||||||
|
// 设备(国标)编码
|
||||||
|
@JSONField(name = "deviceSN")
|
||||||
|
private String deviceSN;
|
||||||
|
// 设备心跳时间
|
||||||
|
@JSONField(name = "heartbeatTime")
|
||||||
|
private String heartbeatTime;
|
||||||
|
// 是否在线,1-在线,0-离线
|
||||||
|
@JSONField(name = "isOnline")
|
||||||
|
private Integer isOnline;
|
||||||
|
// 是否开户,1-开户,0-未开户
|
||||||
|
@JSONField(name = "isOpenAccount")
|
||||||
|
private Integer isOpenAccount;
|
||||||
|
// 是否欠费,1-欠费,0-不欠费
|
||||||
|
@JSONField(name = "isOweMoney")
|
||||||
|
private Integer isOweMoney;
|
||||||
|
// 累计购买金额
|
||||||
|
@JSONField(name = "totalMoney")
|
||||||
|
private java.math.BigDecimal totalMoney;
|
||||||
|
// 购买次数
|
||||||
|
@JSONField(name = "buyTimes")
|
||||||
|
private Integer buyTimes;
|
||||||
|
// 余额
|
||||||
|
@JSONField(name = "balance")
|
||||||
|
private java.math.BigDecimal balance;
|
||||||
|
// 房间号
|
||||||
|
@JSONField(name = "roomNo")
|
||||||
|
private String roomNo;
|
||||||
|
// 项目名称
|
||||||
|
@JSONField(name = "projectName")
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.bootdo.datasend.dianxin.domain.dto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description DeviceOrderInfoDTO
|
||||||
|
* @Author lijingtong
|
||||||
|
* @Date 2025-07-09
|
||||||
|
*/
|
||||||
|
public class DeviceOrderInfoDTO {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.bootdo.datasend.dianxin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.bootdo.datasend.dianxin.domain.DeviceInfoRecord;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description DeviceInfoRecordMapper
|
||||||
|
* @Author lijingtong
|
||||||
|
* @Date 2025-07-09
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DeviceInfoRecordMapper extends BaseMapper<DeviceInfoRecord> {
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.bootdo.datasend.dianxin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.bootdo.datasend.dianxin.domain.DeviceInfoRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description DeviceInfoRecordService
|
||||||
|
* @Author lijingtong
|
||||||
|
* @Date 2025-07-09
|
||||||
|
*/
|
||||||
|
public interface DeviceInfoRecordService extends IService<DeviceInfoRecord> {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.bootdo.datasend.dianxin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.bootdo.datasend.dianxin.domain.DeviceInfoRecord;
|
||||||
|
import com.bootdo.datasend.dianxin.mapper.DeviceInfoRecordMapper;
|
||||||
|
import com.bootdo.datasend.dianxin.service.DeviceInfoRecordService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description DeviceInfoRecordServiceImpl
|
||||||
|
* @Author lijingtong
|
||||||
|
* @Date 2025-07-09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DeviceInfoRecordServiceImpl extends ServiceImpl<DeviceInfoRecordMapper, DeviceInfoRecord> implements DeviceInfoRecordService {
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ public class StandardTask {
|
||||||
private final BaseUserRecordService userRecordService;
|
private final BaseUserRecordService userRecordService;
|
||||||
private final BaseVehicleRecordService vehicleRecordService;
|
private final BaseVehicleRecordService vehicleRecordService;
|
||||||
private final BaseDoorRecordService doorRecordService;
|
private final BaseDoorRecordService doorRecordService;
|
||||||
|
private final DeviceInfoRecordService deviceRecordService;
|
||||||
|
|
||||||
private final RestTemplate restTemplate;
|
private final RestTemplate restTemplate;
|
||||||
|
|
||||||
|
@ -472,4 +473,65 @@ public class StandardTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电表设备信息
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0/5 * * * * ? ")
|
||||||
|
public void DeviceInfoRecord() {
|
||||||
|
|
||||||
|
List<DeviceInfoRecord> lists = deviceRecordService.list(new QueryWrapper<DeviceInfoRecord>()
|
||||||
|
.eq("is_send", "0")
|
||||||
|
.last("limit 100")
|
||||||
|
);
|
||||||
|
|
||||||
|
for (DeviceInfoRecord h : lists) {
|
||||||
|
DeviceInfoDTO dto = new DeviceInfoDTO();
|
||||||
|
|
||||||
|
DeviceInfoDataDTO dataDTO = new DeviceInfoDataDTO();
|
||||||
|
dataDTO.setRequestFlag("single");
|
||||||
|
DeviceInfoDataListDTO dataListDTO = new DeviceInfoDataListDTO();
|
||||||
|
dataListDTO.setGatewaySN(h.getGatewaySN());
|
||||||
|
dataListDTO.setDeviceType(h.getDeviceType());
|
||||||
|
dataListDTO.setDeviceSN(h.getDeviceSN());
|
||||||
|
dataListDTO.setHeartbeatTime(h.getHeartbeatTime());
|
||||||
|
dataListDTO.setIsOnline(h.getIsOnline());
|
||||||
|
dataListDTO.setIsOpenAccount(h.getIsOpenAccount());
|
||||||
|
dataListDTO.setIsOweMoney(h.getIsOweMoney());
|
||||||
|
dataListDTO.setTotalMoney(h.getTotalMoney());
|
||||||
|
dataListDTO.setBuyTimes(h.getBuyTimes());
|
||||||
|
dataListDTO.setBalance(h.getBalance());
|
||||||
|
dataListDTO.setRoomNo(h.getRoomNo());
|
||||||
|
dataListDTO.setProjectName(h.getProjectName());
|
||||||
|
List<DeviceInfoDataListDTO> list = new ArrayList<>();
|
||||||
|
list.add(dataListDTO);
|
||||||
|
dataDTO.setRequestDataList(list);
|
||||||
|
dto.setRequestData(dataDTO);
|
||||||
|
String requestBody = JSON.toJSONString(dto, SerializerFeature.BrowserCompatible);
|
||||||
|
|
||||||
|
String url = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 发送 POST 请求,这里假设接口返回类型为 String ,可根据实际调整
|
||||||
|
// 消息队列发送
|
||||||
|
// rabbitTemplate.convertAndSend(queueName, JSON.toJSONString(dto));
|
||||||
|
// 调接口
|
||||||
|
String result = restTemplate.postForObject(url, requestBody, String.class);
|
||||||
|
logger.info("调用接口返回结果:{}", result);
|
||||||
|
|
||||||
|
// 若返回码符合成功逻辑(需看接口文档定义),更新发送状态
|
||||||
|
h.setIsSend(1);
|
||||||
|
deviceRecordService.saveOrUpdate(h);
|
||||||
|
logger.info("电表数据发送成功:" + h.getId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("调用接口发送数据失败,记录 ID:{},异常:{}", h.getId(), e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送设备订单信息
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue