Merge branch 'dyf-device' into 6170

This commit is contained in:
2025-08-30 09:40:51 +08:00
16 changed files with 800 additions and 35 deletions

View File

@ -153,6 +153,7 @@ public class Device extends TenantEntity {
*/
@Schema(title = "出厂日期")
private Date productionDate;
/**
* 在线状态(0离线1在线)
*/

View File

@ -88,7 +88,7 @@ public class DeviceAlarm extends TenantEntity {
/**
* 报警持续时间
*/
private Date durationTime;
private Long durationTime;
/**
* 0已处理1未处理

View File

@ -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;
}

View File

@ -24,7 +24,7 @@ public class DeviceAlarmBo extends BaseEntity {
/**
* ID
*/
@NotNull(message = "ID不能为空", groups = { EditGroup.class })
@NotNull(message = "ID不能为空", groups = {EditGroup.class})
private Long id;
/**
@ -34,14 +34,27 @@ public class DeviceAlarmBo extends BaseEntity {
/**
* 报警事项
* device_action
*/
private String deviceAction;
private Integer deviceAction;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备MAC
* device_mac
*/
private String deviceMac;
/**
* 设备IMEI
* device_imei
*/
private String deviceImei;
/**
* 数据来源
*/
@ -54,12 +67,12 @@ public class DeviceAlarmBo extends BaseEntity {
/**
* 设备类型
* device_type
*/
private Long deviceType;
/**
* 经度
*/
private Long longitude;
@ -86,12 +99,18 @@ public class DeviceAlarmBo extends BaseEntity {
/**
* 报警持续时间
*/
private Date durationTime;
private Long durationTime;
/**
* 报警查询时间
*/
private String queryTime1;
private String queryTime2;
/**
* 0已处理1未处理
*/
private Long treatmentState;
private Integer treatmentState;
}

View File

@ -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;
}

View File

@ -44,9 +44,10 @@ public class DeviceAlarmVo implements Serializable {
/**
* 报警事项
* 0-强制报警1-撞击闯入2-手动报警3-电子围栏告警4-强制告警
*/
@ExcelProperty(value = "报警事项")
private String deviceAction;
private Integer deviceAction;
/**
* 设备名称
@ -54,6 +55,16 @@ public class DeviceAlarmVo implements Serializable {
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 设备MAC
*/
private String deviceMac;
/**
* 设备IMEI
*/
private String deviceImei;
/**
* 数据来源
*/
@ -71,6 +82,7 @@ public class DeviceAlarmVo implements Serializable {
*/
@ExcelProperty(value = "设备类型")
private Long deviceType;
private String deviceTypeName;
/**
* 经度
@ -106,13 +118,13 @@ public class DeviceAlarmVo implements Serializable {
* 报警持续时间
*/
@ExcelProperty(value = "报警持续时间")
private Date durationTime;
private Long durationTime;
/**
* 0已处理1未处理
*/
@ExcelProperty(value = "0已处理1未处理")
private Long treatmentState;
private Integer treatmentState;
}

View File

@ -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;
}

View File

@ -1,8 +1,12 @@
package com.fuyuanshen.equipment.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
/**
* 设备告警Mapper接口
@ -12,4 +16,13 @@ import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
*/
public interface DeviceAlarmMapper extends BaseMapperPlus<DeviceAlarm, DeviceAlarmVo> {
/**
* 查询设备告警列表
*
* @param bo 设备告警
* @return 设备告警
*/
Page<DeviceAlarmVo> selectVoPage( Page pageQuery,@Param("bo") DeviceAlarmBo bo);
}

View File

@ -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> {
}

View File

@ -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);
}

View File

@ -33,6 +33,7 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
private final DeviceAlarmMapper baseMapper;
/**
* 查询设备告警
*
@ -40,10 +41,11 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
* @return 设备告警
*/
@Override
public DeviceAlarmVo queryById(Long id){
public DeviceAlarmVo queryById(Long id) {
return baseMapper.selectVoById(id);
}
/**
* 分页查询设备告警列表
*
@ -53,11 +55,13 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
*/
@Override
public TableDataInfo<DeviceAlarmVo> queryPageList(DeviceAlarmBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<DeviceAlarm> lqw = buildQueryWrapper(bo);
Page<DeviceAlarmVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
// LambdaQueryWrapper<DeviceAlarm> lqw = buildQueryWrapper(bo);
// Page<DeviceAlarmVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
Page<DeviceAlarmVo> result = baseMapper.selectVoPage(pageQuery.build(), bo);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的设备告警列表
*
@ -75,7 +79,7 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
LambdaQueryWrapper<DeviceAlarm> lqw = Wrappers.lambdaQuery();
lqw.orderByAsc(DeviceAlarm::getId);
lqw.eq(bo.getDeviceId() != null, DeviceAlarm::getDeviceId, bo.getDeviceId());
lqw.eq(StringUtils.isNotBlank(bo.getDeviceAction()), DeviceAlarm::getDeviceAction, bo.getDeviceAction());
// lqw.eq(StringUtils.isNotBlank(bo.getDeviceAction()), DeviceAlarm::getDeviceAction, bo.getDeviceAction());
lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), DeviceAlarm::getDeviceName, bo.getDeviceName());
lqw.eq(StringUtils.isNotBlank(bo.getDataSource()), DeviceAlarm::getDataSource, bo.getDataSource());
lqw.eq(StringUtils.isNotBlank(bo.getContent()), DeviceAlarm::getContent, bo.getContent());
@ -123,8 +127,8 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(DeviceAlarm entity){
//TODO 做一些数据校验,如唯一约束
private void validEntityBeforeSave(DeviceAlarm entity) {
// TODO 做一些数据校验,如唯一约束
}
/**
@ -136,8 +140,8 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
if (isValid) {
// TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}

View File

@ -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;
}
}

View File

@ -1,7 +1,33 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceAlarmMapper">
<!-- 查询设备告警列表 -->
<select id="selectVoPage" resultType="com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo">
select *, d.device_mac as deviceMac, d.device_imei as deviceImei,
d.type_name as deviceTypeName
from device_alarm da
left join device d on da.device_id = d.id
left join device_type dt on dt.id = da.device_type
<where>
<if test="bo.deviceName != null">
and da.device_name = #{bo.deviceName}
</if>
<if test="bo.deviceType != null">
and da.device_type = #{bo.deviceType}
</if>
<if test="bo.deviceAction != null">
and da.device_action = #{bo.deviceAction}
</if>
<if test="bo.treatmentState != null">
and da.treatment_state = #{bo.treatmentState}
</if>
<if test="bo.queryTime1 != null and bo.queryTime2 != null ">
and da.start_time between #{bo.queryTime1} and #{bo.queryTime2}
</if>
</where>
</select>
</mapper>

View File

@ -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>