feat(property): 添加仪表抄记功能
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
parent
adafd52d0f
commit
b4228c0425
@ -0,0 +1,106 @@
|
||||
package org.dromara.property.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.property.domain.vo.TbMeterRecordVo;
|
||||
import org.dromara.property.domain.bo.TbMeterRecordBo;
|
||||
import org.dromara.property.service.ITbMeterRecordService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 抄记录
|
||||
* 前端访问路由地址为:/property/meterRecord
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/meterRecord")
|
||||
public class TbMeterRecordController extends BaseController {
|
||||
|
||||
private final ITbMeterRecordService tbMeterRecordService;
|
||||
|
||||
/**
|
||||
* 查询抄记录列表
|
||||
*/
|
||||
@SaCheckPermission("property:meterRecord:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<TbMeterRecordVo> list(TbMeterRecordBo bo, PageQuery pageQuery) {
|
||||
return tbMeterRecordService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出抄记录列表
|
||||
*/
|
||||
@SaCheckPermission("property:meterRecord:export")
|
||||
@Log(title = "抄记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(TbMeterRecordBo bo, HttpServletResponse response) {
|
||||
List<TbMeterRecordVo> list = tbMeterRecordService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "抄记录", TbMeterRecordVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取抄记录详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("property:meterRecord:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<TbMeterRecordVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
return R.ok(tbMeterRecordService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增抄记录
|
||||
*/
|
||||
@SaCheckPermission("property:meterRecord:add")
|
||||
@Log(title = "抄记录", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody TbMeterRecordBo bo) {
|
||||
return toAjax(tbMeterRecordService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改抄记录
|
||||
*/
|
||||
@SaCheckPermission("property:meterRecord:edit")
|
||||
@Log(title = "抄记录", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TbMeterRecordBo bo) {
|
||||
return toAjax(tbMeterRecordService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除抄记录
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("property:meterRecord:remove")
|
||||
@Log(title = "抄记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable("ids") Long[] ids) {
|
||||
return toAjax(tbMeterRecordService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package org.dromara.property.domain;
|
||||
|
||||
import org.dromara.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;
|
||||
|
||||
/**
|
||||
* 抄记录对象 tb_meter_record
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("tb_meter_record")
|
||||
public class TbMeterRecord extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 仪表编号
|
||||
*/
|
||||
private String meterId;
|
||||
|
||||
/**
|
||||
* 抄表员ID
|
||||
*/
|
||||
private Long readerId;
|
||||
|
||||
/**
|
||||
* 抄表时间
|
||||
*/
|
||||
private Date readingTime;
|
||||
|
||||
/**
|
||||
* 当前读数
|
||||
*/
|
||||
private Long currentReading;
|
||||
|
||||
/**
|
||||
* 上次读数
|
||||
*/
|
||||
private Long previousReading;
|
||||
|
||||
/**
|
||||
* 用量
|
||||
*/
|
||||
private Long consumption;
|
||||
|
||||
/**
|
||||
* 抄表方式(1手动 2自动 3用户上报)
|
||||
*/
|
||||
private Long readingMethod;
|
||||
|
||||
/**
|
||||
* 抄表照片
|
||||
*/
|
||||
private Long imgOssid;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package org.dromara.property.domain.bo;
|
||||
|
||||
import org.dromara.property.domain.TbMeterRecord;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 抄记录业务对象 tb_meter_record
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = TbMeterRecord.class, reverseConvertGenerate = false)
|
||||
public class TbMeterRecordBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
@NotNull(message = "记录ID不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 仪表编号
|
||||
*/
|
||||
@NotBlank(message = "仪表编号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String meterId;
|
||||
|
||||
/**
|
||||
* 抄表员ID
|
||||
*/
|
||||
@NotNull(message = "抄表员ID不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long readerId;
|
||||
|
||||
/**
|
||||
* 抄表时间
|
||||
*/
|
||||
@NotNull(message = "抄表时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Date readingTime;
|
||||
|
||||
/**
|
||||
* 当前读数
|
||||
*/
|
||||
@NotNull(message = "当前读数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long currentReading;
|
||||
|
||||
/**
|
||||
* 上次读数
|
||||
*/
|
||||
@NotNull(message = "上次读数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long previousReading;
|
||||
|
||||
/**
|
||||
* 用量
|
||||
*/
|
||||
private Long consumption;
|
||||
|
||||
/**
|
||||
* 抄表方式(1手动 2自动 3用户上报)
|
||||
*/
|
||||
@NotNull(message = "抄表方式(1手动 2自动 3用户上报)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long readingMethod;
|
||||
|
||||
/**
|
||||
* 抄表照片
|
||||
*/
|
||||
private Long imgOssid;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package org.dromara.property.domain.vo;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.dromara.property.domain.TbMeterRecord;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 抄记录视图对象 tb_meter_record
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = TbMeterRecord.class)
|
||||
public class TbMeterRecordVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
@ExcelProperty(value = "记录ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 仪表编号
|
||||
*/
|
||||
@ExcelProperty(value = "仪表编号")
|
||||
private String meterId;
|
||||
|
||||
/**
|
||||
* 抄表员ID
|
||||
*/
|
||||
@ExcelProperty(value = "抄表员ID")
|
||||
private Long readerId;
|
||||
|
||||
/**
|
||||
* 抄表时间
|
||||
*/
|
||||
@ExcelProperty(value = "抄表时间")
|
||||
private Date readingTime;
|
||||
|
||||
/**
|
||||
* 当前读数
|
||||
*/
|
||||
@ExcelProperty(value = "当前读数")
|
||||
private Long currentReading;
|
||||
|
||||
/**
|
||||
* 上次读数
|
||||
*/
|
||||
@ExcelProperty(value = "上次读数")
|
||||
private Long previousReading;
|
||||
|
||||
/**
|
||||
* 用量
|
||||
*/
|
||||
@ExcelProperty(value = "用量")
|
||||
private Long consumption;
|
||||
|
||||
/**
|
||||
* 抄表方式(1手动 2自动 3用户上报)
|
||||
*/
|
||||
@ExcelProperty(value = "抄表方式(1手动 2自动 3用户上报)")
|
||||
private Long readingMethod;
|
||||
|
||||
/**
|
||||
* 抄表照片
|
||||
*/
|
||||
@ExcelProperty(value = "抄表照片")
|
||||
private Long imgOssid;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.property.mapper;
|
||||
|
||||
import org.dromara.property.domain.TbMeterRecord;
|
||||
import org.dromara.property.domain.vo.TbMeterRecordVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 抄记录Mapper接口
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
public interface TbMeterRecordMapper extends BaseMapperPlus<TbMeterRecord, TbMeterRecordVo> {
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package org.dromara.property.service;
|
||||
|
||||
import org.dromara.property.domain.TbMeterRecord;
|
||||
import org.dromara.property.domain.vo.TbMeterRecordVo;
|
||||
import org.dromara.property.domain.bo.TbMeterRecordBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 抄记录Service接口
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
public interface ITbMeterRecordService {
|
||||
|
||||
/**
|
||||
* 查询抄记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 抄记录
|
||||
*/
|
||||
TbMeterRecordVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询抄记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 抄记录分页列表
|
||||
*/
|
||||
TableDataInfo<TbMeterRecordVo> queryPageList(TbMeterRecordBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的抄记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 抄记录列表
|
||||
*/
|
||||
List<TbMeterRecordVo> queryList(TbMeterRecordBo bo);
|
||||
|
||||
/**
|
||||
* 新增抄记录
|
||||
*
|
||||
* @param bo 抄记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(TbMeterRecordBo bo);
|
||||
|
||||
/**
|
||||
* 修改抄记录
|
||||
*
|
||||
* @param bo 抄记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(TbMeterRecordBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除抄记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.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.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.TbMeterRecordBo;
|
||||
import org.dromara.property.domain.vo.TbMeterRecordVo;
|
||||
import org.dromara.property.domain.TbMeterRecord;
|
||||
import org.dromara.property.mapper.TbMeterRecordMapper;
|
||||
import org.dromara.property.service.ITbMeterRecordService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 抄记录Service业务层处理
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
|
||||
private final TbMeterRecordMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询抄记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 抄记录
|
||||
*/
|
||||
@Override
|
||||
public TbMeterRecordVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询抄记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 抄记录分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<TbMeterRecordVo> queryPageList(TbMeterRecordBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<TbMeterRecord> lqw = buildQueryWrapper(bo);
|
||||
Page<TbMeterRecordVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的抄记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 抄记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<TbMeterRecordVo> queryList(TbMeterRecordBo bo) {
|
||||
LambdaQueryWrapper<TbMeterRecord> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<TbMeterRecord> buildQueryWrapper(TbMeterRecordBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<TbMeterRecord> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(TbMeterRecord::getId);
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMeterId()), TbMeterRecord::getMeterId, bo.getMeterId());
|
||||
lqw.eq(bo.getReaderId() != null, TbMeterRecord::getReaderId, bo.getReaderId());
|
||||
lqw.eq(bo.getReadingTime() != null, TbMeterRecord::getReadingTime, bo.getReadingTime());
|
||||
lqw.eq(bo.getCurrentReading() != null, TbMeterRecord::getCurrentReading, bo.getCurrentReading());
|
||||
lqw.eq(bo.getPreviousReading() != null, TbMeterRecord::getPreviousReading, bo.getPreviousReading());
|
||||
lqw.eq(bo.getConsumption() != null, TbMeterRecord::getConsumption, bo.getConsumption());
|
||||
lqw.eq(bo.getReadingMethod() != null, TbMeterRecord::getReadingMethod, bo.getReadingMethod());
|
||||
lqw.eq(bo.getImgOssid() != null, TbMeterRecord::getImgOssid, bo.getImgOssid());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增抄记录
|
||||
*
|
||||
* @param bo 抄记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(TbMeterRecordBo bo) {
|
||||
TbMeterRecord add = MapstructUtils.convert(bo, TbMeterRecord.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改抄记录
|
||||
*
|
||||
* @param bo 抄记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(TbMeterRecordBo bo) {
|
||||
TbMeterRecord update = MapstructUtils.convert(bo, TbMeterRecord.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(TbMeterRecord entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除抄记录信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user