Просмотр исходного кода

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260622'

jiakai 1 месяц назад
Родитель
Сommit
e7668fa534

+ 4 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/QueryFollowIncomeVo.java

@@ -3,13 +3,17 @@ package com.jzg.commons.entity.finance.vo;
 import com.jzg.commons.core.base.PageRequest;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
 import java.util.List;
 
 @Data
 @AllArgsConstructor
+@NoArgsConstructor
+@Builder
 public class QueryFollowIncomeVo  extends PageRequest implements Serializable {
 
     @Schema(description = "开始年份")

+ 29 - 0
commons/src/main/java/com/jzg/commons/entity/report/dto/ReportOperatingProfitDataDto.java

@@ -88,4 +88,33 @@ public class ReportOperatingProfitDataDto {
     @ColumnWidth(20)
     @Schema(description = "实付")
     private BigDecimal paidMoney;
+
+    /**
+     * 将另一个 DTO 的数值字段累加到当前对象中。
+     * 注意:此方法会修改当前对象(this)。
+     *
+     * @param other 要合并的另一个 DTO 对象
+     */
+    public void merge(ReportOperatingProfitDataDto other) {
+        if (other == null) {
+            return;
+        }
+        this.sumPremium = addSafe(this.sumPremium, other.sumPremium);
+        this.receivableMoney = addSafe(this.receivableMoney, other.receivableMoney);
+        this.meetMoney = addSafe(this.meetMoney, other.meetMoney);
+        this.profitMoney = addSafe(this.profitMoney, other.profitMoney);
+        this.receivedMoney = addSafe(this.receivedMoney, other.receivedMoney);
+        this.paidMoney = addSafe(this.paidMoney, other.paidMoney);
+        // 如果还有其他数值类型字段,请在此处继续添加
+    }
+
+    /**
+     * 安全的 BigDecimal 累加,防止空指针异常。
+     * 规则:null + value = value; value + null = value; null + null = null
+     */
+    private BigDecimal addSafe(BigDecimal a, BigDecimal b) {
+        if (a == null) return b;
+        if (b == null) return a;
+        return a.add(b);
+    }
 }

+ 1 - 1
commons/src/main/java/com/jzg/commons/entity/report/vo/PayableStatisticsDetailParam.java

@@ -17,6 +17,6 @@ public class PayableStatisticsDetailParam extends PageRequest {
     private static final long serialVersionUID = 1L;
 
     @Schema(description = "年月时间,格式:yyyy-MM")
-    private String yearAndMonthTime;
+    private String yearMonth;
 
 }

+ 13 - 0
consoleStatistics/src/main/java/com/jzg/console/client/FeeAuditClient.java

@@ -6,9 +6,12 @@ import com.jzg.commons.entity.dto.FeeAuditParam;
 import com.jzg.commons.entity.orders.vo.FeeAuditSummaryParam;
 import com.jzg.commons.entity.orders.vo.FeeAuditSummaryVO;
 import com.jzg.commons.entity.orders.vo.FeeAuditVo;
+import com.jzg.commons.entity.report.dto.ReportOperatingProfitDataDto;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
 
@@ -34,4 +37,14 @@ public interface FeeAuditClient {
     @PostMapping("/feeAudit/queryAuditSummary")
     HttpResult<List<FeeAuditSummaryVO>> queryAuditSummary(@RequestBody FeeAuditSummaryParam param);
 
+    /**
+     * 查询指定年份的经营利润
+     *
+     * @param year 年份,例如 2026
+     * @author lipf
+     * @date 2026/7/25 11:22
+     */
+    @GetMapping("/feeAudit/queryOperatingProfits")
+    HttpResult<List<ReportOperatingProfitDataDto>> queryOperatingProfits(@RequestParam("year") String year);
+
 }

+ 26 - 3
consoleStatistics/src/main/java/com/jzg/console/controller/ReportFinanceDataManageController.java

@@ -5,20 +5,22 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.orders.vo.FeeAuditVo;
 import com.jzg.commons.entity.report.dto.FeeAuditSummaryVo;
 import com.jzg.commons.entity.report.vo.FeeAuditDetailParam;
 import com.jzg.commons.entity.report.vo.FeeAuditSummaryParam;
 import com.jzg.commons.entity.report.vo.PayableStatisticsDetailParam;
 import com.jzg.commons.entity.report.vo.ReportSearchCommonVo;
-import com.jzg.commons.entity.orders.vo.FeeAuditVo;
 import com.jzg.console.service.*;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
-import java.io.IOException;
 import java.util.List;
 
 /**
@@ -502,5 +504,26 @@ public class ReportFinanceDataManageController extends BaseController {
             return HttpResult.error(e.getMessage());
         }
     }
+    /**
+     * 财务数据-应付统计:按月份汇总查询应付数据导出
+     * @author: jk
+     */
+    @Operation(summary = "财务数据-应付统计导出Excel", description = "财务数据-应付统计导出Excel")
+    @PostMapping(value = "/exportPayableStatistics")
+    public void exportPayableStatistics(@RequestBody ReportSearchCommonVo reportSearchCommonVo) {
+        String systemCode = getSystemCode();
+        reportMeetDataService.exportPayableStatistics(reportSearchCommonVo, systemCode);
+    }
+
+    /**
+     * 财务数据-应付统计明细:查询指定年月的提现明细列表导出
+     * @author: jk
+     */
+    @Operation(summary = "财务数据-应付统计明细导出Excel", description = "财务数据-应付统计明细导出Excel")
+    @PostMapping(value = "/exportPayableStatisticsDetail")
+    public void exportPayableStatisticsDetail(@RequestBody PayableStatisticsDetailParam param) {
+        String systemCode = getSystemCode();
+        reportMeetDataService.exportPayableStatisticsDetail(param, systemCode);
+    }
 
 }

+ 2 - 2
consoleStatistics/src/main/java/com/jzg/console/service/impl/ReportMeetDataServiceImpl.java

@@ -95,7 +95,7 @@ public class ReportMeetDataServiceImpl extends ReportBaseServiceImpl implements
     @Override
     public IPage<?> getPayableStatisticsDetail(PayableStatisticsDetailParam param, String systemCode) {
         log.info("财务数据-应付统计明细. param=[{}], systemCode=[{}]", JSONUtil.toJsonStr(param), systemCode);
-        if (param == null || StrUtil.isBlank(param.getYearAndMonthTime())) {
+        if (param == null || StrUtil.isBlank(param.getYearMonth())) {
             log.warn("查询年月为空,返回空列表");
             return new Page<>(param.getPages(), param.getSize());
         }
@@ -138,7 +138,7 @@ public class ReportMeetDataServiceImpl extends ReportBaseServiceImpl implements
     @Override
     public void exportPayableStatisticsDetail(PayableStatisticsDetailParam param, String systemCode) {
         log.info("财务数据-应付统计明细导出Excel. param=[{}], systemCode=[{}]", JSONUtil.toJsonStr(param), systemCode);
-        if (param == null || StrUtil.isBlank(param.getYearAndMonthTime())) {
+        if (param == null || StrUtil.isBlank(param.getYearMonth())) {
             log.warn("查询年月为空,不导出");
             return;
         }

+ 139 - 14
consoleStatistics/src/main/java/com/jzg/console/service/impl/ReportOperatingProfitDataServiceImpl.java

@@ -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

+ 2 - 2
consoleStatistics/src/main/resources/mapper/ReportMeetDataMapper.xml

@@ -153,8 +153,8 @@
         <where>
             saa.is_delete = 0
             AND saa.system_code = #{systemCode}
-            <if test="param.yearAndMonthTime != null and param.yearAndMonthTime != ''">
-                AND DATE_FORMAT(saa.create_time, '%Y-%m') = #{param.yearAndMonthTime}
+            <if test="param.yearMonth != null and param.yearMonth != ''">
+                AND DATE_FORMAT(saa.create_time, '%Y-%m') = #{param.yearMonth}
             </if>
         </where>
         ORDER BY saa.create_time DESC

+ 17 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/InsFeeOrderController.java

@@ -1,9 +1,11 @@
 package com.jzg.quotation.summary.controller;
 
 import cn.hutool.json.JSONUtil;
+import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.dto.InsFeeOrdersParam;
 import com.jzg.commons.entity.po.InsFeeOrders;
+import com.jzg.commons.entity.report.dto.ReportOperatingProfitDataDto;
 import com.jzg.quotation.summary.entity.dto.RightsAmountUpdateDto;
 import com.jzg.quotation.summary.service.InsFeeOrdersService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -26,6 +28,8 @@ import java.util.List;
 public class InsFeeOrderController {
     @Autowired
     private InsFeeOrdersService insFeeOrdersService;
+    @Autowired
+    private BaseController baseController;
 
     private static final Logger log = LoggerFactory.getLogger(InsFeeOrderController.class);
 
@@ -88,4 +92,17 @@ public class InsFeeOrderController {
         return insFeeOrdersService.updateAvailableAmount(rightsAmountUpdateDto.getOrderNo(),rightsAmountUpdateDto.getAvailableAmount());
     }
 
+
+    /**
+     * 查询指定年份的经营利润
+     *
+     * @param year 年份,例如 2026
+     * @author lipf
+     * @date 2026/7/25 11:22
+     */
+    @GetMapping("/feeAudit/queryOperatingProfits")
+    HttpResult<List<ReportOperatingProfitDataDto>> queryOperatingProfits(@RequestParam("year") String year){
+        String systemCode = baseController.getSystemCode();
+        return HttpResult.ok(insFeeOrdersService.queryOperatingProfits(year,systemCode));
+    }
 }

+ 10 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/InsFeeOrdersService.java

@@ -5,6 +5,7 @@ import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.dto.CostCalculateRespVO;
 import com.jzg.commons.entity.dto.InsFeeOrdersParam;
 import com.jzg.commons.entity.po.InsFeeOrders;
+import com.jzg.commons.entity.report.dto.ReportOperatingProfitDataDto;
 import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
 
 import java.math.BigDecimal;
@@ -57,4 +58,13 @@ public interface InsFeeOrdersService extends IService<InsFeeOrders> {
      */
     InsFeeOrders updateFeeRatio(String orderNo, BigDecimal jqInletRatio, BigDecimal syInletRatio, BigDecimal jyInletRatio,
                                 BigDecimal jqExportRatio, BigDecimal syExportRatio, BigDecimal jyExportRatio);
+
+    /**
+     * 查询指定年份的经营利润
+     *
+     * @param year 年份,例如 2026
+     * @author lipf
+     * @date 2026/7/25 11:22
+     */
+    List<ReportOperatingProfitDataDto> queryOperatingProfits(String year, String systemCode);
 }

+ 17 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeOrdersServiceImpl.java

@@ -14,6 +14,7 @@ import com.jzg.commons.entity.orders.po.InsOrders;
 import com.jzg.commons.entity.orders.po.InsOrdersCosts;
 import com.jzg.commons.entity.po.InsFeeOrders;
 import com.jzg.commons.entity.po.PtlAgreement;
+import com.jzg.commons.entity.report.dto.ReportOperatingProfitDataDto;
 import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
 import com.jzg.commons.exception.SystemException;
 import com.jzg.commons.util.AssertionUtils;
@@ -710,4 +711,20 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         }
         return initAmout;
     }
+
+    /**
+     * 查询指定年份的经营利润
+     *
+     * @param year       年份,例如 2026
+     * @param systemCode
+     * @author lipf
+     * @date 2026/7/25 11:22
+     */
+    @Override
+    public List<ReportOperatingProfitDataDto> queryOperatingProfits(String year, String systemCode) {
+        log.info("查询租户[{}]在指定年份[{}]的经营利润之保费等信息",systemCode,year);
+
+
+        return List.of();
+    }
 }

+ 7 - 6
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -961,11 +961,12 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * 查询收入基础数据
      */
     private List<InsPlyIncomeDto> queryFollowIncomeData(SettlementReportQueryVo queryVo) {
-        QueryFollowIncomeVo incomeVo = new QueryFollowIncomeVo(
-                null, null, baseController.getSystemCode(), null,
-                queryVo.getCompanyId(), queryVo.getStartTime(), queryVo.getEndTime(),
-                queryVo.getSigningStartTime(), queryVo.getSigningEndTime()
-        );
+        QueryFollowIncomeVo incomeVo = QueryFollowIncomeVo.builder()
+                .systemCode(baseController.getSystemCode())
+                .companyId(queryVo.getCompanyId())
+                .startTime(queryVo.getStartTime()).endTime(queryVo.getEndTime())
+                .signingStartTime(queryVo.getSigningStartTime()).signingEndTime(queryVo.getSigningEndTime())
+                .build();
         return baseMapper.queryFollowIncome(incomeVo);
     }
 
@@ -4243,7 +4244,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         String systemCode = baseController.getUserSystemCode();
 
         // 查询该年份下的所有跟进收入数据,并按合作方公司ID进行分组
-        QueryFollowIncomeVo queryFollowIncomeVo = new QueryFollowIncomeVo(startYear, endYear, systemCode, null, null, null, null, null, null);
+        QueryFollowIncomeVo queryFollowIncomeVo = QueryFollowIncomeVo.builder().startYear(startYear).endYear(endYear).systemCode(systemCode).build();
         List<InsPlyIncomeDto> incomes = baseMapper.queryFollowIncome(queryFollowIncomeVo);
 
         // ====================== 增加动态条件过滤 ======================