|
|
@ -1,10 +1,9 @@ |
|
|
package com.thing.qingyuan.carbon.service.impl; |
|
|
package com.thing.qingyuan.carbon.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists; |
|
|
import com.mybatisflex.core.query.QueryWrapper; |
|
|
import com.mybatisflex.core.query.QueryWrapper; |
|
|
import com.thing.qingyuan.carbon.dto.QyCarbonAssetDTO; |
|
|
import com.thing.qingyuan.carbon.dto.QyCarbonAssetDTO; |
|
|
import com.thing.qingyuan.carbon.dto.QyCarbonQuotaInfoDTO; |
|
|
|
|
|
import com.thing.qingyuan.carbon.dto.QyCarbonSumQuotaInfoDTO; |
|
|
import com.thing.qingyuan.carbon.dto.QyCarbonSumQuotaInfoDTO; |
|
|
import com.thing.qingyuan.carbon.dto.QyCcerInfoDTO; |
|
|
|
|
|
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|
|
import com.thing.qingyuan.carbon.entity.QyCarbonQuotaInfoEntity; |
|
|
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|
|
import com.thing.qingyuan.carbon.entity.QyCcerInfoEntity; |
|
|
import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; |
|
|
import com.thing.qingyuan.carbon.entity.QyGreenCertificateInfoEntity; |
|
|
@ -13,20 +12,26 @@ import com.thing.qingyuan.carbon.service.QyCarbonQuotaInfoService; |
|
|
import com.thing.qingyuan.carbon.service.QyCcerInfoService; |
|
|
import com.thing.qingyuan.carbon.service.QyCcerInfoService; |
|
|
import com.thing.qingyuan.carbon.service.QyGreenCertificateInfoService; |
|
|
import com.thing.qingyuan.carbon.service.QyGreenCertificateInfoService; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.RoundingMode; |
|
|
import java.math.RoundingMode; |
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
import java.time.Instant; |
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
import java.time.ZoneId; |
|
|
|
|
|
import java.time.temporal.ChronoUnit; |
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import static com.mybatisflex.core.query.QueryMethods.sum; |
|
|
import static com.mybatisflex.core.query.QueryMethods.sum; |
|
|
import static com.thing.qingyuan.carbon.entity.table.QyCarbonQuotaInfoEntityTableDef.QY_CARBON_QUOTA_INFO_ENTITY; |
|
|
import static com.thing.qingyuan.carbon.entity.table.QyCarbonQuotaInfoEntityTableDef.QY_CARBON_QUOTA_INFO_ENTITY; |
|
|
import static com.thing.qingyuan.carbon.entity.table.QyCcerInfoEntityTableDef.QY_CCER_INFO_ENTITY; |
|
|
import static com.thing.qingyuan.carbon.entity.table.QyCcerInfoEntityTableDef.QY_CCER_INFO_ENTITY; |
|
|
import static com.thing.qingyuan.carbon.entity.table.QyGreenCertificateInfoEntityTableDef.QY_GREEN_CERTIFICATE_INFO_ENTITY; |
|
|
import static com.thing.qingyuan.carbon.entity.table.QyGreenCertificateInfoEntityTableDef.QY_GREEN_CERTIFICATE_INFO_ENTITY; |
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Service |
|
|
@Service |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
public class QyCarbonAssetServiceImpl implements QyCarbonAssetService { |
|
|
public class QyCarbonAssetServiceImpl implements QyCarbonAssetService { |
|
|
@ -166,180 +171,114 @@ public class QyCarbonAssetServiceImpl implements QyCarbonAssetService { |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public List<QyCarbonAssetDTO> countRecentCarbonAsset(Long startTime, Long endTime) { |
|
|
public List<QyCarbonAssetDTO> countRecentCarbonAsset(Long startTime, Long endTime) { |
|
|
//查询碳配额买入碳资产 |
|
|
|
|
|
|
|
|
List<QyCarbonAssetDTO> resList = Lists.newArrayList(); |
|
|
|
|
|
Boolean sixMonth = isSixMonth(startTime, endTime); |
|
|
|
|
|
|
|
|
//查询碳配额这段时间的账户总额度 |
|
|
//查询碳配额这段时间的账户总额度 |
|
|
List<QyCarbonQuotaInfoDTO> carbonQuotaList = qyCarbonQuotaInfoService.getMapper().selectListByQueryAs( |
|
|
|
|
|
QueryWrapper.create() |
|
|
|
|
|
|
|
|
List<QyCarbonAssetDTO> carbonList = qyCarbonQuotaInfoService.getMapper().selectListByQueryAs( |
|
|
|
|
|
QueryWrapper.create().select(sum(QY_CARBON_QUOTA_INFO_ENTITY.TOTAL).as("total") |
|
|
|
|
|
, QY_CARBON_QUOTA_INFO_ENTITY.STATE, QY_CARBON_QUOTA_INFO_ENTITY.ISSUE_DATE) |
|
|
.ge(QyCarbonQuotaInfoEntity::getIssueDate, startTime) |
|
|
.ge(QyCarbonQuotaInfoEntity::getIssueDate, startTime) |
|
|
.lt(QyCarbonQuotaInfoEntity::getIssueDate, endTime) |
|
|
.lt(QyCarbonQuotaInfoEntity::getIssueDate, endTime) |
|
|
, QyCarbonQuotaInfoDTO.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.in(QyCarbonQuotaInfoEntity::getState, "2", "3", "4", "5") |
|
|
|
|
|
.groupBy(QY_CARBON_QUOTA_INFO_ENTITY.STATE, QY_CARBON_QUOTA_INFO_ENTITY.ISSUE_DATE) |
|
|
|
|
|
.orderBy(QY_CARBON_QUOTA_INFO_ENTITY.ISSUE_DATE, true) |
|
|
|
|
|
, QyCarbonAssetDTO.class); |
|
|
|
|
|
|
|
|
//查询CCER这段时间的账户总额度 |
|
|
//查询CCER这段时间的账户总额度 |
|
|
List<QyCcerInfoDTO> ccerInfoList = qyCcerInfoService.getMapper().selectListByQueryAs( |
|
|
|
|
|
QueryWrapper.create().ge(QyCcerInfoEntity::getIssueDate, startTime) |
|
|
|
|
|
|
|
|
List<QyCarbonAssetDTO> ccerInfoList = qyCcerInfoService.getMapper().selectListByQueryAs( |
|
|
|
|
|
QueryWrapper.create().select(sum(QY_CCER_INFO_ENTITY.TOTAL).as("total") |
|
|
|
|
|
, QY_CCER_INFO_ENTITY.STATE, QY_CCER_INFO_ENTITY.ISSUE_DATE) |
|
|
|
|
|
.ge(QyCcerInfoEntity::getIssueDate, startTime) |
|
|
.lt(QyCcerInfoEntity::getIssueDate, endTime) |
|
|
.lt(QyCcerInfoEntity::getIssueDate, endTime) |
|
|
, QyCcerInfoDTO.class); |
|
|
|
|
|
|
|
|
.in(QyCcerInfoEntity::getState, "2", "3", "4", "5") |
|
|
|
|
|
.groupBy(QY_CCER_INFO_ENTITY.STATE, QY_CCER_INFO_ENTITY.ISSUE_DATE) |
|
|
|
|
|
.orderBy(QY_CCER_INFO_ENTITY.ISSUE_DATE, true) |
|
|
|
|
|
, QyCarbonAssetDTO.class); |
|
|
|
|
|
|
|
|
//查询绿证这段时间的账户总额度 |
|
|
//查询绿证这段时间的账户总额度 |
|
|
List<QyCcerInfoDTO> ccerInfoDTOList = qyGreenCertificateInfoService.getMapper().selectListByQueryAs( |
|
|
|
|
|
QueryWrapper.create().ge(QyGreenCertificateInfoEntity::getIssueDate, startTime) |
|
|
|
|
|
|
|
|
List<QyCarbonAssetDTO> greenList = qyGreenCertificateInfoService.getMapper().selectListByQueryAs( |
|
|
|
|
|
QueryWrapper.create().select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.TOTAL).as("total") |
|
|
|
|
|
, QY_GREEN_CERTIFICATE_INFO_ENTITY.STATE, QY_GREEN_CERTIFICATE_INFO_ENTITY.ISSUE_DATE) |
|
|
|
|
|
.ge(QyGreenCertificateInfoEntity::getIssueDate, startTime) |
|
|
.lt(QyGreenCertificateInfoEntity::getIssueDate, endTime) |
|
|
.lt(QyGreenCertificateInfoEntity::getIssueDate, endTime) |
|
|
, QyCcerInfoDTO.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
==============================统计买入量============================================================== |
|
|
|
|
|
*/ |
|
|
|
|
|
//查询碳配额买入碳资产 |
|
|
|
|
|
/* 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 = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper, String.class); |
|
|
|
|
|
|
|
|
|
|
|
//查询ccer买入碳资产 |
|
|
|
|
|
QueryWrapper queryWrapper1 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) |
|
|
|
|
|
.from(QY_CCER_INFO_ENTITY) |
|
|
|
|
|
.where("emission_time >= '" + startTime + "' AND emission_time < '" + endTime + "'") |
|
|
|
|
|
.eq(QyCcerInfoEntity::getAssetState,"1"); |
|
|
|
|
|
//ccerTotal 为ccer中买入碳资产量 |
|
|
|
|
|
String ccerTotal = mapper.selectOneByQueryAs(queryWrapper1, String.class); |
|
|
|
|
|
|
|
|
|
|
|
//查询绿证买入碳资产 |
|
|
|
|
|
QueryWrapper queryWrapper2 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) |
|
|
|
|
|
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|
|
|
|
|
.where("date_issue >= '" + startTime + "' AND date_issue < '" + endTime + "'") |
|
|
|
|
|
.eq(QyGreenCertificateInfoEntity::getAssetState,"1"); |
|
|
|
|
|
//greenTotal 为绿证买入碳资产量 |
|
|
|
|
|
String greenTotal = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper2, String.class); |
|
|
|
|
|
|
|
|
|
|
|
*//* |
|
|
|
|
|
==============================统计核销量===================================================================== |
|
|
|
|
|
*//* |
|
|
|
|
|
//查询碳配额核销量 |
|
|
|
|
|
QueryWrapper queryWrapper3 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.VERIFICATION_VOLUME).as("total")) |
|
|
|
|
|
.from(QY_CARBON_QUOTA_INFO_ENTITY) |
|
|
|
|
|
.where("verification_date >= '" + startTime + "' AND verification_date <= '" + endTime + "'") |
|
|
|
|
|
.eq(QyCarbonQuotaInfoEntity::getAssetState,"2"); |
|
|
|
|
|
//carbonVolume 为碳配额核销量 |
|
|
|
|
|
String carbonVolume = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper3, String.class); |
|
|
|
|
|
|
|
|
|
|
|
//查询ccer核销量 |
|
|
|
|
|
QueryWrapper queryWrapper4 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_CCER_INFO_ENTITY.VERIFICATION_VOLUME).as("total")) |
|
|
|
|
|
.from(QY_CCER_INFO_ENTITY) |
|
|
|
|
|
.where("verification_date >= '" + startTime + "' AND verification_date <= '" + endTime + "'") |
|
|
|
|
|
.eq(QyCcerInfoEntity::getAssetState,"2"); |
|
|
|
|
|
//ccerVolume 为ccer核销量 |
|
|
|
|
|
String ccerVolume = mapper.selectOneByQueryAs(queryWrapper4, String.class); |
|
|
|
|
|
|
|
|
.in(QyGreenCertificateInfoEntity::getState, "2", "3", "4", "5") |
|
|
|
|
|
.groupBy(QY_GREEN_CERTIFICATE_INFO_ENTITY.STATE, QY_GREEN_CERTIFICATE_INFO_ENTITY.ISSUE_DATE) |
|
|
|
|
|
.orderBy(QY_GREEN_CERTIFICATE_INFO_ENTITY.ISSUE_DATE, true) |
|
|
|
|
|
, QyCarbonAssetDTO.class); |
|
|
|
|
|
resList.addAll(carbonList); |
|
|
|
|
|
resList.addAll(ccerInfoList); |
|
|
|
|
|
resList.addAll(greenList); |
|
|
|
|
|
//不超过6个月的查询每天的,超过的查询每个月的 |
|
|
|
|
|
if(!sixMonth){ |
|
|
|
|
|
Map<String, Map<Long, BigDecimal>> grouped = resList.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy( |
|
|
|
|
|
QyCarbonAssetDTO::getState, // 按 state 分组 |
|
|
|
|
|
Collectors.groupingBy( |
|
|
|
|
|
QyCarbonAssetDTO::getIssueDate, // 按 issueDate 分组 |
|
|
|
|
|
Collectors.reducing(BigDecimal.ZERO, QyCarbonAssetDTO::getTotal, BigDecimal::add) // 求 total 的和 |
|
|
|
|
|
) |
|
|
|
|
|
)); |
|
|
|
|
|
resList.clear(); |
|
|
|
|
|
grouped.forEach((state, dateMap) -> { |
|
|
|
|
|
dateMap.forEach((date, total) -> { |
|
|
|
|
|
resList.add(new QyCarbonAssetDTO(date, total,state)); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}else { |
|
|
|
|
|
// 创建一个SimpleDateFormat来将时间戳转换为年月(按月分组) |
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); |
|
|
|
|
|
// 按 state 和 月维度(issueDate转换为年月)分组,并计算每组的 total 和 |
|
|
|
|
|
Map<String, Map<String, BigDecimal>> grouped = resList.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy( |
|
|
|
|
|
QyCarbonAssetDTO::getState, // 按 state 分组 |
|
|
|
|
|
Collectors.groupingBy( |
|
|
|
|
|
dto -> sdf.format(new Date(dto.getIssueDate())), // 将issueDate转换为 "yyyy-MM" 格式 |
|
|
|
|
|
Collectors.reducing(BigDecimal.ZERO, QyCarbonAssetDTO::getTotal, BigDecimal::add) // 计算每组的 total 和 |
|
|
|
|
|
) |
|
|
|
|
|
)); |
|
|
|
|
|
// 将结果重新转换成 List<QyCarbonAssetDTO> |
|
|
|
|
|
resList.clear(); |
|
|
|
|
|
grouped.forEach((state, dateMap) -> { |
|
|
|
|
|
dateMap.forEach((date, total) -> { |
|
|
|
|
|
// 将分组后的数据重新封装成 QyCarbonAssetDTO,月份转回为时间戳 |
|
|
|
|
|
try { |
|
|
|
|
|
Date dateObj = sdf.parse(date); |
|
|
|
|
|
long issueDate = dateObj.getTime(); |
|
|
|
|
|
resList.add(new QyCarbonAssetDTO(issueDate, total,state)); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("日期转换错误",e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
// 按 issueDate 升序排序 |
|
|
|
|
|
resList.sort(Comparator.comparingLong(QyCarbonAssetDTO::getIssueDate)); |
|
|
|
|
|
return resList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//查询绿证核销量 |
|
|
|
|
|
QueryWrapper queryWrapper5 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.VERIFICATION_VOLUME).as("total")) |
|
|
|
|
|
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|
|
|
|
|
.where("verification_date >= '" + startTime + "' AND verification_date <= '" + endTime + "'") |
|
|
|
|
|
.eq(QyGreenCertificateInfoEntity::getAssetState,"2"); |
|
|
|
|
|
//greenVolume 为绿证核销量 |
|
|
|
|
|
String greenVolume = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper5, String.class); |
|
|
|
|
|
|
|
|
private Boolean isSixMonth(Long startTime, Long endTime) { |
|
|
|
|
|
|
|
|
*//* |
|
|
|
|
|
==============================统计发放量===================================================================== |
|
|
|
|
|
*//* |
|
|
|
|
|
//查询碳配额卖出量 |
|
|
|
|
|
QueryWrapper queryWrapper6 = 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,"3"); |
|
|
|
|
|
//carbonSell 为碳配额卖出 |
|
|
|
|
|
String carbonSell = qyCarbonQuotaInfoService.getMapper().selectOneByQueryAs(queryWrapper6, String.class); |
|
|
|
|
|
|
|
|
// 将时间戳转换为 LocalDate(假设我们关心日期而不是时间) |
|
|
|
|
|
LocalDate startDate = Instant.ofEpochMilli(startTime) |
|
|
|
|
|
.atZone(ZoneId.systemDefault()) |
|
|
|
|
|
.toLocalDate(); |
|
|
|
|
|
LocalDate endDate = Instant.ofEpochMilli(endTime) |
|
|
|
|
|
.atZone(ZoneId.systemDefault()) |
|
|
|
|
|
.toLocalDate(); |
|
|
|
|
|
|
|
|
//查询ccer卖出量 |
|
|
|
|
|
QueryWrapper queryWrapper7 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) |
|
|
|
|
|
.from(QY_CCER_INFO_ENTITY) |
|
|
|
|
|
.where("emission_time >= '" + startTime + "' AND emission_time <= '" + endTime + "'") |
|
|
|
|
|
.eq(QyCcerInfoEntity::getAssetState,"3"); |
|
|
|
|
|
//ccerSell 为ccer卖出 |
|
|
|
|
|
String ccerSell = mapper.selectOneByQueryAs(queryWrapper7, String.class); |
|
|
|
|
|
|
|
|
// 计算两个日期之间的月份差 |
|
|
|
|
|
long monthsBetween = ChronoUnit.MONTHS.between(startDate, endDate); |
|
|
|
|
|
|
|
|
//查询绿证卖出量 |
|
|
|
|
|
QueryWrapper queryWrapper8 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) |
|
|
|
|
|
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY) |
|
|
|
|
|
.where("date_issue >= '" + startTime + "' AND date_issue <= '" + endTime + "'") |
|
|
|
|
|
.eq(QyGreenCertificateInfoEntity::getAssetState,"3"); |
|
|
|
|
|
//greenSell 为绿证卖出 |
|
|
|
|
|
String greenSell = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper8, String.class); |
|
|
|
|
|
|
|
|
// 判断是否超过半年(6个月) |
|
|
|
|
|
if (monthsBetween >= 6) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} else { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
*//* |
|
|
|
|
|
==================================碳配额数量===================================================================== |
|
|
|
|
|
*//* |
|
|
|
|
|
//查询碳配额量总量 |
|
|
|
|
|
QueryWrapper queryWrapper9 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_CARBON_QUOTA_INFO_ENTITY.CARBON_QUOTA).as("total")) |
|
|
|
|
|
.where("issue_date >= '" + startTime + "' AND issue_date <= '" + endTime + "'") |
|
|
|
|
|
.from(QY_CARBON_QUOTA_INFO_ENTITY); |
|
|
|
|
|
//numTotal 为碳配额量总量 |
|
|
|
|
|
String carbonSum = mapper.selectOneByQueryAs(queryWrapper9, String.class); |
|
|
|
|
|
*//* |
|
|
|
|
|
==================================CCER数量==================================================================== |
|
|
|
|
|
*//* |
|
|
|
|
|
//查询ccer总量 |
|
|
|
|
|
QueryWrapper queryWrapper11 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_CCER_INFO_ENTITY.RECORD_EMISSION).as("total")) |
|
|
|
|
|
.where("emission_time >= '" + startTime + "' AND emission_time <= '" + endTime + "'") |
|
|
|
|
|
.from(QY_CCER_INFO_ENTITY); |
|
|
|
|
|
//ccerNum 为ccer总量 |
|
|
|
|
|
String ccerSum= mapper.selectOneByQueryAs(queryWrapper11, String.class); |
|
|
|
|
|
*//* |
|
|
|
|
|
====================================绿证数量===================================================================== |
|
|
|
|
|
*//* |
|
|
|
|
|
//查询绿证总量 |
|
|
|
|
|
QueryWrapper queryWrapper13 = QueryWrapper.create() |
|
|
|
|
|
.select(sum(QY_GREEN_CERTIFICATE_INFO_ENTITY.GREEN_TOTAL).as("total")) |
|
|
|
|
|
.where("date_issue >= '" + startTime + "' AND date_issue <= '" + endTime + "'") |
|
|
|
|
|
.from(QY_GREEN_CERTIFICATE_INFO_ENTITY); |
|
|
|
|
|
//greenTotal 为绿证总量 |
|
|
|
|
|
String greenSum = qyGreenCertificateInfoService.getMapper().selectOneByQueryAs(queryWrapper13, String.class); |
|
|
|
|
|
|
|
|
|
|
|
*//* |
|
|
|
|
|
======================================统计账户总余额======================================================== |
|
|
|
|
|
*//* |
|
|
|
|
|
//统计碳配额总余额 |
|
|
|
|
|
BigDecimal carbonAccount = new BigDecimal(carbonSum).subtract(new BigDecimal(carbonVolume)); |
|
|
|
|
|
//统计ccer总余额 |
|
|
|
|
|
BigDecimal ccerAccount = new BigDecimal(ccerSum).subtract(new BigDecimal(ccerVolume)); |
|
|
|
|
|
//统计绿证总余额 |
|
|
|
|
|
BigDecimal greenAccount = (new BigDecimal(greenSum).subtract(new BigDecimal(greenVolume))).multiply(new BigDecimal("0.5703")); |
|
|
|
|
|
//账户余额 |
|
|
|
|
|
BigDecimal remain = carbonAccount.add(ccerAccount).add(greenAccount); |
|
|
|
|
|
|
|
|
|
|
|
//总买入碳资产 |
|
|
|
|
|
BigDecimal buyTotal = new BigDecimal(greenTotal).multiply(new BigDecimal("0.5703")).add(new BigDecimal(carbonTotal)).add(new BigDecimal(ccerTotal)); |
|
|
|
|
|
//总核销碳资产 |
|
|
|
|
|
BigDecimal verTotal = new BigDecimal(greenVolume).multiply(new BigDecimal("0.5703")).add(new BigDecimal(carbonVolume)).add(new BigDecimal(ccerVolume)); |
|
|
|
|
|
//总卖出碳资产 |
|
|
|
|
|
BigDecimal sellTotal = new BigDecimal(greenSell).multiply(new BigDecimal("0.5703")).add(new BigDecimal(carbonSell)).add(new BigDecimal(ccerSell)); |
|
|
|
|
|
*/ |
|
|
|
|
|
//存入结果 |
|
|
|
|
|
HashMap<String, String> temMap = new HashMap<>(); |
|
|
|
|
|
//返回结果 买入 核销 卖出 |
|
|
|
|
|
/*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 null; |
|
|
|
|
|
} |
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取碳资产对应标签的单价,数量,余额,账户总余额 |
|
|
* 获取碳资产对应标签的单价,数量,余额,账户总余额 |
|
|
* @return 返回一个Map |
|
|
* @return 返回一个Map |
|
|
|