设备充放电记录
This commit is contained in:
@ -0,0 +1,108 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 设备充放电记录对象 device_charge_discharge
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("device_charge_discharge")
|
||||
public class DeviceChargeDischarge extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 记录唯一标识
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备唯一标识
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 操作类型: 0 charge-充电, 1 discharge-放电
|
||||
*/
|
||||
private Long operationType;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 起始电量百分比(0-100)
|
||||
*/
|
||||
private Long initialSoc;
|
||||
|
||||
/**
|
||||
* 结束电量百分比(0-100)
|
||||
*/
|
||||
private Long finalSoc;
|
||||
|
||||
/**
|
||||
* 充放电量(kWh)
|
||||
*/
|
||||
private Long energyKwh;
|
||||
|
||||
/**
|
||||
* 设备额定功率(kW)
|
||||
*/
|
||||
private Long powerRating;
|
||||
|
||||
/**
|
||||
* 电压(V)
|
||||
*/
|
||||
private Long voltage;
|
||||
|
||||
/**
|
||||
* 电流(A)
|
||||
*/
|
||||
private Long current;
|
||||
|
||||
/**
|
||||
* 温度(℃)
|
||||
*/
|
||||
private Long temperature;
|
||||
|
||||
/**
|
||||
* 当前状态
|
||||
*/
|
||||
private Long status;
|
||||
|
||||
/**
|
||||
* 错误代码
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.fuyuanshen.equipment.domain.bo;
|
||||
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* 设备充放电记录业务对象 device_charge_discharge
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = DeviceChargeDischarge.class, reverseConvertGenerate = false)
|
||||
public class DeviceChargeDischargeBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 记录唯一标识
|
||||
*/
|
||||
@NotNull(message = "记录唯一标识不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备唯一标识
|
||||
*/
|
||||
@NotBlank(message = "设备唯一标识不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 操作类型: 0 charge-充电, 1 discharge-放电
|
||||
*/
|
||||
@NotNull(message = "操作类型: 0 charge-充电, 1 discharge-放电不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long operationType;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@NotNull(message = "开始时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 起始电量百分比(0-100)
|
||||
*/
|
||||
private Long initialSoc;
|
||||
|
||||
/**
|
||||
* 结束电量百分比(0-100)
|
||||
*/
|
||||
private Long finalSoc;
|
||||
|
||||
/**
|
||||
* 充放电量(kWh)
|
||||
*/
|
||||
private Long energyKwh;
|
||||
|
||||
/**
|
||||
* 设备额定功率(kW)
|
||||
*/
|
||||
private Long powerRating;
|
||||
|
||||
/**
|
||||
* 电压(V)
|
||||
*/
|
||||
private Long voltage;
|
||||
|
||||
/**
|
||||
* 电流(A)
|
||||
*/
|
||||
private Long current;
|
||||
|
||||
/**
|
||||
* 温度(℃)
|
||||
*/
|
||||
private Long temperature;
|
||||
|
||||
/**
|
||||
* 当前状态
|
||||
*/
|
||||
private Long status;
|
||||
|
||||
/**
|
||||
* 错误代码
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
|
||||
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设备充放电记录视图对象 device_charge_discharge
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-30
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = DeviceChargeDischarge.class)
|
||||
public class DeviceChargeDischargeVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 记录唯一标识
|
||||
*/
|
||||
@ExcelProperty(value = "记录唯一标识")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备唯一标识
|
||||
*/
|
||||
@ExcelProperty(value = "设备唯一标识")
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 操作类型: 0 charge-充电, 1 discharge-放电
|
||||
*/
|
||||
@ExcelProperty(value = "操作类型: 0 charge-充电, 1 discharge-放电")
|
||||
private Long operationType;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@ExcelProperty(value = "开始时间")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@ExcelProperty(value = "结束时间")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 起始电量百分比(0-100)
|
||||
*/
|
||||
@ExcelProperty(value = "起始电量百分比(0-100)")
|
||||
private Long initialSoc;
|
||||
|
||||
/**
|
||||
* 结束电量百分比(0-100)
|
||||
*/
|
||||
@ExcelProperty(value = "结束电量百分比(0-100)")
|
||||
private Long finalSoc;
|
||||
|
||||
/**
|
||||
* 充放电量(kWh)
|
||||
*/
|
||||
@ExcelProperty(value = "充放电量(kWh)")
|
||||
private Long energyKwh;
|
||||
|
||||
/**
|
||||
* 设备额定功率(kW)
|
||||
*/
|
||||
@ExcelProperty(value = "设备额定功率(kW)")
|
||||
private Long powerRating;
|
||||
|
||||
/**
|
||||
* 电压(V)
|
||||
*/
|
||||
@ExcelProperty(value = "电压(V)")
|
||||
private Long voltage;
|
||||
|
||||
/**
|
||||
* 电流(A)
|
||||
*/
|
||||
@ExcelProperty(value = "电流(A)")
|
||||
private Long current;
|
||||
|
||||
/**
|
||||
* 温度(℃)
|
||||
*/
|
||||
@ExcelProperty(value = "温度(℃)")
|
||||
private Long temperature;
|
||||
|
||||
/**
|
||||
* 当前状态
|
||||
*/
|
||||
@ExcelProperty(value = "当前状态")
|
||||
private Long status;
|
||||
|
||||
/**
|
||||
* 错误代码
|
||||
*/
|
||||
@ExcelProperty(value = "错误代码")
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ExcelProperty(value = "记录创建时间")
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
@ExcelProperty(value = "记录更新时间")
|
||||
private Date updatedAt;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.fuyuanshen.equipment.mapper;
|
||||
|
||||
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 设备充放电记录Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-30
|
||||
*/
|
||||
public interface DeviceChargeDischargeMapper extends BaseMapperPlus<DeviceChargeDischarge, DeviceChargeDischargeVo> {
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.fuyuanshen.equipment.service;
|
||||
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceChargeDischargeBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备充放电记录Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-30
|
||||
*/
|
||||
public interface IDeviceChargeDischargeService {
|
||||
|
||||
/**
|
||||
* 查询设备充放电记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 设备充放电记录
|
||||
*/
|
||||
DeviceChargeDischargeVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询设备充放电记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备充放电记录分页列表
|
||||
*/
|
||||
TableDataInfo<DeviceChargeDischargeVo> queryPageList(DeviceChargeDischargeBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备充放电记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备充放电记录列表
|
||||
*/
|
||||
List<DeviceChargeDischargeVo> queryList(DeviceChargeDischargeBo bo);
|
||||
|
||||
/**
|
||||
* 新增设备充放电记录
|
||||
*
|
||||
* @param bo 设备充放电记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(DeviceChargeDischargeBo bo);
|
||||
|
||||
/**
|
||||
* 修改设备充放电记录
|
||||
*
|
||||
* @param bo 设备充放电记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(DeviceChargeDischargeBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备充放电记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package com.fuyuanshen.equipment.service.impl;
|
||||
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceChargeDischargeBo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
|
||||
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceChargeDischargeMapper;
|
||||
import com.fuyuanshen.equipment.service.IDeviceChargeDischargeService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备充放电记录Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-30
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class DeviceChargeDischargeServiceImpl implements IDeviceChargeDischargeService {
|
||||
|
||||
private final DeviceChargeDischargeMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询设备充放电记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 设备充放电记录
|
||||
*/
|
||||
@Override
|
||||
public DeviceChargeDischargeVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备充放电记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备充放电记录分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<DeviceChargeDischargeVo> queryPageList(DeviceChargeDischargeBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<DeviceChargeDischarge> lqw = buildQueryWrapper(bo);
|
||||
Page<DeviceChargeDischargeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备充放电记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备充放电记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceChargeDischargeVo> queryList(DeviceChargeDischargeBo bo) {
|
||||
LambdaQueryWrapper<DeviceChargeDischarge> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<DeviceChargeDischarge> buildQueryWrapper(DeviceChargeDischargeBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<DeviceChargeDischarge> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(DeviceChargeDischarge::getId);
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDeviceId()), DeviceChargeDischarge::getDeviceId, bo.getDeviceId());
|
||||
lqw.eq(bo.getOperationType() != null, DeviceChargeDischarge::getOperationType, bo.getOperationType());
|
||||
lqw.eq(bo.getStartTime() != null, DeviceChargeDischarge::getStartTime, bo.getStartTime());
|
||||
lqw.eq(bo.getEndTime() != null, DeviceChargeDischarge::getEndTime, bo.getEndTime());
|
||||
lqw.eq(bo.getInitialSoc() != null, DeviceChargeDischarge::getInitialSoc, bo.getInitialSoc());
|
||||
lqw.eq(bo.getFinalSoc() != null, DeviceChargeDischarge::getFinalSoc, bo.getFinalSoc());
|
||||
lqw.eq(bo.getEnergyKwh() != null, DeviceChargeDischarge::getEnergyKwh, bo.getEnergyKwh());
|
||||
lqw.eq(bo.getPowerRating() != null, DeviceChargeDischarge::getPowerRating, bo.getPowerRating());
|
||||
lqw.eq(bo.getVoltage() != null, DeviceChargeDischarge::getVoltage, bo.getVoltage());
|
||||
lqw.eq(bo.getCurrent() != null, DeviceChargeDischarge::getCurrent, bo.getCurrent());
|
||||
lqw.eq(bo.getTemperature() != null, DeviceChargeDischarge::getTemperature, bo.getTemperature());
|
||||
lqw.eq(bo.getStatus() != null, DeviceChargeDischarge::getStatus, bo.getStatus());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getErrorCode()), DeviceChargeDischarge::getErrorCode, bo.getErrorCode());
|
||||
lqw.eq(bo.getCreatedAt() != null, DeviceChargeDischarge::getCreatedAt, bo.getCreatedAt());
|
||||
lqw.eq(bo.getUpdatedAt() != null, DeviceChargeDischarge::getUpdatedAt, bo.getUpdatedAt());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备充放电记录
|
||||
*
|
||||
* @param bo 设备充放电记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(DeviceChargeDischargeBo bo) {
|
||||
DeviceChargeDischarge add = MapstructUtils.convert(bo, DeviceChargeDischarge.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备充放电记录
|
||||
*
|
||||
* @param bo 设备充放电记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(DeviceChargeDischargeBo bo) {
|
||||
DeviceChargeDischarge update = MapstructUtils.convert(bo, DeviceChargeDischarge.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(DeviceChargeDischarge entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备充放电记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceChargeDischargeMapper">
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user