From e2cba9e4c71da51fd6bf1dca0e3437f99d914c97 Mon Sep 17 00:00:00 2001 From: lishuai Date: Mon, 24 Feb 2025 20:23:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A2=B3=E9=85=8D=E9=A2=9D=202025=E5=B9=B42?= =?UTF-8?q?=E6=9C=8824=E6=97=A520:23:25=20=E8=B5=B5=E7=90=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/QyCarbonAssetController.java | 55 ++--- .../controller/QyCarbonQuotaController.java | 158 --------------- .../QyCarbonQuotaInfoController.java | 7 +- .../qingyuan/carbon/dto/QyCarbonAssetDTO.java | 21 +- .../qingyuan/carbon/dto/QyCarbonQuotaDTO.java | 53 ----- .../carbon/dto/QyCarbonQuotaInfoDTO.java | 25 +-- .../qingyuan/carbon/dto/QyCcerInfoDTO.java | 20 +- .../carbon/dto/QyGreenCertificateInfoDTO.java | 22 +- .../carbon/entity/QyCarbonAssetEntity.java | 24 --- .../carbon/entity/QyCarbonQuotaEntity.java | 86 -------- .../entity/QyCarbonQuotaInfoEntity.java | 38 ++-- .../carbon/entity/QyCcerInfoEntity.java | 26 +-- .../entity/QyGreenCertificateInfoEntity.java | 30 +-- .../carbon/mapper/QyCarbonAssetMapper.java | 9 - .../carbon/mapper/QyCarbonQuotaMapper.java | 38 ---- .../carbon/service/QyCarbonAssetService.java | 9 +- .../carbon/service/QyCarbonQuotaService.java | 42 ---- .../impl/QyCarbonAssetServiceImpl.java | 188 ++++++++++-------- .../impl/QyCarbonQuotaInfoServiceImpl.java | 18 +- .../impl/QyCarbonQuotaServiceImpl.java | 113 ----------- .../service/impl/QyCcerInfoServiceImpl.java | 18 +- .../QyGreenCertificateInfoServiceImpl.java | 12 +- .../qingyuan/carbon/util/CategoryEnum.java | 32 --- .../thing/qingyuan/carbon/util/Constant.java | 13 ++ 24 files changed, 235 insertions(+), 822 deletions(-) delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaController.java delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaDTO.java delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonAssetEntity.java delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaEntity.java delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonAssetMapper.java delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonQuotaMapper.java delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonQuotaService.java delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonQuotaServiceImpl.java delete mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/util/CategoryEnum.java create mode 100644 modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/util/Constant.java diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonAssetController.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonAssetController.java index b4f6a7c..b3d982d 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonAssetController.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonAssetController.java @@ -1,18 +1,18 @@ package com.thing.qingyuan.carbon.controller; -import com.thing.common.core.constants.Constant; -import com.thing.common.core.web.response.PageData; import com.thing.common.core.web.response.Result; import com.thing.qingyuan.carbon.dto.QyCarbonAssetDTO; import com.thing.qingyuan.carbon.service.QyCarbonAssetService; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import java.util.List; import java.util.Map; @RestController @@ -23,27 +23,6 @@ public class QyCarbonAssetController { private final QyCarbonAssetService qyCarbonAssetService; - @GetMapping("page") - @Operation(summary="分页") - @Parameters({ - @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , - @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , - @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , - @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") - }) - public Result> page(@Parameter(hidden = true) @RequestParam Map params){ - PageData pageData = qyCarbonAssetService.getPageData(params, QyCarbonAssetDTO.class); - return new Result>().ok(pageData); - } - - @GetMapping("{id}") - @Operation(summary="信息") - public Result get(@PathVariable("id") Long id){ - QyCarbonAssetDTO data = qyCarbonAssetService.getByIdAs(id, QyCarbonAssetDTO.class); - return new Result().ok(data); - } - - /** * 计算当前碳资产,包括碳配额,CCER,绿证 * @return 返回一个Map @@ -78,6 +57,18 @@ public class QyCarbonAssetController { return new Result>().ok(stateCount); } + /** + * 统计近几个月的碳资产 + * @return 返回一个map + */ + @GetMapping("/recent/months") + @Operation(summary = "统计进几个月的碳资产") + public Result> recentMonths(@RequestParam("startTime") Long startTime, + @RequestParam("endTime") Long endTime) { + List assetList = qyCarbonAssetService.countRecentCarbonAsset(startTime,endTime); + return new Result>().ok(assetList); + } + /** * 获取碳资产对应标签的单价,数量,余额,账户总余额 * @return 返回一个Map @@ -90,15 +81,5 @@ public class QyCarbonAssetController { return new Result>().ok(unitPrice); } - /** - * 统计近几个月的碳资产 - * @return 返回一个map - */ - @GetMapping("/recent/months") - @Operation(summary = "统计进几个月的碳资产") - public Result> recentMonths(@RequestParam("startTime") String startTime, - @RequestParam("endTime") String endTime) { - Map carbonAsset = qyCarbonAssetService.countRecentCarbonAsset(startTime,endTime); - return new Result>().ok(carbonAsset); - } + } diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaController.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaController.java deleted file mode 100644 index 24987eb..0000000 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaController.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.thing.qingyuan.carbon.controller; - -import com.thing.common.core.annotation.LogOperation; -import com.thing.common.core.constants.Constant; -import com.thing.common.core.validator.AssertUtils; -import com.thing.common.core.validator.ValidatorUtils; -import com.thing.common.core.validator.group.AddGroup; -import com.thing.common.core.validator.group.DefaultGroup; -import com.thing.common.core.validator.group.UpdateGroup; -import com.thing.common.core.web.response.PageData; -import com.thing.common.core.web.response.Result; -import com.thing.qingyuan.carbon.dto.QyCarbonQuotaDTO; -import com.thing.qingyuan.carbon.dto.QyRegionDTO; -import com.thing.qingyuan.carbon.entity.QyCarbonQuotaEntity; -import com.thing.qingyuan.carbon.exception.BusinessException; -import com.thing.qingyuan.carbon.service.QyCarbonQuotaService; -import com.thing.qingyuan.carbon.service.QyRegionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - -@RestController -@RequestMapping("v2/carbon/quota") -@Tag(name = "碳配额") -@RequiredArgsConstructor -public class QyCarbonQuotaController { - - @Resource - private final QyCarbonQuotaService qyCarbonQuotaService; - - @Resource - private final QyRegionService qyRegionService; - - @GetMapping("page") - @Operation(summary="分页") - @Parameters({ - @Parameter(name = Constant.PAGE,description ="当前页码,从1开始"), - @Parameter(name = Constant.LIMIT,description ="每页显示记录数"), - @Parameter(name = Constant.ORDER_FIELD,description ="排序字段"), - @Parameter(name = Constant.ORDER,description ="排序方式,可选值(asc、desc)"), - @Parameter(name = "name",description ="控制名称"), - @Parameter(name = "device",description ="设备信息"), - @Parameter(name = "attr",description ="属性信息"), - @Parameter(name = "extendId",description ="通讯协议") - }) - public Result> page(@RequestParam Map params) { - PageData page = qyCarbonQuotaService.getPageData(params,QyCarbonQuotaDTO.class); - return new Result>().ok(page); - } - - @GetMapping("/handle-category") - @Operation(summary = "根据类别处理项目") - @Parameters({ - @Parameter(name = "category", description = "项目类别 (1: 分布光伏, 2: 照明节能, 3: 专用车充电桩)") - }) - public Result handleCategory(@RequestParam String category) { - // 调用 service 层的方法,根据类别处理项目 - String result = qyCarbonQuotaService.handleByCategory(category); - return new Result<>().ok(result); - } - - @GetMapping("{id}") - @Operation(summary="信息") - public Result get(@PathVariable("id") Long id) { - QyCarbonQuotaDTO data = qyCarbonQuotaService.getByIdAs(id, QyCarbonQuotaDTO.class); - return new Result().ok(data); - } - - @PostMapping - @Operation(summary = "保存") - @LogOperation("保存") - public Result save(@RequestBody QyCarbonQuotaDTO dto) { - //校验数据 - ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - qyCarbonQuotaService.validate(dto); - qyCarbonQuotaService.saveDto(dto); - return new Result<>(); - } - - @PutMapping - @Operation(summary = "修改") - @LogOperation("修改") - public Result update(@RequestBody QyCarbonQuotaDTO dto) { - //校验数据 - ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - qyCarbonQuotaService.validate(dto); - qyCarbonQuotaService.updateDto(dto); - return new Result<>(); - } - - @DeleteMapping - @Operation(summary = "删除") - @LogOperation("删除") - public Result delete(@RequestBody Long[] ids) { - //校验数据 - AssertUtils.isArrayEmpty(ids,"id"); - qyCarbonQuotaService.batchDelete(ids); - return new Result<>(); - } - - // 获取区域列表接口 - @GetMapping("region/list") - @Operation(summary = "获取区域列表") - public Result> getRegionList() { - // 调用 QyRegionService 获取所有区域 - List regions = qyRegionService.getAllRegions(); - return new Result>().ok(regions); - } - - // 全局异常处理 - @ExceptionHandler(BusinessException.class) - public Result handleBusinessException(BusinessException ex) { - return new Result().error(ex.getMessage()); - } - /** - * 根据区域查询碳配额 - * @param region 区域名称 - * @return 碳配额列表 - */ - @GetMapping("/findByRegion") - @Operation(summary = "根据区域查询碳配额", description = "根据区域查询对应的碳配额") - public Result> findByRegion(@RequestParam String region) { - List quotas = qyCarbonQuotaService.findByRegion(region); // 调用 Service 层的 findByRegion 方法 - return new Result>().ok(quotas); // 返回查询结果 - } - - /** - * 根据名称查询碳配额 - * @param name 配额名称 - * @return 碳配额列表 - */ - @GetMapping("/findByName") - @Operation(summary = "根据名称查询碳配额", description = "根据配额名称查询碳配额") - public Result> findByName(@RequestParam String name) { - List quotas = qyCarbonQuotaService.findByName(name); // 调用 Service 层的 findByName 方法 - return new Result>().ok(quotas); // 返回查询结果 - } - - /** - * 根据区域和碳状态查询碳配额 - * @param region 区域名称 - * @param carbonState 碳配额状态 - * @return 碳配额列表 - */ - @GetMapping("/findByRegionAndState") - @Operation(summary = "根据区域和碳状态查询碳配额", description = "根据区域和碳配额状态查询") - public Result> findByRegionAndState(@RequestParam String region, @RequestParam String carbonState) { - List quotas = qyCarbonQuotaService.findByRegionAndState(region, carbonState); // 调用 Service 层的 findByRegionAndState 方法 - return new Result>().ok(quotas); // 返回查询结果 - } -} diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaInfoController.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaInfoController.java index fe182e8..7cea79b 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaInfoController.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaInfoController.java @@ -10,8 +10,6 @@ import com.thing.common.core.validator.group.UpdateGroup; import com.thing.common.core.web.response.PageData; import com.thing.common.core.web.response.Result; import com.thing.qingyuan.carbon.dto.QyCarbonQuotaInfoDTO; -import com.thing.qingyuan.carbon.dto.QyRegionDTO; -import com.thing.qingyuan.carbon.entity.QyRegionEntity; import com.thing.qingyuan.carbon.service.QyCarbonQuotaInfoService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -87,7 +85,7 @@ public class QyCarbonQuotaInfoController { * 统计当前碳配额总和和三种状态所占百分比 * @return 返回一个map */ - @GetMapping("/state") + @GetMapping("state") @Operation(summary = "获取碳配额状态统计和百分比") public Result> getCarbonQuotaStatisticsWithStatePercentage() { Map statisticsWithPercentage = qyCarbonQuotaInfoService.getCarbonQuotaStatisticsWithStatePercentage(); @@ -98,9 +96,8 @@ public class QyCarbonQuotaInfoController { * 获取区域减排量占比 * @return 返回一个Map,键为区域名称,值为该区域减排量占总碳配额的百分比 */ - @GetMapping("/region") + @GetMapping("region") @Operation(summary = "获取区域减排量占比") - @Parameter(name = "region", description = "区域名称") public Result>>getEmissionReductionPercentages() { List> percentage = qyCarbonQuotaInfoService.getEmissionReductionPercentagesByState(); return new Result>>().ok(percentage); diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonAssetDTO.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonAssetDTO.java index 82fe5c9..11018a5 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonAssetDTO.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonAssetDTO.java @@ -14,21 +14,22 @@ public class QyCarbonAssetDTO implements Serializable { @Serial private static final long serialVersionUID = 1L; - @Schema(description = "主键") - private Long id; - - @Schema(description = "交易时间") - private Long dealTime; - - @Schema(description = "交易时间") - private String dealXz; @Schema(description = "交易时间") + private Long ts; + @Schema(description = "交易性质") + private String nature; + @Schema(description = "碳资产标签") private String tag; @Schema(description = "单价") - private BigDecimal dj; + private BigDecimal unitPrice; + @Schema(description = "数量") + private BigDecimal num; @Schema(description = "价格") private String price; - private String zhye; + @Schema(description = "账户余额") + private String accountBalance; + @Schema(description = "碳资产状态:0.发放 (默认)1.买入 2.核销 ") + private String assetState; } diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaDTO.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaDTO.java deleted file mode 100644 index e456732..0000000 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaDTO.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.thing.qingyuan.carbon.dto; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; - -/** -* 碳配额信息 -* -* @author xc -* @since 3.0 2025-02-12 -*/ -@Data -@Schema(description = "碳配额信息") -public class QyCarbonQuotaDTO implements Serializable { - @Serial - private static final long serialVersionUID = 1L; - - @Schema(description = "主键") - private Long id; - @Schema(description = "类型:1.已发放碳配额 2.累积中碳配额 3.待发放碳配额") - private String carbonState; - @Schema(description = "项目名称") - private String name; - @Schema(description = "发电户号") - private String generatorNum; - @Schema(description = "认证周期") - private String certificationCycle; - @Schema(description = "认证时间段") - private String certificationTime; - @Schema(description = "类别:1.分布光伏项目 2.照明节能项目 3.专用车充电桩项目") - private String category; - @Schema(description = "区域") - private String region; - @Schema(description = "发放日期") - private String issueDate; - @Schema(description = "认证减排量/tCO2") - private String certifiedEmissionReduct; - @Schema(description = "操作") - private String operate; - @Schema(description = "创建者") - private Long creator; - @Schema(description = "创建时间") - private String createDate; - @Schema(description = "更新者") - private Long updater; - @Schema(description = "更新时间") - private String updateDate; - -} \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaInfoDTO.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaInfoDTO.java index a6bcaa3..9a691ba 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaInfoDTO.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaInfoDTO.java @@ -21,26 +21,26 @@ public class QyCarbonQuotaInfoDTO implements Serializable { @Schema(description = "主键") private Long id; - @Schema(description = "碳配额状态:1.待发放碳配额(tCO2) 2.已发放碳配额(tCO2)") + @Schema(description = "碳配额状态:1.待发放碳配额(tCO2) 2.已发放碳配额(tCO2)3.买入 4.核销 5.卖出") private String state; @Schema(description = "项目名称") private String name; @Schema(description = "项目编号") - private String projectCode; + private String code; @Schema(description = "认证周期") - private Long certificationCycle; + private String certificationCycle; @Schema(description = "认证时间段") - private Long certificationTime; + private String certificationTime; @Schema(description = "认证完成日期") private Long certificationFinishDate; @Schema(description = "区域") private String region; - @Schema(description = "发放日期") + @Schema(description = "所属企业") + private String company; + @Schema(description = "发放日期/核销日期") private Long issueDate; @Schema(description = "碳配额/tCO2") - private BigDecimal carbonQuota; - @Schema(description = "小镇名称") - private String town; + private BigDecimal total; @Schema(description = "创建者") private Long creator; @Schema(description = "创建时间") @@ -55,12 +55,7 @@ public class QyCarbonQuotaInfoDTO implements Serializable { private Long companyId; @Schema(description = "部门id") private Long deptId; - @Schema(description = "核销日期") - private Long verificationDate; - @Schema(description = "核销量") - private Double verificationVolume; @Schema(description = "价格") - private Double price; - @Schema(description = "碳资产状态:1.买入 2.核销 3.发放") - private String assetState; + private BigDecimal price; + } \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCcerInfoDTO.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCcerInfoDTO.java index 36ffa6d..a2a7bfa 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCcerInfoDTO.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCcerInfoDTO.java @@ -22,24 +22,24 @@ public class QyCcerInfoDTO implements Serializable { @Schema(description = "主键") private Long id; - @Schema(description = "CCER状态:1.待申请CCER(tCO2) 2.已申请CCER(tCO2)") + @Schema(description = "CCER状态:1.待申请CCER(tCO2) 2.已申请CCER(tCO2)3.买入 4.核销 5.卖出") private String state; @Schema(description = "项目名称") private String name; @Schema(description = "所属企业") - private String belongCompany; + private String company; @Schema(description = "所属区域") - private String belongRegion; + private String region; @Schema(description = "第一次减排量备案") private String firstEmission; @Schema(description = "备案减排量") - private Double recordEmission; - @Schema(description = "减排量时间") - private Long emissionTime; + private BigDecimal total; + @Schema(description = "减排量时间/核销日期") + private Long issueDate; @Schema(description = "核证机构") private String certificationAuthority; @Schema(description = "价格") - private Double price; + private BigDecimal price; @Schema(description = "创建者") private Long creator; @Schema(description = "创建时间") @@ -54,10 +54,4 @@ public class QyCcerInfoDTO implements Serializable { private Long companyId; @Schema(description = "部门id") private Long deptId; - @Schema(description = "核销日期") - private Long verificationDate; - @Schema(description = "核销量") - private Double verificationVolume; - @Schema(description = "碳资产状态:1.买入 2.核销 3.发放") - private String assetState; } \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyGreenCertificateInfoDTO.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyGreenCertificateInfoDTO.java index efad96d..4b87d1e 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyGreenCertificateInfoDTO.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyGreenCertificateInfoDTO.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; /** * 绿证信息总览 @@ -20,18 +21,18 @@ public class QyGreenCertificateInfoDTO implements Serializable { @Schema(description = "主键") private Long id; - @Schema(description = "绿证状态:1.待发放绿证(MWH) 2.已申请绿证(MWH)") + @Schema(description = "绿证状态:1.待发放绿证(MWH) 2.已申请绿证(MWH)3.买入 4.核销 5.卖出") private String state; @Schema(description = "发电类型") private String powerType; @Schema(description = "申请日期") private Long applicationDate; - @Schema(description = "核发日期") - private Long dateIssue; + @Schema(description = "核发日期/核销日期") + private Long issueDate; @Schema(description = "绿证能源总量") - private Double greenTotal; + private BigDecimal total; @Schema(description = "绿证证书代码") - private String greenCode; + private String code; @Schema(description = "创建者") private Long creator; @Schema(description = "创建时间") @@ -48,13 +49,10 @@ public class QyGreenCertificateInfoDTO implements Serializable { private Long deptId; @Schema(description = "区域") private String region; + @Schema(description = "所属企业") + private String company; @Schema(description = "绿证价格") - private Double price; - @Schema(description = "核销日期") - private Long verificationDate; - @Schema(description = "核销量") - private Double verificationVolume; - @Schema(description = "碳资产状态:1.买入 2.核销 3.发放") - private String assetState; + private BigDecimal price; + } \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonAssetEntity.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonAssetEntity.java deleted file mode 100644 index d53de9c..0000000 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonAssetEntity.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.thing.qingyuan.carbon.entity; - -import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; -import com.mybatisflex.annotation.Table; -import com.mybatisflex.core.keygen.KeyGenerators; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serial; -import java.io.Serializable; - -@Data -@Accessors(chain = true) -@EqualsAndHashCode(callSuper=false) -@Table("qy_carbon_asset") -public class QyCarbonAssetEntity implements Serializable { - @Serial - private static final long serialVersionUID = 1L; - - @Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId) - private Long id; -} diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaEntity.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaEntity.java deleted file mode 100644 index 4ba7438..0000000 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaEntity.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.thing.qingyuan.carbon.entity; - -import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; -import com.mybatisflex.annotation.Table; -import com.mybatisflex.core.keygen.KeyGenerators; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serial; -import java.io.Serializable; - -/** - * 碳配额信息 - * - * @author xc - * @since 3.0 2025-02-12 - */ -@Data -@Accessors(chain = true) -@EqualsAndHashCode(callSuper=false) -@Table("qy_carbon_quota") -public class QyCarbonQuotaEntity implements Serializable { - @Serial - private static final long serialVersionUID = 1L; - - @Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId) - private Long id; - /** - * 类型:1.已发放碳配额 2.累积中碳配额 3.待发放碳配额 - */ - private String carbonState; - /** - * 项目名称 - */ - private String name; - /** - * 发电户号 - */ - private String generatorNum; - /** - * 认证周期 - */ - private String certificationCycle; - /** - * 认证时间段 - */ - private String certificationTime; - /** - * 类别:1.分布光伏项目 2.照明节能项目 3.专用车充电桩项目 - */ - private String category; - /** - * 区域 - */ - private String region; - /** - * 发放日期 - */ - private String issueDate; - /** - * 认证减排量/tCO2 - */ - private String certifiedEmissionReduct; - /** - * 操作 - */ - private String operate; - /** - * 创建者 - */ - private Long creator; - /** - * 创建时间 - */ - private String createDate; - /** - * 更新者 - */ - private Long updater; - /** - * 更新时间 - */ - private String updateDate; -} \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaInfoEntity.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaInfoEntity.java index d271795..00434c7 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaInfoEntity.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaInfoEntity.java @@ -1,10 +1,6 @@ package com.thing.qingyuan.carbon.entity; -import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; -import com.mybatisflex.core.keygen.KeyGenerators; -import com.thing.common.orm.entity.BaseEntity; import com.thing.common.orm.entity.BaseInfoEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -29,7 +25,7 @@ public class QyCarbonQuotaInfoEntity extends BaseInfoEntity implements Serializ private static final long serialVersionUID = 1L; /** - * 碳配额状态:1.待发放碳配额(tCO2) 2.已发放碳配额(tCO2) + * 碳配额状态:1.待发放碳配额(tCO2) 2.已发放碳配额(tCO2)3.买入 4.核销 5.卖出 */ private String state; /** @@ -39,15 +35,15 @@ public class QyCarbonQuotaInfoEntity extends BaseInfoEntity implements Serializ /** * 项目编号 */ - private String projectCode; + private String code; /** * 认证周期 */ - private Long certificationCycle; + private String certificationCycle; /** * 认证时间段 */ - private Long certificationTime; + private String certificationTime; /** * 认证完成日期 */ @@ -56,6 +52,10 @@ public class QyCarbonQuotaInfoEntity extends BaseInfoEntity implements Serializ * 区域 */ private String region; + /** + * 所属企业 + */ + private String company; /** * 发放日期 */ @@ -63,26 +63,12 @@ public class QyCarbonQuotaInfoEntity extends BaseInfoEntity implements Serializ /** * 碳配额/tCO2 */ - private BigDecimal carbonQuota; - /** - * 小镇名称 - */ - private String town; - /** - * 核销日期 - */ - private Long verificationDate; - /** - * 核销量 - */ - private Double verificationVolume; + private BigDecimal total; + /** * 价格 */ - private Double price; - /** - * 碳资产状态:1.买入 2.核销 3.发放 - */ - private String assetState; + private BigDecimal price; + } \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCcerInfoEntity.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCcerInfoEntity.java index 7b0bf49..558978c 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCcerInfoEntity.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCcerInfoEntity.java @@ -8,6 +8,7 @@ import lombok.experimental.Accessors; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; /** * CCER信息总览 @@ -25,7 +26,7 @@ public class QyCcerInfoEntity extends BaseInfoEntity implements Serializable { /** - * CCER状态:1.待申请CCER(tCO2) 2.已申请CCER(tCO2) + * CCER状态:1.待申请CCER(tCO2) 2.已申请CCER(tCO2)3.买入 4.核销 5.卖出 */ private String state; @@ -37,12 +38,12 @@ public class QyCcerInfoEntity extends BaseInfoEntity implements Serializable { /** * 所属企业 */ - private String belongCompany; + private String company; /** * 所属区域 */ - private String belongRegion; + private String region; /** * 第一次减排量备案 @@ -52,12 +53,12 @@ public class QyCcerInfoEntity extends BaseInfoEntity implements Serializable { /** * 备案减排量 */ - private Double recordEmission; + private BigDecimal total; /** * 减排量时间 */ - private Long emissionTime; + private Long issueDate; /** * 核证机构 @@ -67,19 +68,8 @@ public class QyCcerInfoEntity extends BaseInfoEntity implements Serializable { /** * 价格 */ - private Double price; - /** - * 核销日期 - */ - private Long verificationDate; - /** - * 核销量 - */ - private Double verificationVolume; - /** - * 碳资产状态:1.买入 2.核销 3.发放 - */ - private String assetState; + private BigDecimal price; + } \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyGreenCertificateInfoEntity.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyGreenCertificateInfoEntity.java index abc6147..c3627e9 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyGreenCertificateInfoEntity.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyGreenCertificateInfoEntity.java @@ -1,9 +1,6 @@ package com.thing.qingyuan.carbon.entity; -import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; -import com.mybatisflex.core.keygen.KeyGenerators; import com.thing.common.orm.entity.BaseInfoEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -11,6 +8,7 @@ import lombok.experimental.Accessors; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; /** * 绿证信息总览 @@ -23,12 +21,13 @@ import java.io.Serializable; @EqualsAndHashCode(callSuper=false) @Table("qy_green_certificate_info") public class QyGreenCertificateInfoEntity extends BaseInfoEntity implements Serializable { + @Serial private static final long serialVersionUID = 1L; /** - * 绿证状态:1.待发放绿证(MWH) 2.已申请绿证(MWH) + * 绿证状态:1.待发放绿证(MWH) 2.已申请绿证(MWH)3.买入 4.核销 5.卖出 */ private String state; /** @@ -42,34 +41,27 @@ public class QyGreenCertificateInfoEntity extends BaseInfoEntity implements Seri /** * 核发日期 */ - private Long dateIssue; + private Long issueDate; /** * 绿证能源总量 */ - private Double greenTotal; + private BigDecimal total; /** * 绿证证书代码 */ - private String greenCode; + private String code; /** * 区域 */ private String region; /** - * 绿证价格 - */ - private Double price; - /** - * 核销日期 + * 所属企业 */ - private Long verificationDate; + private String company; /** - * 核销量 - */ - private Double verificationVolume; - /** - * 碳资产状态:1.买入 2.核销 3.发放 + * 绿证价格 */ - private String assetState; + private BigDecimal price; + } \ No newline at end of file diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonAssetMapper.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonAssetMapper.java deleted file mode 100644 index e6a60a0..0000000 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonAssetMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.thing.qingyuan.carbon.mapper; - -import com.thing.common.orm.mapper.PowerBaseMapper; -import com.thing.qingyuan.carbon.entity.QyCarbonAssetEntity; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface QyCarbonAssetMapper extends PowerBaseMapper { -} diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonQuotaMapper.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonQuotaMapper.java deleted file mode 100644 index 7b5f4dd..0000000 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonQuotaMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.thing.qingyuan.carbon.mapper; - -import com.thing.common.orm.mapper.PowerBaseMapper; -import com.thing.qingyuan.carbon.entity.QyCarbonQuotaEntity; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; - -@Mapper -public interface QyCarbonQuotaMapper extends PowerBaseMapper { - - /** - * 通过区域查询碳配额信息 - * @param region 区域 - * @return 区域内的碳配额信息表 - */ - @Select("SELECT * FROM qy_carbon_quota WHERE region = #{region}") - List findByRegion(String region); - - /** - * 通过名称查询碳配额信息 - * @param name 名称 - * @return 匹配的碳配额信息表 - */ - @Select("SELECT * FROM qy_carbon_quota WHERE name = #{name}") - List findByName(String name); - - /** - * 通过区域和状态查询碳配额信息 - * @param region 区域 - * @param carbonState 碳状态 - * @return 区域和状态匹配的碳配额信息 - */ - @Select("SELECT * FROM qy_carbon_quota WHERE region = #{region} AND carbon_state = #{carbonState}") - List findByRegionAndState(@Param("region") String region, @Param("carbonState") String carbonState); -} diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonAssetService.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonAssetService.java index 5ce3de9..868a056 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonAssetService.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonAssetService.java @@ -1,13 +1,12 @@ package com.thing.qingyuan.carbon.service; -import com.thing.common.orm.service.IBaseService; -import com.thing.qingyuan.carbon.entity.QyCarbonAssetEntity; +import com.thing.qingyuan.carbon.dto.QyCarbonAssetDTO; +import java.util.List; import java.util.Map; -public interface QyCarbonAssetService extends IBaseService{ - +public interface QyCarbonAssetService { /** * 计算当前碳资产,包括碳配额,CCER,绿证 @@ -31,7 +30,7 @@ public interface QyCarbonAssetService extends IBaseService{ * 统计近几个月的资产 * @return 返回一个map */ - Map countRecentCarbonAsset(String startTime, String endTime); + List countRecentCarbonAsset(Long startTime, Long endTime); /** * 获取碳资产对应标签的单价,数量,余额,账户总余额 diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonQuotaService.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonQuotaService.java deleted file mode 100644 index 4a64f25..0000000 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonQuotaService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.thing.qingyuan.carbon.service; - -import com.thing.common.orm.service.IBaseService; -import com.thing.qingyuan.carbon.dto.QyCarbonQuotaDTO; -import com.thing.qingyuan.carbon.entity.QyCarbonQuotaEntity; - -import java.util.List; - -public interface QyCarbonQuotaService extends IBaseService { - /** - * 认证减排量 - * @param dto 认证减排量DTO - */ - void validate(QyCarbonQuotaDTO dto); - /** - * 根据类别决定项目处理逻辑 - * @param category 项目类别 - * @return 不同类别的处理结果 - */ - String handleByCategory(String category); - /** - * 根据区域查询碳配额 - * @param region 区域名称 - * @return 碳配额实体列表 - */ - List findByRegion(String region); - - /** - * 根据名称查询碳配额 - * @param name 配额名称 - * @return 碳配额实体列表 - */ - List findByName(String name); - - /** - * 根据区域和碳状态查询碳配额 - * @param region 区域名称 - * @param carbonState 碳配额状态 - * @return 碳配额实体列表 - */ - List findByRegionAndState(String region, String carbonState); -} diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonAssetServiceImpl.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonAssetServiceImpl.java index 87d1615..ac4fab6 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonAssetServiceImpl.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonAssetServiceImpl.java @@ -1,14 +1,17 @@ package com.thing.qingyuan.carbon.service.impl; import com.mybatisflex.core.query.QueryWrapper; -import com.thing.common.orm.service.impl.BaseServiceImpl; import com.thing.qingyuan.carbon.dto.QyCarbonAssetDTO; -import com.thing.qingyuan.carbon.entity.QyCarbonAssetEntity; +import com.thing.qingyuan.carbon.dto.QyCarbonQuotaInfoDTO; +import com.thing.qingyuan.carbon.dto.QyCcerInfoDTO; import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; -import com.thing.qingyuan.carbon.mapper.QyCarbonAssetMapper; import com.thing.qingyuan.carbon.service.QyCarbonAssetService; +import com.thing.qingyuan.carbon.service.QyCarbonQuotaInfoService; +import com.thing.qingyuan.carbon.service.QyCcerInfoService; +import com.thing.qingyuan.carbon.service.QyGreenCertificateInfoService; +import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -25,12 +28,12 @@ import static com.thing.qingyuan.carbon.entity.table.QyCcerInfoEntityTableDef.QY import static com.thing.qingyuan.carbon.entity.table.QyGreenCertificateInfoEntityTableDef.QY_GREEN_CERTIFICATE_INFO_ENTITY; @Service -public class QyCarbonAssetServiceImpl extends BaseServiceImpl implements QyCarbonAssetService { +@RequiredArgsConstructor +public class QyCarbonAssetServiceImpl implements QyCarbonAssetService { - @Override - public QueryWrapper getWrapper(Map params) { - return null; - } + private final QyCarbonQuotaInfoService qyCarbonQuotaInfoService; + private final QyCcerInfoService qyCcerInfoService; + private final QyGreenCertificateInfoService qyGreenCertificateInfoService; /** * 计算当前碳资产,包括碳配额,CCER,绿证 @@ -40,54 +43,54 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl countCarbonAsset() { //查询待发放碳配额 QueryWrapper queryWrapper = QueryWrapper.create() - .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) + .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total")) .from(QY_CARBON_QUOTA_INFO_ENTITY) .eq(QyCarbonQuotaInfoEntity::getState,"1"); // sum1 为待发放碳配额 - String sum1 = mapper.selectOneByQueryAs(queryWrapper, String.class); + String sum1 = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper, String.class); //查询待申请CCER QueryWrapper queryWrapper1 = QueryWrapper.create() - .select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) + .select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) .from(QY_CCER_INFO_ENTITY) .eq(QyCcerInfoEntity::getState,"1"); // sum2 为待申请CCER - String sum2 = mapper.selectOneByQueryAs(queryWrapper1, String.class); + String sum2 = qyCcerInfoService.getMapper().selectOneByQueryAs(queryWrapper1, String.class); //查询待发放绿证 QueryWrapper queryWrapper2 = QueryWrapper.create() - .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) + .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) .from(QY_GREEN_CERTIFICATE_INFO_ENTITY) .eq(QyGreenCertificateInfoEntity::getState,"1"); // sum3 为待发放绿证 - String sum3 = mapper.selectOneByQueryAs(queryWrapper2, String.class); + String sum3 = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper2, String.class); //统计当前状态下 碳配额,ccer,绿证总和 BigDecimal addTotal = new BigDecimal(sum1).add(new BigDecimal(sum2)).add(new BigDecimal(sum3)); // 查询已发放碳配额 QueryWrapper queryWrapper3 = QueryWrapper.create() - .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) + .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total")) .from(QY_CARBON_QUOTA_INFO_ENTITY) .eq(QyCarbonQuotaInfoEntity::getState,"2"); // sum4 为已发放碳配额 - String sum4 = mapper.selectOneByQueryAs(queryWrapper3, String.class); + String sum4 = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper3, String.class); // 查询已申请ccer QueryWrapper queryWrapper4 = QueryWrapper.create() - .select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) + .select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) .from(QY_CCER_INFO_ENTITY) .eq(QyCcerInfoEntity::getState,"2"); // sum5 为已申请ccer - String sum5 = mapper.selectOneByQueryAs(queryWrapper4, String.class); + String sum5 = qyCcerInfoService.getMapper().selectOneByQueryAs(queryWrapper4, String.class); // 查询已发放绿证 QueryWrapper queryWrapper5 = QueryWrapper.create() - .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) + .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) .from(QY_GREEN_CERTIFICATE_INFO_ENTITY) .eq(QyGreenCertificateInfoEntity::getState,"2"); // sum6 为已发放绿证 - String sum6 = mapper.selectOneByQueryAs(queryWrapper5, String.class); + String sum6 = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper5, String.class); //统计当前状态下,碳配额,ccer,绿证总和 BigDecimal addTotal1 = new BigDecimal(sum4).add(new BigDecimal(sum5)).add(new BigDecimal(sum6)); @@ -114,22 +117,22 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl countTotalCarbonAsset() { QueryWrapper queryWrapper = QueryWrapper.create() - .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) + .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total")) .from(QY_CARBON_QUOTA_INFO_ENTITY); //sum1 当前碳配额 - String sum1 = mapper.selectOneByQueryAs(queryWrapper, String.class); + String sum1 = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper, String.class); QueryWrapper queryWrapper1 = QueryWrapper.create() - .select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) + .select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) .from(QY_CCER_INFO_ENTITY); //sum2 当前CCER - String sum2 = mapper.selectOneByQueryAs(queryWrapper1, String.class); + String sum2 = qyCcerInfoService.getMapper().selectOneByQueryAs(queryWrapper1, String.class); QueryWrapper queryWrapper2 = QueryWrapper.create() - .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) + .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) .from(QY_GREEN_CERTIFICATE_INFO_ENTITY); //sum3 当前绿证 - String sum3 = mapper.selectOneByQueryAs(queryWrapper2, String.class); + String sum3 = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper2, String.class); //资产综合 BigDecimal sumTotal = new BigDecimal(sum1).add(new BigDecimal(sum2)).add(new BigDecimal(sum3)); @@ -154,17 +157,17 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl temMap = new HashMap<>(); //返回结果 买入 核销 卖出 - temMap.put("buy", buyTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : buyTotal.toString()); + /* temMap.put("buy", buyTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : buyTotal.toString()); temMap.put("ver", verTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : verTotal.toString()); - temMap.put("sell", sellTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : sellTotal.toString()); + temMap.put("sell", sellTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : sellTotal.toString());*/ return temMap; } @@ -254,19 +257,42 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl countRecentCarbonAsset(String startTime, String endTime) { + public List countRecentCarbonAsset(Long startTime, Long endTime) { + //查询碳配额买入碳资产 + //查询碳配额这段时间的账户总额度 + List carbonQuotaList = qyCarbonQuotaInfoService.getMapper().selectListByQueryAs( + QueryWrapper.create() + .ge(QyCarbonQuotaInfoEntity::getIssueDate, startTime) + .lt(QyCarbonQuotaInfoEntity::getIssueDate, endTime) + , QyCarbonQuotaInfoDTO.class); + + + + //查询CCER这段时间的账户总额度 + List ccerInfoList = qyCcerInfoService.getMapper().selectListByQueryAs( + QueryWrapper.create().ge(QyCcerInfoEntity::getIssueDate, startTime) + .lt(QyCcerInfoEntity::getIssueDate, endTime) + , QyCcerInfoDTO.class); + + //查询绿证这段时间的账户总额度 + List ccerInfoDTOList = qyGreenCertificateInfoService.getMapper().selectListByQueryAs( + QueryWrapper.create().ge(QyGreenCertificateInfoEntity::getIssueDate, startTime) + .lt(QyGreenCertificateInfoEntity::getIssueDate, endTime) + , QyCcerInfoDTO.class); + + /* ==============================统计买入量============================================================== */ //查询碳配额买入碳资产 - QueryWrapper queryWrapper = QueryWrapper.create() + /* QueryWrapper queryWrapper = QueryWrapper.create() .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) .from(QY_CARBON_QUOTA_INFO_ENTITY) .where("issue_date >= '" + startTime + "' AND issue_date <'" + endTime + "'") .eq(QyCarbonQuotaInfoEntity::getAssetState,"1"); //numTotal 为碳配额中买入碳资产量 - String carbonTotal = mapper.selectOneByQueryAs(queryWrapper, String.class); + String carbonTotal = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper, String.class); //查询ccer买入碳资产 QueryWrapper queryWrapper1 = QueryWrapper.create() @@ -284,11 +310,11 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl= '" + startTime + "' AND date_issue < '" + endTime + "'") .eq(QyGreenCertificateInfoEntity::getAssetState,"1"); //greenTotal 为绿证买入碳资产量 - String greenTotal = mapper.selectOneByQueryAs(queryWrapper2, String.class); + String greenTotal = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper2, String.class); - /* + *//* ==============================统计核销量===================================================================== - */ + *//* //查询碳配额核销量 QueryWrapper queryWrapper3 = QueryWrapper.create() .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.VERIFICATION_VOLUME).as("total")) @@ -296,7 +322,7 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl= '" + startTime + "' AND verification_date <= '" + endTime + "'") .eq(QyCarbonQuotaInfoEntity::getAssetState,"2"); //carbonVolume 为碳配额核销量 - String carbonVolume = mapper.selectOneByQueryAs(queryWrapper3, String.class); + String carbonVolume = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper3, String.class); //查询ccer核销量 QueryWrapper queryWrapper4 = QueryWrapper.create() @@ -314,11 +340,11 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl= '" + startTime + "' AND verification_date <= '" + endTime + "'") .eq(QyGreenCertificateInfoEntity::getAssetState,"2"); //greenVolume 为绿证核销量 - String greenVolume = mapper.selectOneByQueryAs(queryWrapper5, String.class); + String greenVolume = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper5, String.class); - /* + *//* ==============================统计发放量===================================================================== - */ + *//* //查询碳配额卖出量 QueryWrapper queryWrapper6 = QueryWrapper.create() .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) @@ -326,7 +352,7 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl= '" + startTime + "' AND issue_date <= '" + endTime + "'") .eq(QyCarbonQuotaInfoEntity::getAssetState,"3"); //carbonSell 为碳配额卖出 - String carbonSell = mapper.selectOneByQueryAs(queryWrapper6, String.class); + String carbonSell = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper6, String.class); //查询ccer卖出量 QueryWrapper queryWrapper7 = QueryWrapper.create() @@ -344,11 +370,11 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl= '" + startTime + "' AND date_issue <= '" + endTime + "'") .eq(QyGreenCertificateInfoEntity::getAssetState,"3"); //greenSell 为绿证卖出 - String greenSell = mapper.selectOneByQueryAs(queryWrapper8, String.class); + String greenSell = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper8, String.class); - /* + *//* ==================================碳配额数量===================================================================== - */ + *//* //查询碳配额量总量 QueryWrapper queryWrapper9 = QueryWrapper.create() .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) @@ -356,9 +382,9 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl= '" + startTime + "' AND date_issue <= '" + endTime + "'") .from(QY_GREEN_CERTIFICATE_INFO_ENTITY); //greenTotal 为绿证总量 - String greenSum = mapper.selectOneByQueryAs(queryWrapper13, String.class); + String greenSum = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper13, String.class); - /* + *//* ======================================统计账户总余额======================================================== - */ + *//* //统计碳配额总余额 BigDecimal carbonAccount = new BigDecimal(carbonSum).subtract(new BigDecimal(carbonVolume)); //统计ccer总余额 @@ -395,16 +421,16 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl temMap = new HashMap<>(); //返回结果 买入 核销 卖出 - temMap.put("buy", buyTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : buyTotal.toString()); + /*temMap.put("buy", buyTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : buyTotal.toString()); temMap.put("ver", verTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : verTotal.toString()); temMap.put("sell", sellTotal.compareTo(BigDecimal.ZERO) == 0 ? "0" : sellTotal.toString()); //账户余额 - temMap.put("carbonRemain",remain.toString()); - return temMap; + temMap.put("carbonRemain",remain.toString());*/ + return null; } /** * 获取碳资产对应标签的单价,数量,余额,账户总余额 @@ -413,7 +439,7 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl calculateAsset(String startTime, String endTime) { - QueryWrapper queryWrapper = QueryWrapper.create() + /* QueryWrapper queryWrapper = QueryWrapper.create() .select( QY_CARBON_QUOTA_INFO_ENTITY.ISSUE_DATE.as("deal_time"), QY_CARBON_QUOTA_INFO_ENTITY.PRICE @@ -443,9 +469,9 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl= '" + startTime + "' AND verification_date <= '" + endTime + "'") .from(QY_GREEN_CERTIFICATE_INFO_ENTITY); //greenVer 为绿证核销量 - String greenVer = mapper.selectOneByQueryAs(queryWrapper8, String.class); + String greenVer = mapper.selectOneByQueryAs(queryWrapper8, String.class);*/ /* ======================================统计账户总余额======================================================== */ //统计碳配额总余额 - BigDecimal carbonAccount = new BigDecimal(carbonTotal).subtract(new BigDecimal(carbonVer)); + /* BigDecimal carbonAccount = new BigDecimal(carbonTotal).subtract(new BigDecimal(carbonVer)); //统计ccer总余额 BigDecimal ccerAccount = new BigDecimal(ccerTotal).subtract(new BigDecimal(ccerVer)); //统计绿证总余额 @@ -559,10 +585,10 @@ public class QyCarbonAssetServiceImpl extends BaseServiceImpl getCarbonQuotaStatisticsWithStatePercentage() { //查询待发放碳配额 QueryWrapper queryWrapper1 = QueryWrapper.create() - .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) + .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL)) .from(QY_CARBON_QUOTA_INFO_ENTITY) .eq(QyCarbonQuotaInfoEntity::getState, "1"); //sum1 待发放碳配额总量 @@ -70,14 +67,14 @@ public class QyCarbonQuotaInfoServiceImpl extends BaseServiceImpl> getEmissionReductionPercentagesByState() { // 示例区域列表,可根据实际情况查询数据库中的区域列表 - List regions = Arrays.asList("天玉镇", "河东街道", "富滩镇", "值夏镇", "文陂镇", "富田镇", "东固畲族乡","新圩镇"); // 查询区域和碳配额总和 QueryWrapper queryWrapper4 = QueryWrapper.create() - .select(QY_CARBON_QUOTA_INFO_ENTITY.REGION,sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total") ) + .select(QY_CARBON_QUOTA_INFO_ENTITY.REGION,sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total") ) .from(QY_CARBON_QUOTA_INFO_ENTITY) .groupBy(QY_CARBON_QUOTA_INFO_ENTITY.REGION); // 查询符合条件的小镇碳配额数据 List quotaList1 = mapper.selectListByQueryAs(queryWrapper4,QyCarbonSumQuotaInfoDTO.class); //查询总量 QueryWrapper queryWrapper5 = QueryWrapper.create() - .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total") ) + .select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total") ) .from(QY_CARBON_QUOTA_INFO_ENTITY); String sumtotal = mapper.selectOneByQueryAs(queryWrapper5, String.class); // 存储最终结果 @@ -123,7 +119,7 @@ public class QyCarbonQuotaInfoServiceImpl extends BaseServiceImpl disjunction = CollectionUtil.disjunction(regions, tempRegions); + Collection disjunction = CollectionUtil.disjunction(Constant.REGIONS, tempRegions); for (String s : disjunction) { Map tempMap = new HashMap<>(); tempMap.put("percent", "0"); diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonQuotaServiceImpl.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonQuotaServiceImpl.java deleted file mode 100644 index 93041ac..0000000 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonQuotaServiceImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.thing.qingyuan.carbon.service.impl; - - -import com.mybatisflex.core.query.QueryWrapper; -import com.thing.common.orm.service.impl.BaseServiceImpl; -import com.thing.qingyuan.carbon.dto.QyCarbonQuotaDTO; -import com.thing.qingyuan.carbon.entity.QyCarbonQuotaEntity; -import com.thing.qingyuan.carbon.exception.BusinessException; -import com.thing.qingyuan.carbon.mapper.QyCarbonQuotaMapper; -import com.thing.qingyuan.carbon.service.QyCarbonQuotaService; -import com.thing.qingyuan.carbon.util.CategoryEnum; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - - -@Service -public class QyCarbonQuotaServiceImpl extends BaseServiceImpl implements QyCarbonQuotaService { - - @Resource - private QyCarbonQuotaMapper qyCarbonQuotaMapper; - - @Override - public QueryWrapper getWrapper(Map params) { - QueryWrapper wrapper = new QueryWrapper(); - if (params.containsKey("name")) { - wrapper.like("name", params.get("name")); - } - if (params.containsKey("region")) { - wrapper.eq("region", params.get("region")); - } - if (params.containsKey("carbonState")) { - wrapper.eq("carbon_state", params.get("carbonState")); - } - return wrapper; - } - - - /** - * 根据区域查询碳配额 - * @param region 区域名称 - * @return 碳配额实体列表 - */ - @Override - public List findByRegion(String region) { - return qyCarbonQuotaMapper.findByRegion(region); - } - - /** - * 根据名称查询碳配额 - * @param name 配额名称 - * @return 碳配额实体列表 - */ - @Override - public List findByName(String name) { - return qyCarbonQuotaMapper.findByName(name); - } - - /** - * 根据区域和碳状态查询碳配额 - * @param region 区域名称 - * @param carbonState 碳配额状态 - * @return 碳配额实体列表 - */ - @Override - public List findByRegionAndState(String region, String carbonState) { - return qyCarbonQuotaMapper.findByRegionAndState(region, carbonState); - } - - /** - * 认证减排量 - * @param dto 认证减排量DTO - */ - @Override - public void validate(QyCarbonQuotaDTO dto) { - if (dto.getCertifiedEmissionReduct() == null || dto.getCertifiedEmissionReduct().isEmpty()) { - throw new BusinessException("认证减排量不能为空"); - } - // 进一步的验证逻辑 - if (!dto.getCertifiedEmissionReduct().matches("^[0-9]+(\\.[0-9]{1,2})?$")) { - throw new BusinessException("认证减排量格式不正确,应该是数字,最多两位小数"); - } - } - - /** - * 根据类别决定项目处理逻辑 - * @param category 项目类别 - * @return 不同类别的处理结果 - */ - @Override - public String handleByCategory(String category) { - // 将字符串类型的 category 转换为枚举 - CategoryEnum categoryEnum = CategoryEnum.fromString(category); - - if (categoryEnum == null) { - throw new IllegalArgumentException("无效的项目类别: " + category); - } - - // 根据枚举类型来执行不同的逻辑 - switch (categoryEnum) { - case DISTRIBUTED_SOLAR: - return "处理分布光伏项目逻辑"; - case LIGHTING_ENERGY_SAVING: - return "处理照明节能项目逻辑"; - case SPECIAL_VEHICLE_CHARGING_PILE: - return "处理专用车充电桩项目逻辑"; - default: - throw new IllegalArgumentException("未知的项目类别"); - } - } -} diff --git a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCcerInfoServiceImpl.java b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCcerInfoServiceImpl.java index f365948..b6a9c7d 100644 --- a/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCcerInfoServiceImpl.java +++ b/modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCcerInfoServiceImpl.java @@ -83,19 +83,19 @@ public class QyCcerInfoServiceImpl extends BaseServiceImpl countCcerByState() { QueryWrapper queryWrapper1 = QueryWrapper.create() - .select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) + .select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) .from(QY_CCER_INFO_ENTITY) .eq(QyCcerInfoEntity::getState, "1"); //sum1 待申请CCER String sum1 = mapper.selectOneByQueryAs(queryWrapper1, String.class); QueryWrapper queryWrapper2 = QueryWrapper.create() - .select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) + .select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) .from(QY_CCER_INFO_ENTITY) .eq(QyCcerInfoEntity::getState, "2"); //sum2 已申请CCER String sum2 = mapper.selectOneByQueryAs(queryWrapper2, String.class); QueryWrapper queryWrapper3 = QueryWrapper.create() - .select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) + .select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) .from(QY_CCER_INFO_ENTITY); //sum3 累计CCER(sum=sum1+sum2) String sum3 = mapper.selectOneByQueryAs(queryWrapper3, String.class); @@ -121,14 +121,14 @@ public class QyCcerInfoServiceImpl extends BaseServiceImpl regions = Arrays.asList("天玉镇", "河东街道", "富滩镇", "值夏镇", "文陂镇", "富田镇", "东固畲族乡", "新圩镇"); // 根据区域查询成交量总和 QueryWrapper queryWrapper = QueryWrapper.create() - .select(QY_CCER_INFO_ENTITY.BELONG_REGION, sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) + .select(QY_CCER_INFO_ENTITY.REGION, sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) .from(QY_CCER_INFO_ENTITY) - .groupBy(QY_CCER_INFO_ENTITY.BELONG_REGION); + .groupBy(QY_CCER_INFO_ENTITY.REGION); // 查询符合条件的小镇成交量数据 List quotaList1 = mapper.selectListByQueryAs(queryWrapper, QyCcerSumInfoDTO.class); //查询总量 QueryWrapper queryWrapper2 = QueryWrapper.create() - .select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) + .select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total")) .from(QY_CCER_INFO_ENTITY); String sumTotal = mapper.selectOneByQueryAs(queryWrapper2, String.class); // 存储最终结果 @@ -171,10 +171,10 @@ public class QyCcerInfoServiceImpl extends BaseServiceImpl countGreenByState() { QueryWrapper queryWrapper1 = QueryWrapper.create() - .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) + .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) .from(QY_GREEN_CERTIFICATE_INFO_ENTITY) .eq(QyGreenCertificateInfoEntity::getState,"1"); //sum1 为待发放绿证 String sum1 = mapper.selectOneByQueryAs(queryWrapper1,String.class); QueryWrapper queryWrapper2 = QueryWrapper.create() - .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) + .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) .from(QY_GREEN_CERTIFICATE_INFO_ENTITY) .eq(QyGreenCertificateInfoEntity::getState,"2"); //sum1 为已申请绿证 String sum2 = mapper.selectOneByQueryAs(queryWrapper2,String.class); QueryWrapper queryWrapper3 = QueryWrapper.create() - .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) + .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) .from(QY_GREEN_CERTIFICATE_INFO_ENTITY); //sum1 为累计绿证 (sum=sum1+sum2) String sum = mapper.selectOneByQueryAs(queryWrapper3,String.class); @@ -93,14 +93,14 @@ public class QyGreenCertificateInfoServiceImpl extends BaseServiceImpl regions = Arrays.asList("天玉镇", "河东街道", "富滩镇", "值夏镇", "文陂镇", "富田镇", "东固畲族乡", "新圩镇"); // 根据区域查询成绿证总和 QueryWrapper queryWrapper = QueryWrapper.create() - .select(QY_GREEN_CERTIFICATE_INFO_ENTITY.REGION,sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) + .select(QY_GREEN_CERTIFICATE_INFO_ENTITY.REGION,sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) .from(QY_GREEN_CERTIFICATE_INFO_ENTITY) .groupBy(QY_GREEN_CERTIFICATE_INFO_ENTITY.REGION); // 查询符合条件的小镇绿证数据 List qyGreenSumInfoDTOList = mapper.selectListByQueryAs(queryWrapper, QyGreenSumInfoDTO.class); //查询绿证总能源量 QueryWrapper queryWrapper6 = QueryWrapper.create() - .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) + .select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total")) .from(QY_GREEN_CERTIFICATE_INFO_ENTITY); String sumTotal = mapper.selectOneByQueryAs(queryWrapper6, String.class); //存储最终结果 @@ -145,7 +145,7 @@ public class QyGreenCertificateInfoServiceImpl extends BaseServiceImpl REGIONS = Collections.unmodifiableList( + List.of("天玉镇", "河东街道", "富滩镇", "值夏镇", "文陂镇", "富田镇", "东固畲族乡", "新圩镇") + ); + +}