|
|
@@ -1,24 +1,22 @@
|
|
|
package com.jzg.console.service.impl;
|
|
|
|
|
|
|
|
|
-import com.alibaba.excel.annotation.ExcelProperty;
|
|
|
-import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.jzg.commons.entity.report.dto.ReportOperatingProfitDataDto;
|
|
|
-import com.jzg.commons.entity.report.dto.ReportRiskDataManageDetailDto;
|
|
|
-import com.jzg.commons.entity.report.dto.ReportRiskDataManageDto;
|
|
|
-import com.jzg.commons.entity.report.dto.ReportSalesmanDataManageDto;
|
|
|
import com.jzg.commons.entity.report.vo.ReportSearchCommonVo;
|
|
|
+import com.jzg.console.client.FeeAuditClient;
|
|
|
import com.jzg.console.service.ReportOperatingProfitDataService;
|
|
|
-import com.jzg.console.service.ReportReceivableDataService;
|
|
|
-import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @version
|
|
|
@@ -28,6 +26,12 @@ import java.util.List;
|
|
|
*/
|
|
|
@Service
|
|
|
public class ReportOperatingProfitDataServiceImpl extends ReportBaseServiceImpl implements ReportOperatingProfitDataService {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ReportOperatingProfitDataServiceImpl.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FeeAuditClient feeAuditClient;
|
|
|
+
|
|
|
/**
|
|
|
* @version
|
|
|
* @author: hxl
|
|
|
@@ -36,16 +40,137 @@ public class ReportOperatingProfitDataServiceImpl extends ReportBaseServiceImpl
|
|
|
*/
|
|
|
@Override
|
|
|
public IPage<?> getPageListByParams(ReportSearchCommonVo reportSearchCommonVo) {
|
|
|
- Page<ReportOperatingProfitDataDto> page = new Page<>(reportSearchCommonVo.getPageNo(), reportSearchCommonVo.getPageSize());
|
|
|
+ log.info("财务数据-经营利润-列表查询: reportSearchCommonVo=[{}]", JSONUtil.toJsonStr(reportSearchCommonVo));
|
|
|
+ String sql1 = """
|
|
|
+
|
|
|
+ select
|
|
|
+ a.ym ,
|
|
|
+ sum(a.total_premium),
|
|
|
+ sum(a.total_receivable_premium)
|
|
|
+ -- ,sum(a.total_payable_premium)
|
|
|
+ from
|
|
|
+ (
|
|
|
+ select
|
|
|
+ io.id as order_no,
|
|
|
+ io.signing_time ,
|
|
|
+ DATE_FORMAT(io.signing_time, '%Y-%m') as ym,
|
|
|
+ ifo.total_premium ,
|
|
|
+ ifo.total_payable_premium ,
|
|
|
+ ifo.total_receivable_premium,
|
|
|
+ io.system_code
|
|
|
+ from
|
|
|
+ ins_fee_orders ifo
|
|
|
+ left join ins_orders io on
|
|
|
+ ifo.order_no = io.id
|
|
|
+ where
|
|
|
+ io.system_code = 'G111'
|
|
|
+ and io.signing_time >= '2016-01-01 00:00:00'
|
|
|
+ ) as a
|
|
|
+ group by a.ym
|
|
|
+ order by a.ym asc
|
|
|
+
|
|
|
+ """;
|
|
|
+
|
|
|
+ String sql11 = """
|
|
|
+
|
|
|
+ select
|
|
|
+ a.ym ,
|
|
|
+ sum(a.total_payable_premium)
|
|
|
+ from
|
|
|
+ (
|
|
|
+ select
|
|
|
+ io.id as order_no,
|
|
|
+ io.signing_time ,
|
|
|
+ DATE_FORMAT(io.signing_time, '%Y-%m') as ym,
|
|
|
+ ifo.total_premium ,
|
|
|
+ ifo.total_payable_premium ,
|
|
|
+ ifo.total_receivable_premium,
|
|
|
+ io.system_code
|
|
|
+ from
|
|
|
+ ins_fee_orders ifo
|
|
|
+ left join ins_orders io on
|
|
|
+ ifo.order_no = io.id
|
|
|
+ where
|
|
|
+ io.system_code = 'G111'
|
|
|
+ and io.signing_time >= '2016-01-01 00:00:00'
|
|
|
+ and io.id in (
|
|
|
+ select
|
|
|
+ ifa.order_no
|
|
|
+ from
|
|
|
+ ins_fee_audit ifa
|
|
|
+ where
|
|
|
+ ifa.audit_status = 1
|
|
|
+ )
|
|
|
+ ) as a
|
|
|
+ group by a.ym
|
|
|
+ order by a.ym asc
|
|
|
+
|
|
|
+ """;
|
|
|
+
|
|
|
+ String sql2 = """
|
|
|
+ select
|
|
|
+ sum(ipiis.actual_received_amount),
|
|
|
+ DATE_FORMAT(ipiis.receive_payment_date, '%Y-%m') as ym
|
|
|
+ from
|
|
|
+ ins_ply_income_invoice_settlement ipiis
|
|
|
+ where
|
|
|
+ receive_payment_date >= '2026-07-01 00:00:00'
|
|
|
+ and ipiis.system_code = 'G111'
|
|
|
+ group by ym
|
|
|
+
|
|
|
+ """;
|
|
|
+
|
|
|
+ String sql3 = """
|
|
|
+ select
|
|
|
+ DATE_FORMAT(suacl.create_time, '%Y-%m') as ym,
|
|
|
+ sum(suacl.amount)
|
|
|
+ from
|
|
|
+ sys_user_account_change_log suacl
|
|
|
+ where
|
|
|
+ suacl.system_code = 'G111'
|
|
|
+ and suacl.amount < 0
|
|
|
+ and suacl.create_time >= '2026-01-01 00:00:00'
|
|
|
+ group by
|
|
|
+ ym
|
|
|
+ """;
|
|
|
+
|
|
|
+ Map<String, ReportOperatingProfitDataDto> map1 = new HashMap<>();
|
|
|
+ Map<String, ReportOperatingProfitDataDto> map2 = new HashMap<>();
|
|
|
+ Map<String, ReportOperatingProfitDataDto> map3 = new HashMap<>();
|
|
|
+ Map<String, ReportOperatingProfitDataDto> map4 = new HashMap<>();
|
|
|
+ List<Map<String, ReportOperatingProfitDataDto>> allMaps = new ArrayList<>();
|
|
|
+ Map<String, ReportOperatingProfitDataDto> compMaps = this.mergeMaps(allMaps);
|
|
|
+ List<ReportOperatingProfitDataDto> values = new ArrayList<>(compMaps.values());
|
|
|
+
|
|
|
+
|
|
|
+ // Page<ReportOperatingProfitDataDto> page = new Page<>(reportSearchCommonVo.getPageNo(), reportSearchCommonVo.getPageSize());
|
|
|
IPage<ReportOperatingProfitDataDto> pageList = new Page<ReportOperatingProfitDataDto>();
|
|
|
- List<ReportOperatingProfitDataDto> list = getList();
|
|
|
- pageList.setRecords(list);
|
|
|
- pageList.setTotal(1l);
|
|
|
+ pageList.setRecords(values);
|
|
|
+ pageList.setTotal(CollUtil.size(values));
|
|
|
pageList.setCurrent(reportSearchCommonVo.getPageNo());
|
|
|
pageList.setPages(reportSearchCommonVo.getPageNo());
|
|
|
pageList.setPages(reportSearchCommonVo.getPageSize());
|
|
|
return pageList;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public Map<String, ReportOperatingProfitDataDto> mergeMaps(List<Map<String, ReportOperatingProfitDataDto>> mapList) {
|
|
|
+ return mapList.stream()
|
|
|
+ // 1. 将 List<Map> 展平为 Stream<Map.Entry>
|
|
|
+ .flatMap(map -> map.entrySet().stream())
|
|
|
+ // 2. 收集为新的 LinkedHashMap (保持插入顺序)
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ Map.Entry::getKey,
|
|
|
+ Map.Entry::getValue,
|
|
|
+ (dto1, dto2) -> {
|
|
|
+ // 3. 遇到相同 Key,调用 merge 方法累加字段
|
|
|
+ dto1.merge(dto2);
|
|
|
+ return dto1;
|
|
|
+ },
|
|
|
+ HashMap::new // 保证结果 Map 是 LinkedHashMap
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @version
|
|
|
* @author: hxl
|