电表设备用电信息
This commit is contained in:
parent
404a882829
commit
03117cc185
|
@ -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_power_info")
|
||||
public class DevicePowerInfo {
|
||||
private String useDate;
|
||||
private String deviceSN;
|
||||
private String userName;
|
||||
private String roomNo;
|
||||
private BigDecimal powerUse;
|
||||
private BigDecimal powerStart;
|
||||
private BigDecimal powerEnd;
|
||||
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 DevicePowerInfoDTO
|
||||
* @Author lijingtong
|
||||
* @Date 2025-07-09
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DevicePowerInfoDTO {
|
||||
|
||||
@JSONField(name = "requestData")
|
||||
private DevicePowerInfoDataDTO 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 DevicePowerInfoDataDTO
|
||||
* @Author lijingtong
|
||||
* @Date 2025-07-09
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DevicePowerInfoDataDTO {
|
||||
@JSONField(name = "requestFlag")
|
||||
private String requestFlag;
|
||||
@JSONField(name = "requestDataList")
|
||||
private List<DevicePowerInfoDataListDTO> requestDataList;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.bootdo.datasend.dianxin.domain.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Description DevicePowerInfoDataListDTO
|
||||
* @Author lijingtong
|
||||
* @Date 2025-07-09
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DevicePowerInfoDataListDTO {
|
||||
|
||||
// 使用日期
|
||||
@JSONField(name = "useDate")
|
||||
private String useDate;
|
||||
// 设备(国标)编码
|
||||
@JSONField(name = "deviceSN")
|
||||
private String deviceSN;
|
||||
// 用户名
|
||||
@JSONField(name = "userName")
|
||||
private String userName;
|
||||
// 房间号
|
||||
@JSONField(name = "roomNo")
|
||||
private String roomNo;
|
||||
// 用电量
|
||||
@JSONField(name = "powerUse")
|
||||
private BigDecimal powerUse;
|
||||
// 用电开始量
|
||||
@JSONField(name = "powerStart")
|
||||
private BigDecimal powerStart;
|
||||
// 用电结束量
|
||||
@JSONField(name = "powerEnd")
|
||||
private BigDecimal powerEnd;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.bootdo.datasend.dianxin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bootdo.datasend.dianxin.domain.DevicePowerInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Description DevicePowerInfoMapper
|
||||
* @Author lijingtong
|
||||
* @Date 2025-07-09
|
||||
*/
|
||||
@Mapper
|
||||
public interface DevicePowerInfoMapper extends BaseMapper<DevicePowerInfo> {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.bootdo.datasend.dianxin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bootdo.datasend.dianxin.domain.DevicePowerInfo;
|
||||
|
||||
/**
|
||||
* @Description DevicePowerInfoService
|
||||
* @Author lijingtong
|
||||
* @Date 2025-07-09
|
||||
*/
|
||||
public interface DevicePowerInfoService extends IService<DevicePowerInfo> {
|
||||
}
|
|
@ -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.DevicePowerInfo;
|
||||
import com.bootdo.datasend.dianxin.mapper.DevicePowerInfoMapper;
|
||||
import com.bootdo.datasend.dianxin.service.DevicePowerInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description DevicePowerInfoServiceImpl
|
||||
* @Author lijingtong
|
||||
* @Date 2025-07-09
|
||||
*/
|
||||
@Service
|
||||
public class DevicePowerInfoServiceImpl extends ServiceImpl<DevicePowerInfoMapper, DevicePowerInfo> implements DevicePowerInfoService {
|
||||
}
|
|
@ -35,6 +35,8 @@ public class StandardTask {
|
|||
private final DeviceInfoRecordService deviceRecordService;
|
||||
private final DeviceOrderInfoService deviceOrderInfoService;
|
||||
|
||||
private final DevicePowerInfoService devicePowerInfoService;
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
/**
|
||||
|
@ -580,4 +582,58 @@ public class StandardTask {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 推送电表设备用电信息
|
||||
*/
|
||||
@Scheduled(cron = "0/5 * * * * ? ")
|
||||
public void DevicePowerInfoRecord() {
|
||||
|
||||
List<DevicePowerInfo> lists = devicePowerInfoService.list(new QueryWrapper<DevicePowerInfo>()
|
||||
.eq("is_send", "0")
|
||||
.last("limit 100")
|
||||
);
|
||||
|
||||
for (DevicePowerInfo h : lists) {
|
||||
DevicePowerInfoDTO dto = new DevicePowerInfoDTO();
|
||||
DevicePowerInfoDataDTO dataDTO = new DevicePowerInfoDataDTO();
|
||||
dataDTO.setRequestFlag("single");
|
||||
DevicePowerInfoDataListDTO dataListDTO = new DevicePowerInfoDataListDTO();
|
||||
dataListDTO.setDeviceSN(h.getDeviceSN());
|
||||
|
||||
dataListDTO.setPowerEnd(h.getPowerEnd());
|
||||
dataListDTO.setPowerStart(h.getPowerStart());
|
||||
dataListDTO.setPowerUse(h.getPowerUse());
|
||||
dataListDTO.setRoomNo(h.getRoomNo());
|
||||
dataListDTO.setUseDate(h.getUseDate());
|
||||
dataListDTO.setUserName(h.getUserName());
|
||||
List<DevicePowerInfoDataListDTO> 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);
|
||||
devicePowerInfoService.saveOrUpdate(h);
|
||||
logger.info("电表设备用电信息发送成功:" + h.getId());
|
||||
} catch (Exception e) {
|
||||
logger.error("调用接口发送数据失败,记录 ID:{},异常:{}", h.getId(), e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue