34 changed files with 2128 additions and 0 deletions
-
158modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaController.java
-
112modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCarbonQuotaInfoController.java
-
125modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyCcerInfoController.java
-
78modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyGreenCertificateInfoController.java
-
87modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/controller/QyRegionController.java
-
53modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaDTO.java
-
60modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonQuotaInfoDTO.java
-
28modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCarbonSumQuotaInfoDTO.java
-
57modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCcerInfoDTO.java
-
32modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyCcerSumInfoDTO.java
-
50modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyGreenCertificateInfoDTO.java
-
38modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/dto/QyRegionDTO.java
-
86modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaEntity.java
-
76modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCarbonQuotaInfoEntity.java
-
73modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyCcerInfoEntity.java
-
55modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyGreenCertificateInfoEntity.java
-
34modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/entity/QyRegionEntity.java
-
43modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/exception/BusinessException.java
-
71modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonQuotaInfoMapper.java
-
38modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCarbonQuotaMapper.java
-
16modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyCcerInfoMapper.java
-
9modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyGreenCertificateInfoMapper.java
-
44modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/mapper/QyRegionMapper.java
-
44modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonQuotaInfoService.java
-
42modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCarbonQuotaService.java
-
33modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyCcerInfoService.java
-
7modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyGreenCertificateInfoService.java
-
22modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/QyRegionService.java
-
143modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonQuotaInfoServiceImpl.java
-
113modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCarbonQuotaServiceImpl.java
-
194modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyCcerInfoServiceImpl.java
-
20modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyGreenCertificateInfoServiceImpl.java
-
55modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/service/impl/QyRegionServiceImpl.java
-
32modules/qingyuan/src/main/java/com/thing/qingyuan/carbon/util/CategoryEnum.java
@ -0,0 +1,158 @@ |
|||
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<PageData<QyCarbonQuotaDTO>> page(@RequestParam Map<String, Object> params) { |
|||
PageData<QyCarbonQuotaDTO> page = qyCarbonQuotaService.getPageData(params,QyCarbonQuotaDTO.class); |
|||
return new Result<PageData<QyCarbonQuotaDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("/handle-category") |
|||
@Operation(summary = "根据类别处理项目") |
|||
@Parameters({ |
|||
@Parameter(name = "category", description = "项目类别 (1: 分布光伏, 2: 照明节能, 3: 专用车充电桩)") |
|||
}) |
|||
public Result<Object> handleCategory(@RequestParam String category) { |
|||
// 调用 service 层的方法,根据类别处理项目 |
|||
String result = qyCarbonQuotaService.handleByCategory(category); |
|||
return new Result<>().ok(result); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary="信息") |
|||
public Result<QyCarbonQuotaDTO> get(@PathVariable("id") Long id) { |
|||
QyCarbonQuotaDTO data = qyCarbonQuotaService.getByIdAs(id, QyCarbonQuotaDTO.class); |
|||
return new Result<QyCarbonQuotaDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Operation(summary = "保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> 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<Void> 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<Void> delete(@RequestBody Long[] ids) { |
|||
//校验数据 |
|||
AssertUtils.isArrayEmpty(ids,"id"); |
|||
qyCarbonQuotaService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
// 获取区域列表接口 |
|||
@GetMapping("region/list") |
|||
@Operation(summary = "获取区域列表") |
|||
public Result<List<QyRegionDTO>> getRegionList() { |
|||
// 调用 QyRegionService 获取所有区域 |
|||
List<QyRegionDTO> regions = qyRegionService.getAllRegions(); |
|||
return new Result<List<QyRegionDTO>>().ok(regions); |
|||
} |
|||
|
|||
// 全局异常处理 |
|||
@ExceptionHandler(BusinessException.class) |
|||
public Result<Void> handleBusinessException(BusinessException ex) { |
|||
return new Result<Void>().error(ex.getMessage()); |
|||
} |
|||
/** |
|||
* 根据区域查询碳配额 |
|||
* @param region 区域名称 |
|||
* @return 碳配额列表 |
|||
*/ |
|||
@GetMapping("/findByRegion") |
|||
@Operation(summary = "根据区域查询碳配额", description = "根据区域查询对应的碳配额") |
|||
public Result<List<QyCarbonQuotaEntity>> findByRegion(@RequestParam String region) { |
|||
List<QyCarbonQuotaEntity> quotas = qyCarbonQuotaService.findByRegion(region); // 调用 Service 层的 findByRegion 方法 |
|||
return new Result<List<QyCarbonQuotaEntity>>().ok(quotas); // 返回查询结果 |
|||
} |
|||
|
|||
/** |
|||
* 根据名称查询碳配额 |
|||
* @param name 配额名称 |
|||
* @return 碳配额列表 |
|||
*/ |
|||
@GetMapping("/findByName") |
|||
@Operation(summary = "根据名称查询碳配额", description = "根据配额名称查询碳配额") |
|||
public Result<List<QyCarbonQuotaEntity>> findByName(@RequestParam String name) { |
|||
List<QyCarbonQuotaEntity> quotas = qyCarbonQuotaService.findByName(name); // 调用 Service 层的 findByName 方法 |
|||
return new Result<List<QyCarbonQuotaEntity>>().ok(quotas); // 返回查询结果 |
|||
} |
|||
|
|||
/** |
|||
* 根据区域和碳状态查询碳配额 |
|||
* @param region 区域名称 |
|||
* @param carbonState 碳配额状态 |
|||
* @return 碳配额列表 |
|||
*/ |
|||
@GetMapping("/findByRegionAndState") |
|||
@Operation(summary = "根据区域和碳状态查询碳配额", description = "根据区域和碳配额状态查询") |
|||
public Result<List<QyCarbonQuotaEntity>> findByRegionAndState(@RequestParam String region, @RequestParam String carbonState) { |
|||
List<QyCarbonQuotaEntity> quotas = qyCarbonQuotaService.findByRegionAndState(region, carbonState); // 调用 Service 层的 findByRegionAndState 方法 |
|||
return new Result<List<QyCarbonQuotaEntity>>().ok(quotas); // 返回查询结果 |
|||
} |
|||
} |
|||
@ -0,0 +1,112 @@ |
|||
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.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; |
|||
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 java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("v2/quota") |
|||
@Tag(name="碳配额信息总览") |
|||
@RequiredArgsConstructor |
|||
public class QyCarbonQuotaInfoController { |
|||
|
|||
private final QyCarbonQuotaInfoService qyCarbonQuotaInfoService; |
|||
|
|||
@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<PageData<QyCarbonQuotaInfoDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ |
|||
PageData<QyCarbonQuotaInfoDTO> pageData = qyCarbonQuotaInfoService.getPageData(params, QyCarbonQuotaInfoDTO.class); |
|||
return new Result<PageData<QyCarbonQuotaInfoDTO>>().ok(pageData); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary="信息") |
|||
public Result<QyCarbonQuotaInfoDTO> get(@PathVariable("id") Long id){ |
|||
QyCarbonQuotaInfoDTO data = qyCarbonQuotaInfoService.getByIdAs(id, QyCarbonQuotaInfoDTO.class); |
|||
return new Result<QyCarbonQuotaInfoDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Operation(summary="保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody QyCarbonQuotaInfoDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
qyCarbonQuotaInfoService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Operation(summary="修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody QyCarbonQuotaInfoDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
qyCarbonQuotaInfoService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@Operation(summary="删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids){ |
|||
//效验数据 |
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
qyCarbonQuotaInfoService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/region/{id}") |
|||
@Operation(summary = "获取单个区域信息") |
|||
public Result<QyRegionEntity> getRegionById(@PathVariable("id") Long id) { |
|||
try { |
|||
QyRegionEntity region = qyCarbonQuotaInfoService.getRegionById(id); // 通过ID获取区域的服务方法 |
|||
return new Result<QyRegionEntity>().ok(region); |
|||
} catch (Exception e) { |
|||
return new Result<QyRegionEntity>().error("获取区域信息失败: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/state") |
|||
@Operation(summary = "获取碳配额状态统计和百分比") |
|||
public Result<Map<String, String>> getCarbonQuotaStatisticsWithStatePercentage() { |
|||
Map<String, String> statisticsWithPercentage = qyCarbonQuotaInfoService.getCarbonQuotaStatisticsWithStatePercentage(); |
|||
return new Result<Map<String, String>>().ok(statisticsWithPercentage); |
|||
} |
|||
|
|||
@GetMapping("/region") |
|||
@Operation(summary = "获取区域减排量占比") |
|||
@Parameter(name = "region", description = "区域名称") |
|||
public Result<List<Map<String, String>>>getEmissionReductionPercentages() { |
|||
List<Map<String, String>> percentage = qyCarbonQuotaInfoService.getEmissionReductionPercentagesByState(); |
|||
return new Result<List<Map<String, String>>>().ok(percentage); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,125 @@ |
|||
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.QyCcerInfoDTO; |
|||
import com.thing.qingyuan.carbon.dto.QyCcerSumInfoDTO; |
|||
import com.thing.qingyuan.carbon.service.QyCcerInfoService; |
|||
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 java.math.BigDecimal; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* CCER信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("v2/ccer/info") |
|||
@Tag(name="CCER信息总览") |
|||
@RequiredArgsConstructor |
|||
public class QyCcerInfoController { |
|||
|
|||
private final QyCcerInfoService qyCcerInfoService; |
|||
|
|||
@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<PageData<QyCcerInfoDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ |
|||
PageData<QyCcerInfoDTO> page = qyCcerInfoService.getPageData(params, QyCcerInfoDTO.class); |
|||
return new Result<PageData<QyCcerInfoDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary="信息") |
|||
public Result<QyCcerInfoDTO> get(@PathVariable("id") Long id){ |
|||
QyCcerInfoDTO data = qyCcerInfoService.getByIdAs(id, QyCcerInfoDTO.class); |
|||
return new Result<QyCcerInfoDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Operation(summary="保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody QyCcerInfoDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
qyCcerInfoService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Operation(summary="修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody QyCcerInfoDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
qyCcerInfoService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@Operation(summary="删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids){ |
|||
//效验数据 |
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
qyCcerInfoService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
/** |
|||
* 获取根据状态统计的CCER数量 |
|||
* @return 各状态的CCER数量 |
|||
*/ |
|||
@GetMapping("/count/ByState") |
|||
@Operation(summary = "根据状态统计CCER数量", description = "待申请、已申请三种状态的CCER数量") |
|||
public Result<Map<String, String>> countCcerByState() { |
|||
Map<String, String> countResult = qyCcerInfoService.countCcerByState(); |
|||
return new Result<Map<String, String>>().ok(countResult); |
|||
} |
|||
|
|||
/** |
|||
* 根据区域与小区统计成交量,并计算每个小镇在所属区域内的成交量占比 |
|||
* @return 返回一个List,包含每个区域下每个小镇的成交量占比 |
|||
*/ |
|||
@GetMapping("/region") |
|||
@Operation(summary = "获取区域减排量占比") |
|||
@Parameter(name = "region", description = "区域名称") |
|||
public Result<List<Map<String, String>>>getEmissionReductionPercentages() { |
|||
List<Map<String, String>> percentage = qyCcerInfoService.getEmissionReductionPercentagesByState(); |
|||
return new Result<List<Map<String, String>>>().ok(percentage); |
|||
} |
|||
/** |
|||
*获取今日的总成交量 |
|||
* @return 今日的总成交量 |
|||
*/ |
|||
@GetMapping("/today") |
|||
@Operation(summary = "今日总成交量",description = "获取今日的总成交量") |
|||
public Result<QyCcerSumInfoDTO> getTodayTotalVolume() { |
|||
// 获取今日总成交量,假设按时间段分的结果 |
|||
QyCcerSumInfoDTO volumeList = qyCcerInfoService.getTodayTotalTransactionVolumeAndPriceByTime(); |
|||
// 返回总成交量的列表映射 |
|||
return new Result<QyCcerSumInfoDTO>().ok(volumeList); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
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.UpdateGroup; |
|||
import com.thing.common.core.web.response.PageData; |
|||
import com.thing.common.core.web.response.Result; |
|||
import com.thing.qingyuan.carbon.dto.QyGreenCertificateInfoDTO; |
|||
import com.thing.qingyuan.carbon.service.QyGreenCertificateInfoService; |
|||
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 jakarta.validation.groups.Default; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("v2/qy/green/certificate/info") |
|||
@Tag(name = "绿证信息总览") |
|||
@RequiredArgsConstructor |
|||
public class QyGreenCertificateInfoController { |
|||
|
|||
private final QyGreenCertificateInfoService qyGreenCertificateInfoService; |
|||
|
|||
@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<PageData<QyGreenCertificateInfoDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) { |
|||
PageData<QyGreenCertificateInfoDTO> page = qyGreenCertificateInfoService.getPageData(params, QyGreenCertificateInfoDTO.class); |
|||
return new Result<PageData<QyGreenCertificateInfoDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary = "信息") |
|||
public Result<QyGreenCertificateInfoDTO> info(@PathVariable("id") Integer id) { |
|||
QyGreenCertificateInfoDTO data = qyGreenCertificateInfoService.getByIdAs(id, QyGreenCertificateInfoDTO.class); |
|||
return new Result<QyGreenCertificateInfoDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping() |
|||
@Operation(summary = "保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody QyGreenCertificateInfoDTO dto) { |
|||
//校验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, Default.class); |
|||
qyGreenCertificateInfoService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
@PutMapping() |
|||
@Operation(summary = "修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody QyGreenCertificateInfoDTO dto) { |
|||
//校验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, Default.class); |
|||
qyGreenCertificateInfoService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
@DeleteMapping() |
|||
@Operation(summary = "删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids) { |
|||
//校验数据 |
|||
AssertUtils.isArrayEmpty(ids,"id"); |
|||
qyGreenCertificateInfoService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
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.QyRegionDTO; |
|||
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 java.util.Map; |
|||
|
|||
/** |
|||
* 区域列表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-12 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("v2/qyregion") |
|||
@Tag(name="区域列表") |
|||
@RequiredArgsConstructor |
|||
public class QyRegionController { |
|||
|
|||
private final QyRegionService qyRegionService; |
|||
|
|||
@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<PageData<QyRegionDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ |
|||
PageData<QyRegionDTO> page = qyRegionService.getPageData(params, QyRegionDTO.class); |
|||
return new Result<PageData<QyRegionDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
@Operation(summary="信息") |
|||
public Result<QyRegionDTO> get(@PathVariable("id") Long id){ |
|||
QyRegionDTO data = qyRegionService.getByIdAs(id, QyRegionDTO.class); |
|||
return new Result<QyRegionDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Operation(summary="保存") |
|||
@LogOperation("保存") |
|||
public Result<Void> save(@RequestBody QyRegionDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
qyRegionService.saveDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Operation(summary="修改") |
|||
@LogOperation("修改") |
|||
public Result<Void> update(@RequestBody QyRegionDTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
qyRegionService.updateDto(dto); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
@Operation(summary="删除") |
|||
@LogOperation("删除") |
|||
public Result<Void> delete(@RequestBody Long[] ids){ |
|||
//效验数据 |
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
qyRegionService.batchDelete(ids); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
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; |
|||
|
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
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; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 碳配额信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-14 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "碳配额信息总览") |
|||
public class QyCarbonQuotaInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "主键") |
|||
private Long id; |
|||
@Schema(description = "碳配额状态:1.累计碳配额(tCO2) 2.待发放碳配额(tCO2) 3.已发放碳配额(tCO2)") |
|||
private String state; |
|||
@Schema(description = "项目名称") |
|||
private String name; |
|||
@Schema(description = "项目编号") |
|||
private String projectCode; |
|||
@Schema(description = "认证周期") |
|||
private Long certificationCycle; |
|||
@Schema(description = "认证时间段") |
|||
private Long certificationTime; |
|||
@Schema(description = "类别:1.累计碳配额(tCO2) 2.待发放碳配额(tCO2) 3.已发放碳配额(tCO2)") |
|||
private String category; |
|||
@Schema(description = "认证完成日期") |
|||
private Long certificationFinishDate; |
|||
@Schema(description = "区域") |
|||
private String region; |
|||
@Schema(description = "发放日期") |
|||
private Long issueDate; |
|||
@Schema(description = "碳配额/tCO2") |
|||
private BigDecimal carbonQuota; |
|||
@Schema(description = "小镇名称") |
|||
private String town; |
|||
@Schema(description = "创建者") |
|||
private Long creator; |
|||
@Schema(description = "创建时间") |
|||
private Long createDate; |
|||
@Schema(description = "更新者") |
|||
private Long updater; |
|||
@Schema(description = "更新时间") |
|||
private Long updateDate; |
|||
@Schema(description = "租户编码") |
|||
private Long tenantCode; |
|||
@Schema(description = "公司id") |
|||
private Long companyId; |
|||
@Schema(description = "部门id") |
|||
private Long deptId; |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
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; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 区域碳配额统计信息 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-14 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "区域碳配额统计信息") |
|||
public class QyCarbonSumQuotaInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "区域") |
|||
private String region; |
|||
@Schema(description = "统计") |
|||
private String total; |
|||
@Schema(description = "状态") |
|||
private String state; |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
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; |
|||
import java.math.BigDecimal; |
|||
import java.time.LocalDate; |
|||
|
|||
/** |
|||
* CCER信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "CCER信息总览") |
|||
public class QyCcerInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "主键") |
|||
private Long id; |
|||
@Schema(description = "CCER状态:1.待申请CCER(tCO2) 2.已申请CCER(tCO2)") |
|||
private String state; |
|||
@Schema(description = "项目名称") |
|||
private String name; |
|||
@Schema(description = "所属企业") |
|||
private String belongCompany; |
|||
@Schema(description = "所属区域") |
|||
private String belongRegion; |
|||
@Schema(description = "第一次减排量备案") |
|||
private String firstEmission; |
|||
@Schema(description = "备案减排量") |
|||
private Double recordEmission; |
|||
@Schema(description = "减排量时间") |
|||
private Long emissionTime; |
|||
@Schema(description = "核证机构") |
|||
private String certificationAuthority; |
|||
@Schema(description = "价格") |
|||
private Double price; |
|||
@Schema(description = "创建者") |
|||
private Long creator; |
|||
@Schema(description = "创建时间") |
|||
private Long createDate; |
|||
@Schema(description = "更新者") |
|||
private Long updater; |
|||
@Schema(description = "更新时间") |
|||
private Long updateDate; |
|||
@Schema(description = "租户编码") |
|||
private Long tenantCode; |
|||
@Schema(description = "公司id") |
|||
private Long companyId; |
|||
@Schema(description = "部门id") |
|||
private Long deptId; |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
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; |
|||
|
|||
@Data |
|||
@Schema(description = "区域成交量统计信息") |
|||
public class QyCcerSumInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "区域") |
|||
private String belongRegion; |
|||
@Schema(description = "统计") |
|||
private String total; |
|||
@Schema(description = "状态") |
|||
private String state; |
|||
@Schema(description = "价格") |
|||
private Double price; |
|||
@Schema(description = "备案减排量") |
|||
private Double recordEmission; |
|||
@Schema(description = "待申请CCER") |
|||
private Double pending; |
|||
@Schema(description = "已申请CCER") |
|||
private Double applied; |
|||
@Schema(description = "累计CCER") |
|||
private Double total1; |
|||
} |
|||
|
|||
@ -0,0 +1,50 @@ |
|||
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-17 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "绿证信息总览") |
|||
public class QyGreenCertificateInfoDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "主键") |
|||
private Long id; |
|||
@Schema(description = "绿证状态:1.累计绿证(MWH) 2.待发放绿证(MWH) 3.已申请绿证(MWH)") |
|||
private String state; |
|||
@Schema(description = "发电类型") |
|||
private String powerType; |
|||
@Schema(description = "申请日期") |
|||
private Long applicationDate; |
|||
@Schema(description = "核发日期") |
|||
private Long dateIssue; |
|||
@Schema(description = "绿证能源总量") |
|||
private String greenTotal; |
|||
@Schema(description = "绿证证书代码") |
|||
private String greenCode; |
|||
@Schema(description = "创建者") |
|||
private Long creator; |
|||
@Schema(description = "创建时间") |
|||
private Long createDate; |
|||
@Schema(description = "更新者") |
|||
private Long updater; |
|||
@Schema(description = "更新时间") |
|||
private Long updateDate; |
|||
@Schema(description = "租户编码") |
|||
private String tenantCode; |
|||
@Schema(description = "公司id") |
|||
private Long companyId; |
|||
@Schema(description = "部门id") |
|||
private Long deptId; |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
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 QyRegionDTO implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "主键") |
|||
private Long id; |
|||
@Schema(description = "区域名称") |
|||
private String name; |
|||
@Schema(description = "创建者") |
|||
private Long creator; |
|||
@Schema(description = "创建时间") |
|||
private Long createDate; |
|||
@Schema(description = "更新者") |
|||
private Long updater; |
|||
@Schema(description = "更新时间") |
|||
private Long updateDate; |
|||
|
|||
public QyRegionDTO(Long id, String name) { |
|||
this.id = id; |
|||
this.name = name; |
|||
} |
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
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; |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
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; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 碳配额信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-14 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("qy_carbon_quota_info") |
|||
public class QyCarbonQuotaInfoEntity extends BaseInfoEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 碳配额状态:1.累计碳配额(tCO2) 2.待发放碳配额(tCO2) 3.已发放碳配额(tCO2) |
|||
*/ |
|||
private String state; |
|||
/** |
|||
* 项目名称 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 项目编号 |
|||
*/ |
|||
private String projectCode; |
|||
/** |
|||
* 认证周期 |
|||
*/ |
|||
private Long certificationCycle; |
|||
/** |
|||
* 认证时间段 |
|||
*/ |
|||
private Long certificationTime; |
|||
/** |
|||
* 类别:1.累计碳配额(tCO2) 2.待发放碳配额(tCO2) 3.已发放碳配额(tCO2) |
|||
*/ |
|||
private String category; |
|||
/** |
|||
* 认证完成日期 |
|||
*/ |
|||
private Long certificationFinishDate; |
|||
/** |
|||
* 区域 |
|||
*/ |
|||
private String region; |
|||
/** |
|||
* 发放日期 |
|||
*/ |
|||
private Long issueDate; |
|||
/** |
|||
* 碳配额/tCO2 |
|||
*/ |
|||
private BigDecimal carbonQuota; |
|||
/** |
|||
* 小镇名称 |
|||
*/ |
|||
private String town; |
|||
|
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
package com.thing.qingyuan.carbon.entity; |
|||
|
|||
import com.mybatisflex.annotation.Table; |
|||
import com.thing.common.orm.entity.BaseInfoEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* CCER信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@Table("qy_ccer_info") |
|||
public class QyCcerInfoEntity extends BaseInfoEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
/** |
|||
* CCER状态:1.待申请CCER(tCO2) 2.已申请CCER(tCO2) |
|||
*/ |
|||
private String state; |
|||
|
|||
/** |
|||
* 项目名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 所属企业 |
|||
*/ |
|||
private String belongCompany; |
|||
|
|||
/** |
|||
* 所属区域 |
|||
*/ |
|||
private String belongRegion; |
|||
|
|||
/** |
|||
* 第一次减排量备案 |
|||
*/ |
|||
private String firstEmission; |
|||
|
|||
/** |
|||
* 备案减排量 |
|||
*/ |
|||
private Double recordEmission; |
|||
|
|||
/** |
|||
* 减排量时间 |
|||
*/ |
|||
private Long emissionTime; |
|||
|
|||
/** |
|||
* 核证机构 |
|||
*/ |
|||
private String certificationAuthority; |
|||
|
|||
/** |
|||
* 价格 |
|||
*/ |
|||
|
|||
private Double price; |
|||
|
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
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; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 绿证信息总览 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-17 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@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) 3.已申请绿证(MWH) |
|||
*/ |
|||
private String state; |
|||
/** |
|||
* 发电类型 |
|||
*/ |
|||
private String powerType; |
|||
/** |
|||
* 申请日期 |
|||
*/ |
|||
private Long applicationDate; |
|||
/** |
|||
* 核发日期 |
|||
*/ |
|||
private Long dateIssue; |
|||
/** |
|||
* 绿证能源总量 |
|||
*/ |
|||
private String greenTotal; |
|||
/** |
|||
* 绿证证书代码 |
|||
*/ |
|||
private String greenCode; |
|||
|
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
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; |
|||
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_region") |
|||
public class QyRegionEntity extends BaseInfoEntity implements Serializable { |
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 区域名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.thing.qingyuan.carbon.exception; |
|||
|
|||
|
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
public class BusinessException extends RuntimeException { |
|||
// 获取错误码 |
|||
// 错误码 |
|||
private final String code; |
|||
// 错误信息 |
|||
private final String message; |
|||
|
|||
// 无参构造函数 |
|||
public BusinessException() { |
|||
super(); |
|||
this.code = "500"; // 默认为500 |
|||
this.message = "业务异常"; |
|||
} |
|||
|
|||
// 传入错误信息的构造函数 |
|||
public BusinessException(String message) { |
|||
super(message); |
|||
this.code = "500"; // 默认为500 |
|||
this.message = message; |
|||
} |
|||
|
|||
// 传入错误码和错误信息的构造函数 |
|||
public BusinessException(String code, String message) { |
|||
super(message); |
|||
this.code = code; |
|||
this.message = message; |
|||
} |
|||
|
|||
// 获取错误信息 |
|||
@Override |
|||
public String getMessage() { |
|||
return message; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,71 @@ |
|||
package com.thing.qingyuan.carbon.mapper; |
|||
|
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface QyCarbonQuotaInfoMapper extends PowerBaseMapper<QyCarbonQuotaInfoEntity> { |
|||
|
|||
/** |
|||
* 查询指定状态下的碳配额总和 |
|||
* @param state 状态值 |
|||
* @return 返回碳配额的总和 |
|||
*/ |
|||
@Select("SELECT SUM(carbonQuota) " + |
|||
"FROM qy_carbon_quota_info " + |
|||
"WHERE state = #{state}") |
|||
BigDecimal getTotalCarbonQuotaByState(String state); |
|||
|
|||
|
|||
/** |
|||
* 查询指定小镇和区域的碳配额总和 |
|||
* @param town 小镇名称 |
|||
* @param region 区域名称 |
|||
* @return 返回小镇在指定区域的碳配额总和 |
|||
*/ |
|||
@Select("SELECT SUM(carbonQuota) " + |
|||
"FROM qy_carbon_quota_info " + |
|||
"WHERE town = #{town} AND region = #{region}") |
|||
BigDecimal getTotalCarbonQuotaByTown(@Param("town") String town, @Param("region") String region); |
|||
|
|||
/** |
|||
* 查询指定区域的所有小镇名称 |
|||
* @param region 区域名称 |
|||
* @return 返回该区域下所有小镇的列表 |
|||
*/ |
|||
@Select("SELECT DISTINCT town " + |
|||
"FROM qy_carbon_quota_info " + |
|||
"WHERE region = #{region}") |
|||
List<String> getDistinctTownsByRegion(@Param("region") String region); |
|||
|
|||
/** |
|||
* 查询所有碳配额的总和 |
|||
* @return 返回所有碳配额的总和 |
|||
*/ |
|||
@Select("SELECT SUM(carbonQuota) " + |
|||
"FROM qy_carbon_quota_info") |
|||
BigDecimal selectSumCarbonQuota(); |
|||
|
|||
/** |
|||
* 根据状态查询碳配额 |
|||
* @param number 状态值 |
|||
* @return 返回该状态下的碳配额总和 |
|||
*/ |
|||
@Select("SELECT SUM(carbonQuota) " + |
|||
"FROM qy_carbon_quota_info " + |
|||
"WHERE state = #{number}") |
|||
BigDecimal selectCarbonQuotaByState(String number); |
|||
|
|||
/** |
|||
* 获取指定小镇的减排量占比 |
|||
* @param regions 小镇名称 |
|||
* @return 小镇的减排量占比 |
|||
*/ |
|||
List<QyCarbonQuotaInfoEntity> findByTownIn(List<String> regions); |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
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<QyCarbonQuotaEntity> { |
|||
|
|||
/** |
|||
* 通过区域查询碳配额信息 |
|||
* @param region 区域 |
|||
* @return 区域内的碳配额信息表 |
|||
*/ |
|||
@Select("SELECT * FROM qy_carbon_quota WHERE region = #{region}") |
|||
List<QyCarbonQuotaEntity> findByRegion(String region); |
|||
|
|||
/** |
|||
* 通过名称查询碳配额信息 |
|||
* @param name 名称 |
|||
* @return 匹配的碳配额信息表 |
|||
*/ |
|||
@Select("SELECT * FROM qy_carbon_quota WHERE name = #{name}") |
|||
List<QyCarbonQuotaEntity> findByName(String name); |
|||
|
|||
/** |
|||
* 通过区域和状态查询碳配额信息 |
|||
* @param region 区域 |
|||
* @param carbonState 碳状态 |
|||
* @return 区域和状态匹配的碳配额信息 |
|||
*/ |
|||
@Select("SELECT * FROM qy_carbon_quota WHERE region = #{region} AND carbon_state = #{carbonState}") |
|||
List<QyCarbonQuotaEntity> findByRegionAndState(@Param("region") String region, @Param("carbonState") String carbonState); |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.thing.qingyuan.carbon.mapper; |
|||
|
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import com.thing.qingyuan.carbon.dto.QyCcerInfoDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
import org.springframework.dao.DataAccessException; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface QyCcerInfoMapper extends PowerBaseMapper<QyCcerInfoEntity> { |
|||
|
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
package com.thing.qingyuan.carbon.mapper; |
|||
|
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface QyGreenCertificateInfoMapper extends PowerBaseMapper<QyGreenCertificateInfoEntity> { |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package com.thing.qingyuan.carbon.mapper; |
|||
|
|||
import com.thing.common.orm.mapper.PowerBaseMapper; |
|||
import com.thing.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
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 QyRegionMapper extends PowerBaseMapper<QyRegionEntity> { |
|||
|
|||
/** |
|||
* 获取所有区域的列表,包括每个区域的基本信息。 |
|||
* @return 区域列表,包含区域基本信息的 DTO |
|||
*/ |
|||
@Select("SELECT * FROM qy_region") |
|||
List<QyRegionDTO> findAll(); |
|||
|
|||
/** |
|||
* 查询所有区域实体数据 |
|||
* @param o 过滤条件或查询参数,可以传入null查询所有区域 |
|||
* @return 区域列表,包含区域的实体信息 |
|||
*/ |
|||
@Select("<script>" + |
|||
"SELECT * FROM qy_region" + |
|||
"<where>" + |
|||
"<if test='o != null'> AND region_name = #{o.regionName} </if>" + |
|||
"</where>" + |
|||
"</script>") |
|||
List<QyRegionEntity> selectList(@Param("o") Object o); |
|||
|
|||
/** |
|||
* 根据区域 ID 查询指定区域 |
|||
* @param id 区域的唯一标识 |
|||
* @return 返回对应区域的实体对象 |
|||
*/ |
|||
@Select("SELECT * FROM qy_region WHERE id = #{id}") |
|||
QyRegionEntity selectById(Long id); |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
|
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
public interface QyCarbonQuotaInfoService extends IBaseService<QyCarbonQuotaInfoEntity> { |
|||
|
|||
/** |
|||
* 获取区域减排量占比 |
|||
* |
|||
* @return 返回一个Map,键为区域名称,值为该区域减排量占总碳配额的百分比 |
|||
*/ |
|||
List<Map<String, String>> getEmissionReductionPercentagesByState(); |
|||
|
|||
/** |
|||
* 根据ID获取指定区域 |
|||
* |
|||
* @param id 区域ID |
|||
* @return 返回区域对象 |
|||
*/ |
|||
QyRegionEntity getRegionById(Long id); |
|||
|
|||
/** |
|||
* 统计当前碳配额总和和三种状态所占百分比 |
|||
* |
|||
* @return 返回一个Map,其中包含: |
|||
* 1. "total" - 当前总碳配额 |
|||
* 2. "state1Percentage" - 累计碳配额状态的百分比 |
|||
* 3. "state2Percentage" - 待发放碳配额状态的百分比 |
|||
* 4. "state3Percentage" - 已发放碳配额状态的百分比 |
|||
*/ |
|||
Map<String, String> getCarbonQuotaStatisticsWithStatePercentage(); |
|||
|
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,42 @@ |
|||
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<QyCarbonQuotaEntity> { |
|||
/** |
|||
* 认证减排量 |
|||
* @param dto 认证减排量DTO |
|||
*/ |
|||
void validate(QyCarbonQuotaDTO dto); |
|||
/** |
|||
* 根据类别决定项目处理逻辑 |
|||
* @param category 项目类别 |
|||
* @return 不同类别的处理结果 |
|||
*/ |
|||
String handleByCategory(String category); |
|||
/** |
|||
* 根据区域查询碳配额 |
|||
* @param region 区域名称 |
|||
* @return 碳配额实体列表 |
|||
*/ |
|||
List<QyCarbonQuotaEntity> findByRegion(String region); |
|||
|
|||
/** |
|||
* 根据名称查询碳配额 |
|||
* @param name 配额名称 |
|||
* @return 碳配额实体列表 |
|||
*/ |
|||
List<QyCarbonQuotaEntity> findByName(String name); |
|||
|
|||
/** |
|||
* 根据区域和碳状态查询碳配额 |
|||
* @param region 区域名称 |
|||
* @param carbonState 碳配额状态 |
|||
* @return 碳配额实体列表 |
|||
*/ |
|||
List<QyCarbonQuotaEntity> findByRegionAndState(String region, String carbonState); |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
|
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.carbon.dto.QyCcerSumInfoDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface QyCcerInfoService extends IBaseService<QyCcerInfoEntity> { |
|||
|
|||
/** |
|||
* 根据状态统计CCER数量 |
|||
* @return 各状态的CCER数量 |
|||
*/ |
|||
Map<String, String> countCcerByState(); |
|||
|
|||
/** |
|||
* 根据区域与小镇统计成交量,并计算每个小镇在所属区域内的成交量占比 |
|||
* @return 返回一个Map,包含每个区域下每个小镇的成交量占比 |
|||
*/ |
|||
List<Map<String, String>> getEmissionReductionPercentagesByState(); |
|||
|
|||
|
|||
/** |
|||
* 获取今日的总成交量和今日总成交金额 |
|||
* @return 今日的总成交量和今日总成交金额 |
|||
*/ |
|||
QyCcerSumInfoDTO getTodayTotalTransactionVolumeAndPriceByTime(); |
|||
|
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; |
|||
|
|||
public interface QyGreenCertificateInfoService extends IBaseService<QyGreenCertificateInfoEntity> { |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package com.thing.qingyuan.carbon.service; |
|||
|
|||
import com.thing.common.orm.service.IBaseService; |
|||
import com.thing.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 区域列表 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2025-02-12 |
|||
*/ |
|||
public interface QyRegionService extends IBaseService<QyRegionEntity> { |
|||
|
|||
/** |
|||
* 获取所有区域列表 |
|||
* @return 所有区域的DTO列表 |
|||
*/ |
|||
List<QyRegionDTO> getAllRegions(); |
|||
} |
|||
@ -0,0 +1,143 @@ |
|||
package com.thing.qingyuan.carbon.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import com.google.common.collect.Lists; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import com.thing.qingyuan.carbon.dto.QyCarbonSumQuotaInfoDTO; |
|||
import com.thing.qingyuan.carbon.dto.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
import com.thing.qingyuan.carbon.mapper.QyCarbonQuotaInfoMapper; |
|||
import com.thing.qingyuan.carbon.mapper.QyRegionMapper; |
|||
import com.thing.qingyuan.carbon.service.QyCarbonQuotaInfoService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.mybatisflex.core.query.QueryMethods.sum; |
|||
import static com.thing.qingyuan.carbon.entity.table.QyCarbonQuotaInfoEntityTableDef.QY_CARBON_QUOTA_INFO_ENTITY; |
|||
|
|||
@Service |
|||
public class QyCarbonQuotaInfoServiceImpl extends BaseServiceImpl<QyCarbonQuotaInfoMapper, QyCarbonQuotaInfoEntity> implements QyCarbonQuotaInfoService { |
|||
|
|||
|
|||
@Resource |
|||
private QyRegionMapper qyRegionMapper; |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper queryWrapper = new QueryWrapper(); |
|||
if (params.containsKey("state")) { |
|||
queryWrapper.eq("state", params.get("state")); |
|||
} |
|||
if (params.containsKey("region")) { |
|||
queryWrapper.eq("region", params.get("region")); |
|||
} |
|||
if (params.containsKey("name")) { |
|||
queryWrapper.like("name", params.get("name")); |
|||
} |
|||
if (params.containsKey("projectCode")) { |
|||
queryWrapper.eq("projectCode", params.get("projectCode")); |
|||
} |
|||
if (params.containsKey("startDate") && params.containsKey("endDate")) { |
|||
queryWrapper.between("issueDate", params.get("startDate"), params.get("endDate")); |
|||
} |
|||
if (params.containsKey("createDateStart") && params.containsKey("createDateEnd")) { |
|||
queryWrapper.between("createDate", params.get("createDateStart"), params.get("createDateEnd")); |
|||
} |
|||
return queryWrapper; |
|||
} |
|||
|
|||
/** |
|||
* 统计当前碳配额总和和三种状态所占百分比 |
|||
* @return 返回一个Map,其中包含: |
|||
*/ |
|||
@Override |
|||
public Map<String, String> getCarbonQuotaStatisticsWithStatePercentage() { |
|||
QueryWrapper queryWrapper1 = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|||
.eq(QyCarbonQuotaInfoEntity::getState, "1"); |
|||
//sum1 待发放碳配额总量 |
|||
String sum1 = mapper.selectOneByQueryAs(queryWrapper1, String.class); |
|||
QueryWrapper queryWrapper2 = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|||
.eq(QyCarbonQuotaInfoEntity::getState, "2"); |
|||
//sum2 已发放碳配额总量 |
|||
String sum2 = mapper.selectOneByQueryAs(queryWrapper2, String.class); |
|||
//sum 为总碳配额量 即累计(sum=sum1+sum2) |
|||
QueryWrapper queryWrapper3 = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY); |
|||
String sum = mapper.selectOneByQueryAs(queryWrapper3, String.class); |
|||
|
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
//已发放碳配额 |
|||
tempMap.put("issuedPercent", new BigDecimal(sum1).divide(new BigDecimal(sum), 2, RoundingMode.HALF_UP).toString()); |
|||
//待申请碳配额 |
|||
tempMap.put("pendingPercent", new BigDecimal(sum2).divide(new BigDecimal(sum), 2, RoundingMode.HALF_UP).toString()); |
|||
tempMap.put("issued",sum1); |
|||
tempMap.put("pending",sum2); |
|||
tempMap.put("total",sum); |
|||
return tempMap; |
|||
} |
|||
/** |
|||
* 获取指定小镇的减排量占比 |
|||
* @return 返回所有指定小镇的减排量占比 |
|||
*/ |
|||
@Override |
|||
public List<Map<String, String>> getEmissionReductionPercentagesByState() { |
|||
// 示例区域列表,可根据实际情况查询数据库中的区域列表 |
|||
List<String> regions = Arrays.asList("天玉镇", "河东街道", "富滩镇", "值夏镇", "文陂镇", "富田镇", "东固畲族乡","新圩镇"); |
|||
// 查询区域和碳配额总和 |
|||
QueryWrapper queryWrapper4 = QueryWrapper.create() |
|||
.select(QY_CARBON_QUOTA_INFO_ENTITY.REGION,sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total") ) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|||
.groupBy(QY_CARBON_QUOTA_INFO_ENTITY.REGION); |
|||
// 查询符合条件的小镇碳配额数据 |
|||
List<QyCarbonSumQuotaInfoDTO> quotaList1 = mapper.selectListByQueryAs(queryWrapper4,QyCarbonSumQuotaInfoDTO.class); |
|||
//查询总量 |
|||
QueryWrapper queryWrapper5 = QueryWrapper.create() |
|||
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total") ) |
|||
.from(QY_CARBON_QUOTA_INFO_ENTITY); |
|||
String sumtotal = mapper.selectOneByQueryAs(queryWrapper5, String.class); |
|||
// 存储最终结果 |
|||
List<Map<String, String>> resultList = new ArrayList<>(); |
|||
List<String> tempRegions = Lists.newArrayList(); |
|||
for (QyCarbonSumQuotaInfoDTO quotaInfoDTO : quotaList1) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
//占比 |
|||
tempMap.put("percent", new BigDecimal(quotaInfoDTO.getTotal()).divide(new BigDecimal(sumtotal), 2, RoundingMode.HALF_UP).toString()); |
|||
tempMap.put("region", quotaInfoDTO.getRegion()); |
|||
resultList.add(tempMap); |
|||
tempRegions.add(quotaInfoDTO.getRegion()); |
|||
} |
|||
//差集 |
|||
Collection<String> disjunction = CollectionUtil.disjunction(regions, tempRegions); |
|||
for (String s : disjunction) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
tempMap.put("percent", "0"); |
|||
tempMap.put("region", s); |
|||
resultList.add(tempMap); |
|||
} |
|||
return resultList; |
|||
} |
|||
|
|||
/** |
|||
* 根据ID获取指定区域 |
|||
* @param id 区域ID |
|||
* @return 返回区域对象 |
|||
*/ |
|||
@Override |
|||
public QyRegionEntity getRegionById(Long id) { |
|||
return qyRegionMapper.selectById(id); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,113 @@ |
|||
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<QyCarbonQuotaMapper, QyCarbonQuotaEntity> implements QyCarbonQuotaService { |
|||
|
|||
@Resource |
|||
private QyCarbonQuotaMapper qyCarbonQuotaMapper; |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> 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<QyCarbonQuotaEntity> findByRegion(String region) { |
|||
return qyCarbonQuotaMapper.findByRegion(region); |
|||
} |
|||
|
|||
/** |
|||
* 根据名称查询碳配额 |
|||
* @param name 配额名称 |
|||
* @return 碳配额实体列表 |
|||
*/ |
|||
@Override |
|||
public List<QyCarbonQuotaEntity> findByName(String name) { |
|||
return qyCarbonQuotaMapper.findByName(name); |
|||
} |
|||
|
|||
/** |
|||
* 根据区域和碳状态查询碳配额 |
|||
* @param region 区域名称 |
|||
* @param carbonState 碳配额状态 |
|||
* @return 碳配额实体列表 |
|||
*/ |
|||
@Override |
|||
public List<QyCarbonQuotaEntity> 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("未知的项目类别"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,194 @@ |
|||
package com.thing.qingyuan.carbon.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import com.google.common.collect.Lists; |
|||
import com.mybatisflex.core.query.QueryWrapper; |
|||
import com.thing.common.orm.service.impl.BaseServiceImpl; |
|||
import com.thing.qingyuan.carbon.dto.QyCcerInfoDTO; |
|||
import com.thing.qingyuan.carbon.dto.QyCcerSumInfoDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|||
import com.thing.qingyuan.carbon.mapper.QyCcerInfoMapper; |
|||
import com.thing.qingyuan.carbon.service.QyCcerInfoService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.time.ZoneId; |
|||
import java.util.*; |
|||
|
|||
import static com.mybatisflex.core.query.QueryMethods.sum; |
|||
import static com.thing.qingyuan.carbon.entity.table.QyCcerInfoEntityTableDef.QY_CCER_INFO_ENTITY; |
|||
|
|||
|
|||
@Service |
|||
public class QyCcerInfoServiceImpl extends BaseServiceImpl<QyCcerInfoMapper, QyCcerInfoEntity> implements QyCcerInfoService { |
|||
|
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper qw = new QueryWrapper(); |
|||
|
|||
// 判断并处理查询参数 |
|||
if (params != null) { |
|||
// 根据项目名称查询 |
|||
if (params.containsKey("name") && params.get("name") != null) { |
|||
qw.like("name", params.get("name")); |
|||
} |
|||
// 根据CCER状态查询 |
|||
if (params.containsKey("state") && params.get("state") != null) { |
|||
qw.eq("state", params.get("state")); |
|||
} |
|||
// 根据所属企业查询 |
|||
if (params.containsKey("belongCompany") && params.get("belongCompany") != null) { |
|||
qw.like("belongCompany", params.get("belongCompany")); |
|||
} |
|||
// 根据所属区域查询 |
|||
if (params.containsKey("belongRegion") && params.get("belongRegion") != null) { |
|||
qw.like("belongRegion", params.get("belongRegion")); |
|||
} |
|||
// 根据所属小镇查询 |
|||
if (params.containsKey("belongTown") && params.get("belongTown") != null) { |
|||
qw.like("belongTown", params.get("belongTown")); |
|||
} |
|||
// 根据创建时间范围查询 |
|||
if (params.containsKey("createDateStart") && params.get("createDateStart") != null) { |
|||
qw.ge("createDate", params.get("createDateStart")); // >= |
|||
} |
|||
if (params.containsKey("createDateEnd") && params.get("createDateEnd") != null) { |
|||
qw.le("createDate", params.get("createDateEnd")); // <= |
|||
} |
|||
// 根据更新者查询 |
|||
if (params.containsKey("updater") && params.get("updater") != null) { |
|||
qw.eq("updater", params.get("updater")); |
|||
} |
|||
// 根据租户编码查询 |
|||
if (params.containsKey("tenantCode") && params.get("tenantCode") != null) { |
|||
qw.eq("tenantCode", params.get("tenantCode")); |
|||
} |
|||
// 根据成交量查询 |
|||
if (params.containsKey("transactionVolume") && params.get("transactionVolume") != null) { |
|||
qw.like("transactionVolume", params.get("transactionVolume")); |
|||
} |
|||
} |
|||
|
|||
return qw; |
|||
} |
|||
|
|||
/** |
|||
* 根据状态统计ccer数量 |
|||
* |
|||
* @return 个状态的ccer数量 |
|||
*/ |
|||
@Override |
|||
public Map<String, String> countCcerByState() { |
|||
QueryWrapper queryWrapper1 = QueryWrapper.create() |
|||
.select(QY_CCER_INFO_ENTITY.RECORD_EMISSION.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(QY_CCER_INFO_ENTITY.RECORD_EMISSION.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(QY_CCER_INFO_ENTITY.RECORD_EMISSION.as("total")) |
|||
.from(QY_CCER_INFO_ENTITY); |
|||
//sum3 累计CCER(sum=sum1+sum2) |
|||
String sum3 = mapper.selectOneByQueryAs(queryWrapper3, String.class); |
|||
|
|||
HashMap<String, String> temMap = new HashMap<>(); |
|||
//待申请CCER |
|||
temMap.put("pending", StringUtils.isBlank(sum1) ? "0" : sum1); |
|||
//已申请CCER |
|||
temMap.put("applied", StringUtils.isBlank(sum2) ? "0" : sum2); |
|||
//累计CCER |
|||
temMap.put("total1", StringUtils.isBlank(sum3) ? "0" : sum3); |
|||
return temMap; |
|||
} |
|||
|
|||
/** |
|||
* 获取指定小镇的减排量占比 |
|||
* |
|||
* @return 返回所有指定小镇的减排量占比 |
|||
*/ |
|||
@Override |
|||
public List<Map<String, String>> getEmissionReductionPercentagesByState() { |
|||
// 示例区域列表,可根据实际情况查询数据库中的区域列表 |
|||
List<String> regions = Arrays.asList("天玉镇", "河东街道", "富滩镇", "值夏镇", "文陂镇", "富田镇", "东固畲族乡", "新圩镇"); |
|||
// 根据区域查询成交量总和 |
|||
QueryWrapper queryWrapper = QueryWrapper.create() |
|||
.select(QY_CCER_INFO_ENTITY.BELONG_REGION, sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) |
|||
.from(QY_CCER_INFO_ENTITY) |
|||
.groupBy(QY_CCER_INFO_ENTITY.BELONG_REGION); |
|||
// 查询符合条件的小镇成交量数据 |
|||
List<QyCcerSumInfoDTO> quotaList1 = mapper.selectListByQueryAs(queryWrapper, QyCcerSumInfoDTO.class); |
|||
//查询总量 |
|||
QueryWrapper queryWrapper2 = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) |
|||
.from(QY_CCER_INFO_ENTITY); |
|||
String sumTotal = mapper.selectOneByQueryAs(queryWrapper2, String.class); |
|||
// 存储最终结果 |
|||
List<Map<String, String>> resultList = new ArrayList<>(); |
|||
List<String> tempRegions = Lists.newArrayList(); |
|||
for (QyCcerSumInfoDTO quotaInfoDTO : quotaList1) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
//占比 |
|||
tempMap.put("percent", new BigDecimal(quotaInfoDTO.getTotal()).divide(new BigDecimal(sumTotal), 2, RoundingMode.HALF_UP).toString()); |
|||
tempMap.put("region", quotaInfoDTO.getBelongRegion()); |
|||
resultList.add(tempMap); |
|||
tempRegions.add(quotaInfoDTO.getBelongRegion()); |
|||
} |
|||
//差集 |
|||
Collection<String> disjunction = CollectionUtil.disjunction(regions, tempRegions); |
|||
for (String s : disjunction) { |
|||
Map<String, String> tempMap = new HashMap<>(); |
|||
tempMap.put("percent", "0"); |
|||
tempMap.put("region", s); |
|||
resultList.add(tempMap); |
|||
} |
|||
return resultList; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取今日的总成交量和总成交金额 |
|||
* |
|||
* @return 今日的总成交量和总成交金额 |
|||
*/ |
|||
@Override |
|||
public QyCcerSumInfoDTO getTodayTotalTransactionVolumeAndPriceByTime() { |
|||
// 获取今天的日期 |
|||
LocalDate today = LocalDate.now(); |
|||
// 将今天的日期转换为 Date 类型 |
|||
Long startOfDay = today.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
|||
Long endOfDay = today.atTime(23, 59, 59, 999999999) |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toInstant() |
|||
.toEpochMilli(); |
|||
// 查询今天的总成交量,按时间段分 |
|||
QueryWrapper queryWrapper = QueryWrapper.create() |
|||
.select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("recordEmission"), |
|||
sum(QY_CCER_INFO_ENTITY.PRICE).as("price")) |
|||
.ge(QyCcerInfoEntity::getEmissionTime, startOfDay) |
|||
.le(QyCcerInfoEntity::getEmissionTime, endOfDay) |
|||
.from(QY_CCER_INFO_ENTITY); |
|||
|
|||
// 执行查询,返回结果 |
|||
QyCcerSumInfoDTO qyCcerSumInfoDTO = mapper.selectOneByQueryAs(queryWrapper, QyCcerSumInfoDTO.class); |
|||
if (qyCcerSumInfoDTO == null) { |
|||
qyCcerSumInfoDTO = new QyCcerSumInfoDTO(); |
|||
qyCcerSumInfoDTO.setRecordEmission(0.0); |
|||
qyCcerSumInfoDTO.setPrice(0.0); |
|||
} |
|||
return qyCcerSumInfoDTO; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,20 @@ |
|||
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.entity.QyGreenCertificateInfoEntity; |
|||
import com.thing.qingyuan.carbon.mapper.QyGreenCertificateInfoMapper; |
|||
import com.thing.qingyuan.carbon.service.QyGreenCertificateInfoService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class QyGreenCertificateInfoServiceImpl extends BaseServiceImpl<QyGreenCertificateInfoMapper, QyGreenCertificateInfoEntity> implements QyGreenCertificateInfoService { |
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper qw = new QueryWrapper(); |
|||
return qw; |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
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.QyRegionDTO; |
|||
import com.thing.qingyuan.carbon.entity.QyRegionEntity; |
|||
import com.thing.qingyuan.carbon.mapper.QyRegionMapper; |
|||
import com.thing.qingyuan.carbon.service.QyRegionService; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class QyRegionServiceImpl extends BaseServiceImpl<QyRegionMapper, QyRegionEntity> implements QyRegionService { |
|||
|
|||
@Resource |
|||
private QyRegionMapper qyRegionMapper; |
|||
|
|||
@Override |
|||
public QueryWrapper getWrapper(Map<String, Object> params) { |
|||
QueryWrapper qw = new QueryWrapper(); |
|||
// 判断传入的参数是否为空,如果不为空则构建查询条件 |
|||
if (params.containsKey("name")) { |
|||
qw.like("name", params.get("name")); |
|||
} |
|||
|
|||
if (params.containsKey("type")) { |
|||
qw.eq("type", params.get("type")); |
|||
} |
|||
|
|||
return qw; |
|||
} |
|||
|
|||
/** |
|||
* 获取所有区域列表 |
|||
* @return 所以区域的DTO列表 |
|||
*/ |
|||
@Override |
|||
public List<QyRegionDTO> getAllRegions() { |
|||
try { |
|||
//获取所有区域 |
|||
List<QyRegionDTO> regions = qyRegionMapper.findAll(); |
|||
return regions.stream() |
|||
.map(region -> new QyRegionDTO(region.getId(), region.getName())) |
|||
.collect(Collectors.toList()); |
|||
}catch (Exception e){ |
|||
throw new RuntimeException("获取区域列表失败",e); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
package com.thing.qingyuan.carbon.util; |
|||
|
|||
public enum CategoryEnum { |
|||
DISTRIBUTED_SOLAR(1, "分布光伏项目"), |
|||
LIGHTING_ENERGY_SAVING(2, "照明节能项目"), |
|||
SPECIAL_VEHICLE_CHARGING_PILE(3, "专用车充电桩项目"); |
|||
|
|||
private final int code; |
|||
private final String description; |
|||
|
|||
CategoryEnum(int code, String description) { |
|||
this.code = code; |
|||
this.description = description; |
|||
} |
|||
|
|||
public int getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getDescription() { |
|||
return description; |
|||
} |
|||
|
|||
public static CategoryEnum fromString(String category) { |
|||
for (CategoryEnum c : CategoryEnum.values()) { |
|||
if (c.getDescription().equals(category)) { |
|||
return c; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue