feat(energy): 添加 simple-list/summary/detail-list/adjustment-list 接口
新增5个端点跨3个Controller:站点配置simple-list、账户simple-list和summary汇总统计、账单detail-list和adjustment/list调整记录列表。新增3个VO类及对应Service方法、Convert映射方法。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -92,6 +92,20 @@ public class EnergyAccountController {
|
||||
return success(cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList(list, EnergyAccountConvert.INSTANCE::convert));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得账户简单列表")
|
||||
public CommonResult<List<EnergyAccountSimpleVO>> getSimpleList() {
|
||||
List<EnergyAccountDO> list = accountService.getAccountList();
|
||||
return success(EnergyAccountConvert.INSTANCE.convertSimpleList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/summary")
|
||||
@Operation(summary = "获得账户汇总统计")
|
||||
@PreAuthorize("@ss.hasPermission('energy:account:query')")
|
||||
public CommonResult<EnergyAccountSummaryVO> getAccountSummary() {
|
||||
return success(accountService.getAccountSummary());
|
||||
}
|
||||
|
||||
// ===== 流水查询 =====
|
||||
|
||||
@GetMapping("/flow/page")
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.energy.controller.admin.account.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 能源账户简单 Response VO")
|
||||
@Data
|
||||
public class EnergyAccountSimpleVO {
|
||||
@Schema(description = "账户ID")
|
||||
private Long id;
|
||||
@Schema(description = "客户ID")
|
||||
private Long customerId;
|
||||
@Schema(description = "客户名称")
|
||||
private String customerName;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.energy.controller.admin.account.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 能源账户汇总 Response VO")
|
||||
@Data
|
||||
public class EnergyAccountSummaryVO {
|
||||
@Schema(description = "账户总数")
|
||||
private Integer totalCount;
|
||||
@Schema(description = "总余额")
|
||||
private BigDecimal totalBalance;
|
||||
@Schema(description = "累计充值")
|
||||
private BigDecimal totalRecharge;
|
||||
@Schema(description = "预警账户数")
|
||||
private Integer warningCount;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.bill.vo.*;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.detail.vo.HydrogenDetailRespVO;
|
||||
import cn.iocoder.yudao.module.energy.convert.bill.EnergyBillConvert;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.bill.EnergyBillDO;
|
||||
import cn.iocoder.yudao.module.energy.service.bill.EnergyBillService;
|
||||
@@ -115,4 +116,20 @@ public class EnergyBillController {
|
||||
billService.deleteAdjustment(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/detail-list")
|
||||
@Operation(summary = "获得账单关联明细列表")
|
||||
@Parameter(name = "billId", description = "账单ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('energy:bill:query')")
|
||||
public CommonResult<List<HydrogenDetailRespVO>> getBillDetailList(@RequestParam("billId") Long billId) {
|
||||
return success(billService.getBillDetailList(billId));
|
||||
}
|
||||
|
||||
@GetMapping("/adjustment/list")
|
||||
@Operation(summary = "获得账单调整记录列表")
|
||||
@Parameter(name = "billId", description = "账单ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('energy:bill:query')")
|
||||
public CommonResult<List<EnergyBillAdjustmentRespVO>> getAdjustmentList(@RequestParam("billId") Long billId) {
|
||||
return success(billService.getAdjustmentList(billId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.energy.controller.admin.bill.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 账单调整记录 Response VO")
|
||||
@Data
|
||||
public class EnergyBillAdjustmentRespVO {
|
||||
@Schema(description = "调整ID")
|
||||
private Long id;
|
||||
@Schema(description = "账单ID")
|
||||
private Long billId;
|
||||
@Schema(description = "关联明细ID")
|
||||
private Long detailId;
|
||||
@Schema(description = "调整类型")
|
||||
private Integer adjustmentType;
|
||||
@Schema(description = "调整金额")
|
||||
private BigDecimal amount;
|
||||
@Schema(description = "调整原因")
|
||||
private String reason;
|
||||
@Schema(description = "附件")
|
||||
private String attachmentUrls;
|
||||
@Schema(description = "操作人ID")
|
||||
private Long operatorId;
|
||||
@Schema(description = "操作人名称")
|
||||
private String operatorName;
|
||||
@Schema(description = "操作时间")
|
||||
private LocalDateTime operateTime;
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigRespVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigSimpleVO;
|
||||
import cn.iocoder.yudao.module.energy.convert.config.EnergyStationConfigConvert;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.config.EnergyStationConfigDO;
|
||||
import cn.iocoder.yudao.module.energy.service.config.EnergyStationConfigService;
|
||||
@@ -17,6 +18,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 加氢站配置")
|
||||
@@ -59,4 +62,11 @@ public class EnergyStationConfigController {
|
||||
PageResult<EnergyStationConfigDO> pageResult = stationConfigService.getConfigPage(pageReqVO);
|
||||
return success(EnergyStationConfigConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得站点配置简单列表")
|
||||
public CommonResult<List<EnergyStationConfigSimpleVO>> getSimpleList() {
|
||||
List<EnergyStationConfigDO> list = stationConfigService.getConfigList();
|
||||
return success(EnergyStationConfigConvert.INSTANCE.convertSimpleList(list));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.energy.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 加氢站配置简单 Response VO")
|
||||
@Data
|
||||
public class EnergyStationConfigSimpleVO {
|
||||
@Schema(description = "配置ID")
|
||||
private Long id;
|
||||
@Schema(description = "站点ID")
|
||||
private Long stationId;
|
||||
@Schema(description = "站点名称")
|
||||
private String stationName;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.energy.convert.account;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountExcelVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountRespVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountSimpleVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyProjectAccountRespVO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.account.EnergyAccountDO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.account.EnergyProjectAccountDO;
|
||||
@@ -19,4 +20,5 @@ public interface EnergyAccountConvert {
|
||||
EnergyProjectAccountRespVO convert(EnergyProjectAccountDO bean);
|
||||
PageResult<EnergyProjectAccountRespVO> convertProjectPage(PageResult<EnergyProjectAccountDO> page);
|
||||
List<EnergyAccountExcelVO> convertExcelList(List<EnergyAccountDO> list);
|
||||
List<EnergyAccountSimpleVO> convertSimpleList(List<EnergyAccountDO> list);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package cn.iocoder.yudao.module.energy.convert.bill;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.bill.vo.EnergyBillAdjustmentRespVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.bill.vo.EnergyBillExcelVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.bill.vo.EnergyBillRespVO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.bill.EnergyBillAdjustmentDO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.bill.EnergyBillDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -15,4 +17,5 @@ public interface EnergyBillConvert {
|
||||
EnergyBillRespVO convert(EnergyBillDO bean);
|
||||
PageResult<EnergyBillRespVO> convertPage(PageResult<EnergyBillDO> page);
|
||||
List<EnergyBillExcelVO> convertExcelList(List<EnergyBillDO> list);
|
||||
List<EnergyBillAdjustmentRespVO> convertAdjustmentList(List<EnergyBillAdjustmentDO> list);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,18 @@ package cn.iocoder.yudao.module.energy.convert.config;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigRespVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigSimpleVO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.config.EnergyStationConfigDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface EnergyStationConfigConvert {
|
||||
EnergyStationConfigConvert INSTANCE = Mappers.getMapper(EnergyStationConfigConvert.class);
|
||||
EnergyStationConfigDO convert(EnergyStationConfigSaveReqVO bean);
|
||||
EnergyStationConfigRespVO convert(EnergyStationConfigDO bean);
|
||||
PageResult<EnergyStationConfigRespVO> convertPage(PageResult<EnergyStationConfigDO> page);
|
||||
List<EnergyStationConfigSimpleVO> convertSimpleList(List<EnergyStationConfigDO> list);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
public interface HydrogenDetailConvert {
|
||||
HydrogenDetailConvert INSTANCE = Mappers.getMapper(HydrogenDetailConvert.class);
|
||||
HydrogenDetailRespVO convert(EnergyHydrogenDetailDO bean);
|
||||
List<HydrogenDetailRespVO> convertList(List<EnergyHydrogenDetailDO> list);
|
||||
PageResult<HydrogenDetailRespVO> convertPage(PageResult<EnergyHydrogenDetailDO> page);
|
||||
List<HydrogenDetailExcelVO> convertExcelList(List<EnergyHydrogenDetailDO> list);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.energy.service.account;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountFlowPageReqVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountPageReqVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountSummaryVO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.account.EnergyAccountDO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.account.EnergyAccountFlowDO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.account.EnergyProjectAccountDO;
|
||||
@@ -19,4 +20,6 @@ public interface EnergyAccountService {
|
||||
void recharge(Long customerId, BigDecimal amount, Long bizId, String bizCode, String remark);
|
||||
void updateThreshold(Long id, BigDecimal threshold);
|
||||
PageResult<EnergyAccountFlowDO> getFlowPage(EnergyAccountFlowPageReqVO reqVO);
|
||||
List<EnergyAccountDO> getAccountList();
|
||||
EnergyAccountSummaryVO getAccountSummary();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.energy.service.account;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountFlowPageReqVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountPageReqVO;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.account.vo.EnergyAccountSummaryVO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.account.EnergyAccountDO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.account.EnergyAccountFlowDO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.account.EnergyProjectAccountDO;
|
||||
@@ -211,6 +212,29 @@ public class EnergyAccountServiceImpl implements EnergyAccountService {
|
||||
return accountFlowMapper.selectPage(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnergyAccountDO> getAccountList() {
|
||||
return accountMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyAccountSummaryVO getAccountSummary() {
|
||||
List<EnergyAccountDO> accounts = accountMapper.selectList();
|
||||
EnergyAccountSummaryVO vo = new EnergyAccountSummaryVO();
|
||||
vo.setTotalCount(accounts.size());
|
||||
vo.setTotalBalance(accounts.stream()
|
||||
.map(EnergyAccountDO::getBalance)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setTotalRecharge(accounts.stream()
|
||||
.map(EnergyAccountDO::getAccumulatedRecharge)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setWarningCount((int) accounts.stream()
|
||||
.filter(a -> a.getReminderThreshold() != null
|
||||
&& a.getBalance().compareTo(a.getReminderThreshold()) <= 0)
|
||||
.count());
|
||||
return vo;
|
||||
}
|
||||
|
||||
// ===== Private helpers =====
|
||||
|
||||
private boolean updateAccountWithRetry(EnergyAccountDO account, BigDecimal balanceAfter, BigDecimal amount, boolean isDeduction) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.energy.service.bill;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.bill.vo.*;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.detail.vo.HydrogenDetailRespVO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.bill.EnergyBillDO;
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,4 +16,6 @@ public interface EnergyBillService {
|
||||
void auditBill(Long id, Boolean approved, String remark);
|
||||
Long createAdjustment(EnergyBillAdjustmentSaveReqVO reqVO);
|
||||
void deleteAdjustment(Long adjustmentId);
|
||||
List<HydrogenDetailRespVO> getBillDetailList(Long billId);
|
||||
List<EnergyBillAdjustmentRespVO> getAdjustmentList(Long billId);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package cn.iocoder.yudao.module.energy.service.bill;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.bill.vo.*;
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.detail.vo.HydrogenDetailRespVO;
|
||||
import cn.iocoder.yudao.module.energy.convert.bill.EnergyBillConvert;
|
||||
import cn.iocoder.yudao.module.energy.convert.detail.HydrogenDetailConvert;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.bill.EnergyBillAdjustmentDO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.bill.EnergyBillDO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.detail.EnergyHydrogenDetailDO;
|
||||
@@ -200,6 +203,18 @@ public class EnergyBillServiceImpl implements EnergyBillService {
|
||||
adjustmentMapper.deleteById(adjustmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HydrogenDetailRespVO> getBillDetailList(Long billId) {
|
||||
List<EnergyHydrogenDetailDO> details = detailMapper.selectListByBillId(billId);
|
||||
return HydrogenDetailConvert.INSTANCE.convertList(details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnergyBillAdjustmentRespVO> getAdjustmentList(Long billId) {
|
||||
List<EnergyBillAdjustmentDO> adjustments = adjustmentMapper.selectListByBillId(billId);
|
||||
return EnergyBillConvert.INSTANCE.convertAdjustmentList(adjustments);
|
||||
}
|
||||
|
||||
private EnergyBillDO validateBillExists(Long id) {
|
||||
EnergyBillDO bill = billMapper.selectById(id);
|
||||
if (bill == null) {
|
||||
|
||||
@@ -5,10 +5,13 @@ import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationCo
|
||||
import cn.iocoder.yudao.module.energy.controller.admin.config.vo.EnergyStationConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.energy.dal.dataobject.config.EnergyStationConfigDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EnergyStationConfigService {
|
||||
Long createConfig(EnergyStationConfigSaveReqVO createReqVO);
|
||||
void updateConfig(EnergyStationConfigSaveReqVO updateReqVO);
|
||||
EnergyStationConfigDO getConfig(Long id);
|
||||
PageResult<EnergyStationConfigDO> getConfigPage(EnergyStationConfigPageReqVO pageReqVO);
|
||||
EnergyStationConfigDO getByStationId(Long stationId);
|
||||
List<EnergyStationConfigDO> getConfigList();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.energy.enums.ErrorCodeConstants.*;
|
||||
|
||||
@@ -54,6 +56,11 @@ public class EnergyStationConfigServiceImpl implements EnergyStationConfigServic
|
||||
return stationConfigMapper.selectByStationId(stationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnergyStationConfigDO> getConfigList() {
|
||||
return stationConfigMapper.selectList();
|
||||
}
|
||||
|
||||
private void validateConfigExists(Long id) {
|
||||
if (stationConfigMapper.selectById(id) == null) {
|
||||
throw exception(STATION_CONFIG_NOT_EXISTS);
|
||||
|
||||
Reference in New Issue
Block a user