Parcourir la source

手续费/跟单费应收、结算记录、结算明细导出 (车险、非车险)

Qchen il y a 1 an
Parent
commit
652c18db7f
27 fichiers modifiés avec 2246 ajouts et 9 suppressions
  1. 4 0
      commons/src/main/java/com/jzg/commons/entity/dto/AgreementAddParam.java
  2. 4 0
      commons/src/main/java/com/jzg/commons/entity/dto/AgreementEditParam.java
  3. 41 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/CompanySuperviseSettlementReportDto.java
  4. 113 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherExcelDto.java
  5. 83 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherJyExcelDto.java
  6. 95 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherSettlementDetailExcelDto.java
  7. 84 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherSettlementDetailJyExcelDto.java
  8. 57 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherSettlementExcelDto.java
  9. 111 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseExcelDto.java
  10. 77 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseJyExcelDto.java
  11. 96 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementDetailExcelDto.java
  12. 84 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementDetailJyExcelDto.java
  13. 57 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementExcelDto.java
  14. 19 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/InvoiceAmountDto.java
  15. 25 0
      commons/src/main/java/com/jzg/commons/entity/finance/po/InsPlyIncome.java
  16. 8 0
      commons/src/main/java/com/jzg/commons/entity/finance/vo/ReceivableQueryVo.java
  17. 46 0
      commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementQueryVo.java
  18. 32 0
      commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementReportQueryVo.java
  19. 3 0
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreement.java
  20. 29 0
      commons/src/main/java/com/jzg/commons/util/EasyExcelUtils.java
  21. 6 2
      gateway/src/main/resources/application-dev.yml
  22. 69 4
      tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java
  23. 87 1
      tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java
  24. 56 0
      tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java
  25. 347 1
      tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java
  26. 12 0
      tenant/organization/src/main/resources/application.yml
  27. 601 1
      tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

+ 4 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementAddParam.java

@@ -55,6 +55,10 @@ public class AgreementAddParam {
     @NotNull(message = "请选择保险公司")
     private String companyId;
 
+    @Schema(description = "合作-保险公司id")
+    @NotNull(message = "请选择合作保险公司")
+    private String partnerCompanyId;
+
     @Schema(description = "协议类型 1-平台协议-平台结算 2-私有协议-自行结算 3-网销协议-自行结算")
     @NotNull(message = "请选择协议类型")
     private Integer agreementType;

+ 4 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementEditParam.java

@@ -61,6 +61,10 @@ public class AgreementEditParam {
     @NotNull(message = "请选择保险公司")
     private String companyId;
 
+    @Schema(description = "合作-保险公司id")
+    @NotNull(message = "请选择合作保险公司")
+    private String partnerCompanyId;
+
     @Schema(description = "协议类型 1-平台协议-平台结算 2-私有协议-自行结算 3-网销协议-自行结算")
     @NotNull(message = "请选择协议类型")
     private Integer agreementType;

+ 41 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/CompanySuperviseSettlementReportDto.java

@@ -0,0 +1,41 @@
+package com.jzg.commons.entity.finance.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author quchen
+ * @date 2025/7/31 17:53
+ */
+
+@Data
+public class CompanySuperviseSettlementReportDto {
+    @Schema(description = "保险公司Id")
+    private String companyId;
+
+    @Schema(description = "保险公司")
+    private String companyName;
+
+    @Schema(description = "累计应收")
+    private String totalReceivable;
+
+    @Schema(description = "应收手续费")
+    private String superviseFee;
+
+    @Schema(description = "已开票金额")
+    private String invoicedAmount;
+
+    @Schema(description = "已结算金额")
+    private String settledAmount;
+
+    @Schema(description = "未开票金额")
+    private String unInvoicedAmount;
+
+    @Schema(description = "未结算金额")
+    private String unSettledAmount;
+
+    @Schema(description = "子保险公司数据")
+    private List<CompanySuperviseSettlementReportDto> children;
+}

+ 113 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherExcelDto.java

@@ -0,0 +1,113 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/29 10:07
+ */
+
+@Data
+public class ExportOtherExcelDto {
+    @Schema(description = "签单时间")
+    @ExcelProperty(value = "签单时间")
+    private String signingTime;
+
+    @Schema(description = "订单号")
+    @ExcelProperty(value = "订单号")
+    private String orderNo;
+
+    @Schema(description = "保司名称")
+    @ExcelProperty(value = "保司名称")
+    private String companyName;
+
+    @Schema(description = "出单机构")
+    @ExcelProperty(value = "出单机构")
+    private String deptName;
+
+    @Schema(description = "出单协议")
+    @ExcelProperty(value = "出单协议")
+    private String agreementName;
+
+    @Schema(description = "订单类型")
+    @ExcelProperty(value = "订单类型")
+    private String entryStatus;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @Schema(description = "应收跟单费")
+    @ExcelProperty(value = "应收跟单费")
+    private String receivableAmount;
+
+    @Schema(description = "险种")
+    @ExcelProperty(value = "险种")
+    private String productName;
+
+    @Schema(description = "被保人")
+    @ExcelProperty(value = "被保人")
+    private String insuredPerson;
+
+    @Schema(description = "交强保单号")
+    @ExcelProperty(value = "交强保单号")
+    private String jqPolicyNo;
+
+    @Schema(description = "交强保费")
+    @ExcelProperty(value = "交强保费")
+    private String jqPremium;
+
+    @Schema(description = "交强险不含税保费")
+    @ExcelProperty(value = "交强险不含税保费")
+    private String jqPremiumNoTax;
+
+    @Schema(description = "交强跟单费比例")
+    @ExcelProperty(value = "交强跟单费比例")
+    private String jqSuperviseCostsProportion;
+
+    @Schema(description = "交强起保日期")
+    @ExcelProperty(value = "交强起保日期")
+    private String jqStartDate;
+
+    @Schema(description = "商业保单号")
+    @ExcelProperty(value = "商业保单号")
+    private String syPolicyNo;
+
+    @Schema(description = "商业保费")
+    @ExcelProperty(value = "商业保费")
+    private String syPremium;
+
+    @Schema(description = "商业险不含税保费")
+    @ExcelProperty(value = "商业险不含税保费")
+    private String syPremiumNoTax;
+
+    @Schema(description = "商业跟单费比例")
+    @ExcelProperty(value = "商业跟单费比例")
+    private String sySuperviseCostsProportion;
+
+    @Schema(description = "商业起保日期")
+    @ExcelProperty(value = "商业起保日期")
+    private String syStartDate;
+
+    @Schema(description = "车船税")
+    @ExcelProperty(value = "车船税")
+    private String taxPremium;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty(value = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @Schema(description = "创建人")
+    @ExcelProperty(value = "创建人")
+    private String createBy;
+
+    @Schema(description = "对接人")
+    @ExcelProperty(value = "对接人")
+    private String contactPerson;
+}

+ 83 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherJyExcelDto.java

@@ -0,0 +1,83 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/29 16:16
+ */
+
+@Data
+public class ExportOtherJyExcelDto {
+    @Schema(description = "签单时间")
+    @ExcelProperty(value = "签单时间")
+    private String signingTime;
+
+    @Schema(description = "订单号")
+    @ExcelProperty(value = "订单号")
+    private String orderNo;
+
+    @Schema(description = "保司名称")
+    @ExcelProperty(value = "保司名称")
+    private String companyName;
+
+    @Schema(description = "出单机构")
+    @ExcelProperty(value = "出单机构")
+    private String deptName;
+
+    @Schema(description = "出单协议")
+    @ExcelProperty(value = "出单协议")
+    private String agreementName;
+
+    @Schema(description = "订单类型")
+    @ExcelProperty(value = "订单类型")
+    private String entryStatus;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @Schema(description = "应收跟单费")
+    @ExcelProperty(value = "应收跟单费")
+    private String receivableAmount;
+
+    @Schema(description = "险种")
+    @ExcelProperty(value = "险种")
+    private String productName;
+
+    @Schema(description = "被保人")
+    @ExcelProperty(value = "被保人")
+    private String insuredPerson;
+
+    @Schema(description = "非车保单号")
+    @ExcelProperty(value = "非车保单号")
+    private String jqPolicyNo;
+
+    @Schema(description = "非车保费")
+    @ExcelProperty(value = "非车保费")
+    private String jqPremium;
+
+    @Schema(description = "非车险不含税保费")
+    @ExcelProperty(value = "非车险不含税保费")
+    private String jqPremiumNoTax;
+
+    @Schema(description = "非车跟单费比例")
+    @ExcelProperty(value = "非车跟单费比例")
+    private String jqSuperviseCostsProportion;
+
+    @Schema(description = "交强起保日期")
+    @ExcelProperty(value = "交强起保日期")
+    private String jqStartDate;
+
+    @Schema(description = "商业起保日期")
+    @ExcelProperty(value = "商业起保日期")
+    private String syStartDate;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+}

+ 95 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherSettlementDetailExcelDto.java

@@ -0,0 +1,95 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/30 15:28
+ */
+
+@Data
+public class ExportOtherSettlementDetailExcelDto {
+    @Schema(description = "结算记录编号")
+    @ExcelProperty("结算记录编号")
+    private String settlementId;
+
+    @Schema(description = "开票记录编号")
+    @ExcelProperty("开票记录编号")
+    private String invoiceId;
+
+    @Schema(description = "保险公司")
+    @ExcelProperty(value = "保险公司")
+    private String companyName;
+
+    @Schema(description = "开票方")
+    @ExcelProperty(value = "开票方")
+    private String invoiceParty;
+
+    @Schema(description = "签单时间")
+    @ExcelProperty(value = "签单时间")
+    private String signingTime;
+
+    @Schema(description = "状态")
+    @ExcelProperty(value = "状态")
+    private String status;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @Schema(description = "险种")
+    @ExcelProperty(value = "险种")
+    private String productName;
+
+    @Schema(description = "应收跟单费")
+    @ExcelProperty(value = "应收跟单费")
+    private String receivableOtherCosts;
+
+    @Schema(description = "交强保单号")
+    @ExcelProperty(value = "交强保单号")
+    private String jqPolicyNo;
+
+    @Schema(description = "交强保费")
+    @ExcelProperty(value = "交强保费")
+    private String jqPremium;
+
+    @Schema(description = "交强跟单费比例")
+    @ExcelProperty(value = "交强跟单费比例")
+    private String jqOtherCostsProportion;
+
+    @Schema(description = "商业保单号")
+    @ExcelProperty(value = "商业保单号")
+    private String syPolicyNo;
+
+    @Schema(description = "商业保费")
+    @ExcelProperty(value = "商业保费")
+    private String syPremium;
+
+    @Schema(description = "商业跟单费比例")
+    @ExcelProperty(value = "商业跟单费比例")
+    private String syOtherCostsProportion;
+
+    @Schema(description = "车船税")
+    @ExcelProperty(value = "车船税")
+    private String taxPremium;
+
+    @Schema(description = "开票人")
+    @ExcelProperty(value = "开票人")
+    private String invoicePerson;
+
+    @Schema(description = "开票时间")
+    @ExcelProperty(value = "开票时间")
+    private LocalDateTime invoiceTime;
+
+    @Schema(description = "结算人")
+    @ExcelProperty(value = "结算人")
+    private String settlementPerson;
+
+    @Schema(description = "结算时间")
+    @ExcelProperty(value = "结算时间")
+    private LocalDateTime settlementTime;
+}

+ 84 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherSettlementDetailJyExcelDto.java

@@ -0,0 +1,84 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/30 15:29
+ */
+
+@Data
+public class ExportOtherSettlementDetailJyExcelDto {
+    @Schema(description = "开票记录编号")
+    @ExcelProperty(value = "开票记录编号")
+    private String invoiceId;
+
+    @Schema(description = "结算记录编号")
+    @ExcelProperty(value = "结算记录编号")
+    private String settlementId;
+
+    @Schema(description = "保险公司")
+    @ExcelProperty(value = "保险公司")
+    private String companyName;
+
+    @Schema(description = "开票方")
+    @ExcelProperty(value = "开票方")
+    private String invoiceParty;
+
+    @Schema(description = "签单时间")
+    @ExcelProperty(value = "签单时间")
+    private String signingTime;
+
+    @Schema(description = "状态")
+    @ExcelProperty(value = "状态")
+    private String status;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @Schema(description = "险种")
+    @ExcelProperty(value = "险种")
+    private String productName;
+
+    @Schema(description = "应收跟单费")
+    @ExcelProperty(value = "应收跟单费")
+    private String receivableSuperviseCosts;
+
+    @Schema(description = "非车保单号")
+    @ExcelProperty(value = "非车保单号")
+    private String jyPolicyNo;
+
+    @Schema(description = "非车保费")
+    @ExcelProperty(value = "非车保费")
+    private String jyPremium;
+
+    @Schema(description = "非车跟单费比例")
+    @ExcelProperty(value = "非车跟单费比例")
+    private String jyOtherCostsProportion;
+
+    @Schema(description = "商业保单号")
+    @ExcelProperty(value = "商业保单号")
+    private String syPolicyNo;
+
+    @Schema(description = "开票人")
+    @ExcelProperty(value = "开票人")
+    private String invoicePerson;
+
+    @Schema(description = "开票时间")
+    @ExcelProperty(value = "开票时间")
+    private LocalDateTime invoiceTime;
+
+    @Schema(description = "结算人")
+    @ExcelProperty(value = "结算人")
+    private String settlementPerson;
+
+    @Schema(description = "结算时间")
+    @ExcelProperty(value = "结算时间")
+    private LocalDateTime settlementTime;
+
+}

+ 57 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherSettlementExcelDto.java

@@ -0,0 +1,57 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/30 10:49
+ */
+
+@Data
+public class ExportOtherSettlementExcelDto {
+
+    @Schema(description = "结算记录编号")
+    @ExcelProperty(value = "结算记录编号")
+    private String settlementId;
+
+    @Schema(description = "保险公司")
+    @ExcelProperty(value = "保险公司")
+    private String companyName;
+
+    @Schema(description = "开票方")
+    @ExcelProperty(value = "开票方")
+    private String invoiceParty;
+
+    @Schema(description = "应收项")
+    @ExcelProperty(value = "应收项")
+    private String invoiceType;
+
+    @Schema(description = "税点")
+    @ExcelProperty(value = "税点")
+    private String taxPoint;
+
+    @Schema(description = "实收金额")
+    @ExcelProperty(value = "实收金额")
+    private String actualReceivedAmount;
+
+    @Schema(description = "收款日期")
+    @ExcelProperty(value = "收款日期")
+    private String receivePaymentDate;
+
+    @Schema(description = "结算人")
+    @ExcelProperty(value = "结算人")
+    private String createBy;
+
+    @Schema(description = "结算时间")
+    @ExcelProperty(value = "结算时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "开票记录编号")
+    @ExcelProperty(value = "开票记录编号")
+    private String invoiceId;
+
+}

+ 111 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseExcelDto.java

@@ -0,0 +1,111 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/25 10:05
+ * 手续费 车险应收
+ */
+
+@Data
+public class ExportSuperviseExcelDto {
+    @Schema(description = "签单时间")
+    @ExcelProperty(value = "签单时间")
+    private String signingTime;
+
+    @Schema(description = "订单号")
+    @ExcelProperty(value = "订单号")
+    private String orderNo;
+
+    @Schema(description = "保司名称")
+    @ExcelProperty(value = "保司名称")
+    private String companyName;
+
+    @Schema(description = "出单机构")
+    @ExcelProperty(value = "出单机构")
+    private String deptName;
+
+    @Schema(description = "出单协议")
+    @ExcelProperty(value = "出单协议")
+    private String agreementName;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @Schema(description = "总应收金额")
+    @ExcelProperty(value = "总应收金额")
+    private String receivableAmount;
+
+    @Schema(description = "险种")
+    @ExcelProperty(value = "险种")
+    private String productName;
+
+    @Schema(description = "被保人")
+    @ExcelProperty(value = "被保人")
+    private String insuredPerson;
+
+    @Schema(description = "交强保单号")
+    @ExcelProperty(value = "交强保单号")
+    private String jqPolicyNo;
+
+    @Schema(description = "交强保费")
+    @ExcelProperty(value = "交强保费")
+    private String jqPremium;
+
+    @Schema(description = "交强手续费比例")
+    @ExcelProperty(value = "交强手续费比例")
+    private String jqSuperviseCostsProportion;
+
+    @Schema(description = "交强起保日期")
+    @ExcelProperty(value = "交强起保日期")
+    private String jqStartDate;
+
+    @Schema(description = "商业保单号")
+    @ExcelProperty(value = "商业保单号")
+    private String syPolicyNo;
+
+    @Schema(description = "商业保费")
+    @ExcelProperty(value = "商业保费")
+    private String syPremium;
+
+    @Schema(description = "商业手续费比例")
+    @ExcelProperty(value = "商业手续费比例")
+    private String sySuperviseCostsProportion;
+
+    @Schema(description = "商业起保日期")
+    @ExcelProperty(value = "商业起保日期")
+    private String syStartDate;
+
+    @Schema(description = "车船税")
+    @ExcelProperty(value = "车船税")
+    private String taxPremium;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty(value = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @Schema(description = "创建人")
+    @ExcelProperty(value = "创建人")
+    private String createBy;
+
+    @Schema(description = "操作时间")
+    @ExcelProperty(value = "操作时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+
+    @Schema(description = "操作人")
+    @ExcelProperty(value = "操作人")
+    private String updateBy;
+
+    @Schema(description = "对接人")
+    @ExcelProperty(value = "对接人")
+    private String contactPerson;
+}

+ 77 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseJyExcelDto.java

@@ -0,0 +1,77 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author quchen
+ * @date 2025/7/29 15:07
+ */
+
+@Data
+public class ExportSuperviseJyExcelDto {
+    @Schema(description = "签单时间")
+    @ExcelProperty(value = "签单时间")
+    private String signingTime;
+
+    @Schema(description = "订单号")
+    @ExcelProperty(value = "订单号")
+    private String orderNo;
+
+    @Schema(description = "保司名称")
+    @ExcelProperty(value = "保司名称")
+    private String companyName;
+
+    @Schema(description = "出单机构")
+    @ExcelProperty(value = "出单机构")
+    private String deptName;
+
+    @Schema(description = "出单协议")
+    @ExcelProperty(value = "出单协议")
+    private String agreementName;
+
+    @Schema(description = "订单类型")
+    @ExcelProperty(value = "订单类型")
+    private String entryStatus;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @Schema(description = "险种")
+    @ExcelProperty(value = "险种")
+    private String productName;
+
+    @Schema(description = "被保人")
+    @ExcelProperty(value = "被保人")
+    private String insuredPerson;
+
+    @Schema(description = "非车保单号")
+    @ExcelProperty(value = "非车保单号")
+    private String jyPolicyNo;
+
+    @Schema(description = "非车保费")
+    @ExcelProperty(value = "非车保费")
+    private String jyPremium;
+
+    @Schema(description = "非车手续费比例")
+    @ExcelProperty(value = "非车手续费比例")
+    private String jySuperviseCostsProportion;
+
+    @Schema(description = "交强起保日期")
+    @ExcelProperty(value = "交强起保日期")
+    private String jqStartDate;
+
+    @Schema(description = "商业起保日期")
+    @ExcelProperty(value = "商业起保日期")
+    private String syStartDate;
+
+    @Schema(description = "创建人")
+    @ExcelProperty(value = "创建人")
+    private String createBy;
+
+    @Schema(description = "对接人")
+    @ExcelProperty(value = "对接人")
+    private String contactPerson;
+}

+ 96 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementDetailExcelDto.java

@@ -0,0 +1,96 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/28 16:37
+ */
+
+@Data
+public class ExportSuperviseSettlementDetailExcelDto {
+    @Schema(description = "结算记录编号")
+    @ExcelProperty("结算记录编号")
+    private String settlementId;
+
+    @Schema(description = "开票记录编号")
+    @ExcelProperty("开票记录编号")
+    private String invoiceId;
+
+    @Schema(description = "保险公司")
+    @ExcelProperty(value = "保险公司")
+    private String companyName;
+
+    @Schema(description = "开票方")
+    @ExcelProperty(value = "开票方")
+    private String invoiceParty;
+
+    @Schema(description = "签单时间")
+    @ExcelProperty(value = "签单时间")
+    private String signingTime;
+
+    @Schema(description = "状态")
+    @ExcelProperty(value = "状态")
+    private String status;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @Schema(description = "险种")
+    @ExcelProperty(value = "险种")
+    private String productName;
+
+    @Schema(description = "应收手续费")
+    @ExcelProperty(value = "应收手续费")
+    private String receivableSuperviseCosts;
+
+    @Schema(description = "交强保单号")
+    @ExcelProperty(value = "交强保单号")
+    private String jqPolicyNo;
+
+    @Schema(description = "交强保费")
+    @ExcelProperty(value = "交强保费")
+    private String jqPremium;
+
+    @Schema(description = "交强手续费比例")
+    @ExcelProperty(value = "交强手续费比例")
+    private String jqSuperviseCostsProportion;
+
+    @Schema(description = "商业保单号")
+    @ExcelProperty(value = "商业保单号")
+    private String syPolicyNo;
+
+    @Schema(description = "商业保费")
+    @ExcelProperty(value = "商业保费")
+    private String syPremium;
+
+    @Schema(description = "商业手续费比例")
+    @ExcelProperty(value = "商业手续费比例")
+    private String sySuperviseCostsProportion;
+
+    @Schema(description = "车船税")
+    @ExcelProperty(value = "车船税")
+    private String taxPremium;
+
+    @Schema(description = "开票人")
+    @ExcelProperty(value = "开票人")
+    private String invoicePerson;
+
+    @Schema(description = "开票时间")
+    @ExcelProperty(value = "开票时间")
+    private LocalDateTime invoiceTime;
+
+    @Schema(description = "结算人")
+    @ExcelProperty(value = "结算人")
+    private String settlementPerson;
+
+    @Schema(description = "结算时间")
+    @ExcelProperty(value = "结算时间")
+    private LocalDateTime settlementTime;
+
+}

+ 84 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementDetailJyExcelDto.java

@@ -0,0 +1,84 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/29 9:25
+ */
+
+@Data
+public class ExportSuperviseSettlementDetailJyExcelDto {
+    @Schema(description = "结算记录编号")
+    @ExcelProperty("结算记录编号")
+    private String settlementId;
+
+    @Schema(description = "开票记录编号")
+    @ExcelProperty("开票记录编号")
+    private String invoiceId;
+
+    @Schema(description = "保险公司")
+    @ExcelProperty(value = "保险公司")
+    private String companyName;
+
+    @Schema(description = "开票方")
+    @ExcelProperty(value = "开票方")
+    private String invoiceParty;
+
+    @Schema(description = "签单时间")
+    @ExcelProperty(value = "签单时间")
+    private String signingTime;
+
+    @Schema(description = "状态")
+    @ExcelProperty(value = "状态")
+    private String status;
+
+    @Schema(description = "车牌号")
+    @ExcelProperty(value = "车牌号")
+    private String licenseNo;
+
+    @Schema(description = "险种")
+    @ExcelProperty(value = "险种")
+    private String productName;
+
+    @Schema(description = "应收手续费")
+    @ExcelProperty(value = "应收手续费")
+    private String receivableSuperviseCosts;
+
+    @Schema(description = "非车保单号")
+    @ExcelProperty(value = "非车保单号")
+    private String jyPolicyNo;
+
+    @Schema(description = "非车保费")
+    @ExcelProperty(value = "非车保费")
+    private String jyPremium;
+
+    @Schema(description = "非车手续费比例")
+    @ExcelProperty(value = "非车手续费比例")
+    private String jySuperviseCostsProportion;
+
+    @Schema(description = "商业保单号")
+    @ExcelProperty(value = "商业保单号")
+    private String syPolicyNo;
+
+    @Schema(description = "开票人")
+    @ExcelProperty(value = "开票人")
+    private String invoicePerson;
+
+    @Schema(description = "开票时间")
+    @ExcelProperty(value = "开票时间")
+    private LocalDateTime invoiceTime;
+
+    @Schema(description = "结算人")
+    @ExcelProperty(value = "结算人")
+    private String settlementPerson;
+
+    @Schema(description = "结算时间")
+    @ExcelProperty(value = "结算时间")
+    private LocalDateTime settlementTime;
+
+}

+ 57 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementExcelDto.java

@@ -0,0 +1,57 @@
+package com.jzg.commons.entity.finance.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author quchen
+ * @date 2025/7/28 14:42
+ */
+
+@Data
+public class ExportSuperviseSettlementExcelDto {
+
+    @Schema(description = "结算记录编号")
+    @ExcelProperty(value = "结算记录编号")
+    private String settlementId;
+
+    @Schema(description = "保险公司")
+    @ExcelProperty(value = "保险公司")
+    private String companyName;
+
+    @Schema(description = "开票方")
+    @ExcelProperty(value = "开票方")
+    private String invoiceParty;
+
+    @Schema(description = "应收项")
+    @ExcelProperty(value = "应收项")
+    private String invoiceType;
+
+    @Schema(description = "税点")
+    @ExcelProperty(value = "税点")
+    private String taxPoint;
+
+    @Schema(description = "实收金额")
+    @ExcelProperty(value = "实收金额")
+    private String actualReceivedAmount;
+
+    @Schema(description = "收款日期")
+    @ExcelProperty(value = "收款日期")
+    private String receivePaymentDate;
+
+    @Schema(description = "结算人")
+    @ExcelProperty(value = "结算人")
+    private String createBy;
+
+    @Schema(description = "结算时间")
+    @ExcelProperty(value = "结算时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "开票记录编号")
+    @ExcelProperty(value = "开票记录编号")
+    private String invoiceId;
+
+}

+ 19 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/InvoiceAmountDto.java

@@ -0,0 +1,19 @@
+package com.jzg.commons.entity.finance.dto;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author quchen
+ * @date 2025/8/4 10:34
+ */
+
+@Data
+public class InvoiceAmountDto {
+    private String companyId;
+
+    private String companyName;
+
+    private BigDecimal superviseAmount;
+}

+ 25 - 0
commons/src/main/java/com/jzg/commons/entity/finance/po/InsPlyIncome.java

@@ -21,6 +21,12 @@ public class InsPlyIncome  extends BaseModel {
     @Schema(description = "机构名称")
     private String deptName;
 
+    @Schema(description = "产品id")
+    private String productId;
+
+    @Schema(description = "产品名称")
+    private String productName;
+
     @Schema(description = "险种")
     private String riskCode;
 
@@ -42,6 +48,9 @@ public class InsPlyIncome  extends BaseModel {
     @Schema(description = "协议名称")
     private String agreementName;
 
+    @Schema(description = "被保人")
+    private String insuredPerson;
+
     @Schema(description = "车牌号")
     private String licenseNo;
 
@@ -84,6 +93,9 @@ public class InsPlyIncome  extends BaseModel {
     @Schema(description = "驾意手续费比例")
     private String jySuperviseCostsProportion;
 
+    @Schema(description = "应收手续费")
+    private String superviseCostsPremiums;
+
     @Schema(description = "交强跟单费比例")
     private String jqOtherCostsProportion;
 
@@ -111,6 +123,9 @@ public class InsPlyIncome  extends BaseModel {
     @Schema(description = "驾意应收费用")
     private String jyReceivablePremium;
 
+    @Schema(description = "总应收金额")
+    private String receivableAmount;
+
     @Schema(description = "手续费是否已经结算")
     private String superviseSettlement;
 
@@ -132,4 +147,14 @@ public class InsPlyIncome  extends BaseModel {
     @Schema(description = "对接人")
     private String contactPerson;
 
+    @Schema(description = "系统code")
+    private String systemCode;
+
+    @Schema(description = "交强起保日期")
+    private String jqStartDate;
+
+    @Schema(description = "商业起保日期")
+    private String syStartDate;
+
+
 }

+ 8 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/ReceivableQueryVo.java

@@ -3,6 +3,8 @@ package com.jzg.commons.entity.finance.vo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.util.List;
+
 
 /**
  * @author tz
@@ -31,12 +33,18 @@ public class ReceivableQueryVo {
     @Schema(description = "订单号")
     private String orderNo;
 
+    @Schema(description = "订单号集合")
+    private List<String> orderNos;
+
     @Schema(description = "协议id")
     private String agreementId;
 
     @Schema(description = "出单机构")
     private String deptId;
 
+    @Schema(description = "产品id")
+    private String productId;
+
     @Schema(description = "险种")
     private String riskCode;
 

+ 46 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementQueryVo.java

@@ -0,0 +1,46 @@
+package com.jzg.commons.entity.finance.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author quchen
+ * @date 2025/7/28 17:41
+ */
+
+@Data
+@Schema(description = "结算记录查询Vo")
+public class SettlementQueryVo {
+
+    @Schema(description = "结算记录编号")
+    private String settlementId;
+
+    @Schema(description = "开票记录编号")
+    private String invoiceId;
+
+    @Schema(description = "保险公司Id")
+    private String companyId;
+
+    @Schema(description = "开票方")
+    private String invoiceParty;
+
+    @Schema(description = "结算状态")
+    private String status;
+
+    @Schema(description = "结算人")
+    private String settlementPerson;
+
+    @Schema(description = "结算时间开始")
+    private String settlementTimeStart;
+
+    @Schema(description = "结算时间结束")
+    private String settlementTimeEnd;
+
+    @Schema(description = "结算记录编号集合")
+    private List<String> settlementIds;
+
+    @Schema(description = "开票类型集合")
+    private List<String> invoiceTypes;
+}

+ 32 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementReportQueryVo.java

@@ -0,0 +1,32 @@
+package com.jzg.commons.entity.finance.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author quchen
+ * @date 2025/7/31 17:59
+ */
+
+@Data
+public class SettlementReportQueryVo {
+    @Schema(description = "保险公司id")
+    private String companyId;
+
+    @Schema(description = "开始时间")
+    private String startTime;
+
+    @Schema(description = "结束时间")
+    private String endTime;
+
+    @Schema(description = "结算状态")
+    private String status;
+
+    @Schema(description = "开票类型 1 手续费  2 跟单费  3 驾意险手续费 4 驾意险跟单费")
+    private List<String> invoiceTypes;
+
+    @Schema(description = "上级公司id")
+    private String parentId;
+}

+ 3 - 0
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreement.java

@@ -52,6 +52,9 @@ public class PtlAgreement extends BaseModel {
     @Schema(description = "关联-保险公司id")
     private String companyId;
 
+    @Schema(description = "合作-保险公司id")
+    private String partnerCompanyId;
+
     /** 协议起期 */
     @Schema(description = "协议起期")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")

+ 29 - 0
commons/src/main/java/com/jzg/commons/util/EasyExcelUtils.java

@@ -0,0 +1,29 @@
+package com.jzg.commons.util;
+
+import com.alibaba.excel.EasyExcel;
+import com.jzg.commons.entity.finance.dto.ExportSuperviseExcelDto;
+import com.jzg.commons.entity.finance.po.InsPlyIncome;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Random;
+
+/**
+ * @author quchen
+ * @date 2025/7/21 16:32
+ */
+
+@Component
+public class EasyExcelUtils {
+    public static String downExcel(String uploadFilePath, String fileName, Class clz, List<?> list) {
+        Random random = new Random();
+        int randomNum = random.nextInt(100000);
+        String formattedNum = String.format("%05d", randomNum);
+        String file = fileName + System.currentTimeMillis() / 1000 + formattedNum + ".xlsx";
+        String filePath = uploadFilePath + file;
+        EasyExcel.write(filePath, clz).sheet("1").doWrite(list);
+        return file;
+    }
+
+
+}

+ 6 - 2
gateway/src/main/resources/application-dev.yml

@@ -33,8 +33,12 @@ spring:
         - id: tenant_route
           uri: http://localhost:8084/
           predicates:
-            - Path=/tenant/**,/dept/**,/area/**,/dict/**,/userInfo/**,/sysOrganization/**,/activity/**,/message/**,/messageNotice/**,/poster/**,/agreement/**,/pltAgreement/**,/agreementRules/**,/plt/areaLicense/**,/scheme/**,/schemeRules/**,/schemeRulesAttrLink/**,/schemeRulesAttr/**,/schemeRulesDictLable/**,/schemeRulesUndwrt/**,/schemeRulesUndwrtAttrLink/**,/schemeRulesUndwrtAttr/**,/schemeRulesUndwrtDictLable/**,/schemeRulesUndwrtRules/**,/schemeRulesUndwrtRulesAttrLink/**,/schemeRules,/ptlAgreementCost/**,/ptlAgreementCost/**,/ptlAgreementCostExternal/**,/operatorTrajectory/**,/messageTemplate/**,/message/**,/appUser/**,/userBankCard/**
-
+            - Path=/tenant/**,/dept/**,/area/**,/dict/**,/userInfo/**,/sysOrganization/**,/activity/**,/message/**,/messageNotice/**,
+             /poster/**,/agreement/**,/pltAgreement/**,/agreementRules/**,/plt/areaLicense/**,/scheme/**,/schemeRules/**,/schemeRulesAttrLink/**,
+             /schemeRulesAttr/**,/schemeRulesDictLable/**,/schemeRulesUndwrt/**,/schemeRulesUndwrtAttrLink/**,/schemeRulesUndwrtAttr/**,
+             /schemeRulesUndwrtDictLable/**,/schemeRulesUndwrtRules/**,/schemeRulesUndwrtRulesAttrLink/**,/schemeRules,/ptlAgreementCost/**,
+             /ptlAgreementCost/**,/ptlAgreementCostExternal/**,/operatorTrajectory/**,/messageTemplate/**,/message/**,/appUser/**,/userBankCard/**,
+             /receivable/**
         - id: summary_route
           uri: http://localhost:9898/
           predicates:

+ 69 - 4
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -4,10 +4,7 @@ import com.jzg.commons.constants.dict.InsOrderStatusEnum;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.finance.po.InsPlyIncome;
 import com.jzg.commons.entity.finance.po.InsPlyIncomeInvoiceSettlement;
-import com.jzg.commons.entity.finance.vo.ImportExcelResultVo;
-import com.jzg.commons.entity.finance.vo.InvoicingVo;
-import com.jzg.commons.entity.finance.vo.ReceivableQueryVo;
-import com.jzg.commons.entity.finance.vo.SettlementVo;
+import com.jzg.commons.entity.finance.vo.*;
 import com.jzg.commons.request.RequestSingleParam;
 import com.jzg.organization.service.ReceivableService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -16,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -168,5 +166,72 @@ public class ReceivableController {
 //    public HttpResult batchModify(@RequestBody List<SettlementVo> settlementVoList){
 //        return receivableService.batchModify(settlementVoList) ? HttpResult.ok("批量修改成功") : HttpResult.error("批量修改失败");
 //    }
+    @PostMapping("exportSuperviseExcel")
+    @Operation(summary = "导出应收手续费excel文件(车险)")
+    public HttpResult exportSuperviseExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportSuperviseExcel(receivableQueryVo));
+    }
+
+    @PostMapping("exportSuperviseJyExcel")
+    @Operation(summary = "导出应收手续费excel文件(非车险)")
+    public HttpResult exportSuperviseJyExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportSuperviseJyExcel(receivableQueryVo));
+    }
+
+    @PostMapping("exportSuperviseSettlementExcel")
+    @Operation(summary = "导出应收手续费结算记录excel文件")
+    public HttpResult exportSuperviseSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportSuperviseSettlementExcel(settlementQueryVo));
+    }
+
+    @PostMapping("exportSuperviseSettlementDetailExcel")
+    @Operation(summary = "导出应收手续费结算明细excel文件")
+    public HttpResult exportSuperviseSettlementDetailExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportSuperviseSettlementDetailExcel(settlementQueryVo));
+    }
+
+    @PostMapping("exportSuperviseSettlementDetailJyExcel")
+    @Operation(summary = "导出应收手续费结算(非车)明细excel文件")
+    public HttpResult exportSuperviseSettlementDetailJyExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportSuperviseSettlementDetailJyExcel(settlementQueryVo));
+    }
+
+    @PostMapping("exportOtherExcel")
+    @Operation(summary = "导出应收跟单费(车险)excel文件")
+    public HttpResult exportOtherExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportOtherExcel(receivableQueryVo));
+    }
+
+    @PostMapping("exportOtherJyExcel")
+    @Operation(summary = "导出应收跟单费(非车险)excel文件")
+    public HttpResult exportOtherJyExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportOtherJyExcel(receivableQueryVo));
+    }
+
+    @PostMapping("exportOtherSettlementExcel")
+    @Operation(summary = "导出应收跟单费结算记录excel文件")
+    public HttpResult exportOtherSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportOtherSettlementExcel(settlementQueryVo));
+    }
+
+    @PostMapping("exportOtherSettlementDetailExcel")
+    @Operation(summary = "导出应收跟单费结算明细excel文件 (车险)")
+    public HttpResult exportOtherSettlementDetailExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportOtherSettlementDetailExcel(settlementQueryVo));
+    }
+
+    @PostMapping("exportOtherSettlementDetailJyExcel")
+    @Operation(summary = "导出应收跟单费结算明细excel文件 (非车险)")
+    public HttpResult exportOtherSettlementDetailJyExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        return HttpResult.ok(receivableService.exportOtherSettlementDetailJyExcel(settlementQueryVo));
+    }
+
+    @PostMapping("companySuperviseSettlementReport")
+    @Operation(summary = "保险公司手续费结算报表")
+    public HttpResult companySuperviseSettlementReport(@RequestBody SettlementReportQueryVo settlementReportQueryVo) {
+        return HttpResult.ok(receivableService.companySuperviseSettlementReport(settlementReportQueryVo));
+    }
+
+
 
 }

+ 87 - 1
tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java

@@ -1,13 +1,17 @@
 package com.jzg.organization.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jzg.commons.entity.finance.dto.*;
 import com.jzg.commons.entity.finance.po.InsPlyIncome;
 import com.jzg.commons.entity.finance.vo.InvoicingVo;
 import com.jzg.commons.entity.finance.vo.ReceivableQueryVo;
+import com.jzg.commons.entity.finance.vo.SettlementQueryVo;
+import com.jzg.commons.entity.finance.vo.SettlementReportQueryVo;
 import com.jzg.commons.entity.po.EsmInsCompany;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Mapper
@@ -26,11 +30,93 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
     List<EsmInsCompany> getReceivableCompany(@Param("invoicingVo") InvoicingVo invoicingVo);
 
     /**
-     * 获取应收列表
+     * 获取车险应收列表
      * @param receivableQueryVo
      * @return
      */
     List<InsPlyIncome> getReceivableList(@Param("receivableQueryVo") ReceivableQueryVo receivableQueryVo);
 
+    /**
+     * 获取非车险应收列表(手续费)
+     * @param receivableQueryVo
+     * @return
+     */
+    List<ExportSuperviseJyExcelDto> getSuperviseJyExcelDtos(@Param("receivableQueryVo") ReceivableQueryVo receivableQueryVo);
+
+    /**
+     * 获取应收结算记录列表
+     * @param settlementQueryVo
+     * @return
+     */
+    List<ExportSuperviseSettlementExcelDto> getSuperviseSettlementExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+
+    /**
+     * 获取应收结算记录明细列表
+     * @param settlementQueryVo
+     * @return
+     */
+    List<ExportSuperviseSettlementDetailExcelDto> getSuperviseSettlementDetailExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+
+    /**
+     * 获取应收结算记录明细列表(非车)
+     * @param settlementQueryVo
+     * @return
+     */
+    List<ExportSuperviseSettlementDetailJyExcelDto> getSuperviseSettlementDetailJyExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+
+    /**
+     * 获取车险跟单费数据
+     * @param receivableQueryVo
+     * @return
+     */
+    List<ExportOtherExcelDto> getOtherExcelDtos(@Param("receivableQueryVo") ReceivableQueryVo receivableQueryVo);
+
+    /**
+     * 获取非车险跟单费数据
+     * @param receivableQueryVo
+     * @return
+     */
+    List<ExportOtherJyExcelDto> getOtherJyExcelDtos(@Param("receivableQueryVo") ReceivableQueryVo receivableQueryVo);
+
+    /**
+     * 获取车险跟单费结算数据
+     * @param settlementQueryVo
+     * @return
+     */
+    List<ExportOtherSettlementExcelDto> getOtherSettlementExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+
+    /**
+     * 获取车险跟单费结算明细数据
+     * @param settlementQueryVo
+     * @return
+     */
+    List<ExportOtherSettlementDetailExcelDto> getOtherSettlementDetailExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+
+
+    /**
+     * 获取车险跟单费结算明细数据(非车险)
+     * @param settlementQueryVo
+     * @return
+     */
+    List<ExportOtherSettlementDetailJyExcelDto> getOtherSettlementDetailJyExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+
+    /**
+     * 获取保险公司手续费结算报表
+     * @param settlementReportQueryVo
+     * @return
+     */
+    //List<CompanySuperviseSettlementReportDto> companySuperviseSettlementReport(@Param("settlementReportQueryVo")SettlementReportQueryVo settlementReportQueryVo)
+
+    /**
+     * 获取所有根级保险公司(无父公司)
+     */
+    List<CompanySuperviseSettlementReportDto> selectRootCompanies(@Param("settlementReportQueryVo") SettlementReportQueryVo settlementReportQueryVo);
+
+    /**
+     * 根据父公司ID获取子公司
+     */
+    List<CompanySuperviseSettlementReportDto> selectChildrenByParentId(@Param("parentId") String parentId, @Param("invoiceTypes") List<String> invoiceTypes);
+
+    List<InvoiceAmountDto> getSuperviseAmount();
     Integer invoicingCheck(@Param("invoicingVo") InvoicingVo invoicingVo);
 }

+ 56 - 0
tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java

@@ -1,6 +1,7 @@
 package com.jzg.organization.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.entity.finance.dto.CompanySuperviseSettlementReportDto;
 import com.jzg.commons.entity.finance.po.InsPlyIncome;
 import com.jzg.commons.entity.finance.po.InsPlyIncomeInvoiceSettlement;
 import com.jzg.commons.entity.finance.vo.*;
@@ -8,6 +9,7 @@ import com.jzg.commons.entity.po.EsmInsCompany;
 import com.jzg.commons.entity.scheme.po.PtlScheme;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.List;
 
@@ -137,4 +139,58 @@ public interface ReceivableService extends IService<InsPlyIncome> {
      * @return
      */
     BigDecimal calcReceivableAmount(BigDecimal premium,BigDecimal ratio);
+
+    /**
+     * 导出应收手续费excel(车险)
+     */
+    String exportSuperviseExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+
+    /**
+     * 导出应收手续费excel(非车险)
+     */
+    String exportSuperviseJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+
+
+    /**
+     * 导出应收手续费结算记录excel
+     */
+    String exportSuperviseSettlementExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+
+    /**
+     * 导出应收手续费结算明细excel(车险)
+     */
+    String exportSuperviseSettlementDetailExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+
+    /**
+     * 导出应收手续费结算明细excel(非车险)
+     */
+    String exportSuperviseSettlementDetailJyExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+
+    /**
+     * 导出应收跟单费excel文件(车险)
+     */
+    String exportOtherExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+
+    /**
+     * 导出应收跟单费excel文件(非车险)
+     */
+    String exportOtherJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+
+    /**
+     * 导出应收跟单费结算记录excel文件
+     */
+    String exportOtherSettlementExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+
+    /**
+     * 导出应收跟单费结算明细excel文件 (车险)
+     */
+    String exportOtherSettlementDetailExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+
+
+    /**
+     * 导出应收跟单费结算明细excel文件 (非车险)
+     */
+    String exportOtherSettlementDetailJyExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+
+    List<CompanySuperviseSettlementReportDto> companySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
 }

+ 347 - 1
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -5,14 +5,15 @@ import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.jzg.commons.constants.dict.InsOrderStatusEnum;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.finance.dto.*;
 import com.jzg.commons.entity.finance.po.*;
 import com.jzg.commons.entity.finance.vo.*;
 import com.jzg.commons.entity.po.EsmInsCompany;
 import com.jzg.commons.entity.po.PtlAgreement;
 import com.jzg.commons.util.AssertionUtils;
+import com.jzg.commons.util.EasyExcelUtils;
 import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.organization.client.EsmInsCompanyClient;
 import com.jzg.organization.excel.listener.JyExcelListener;
@@ -24,14 +25,19 @@ import org.redisson.api.RBucket;
 import org.redisson.api.RKeys;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
@@ -71,6 +77,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     @Autowired
     private PtlAgreementMapper ptlAgreementMapper;
 
+    @Value("${upload.file.path}")
+    private String uploadPath;
+
     // 车辆险种手续费结算锁
     private static final String CAR_INVOICING_COMMISSION_LOCK = "CAR_INVOICING_COMMISSION_LOCK:";
     // 车辆险种跟单费结算锁
@@ -427,6 +436,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             InsPlyIncome insPlyIncome = new InsPlyIncome();
             insPlyIncome.setId(IdGenerate.nextId());
             insPlyIncome.setCompanyId(matchCompany.getId());
+            insPlyIncome.setCompanyName(matchCompany.getName());
             insPlyIncome.setSigningTime(signDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
             insPlyIncome.setAgreementId(ptlAgreement.getId());
             insPlyIncome.setLicenseNo(vo.getLicenseNo());
@@ -697,5 +707,341 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     public BigDecimal calcReceivableAmount(BigDecimal premium,BigDecimal ratio) {
         return premium.multiply(ratio);
     }
+
+    private void verifyUploadPath() throws IOException {
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            Files.createDirectories(path);
+        }
+    }
+
+    /**
+     * 导出应收手续费数据 (车险)
+     * @param receivableQueryVo
+     * @return
+     */
+    @Override
+    public String exportSuperviseExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
+        verifyUploadPath();
+        List<InsPlyIncome> receivableList = getReceivableList(receivableQueryVo);
+        // 转换为DTO列表,只包含需要的字段
+        List<ExportSuperviseExcelDto> dtoList = receivableList.stream()
+                .map(this::convertToDto)
+                .toList();
+        return EasyExcelUtils.downExcel(uploadPath, "车险手续费应收明细", ExportSuperviseExcelDto.class, dtoList);
+    }
+
+    // 过滤不需要的字段
+    private ExportSuperviseExcelDto convertToDto(InsPlyIncome income) {
+        ExportSuperviseExcelDto dto = new ExportSuperviseExcelDto();
+        dto.setSigningTime(income.getSigningTime());
+        dto.setOrderNo(income.getOrderNo());
+        dto.setCompanyName(income.getCompanyName());
+        dto.setDeptName(income.getDeptName());
+        dto.setAgreementName(income.getAgreementName());
+        dto.setLicenseNo(income.getLicenseNo());
+        dto.setReceivableAmount(income.getReceivableAmount());
+        dto.setProductName(income.getProductName());
+        dto.setInsuredPerson(income.getInsuredPerson());
+        dto.setJqPolicyNo(income.getJqPolicyNo());
+        dto.setJqPremium(income.getJqPremium());
+        dto.setJqSuperviseCostsProportion(income.getJqSuperviseCostsProportion());
+        dto.setJqStartDate(income.getJqStartDate());
+        dto.setSyPolicyNo(income.getSyPolicyNo());
+        dto.setSyPremium(income.getSyPremium());
+        dto.setSySuperviseCostsProportion(income.getSySuperviseCostsProportion());
+        dto.setSyStartDate(income.getSyStartDate());
+        dto.setTaxPremium(income.getTaxPremium());
+        dto.setCreateTime(income.getCreateTime());
+        dto.setCreateBy(income.getCreateBy());
+        dto.setUpdateTime(income.getUpdateTime());
+        dto.setUpdateBy(income.getUpdateBy());
+        dto.setContactPerson(income.getContactPerson());
+        return dto;
+    }
+
+    @Override
+    public String exportSuperviseJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportSuperviseJyExcelDto> exportSuperviseJyExcelDtos = baseMapper.getSuperviseJyExcelDtos(receivableQueryVo);
+        exportSuperviseJyExcelDtos.forEach(dto -> {
+            switch (dto.getEntryStatus()) {
+                case "1" -> dto.setEntryStatus("车险订单");
+                case "2" -> dto.setEntryStatus("代客录单");
+                case "3" -> dto.setEntryStatus("补录订单");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "非车险手续费应收明细", ExportSuperviseJyExcelDto.class, exportSuperviseJyExcelDtos);
+    }
+
+
+    /**
+     * 导出应收手续费结算记录
+     * @param settlementQueryVo
+     * @return
+     */
+    @Override
+    public String exportSuperviseSettlementExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.getSuperviseSettlementExcelDtos(settlementQueryVo);
+        exportSuperviseSettlementExcelDtos.forEach(dto -> {
+            if (dto.getInvoiceParty().equals("1")) {
+                dto.setInvoiceParty("我方开票");
+            } else if (dto.getInvoiceParty().equals("2")) {
+                dto.setInvoiceParty("保司开票");
+            }
+            switch (dto.getInvoiceType()) {
+                case "1" -> dto.setInvoiceType("手续费");
+                case "2" -> dto.setInvoiceType("跟单费");
+                case "3" -> dto.setInvoiceType("驾意险手续费");
+                case "4" -> dto.setInvoiceType("驾意险跟单费");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "手续费结算记录", ExportSuperviseSettlementExcelDto.class, exportSuperviseSettlementExcelDtos);
+    }
+
+    /**
+     * 导出应收手续费结算记录明细
+     * @param settlementQueryVo
+     * @return
+     */
+    @Override
+    public String exportSuperviseSettlementDetailExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportSuperviseSettlementDetailExcelDto> exportSuperviseSettlementDetailExcelDtos = baseMapper.getSuperviseSettlementDetailExcelDtos(settlementQueryVo);
+        exportSuperviseSettlementDetailExcelDtos.forEach(dto -> {
+            if (dto.getInvoiceParty().equals("1")) {
+                dto.setInvoiceParty("我方开票");
+            } else if (dto.getInvoiceParty().equals("2")) {
+                dto.setInvoiceParty("保司开票");
+            }
+            if (dto.getStatus().equals("1")) {
+                dto.setStatus("已结算");
+            } else if (dto.getStatus().equals("0")) {
+                dto.setStatus("未结算");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "车险手续费结算明细", ExportSuperviseSettlementDetailExcelDto.class, exportSuperviseSettlementDetailExcelDtos);
+    }
+
+    /**
+     * 导出应收手续费结算记录明细(非车)
+     * @param settlementQueryVo
+     * @return
+     */
+    @Override
+    public String exportSuperviseSettlementDetailJyExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportSuperviseSettlementDetailJyExcelDto> exportSuperviseSettlementDetailJyExcelDtos = baseMapper.getSuperviseSettlementDetailJyExcelDtos(settlementQueryVo);
+        exportSuperviseSettlementDetailJyExcelDtos.forEach(dto -> {
+            if (dto.getInvoiceParty().equals("1")) {
+                dto.setInvoiceParty("我方开票");
+            } else if (dto.getInvoiceParty().equals("2")) {
+                dto.setInvoiceParty("保司开票");
+            }
+            if (dto.getStatus().equals("1")) {
+                dto.setStatus("已结算");
+            } else if (dto.getStatus().equals("0")) {
+                dto.setStatus("未结算");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "非车险手续费结算明细", ExportSuperviseSettlementDetailJyExcelDto.class, exportSuperviseSettlementDetailJyExcelDtos);
+    }
+
+    /**
+     * 导出车险跟单费数据(车险)
+     */
+    @Override
+    public String exportOtherExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportOtherExcelDto> exportOtherExcelDtos = baseMapper.getOtherExcelDtos(receivableQueryVo);
+        exportOtherExcelDtos.forEach(dto -> {
+            switch (dto.getEntryStatus()) {
+                case "1" -> dto.setEntryStatus("车险订单");
+                case "2" -> dto.setEntryStatus("代客录单");
+                case "3" -> dto.setEntryStatus("补录订单");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "车险跟单费应收明细", ExportOtherExcelDto.class, exportOtherExcelDtos);
+    }
+
+    /**
+     * 导出车险跟单费数据(非车险)
+     */
+    @Override
+    public String exportOtherJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportOtherJyExcelDto> exportOtherJyExcelDtos = baseMapper.getOtherJyExcelDtos(receivableQueryVo);
+        exportOtherJyExcelDtos.forEach(dto -> {
+            switch (dto.getEntryStatus()) {
+                case "1" -> dto.setEntryStatus("车险订单");
+                case "2" -> dto.setEntryStatus("代客录单");
+                case "3" -> dto.setEntryStatus("补录订单");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "非车险跟单费应收明细", ExportOtherJyExcelDto.class, exportOtherJyExcelDtos);
+    }
+
+    /**
+     * 导出车险跟单费结算记录
+     */
+    @Override
+    public String exportOtherSettlementExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportOtherSettlementExcelDto> exportOtherSettlementExcelDtos = baseMapper.getOtherSettlementExcelDtos(settlementQueryVo);
+        exportOtherSettlementExcelDtos.forEach(dto -> {
+            if (dto.getInvoiceParty().equals("1")) {
+                dto.setInvoiceParty("我方开票");
+            } else if (dto.getInvoiceParty().equals("2")) {
+                dto.setInvoiceParty("保司开票");
+            }
+            switch (dto.getInvoiceType()) {
+                case "1" -> dto.setInvoiceType("手续费");
+                case "2" -> dto.setInvoiceType("跟单费");
+                case "3" -> dto.setInvoiceType("驾意险手续费");
+                case "4" -> dto.setInvoiceType("驾意险跟单费");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "非车险跟单费应收明细", ExportSuperviseSettlementExcelDto.class, exportOtherSettlementExcelDtos);
+    }
+
+    /**
+     * 导出应收跟单费结算记录明细(车险)
+     */
+    @Override
+    public String exportOtherSettlementDetailExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportOtherSettlementDetailExcelDto> exportOtherSettlementDetailExcelDtos = baseMapper.getOtherSettlementDetailExcelDtos(settlementQueryVo);
+        exportOtherSettlementDetailExcelDtos.forEach(dto -> {
+            if (dto.getInvoiceParty().equals("1")) {
+                dto.setInvoiceParty("我方开票");
+            } else if (dto.getInvoiceParty().equals("2")) {
+                dto.setInvoiceParty("保司开票");
+            }
+            if (dto.getStatus().equals("1")) {
+                dto.setStatus("已结算");
+            } else if (dto.getStatus().equals("0")) {
+                dto.setStatus("未结算");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "车险跟单费结算明细", ExportOtherSettlementDetailExcelDto.class, exportOtherSettlementDetailExcelDtos);
+    }
+
+    /**
+     * 导出车险应收跟单费结算记录明细(非车险)
+     * @param settlementQueryVo
+     * @return
+     * @throws IOException
+     */
+    @Override
+    public String exportOtherSettlementDetailJyExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+        verifyUploadPath();
+        List<ExportOtherSettlementDetailJyExcelDto> exportOtherSettlementDetailJyExcelDtos = baseMapper.getOtherSettlementDetailJyExcelDtos(settlementQueryVo);
+        exportOtherSettlementDetailJyExcelDtos.forEach(dto -> {
+            if (dto.getInvoiceParty().equals("1")) {
+                dto.setInvoiceParty("我方开票");
+            } else if (dto.getInvoiceParty().equals("2")) {
+                dto.setInvoiceParty("保司开票");
+            }
+            if (dto.getStatus().equals("1")) {
+                dto.setStatus("已结算");
+            } else if (dto.getStatus().equals("0")) {
+                dto.setStatus("未结算");
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadPath, "非车险跟单费结算明细", ExportOtherSettlementDetailJyExcelDto.class, exportOtherSettlementDetailJyExcelDtos);
+    }
+
+    @Override
+    public List<CompanySuperviseSettlementReportDto> companySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo) {
+        // 构建查手续费类型的数组
+        List<String> invoiceTypes = new ArrayList<>();
+        invoiceTypes.add("1");
+        invoiceTypes.add("3");
+        settlementReportQueryVo.setInvoiceTypes(invoiceTypes);
+        // 手续费应开票金额
+        List<InvoiceAmountDto> commissionInvoicingAmount = baseMapper.getSuperviseAmount();
+        Map<String, BigDecimal> invoicingAmountMap = commissionInvoicingAmount.stream()
+                .collect(Collectors.toMap(
+                        InvoiceAmountDto::getCompanyId,
+                        dto -> dto.getSuperviseAmount() != null ? dto.getSuperviseAmount() : BigDecimal.ZERO,
+                        (existing, replacement) -> existing
+                ));
+
+        List<CompanySuperviseSettlementReportDto> companySuperviseSettlementReportDtos = baseMapper.selectRootCompanies(settlementReportQueryVo);
+        for (CompanySuperviseSettlementReportDto companySuperviseSettlementReportDto : companySuperviseSettlementReportDtos) {
+            // 递归设置子公司数据
+            setChildren(companySuperviseSettlementReportDto);
+            updateUnInvoicedAmount(companySuperviseSettlementReportDto, invoicingAmountMap);
+        }
+
+        return companySuperviseSettlementReportDtos;
+    }
+
+    private void setChildren(CompanySuperviseSettlementReportDto companySuperviseSettlementReportDto) {
+        // 构建查手续费类型的数组
+        List<String> invoiceTypes = new ArrayList<>();
+        invoiceTypes.add("1");
+        invoiceTypes.add("3");
+        // 获取子公司数据
+        List<CompanySuperviseSettlementReportDto> children = baseMapper.selectChildrenByParentId(companySuperviseSettlementReportDto.getCompanyId(),invoiceTypes);
+        // 如果子公司存在,递归设置每个子公司的children
+        if (children != null && !children.isEmpty()) {
+            companySuperviseSettlementReportDto.setChildren(children);
+            // 递归调用,设置每个子公司的children
+            for (CompanySuperviseSettlementReportDto child : children) {
+                setChildren(child);
+
+                // 将子公司的数据加到父公司
+                companySuperviseSettlementReportDto.setTotalReceivable(
+                        addAmounts(companySuperviseSettlementReportDto.getTotalReceivable(), child.getTotalReceivable())
+                );
+                companySuperviseSettlementReportDto.setSuperviseFee(
+                        addAmounts(companySuperviseSettlementReportDto.getSuperviseFee(), child.getSuperviseFee())
+                );
+                companySuperviseSettlementReportDto.setInvoicedAmount(
+                        addAmounts(companySuperviseSettlementReportDto.getInvoicedAmount(), child.getInvoicedAmount())
+                );
+                companySuperviseSettlementReportDto.setSettledAmount(
+                        addAmounts(companySuperviseSettlementReportDto.getSettledAmount(), child.getSettledAmount())
+                );
+                companySuperviseSettlementReportDto.setUnInvoicedAmount(
+                        addAmounts(companySuperviseSettlementReportDto.getUnInvoicedAmount(), child.getUnInvoicedAmount())
+                );
+                companySuperviseSettlementReportDto.setUnSettledAmount(
+                        addAmounts(companySuperviseSettlementReportDto.getUnSettledAmount(), child.getUnSettledAmount())
+                );
+            }
+        }
+    }
+
+    private void updateUnInvoicedAmount(CompanySuperviseSettlementReportDto dto, Map<String, BigDecimal> invoicingAmountMap) {
+        // 1. 获取当前公司的应开票金额(默认0)
+        BigDecimal invoicingAmount = invoicingAmountMap.getOrDefault(dto.getCompanyId(), BigDecimal.ZERO);
+
+        // 2. 获取当前公司的已开票金额(默认0)
+        BigDecimal invoicedAmount = dto.getInvoicedAmount() != null ? new BigDecimal(dto.getInvoicedAmount()) : BigDecimal.ZERO;
+
+        // 3. 计算未开票金额(应开票 - 已开票)
+        BigDecimal unInvoicedAmount = invoicingAmount.subtract(invoicedAmount);
+
+        // 4. 设置未开票金额
+        dto.setUnInvoicedAmount(String.valueOf(unInvoicedAmount));
+
+        // 5. 递归处理子公司
+        List<CompanySuperviseSettlementReportDto> children = dto.getChildren();
+        if (children != null && !children.isEmpty()) {
+            for (CompanySuperviseSettlementReportDto child : children) {
+                updateUnInvoicedAmount(child, invoicingAmountMap);
+            }
+        }
+    }
+    // 用于加总字符串金额
+    private String addAmounts(String amount1, String amount2) {
+        BigDecimal value1 = new BigDecimal(amount1 != null ? amount1 : "0");
+        BigDecimal value2 = new BigDecimal(amount2 != null ? amount2 : "0");
+        return value1.add(value2).toString();
+    }
 }
 

+ 12 - 0
tenant/organization/src/main/resources/application.yml

@@ -17,6 +17,11 @@ mybatis-plus:
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
+#文件导出路径
+upload:
+  file:
+    path: D:/nasData
+
 #多租户配置
 tenant:
   enable: true
@@ -71,6 +76,13 @@ tenant:
     - ins_orders_car_info
     - ins_orders_policy
     - sys_relation_person
+    - ptl_agreement
+    - ins_ply_income_invoice_link
+    - ins_orders_risk
+    - ins_orders_car_user_info
+    - ins_ply_income
+    - ins_ply_income_invoice
+    - ins_ply_income_invoice_settlement
 
 
   ignoreLoginNames:

+ 601 - 1
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -69,9 +69,19 @@
 
     <select id="getReceivableList" resultType="com.jzg.commons.entity.finance.po.InsPlyIncome">
         SELECT
-            *
+            *,
+            (ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium) as receivableAmount,  -- 总应收金额
+            (ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums) as superviseCostsPremiums, -- 总应收手续费
+            iocui.name AS insuredPerson,
+            ior1.start_date as jqStartDate,
+            ior2.start_date as syStartDate,
+            io.product_name AS productName
         FROM
             ins_ply_income ipi
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
+        LEFT JOIN ins_orders_car_user_info iocui ON ipi.order_no = iocui.order_no and iocui.policy_person_type = '3'
+        LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
+        LEFT JOIN ins_orders_risk ior2 ON ipi.order_no = ior2.order_no and ior2.risk_code = '0510'
         WHERE
             1=1
           AND NOT EXISTS ( SELECT 1 FROM ins_ply_income_invoice_link ipil WHERE ipil.income_id = ipi.id )
@@ -93,6 +103,12 @@
         <if test="receivableQueryVo.orderNo != null and receivableQueryVo.orderNo != ''">
             AND ipi.order_no = #{receivableQueryVo.orderNo}
         </if>
+        <if test="receivableQueryVo.orderNos != null and receivableQueryVo.orderNos != ''">
+            AND ipi.order_no IN
+            <foreach collection="receivableQueryVo.orderNos" item="orderNo" open="(" separator="," close=")">
+                #{orderNo}
+            </foreach>
+        </if>
         <if test="receivableQueryVo.agreementId != null and receivableQueryVo.agreementId != ''">
             AND ipi.agreement_id = #{receivableQueryVo.agreementId}
         </if>
@@ -105,8 +121,471 @@
         <if test="receivableQueryVo.signingTimeStart != null and receivableQueryVo.signingTimeStart != ''">
             AND ipi.signing_time between #{receivableQueryVo.signingTimeStart} and  #{receivableQueryVo.signingTimeEnd}
         </if>
+    </select>
 
+    <select id="getSuperviseJyExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseJyExcelDto">
+        SELECT
+        ipi.signing_time as signingTime,
+        ipi.order_no as orderNo,
+        ipi.company_name as companyName,
+        ipi.dept_name as deptName,
+        ipi.agreement_name as agreementName,
+        io.entry_status as entryStatus,
+        ipi.license_no as licenseNo,
+        (ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium) as receivableAmount,
+        ipi.product_name as productName,
+        iocui.name AS insuredPerson,
+        ipi.jy_premium as jqPremium,
+        ipi.jy_supervise_costs_proportion as jqSuperviseCostsProportion,
+        ipi.jy_policy_no as jyPolicyNo,
+        ior1.start_date as jqStartDate,
+        ior2.start_date as syStartDate,
+        ipi.create_time as createTime,
+        ipi.contact_person as contactPerson
+        FROM
+        ins_ply_income ipi
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
+        LEFT JOIN ins_orders_car_user_info iocui ON ipi.order_no = iocui.order_no and iocui.policy_person_type = '3'
+        LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
+        LEFT JOIN ins_orders_risk ior2 ON ipi.order_no = ior2.order_no and ior2.risk_code = '0510'
+        WHERE
+        1=1
+        AND NOT EXISTS ( SELECT 1 FROM ins_ply_income_invoice_link ipil WHERE ipil.income_id = ipi.id )
+        <if test="receivableQueryVo.queryType != null and receivableQueryVo.queryType == 1">
+            AND ipi.supervise_settlement = 0
+        </if>
+        <if test="receivableQueryVo.queryType!= null and receivableQueryVo.queryType == 2">
+            AND ipi.other_settlement = 1
+        </if>
+        <if test="receivableQueryVo.queryType!= null and (receivableQueryVo.queryType == 3 or receivableQueryVo.queryType == 4)">
+            AND ipi.jy_premium != 0
+        </if>
+        <if test="receivableQueryVo.licenseNo != null and receivableQueryVo.licenseNo != ''">
+            AND ipi.license_no LIKE CONCAT('%', #{receivableQueryVo.licenseNo}, '%')
+        </if>
+        <if test="receivableQueryVo.companyId != null and receivableQueryVo.companyId != ''">
+            AND ipi.company_id = #{receivableQueryVo.companyId}
+        </if>
+        <if test="receivableQueryVo.orderNo != null and receivableQueryVo.orderNo != ''">
+            AND ipi.order_no = #{receivableQueryVo.orderNo}
+        </if>
+        <if test="receivableQueryVo.orderNos != null and receivableQueryVo.orderNos != ''">
+            AND ipi.order_no IN
+            <foreach collection="receivableQueryVo.orderNos" item="orderNo" open="(" separator="," close=")">
+                #{orderNo}
+            </foreach>
+        </if>
+        <if test="receivableQueryVo.agreementId != null and receivableQueryVo.agreementId != ''">
+            AND ipi.agreement_id = #{receivableQueryVo.agreementId}
+        </if>
+        <if test="receivableQueryVo.deptId != null and receivableQueryVo.deptId != ''">
+            AND ipi.dept_id = #{receivableQueryVo.deptId}
+        </if>
+        <if test="receivableQueryVo.productId!= null and receivableQueryVo.productId!= ''">
+            AND ipi.product_id = #{receivableQueryVo.productId}
+        </if>
+        <if test="receivableQueryVo.signingTimeStart != null and receivableQueryVo.signingTimeStart != ''">
+            AND ipi.signing_time between #{receivableQueryVo.signingTimeStart} and  #{receivableQueryVo.signingTimeEnd}
+        </if>
+    </select>
 
+    <select id="getSuperviseSettlementExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementExcelDto">
+        select
+            ipiis.id as settlementId,
+            ipiis.invoice_id as invoiceId,
+            ipi.company_name as companyName,
+            ipii.invoice_type as invoiceType,
+            ipii.invoice_party as invoiceParty,
+            ipii.tax_point as taxPoint,
+            ipiis.actual_received_amount as actualReceivedAmount,
+            ipiis.receive_payment_date as receivePaymentDate,
+            ipiis.create_by as createBy,
+            ipiis.create_time as createTime
+        FROM
+            ins_ply_income_invoice_settlement ipiis
+        LEFT JOIN ins_ply_income_invoice ipii ON ipii.id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
+        WHERE
+            1=1
+        <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
+            AND ipiis.id IN
+            <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
+                #{settlementId}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
+            AND ipi.invoice_type IN
+            <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
+                #{invoiceType}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getSuperviseSettlementDetailExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementDetailExcelDto">
+        select
+        ipiis.id as settlementId, -- 结算记录编号
+        ipiis.invoice_id as invoiceId, -- 开票记录编号
+        ipi.company_name as companyName,  -- 保险公司
+        ipi.signing_time as signingTime, -- 签单时间
+        ipii.status as status, -- 状态
+        ipi.license_no as licenseNo, -- 车牌号
+        io.product_name as productName, -- 险种
+        ipii.invoice_type as invoiceType, -- 应收项
+        ipii.invoice_party as invoiceParty, -- 开票方
+        ipii.tax_point as taxPoint, -- 税点
+        (ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums) as receivableSuperviseCosts, -- 应收手续费
+        ipi.jq_premium as jqPremium, -- 交强保费
+        ipi.jq_supervise_costs_proportion as jqSuperviseCostsProportion, -- 交强手续费比例
+        ipi.jq_policy_no as jqPolicyNo, -- 交强保单号
+        ipi.sy_premium as syPremium, -- 商业保费
+        ipi.sy_supervise_costs_proportion as sySuperviseCostsProportion, -- 商业手续费比例
+        ipi.sy_policy_no as syPolicyNo, -- 商业保单号
+        ipi.tax_premium as taxPremium, -- 车船税
+        ipii.create_by as invoicePerson, -- 开票人
+        ipii.create_time as invoiceTime, -- 开票时间
+        ipiis.create_by as settlementPerson, -- 结算人
+        ipiis.create_time as settlementTime -- 结算时间
+        FROM
+        ins_ply_income_invoice ipii
+        LEFT JOIN ins_ply_income_invoice_settlement ipiis ON ipiis.invoice_id = ipiis.id
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
+        WHERE
+        1=1
+        <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
+            AND ipiis.id IN
+            <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
+                #{settlementId}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
+            AND ipi.invoice_type IN
+            <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
+                #{invoiceType}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
+            AND ipiis.invoice_id = #{settlementQueryVo.invoiceId}
+        </if>
+        <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
+            AND ipi.company_id = #{settlementQueryVo.companyId}
+        </if>
+        <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
+            AND ipi.invoice_party = #{settlementQueryVo.invoiceParty}
+        </if>
+        <if test="settlementQueryVo.settlementPerson != null and settlementQueryVo.settlementPerson != ''">
+            AND ipiis.create_by = #{settlementQueryVo.settlementPerson}
+        </if>
+        <if test="settlementQueryVo.settlementTimeStart != null and settlementQueryVo.settlementTimeStart != ''">
+            AND ipiis.create_time between #{settlementQueryVo.signingTimeStart} and #{settlementQueryVo.signingTimeEnd}
+        </if>
+    </select>
+
+    <select id="getSuperviseSettlementDetailJyExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementDetailJyExcelDto">
+        select
+        ipiis.id as settlementId, -- 结算记录编号
+        ipiis.invoice_id as invoiceId, -- 开票记录编号
+        ipi.company_name as companyName,  -- 保险公司
+        ipi.signing_time as signingTime, -- 签单时间
+        ipii.status as status, -- 状态
+        ipi.license_no as licenseNo, -- 车牌号
+        io.product_name as productName, -- 险种
+        ipii.invoice_type as invoiceType, -- 应收项
+        ipii.invoice_party as invoiceParty, -- 开票方
+        ipii.tax_point as taxPoint, -- 税点
+        (ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums) as receivableSuperviseCosts, -- 应收手续费
+        ipi.jy_premium as jqPremium, -- 驾意保费
+        ipi.jy_supervise_costs_proportion as jySuperviseCostsProportion, -- 驾意险手续费比例
+        ipi.jy_policy_no as jqPolicyNo, -- 交强保单号
+        ipi.sy_policy_no as syPolicyNo, -- 商业保单号
+        ipii.create_by as invoicePerson, -- 开票人
+        ipii.create_time as invoiceTime, -- 开票时间
+        ipiis.create_by as settlementPerson, -- 结算人
+        ipiis.create_time as settlementTime -- 结算时间
+        FROM
+        ins_ply_income_invoice ipii
+        LEFT JOIN ins_ply_income_invoice_settlement ipiis ON ipiis.invoice_id = ipiis.id
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
+        WHERE
+        1=1
+        <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
+            AND ipiis.id IN
+            <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
+                #{settlementId}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
+            AND ipi.invoice_type IN
+            <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
+                #{invoiceType}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
+            AND ipiis.invoice_id = #{settlementQueryVo.invoiceId}
+        </if>
+        <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
+            AND ipi.company_id = #{settlementQueryVo.companyId}
+        </if>
+        <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
+            AND ipi.invoice_party = #{settlementQueryVo.invoiceParty}
+        </if>
+        <if test="settlementQueryVo.settlementPerson != null and settlementQueryVo.settlementPerson != ''">
+            AND ipiis.create_by = #{settlementQueryVo.settlementPerson}
+        </if>
+        <if test="settlementQueryVo.settlementTimeStart != null and settlementQueryVo.settlementTimeStart != ''">
+            AND ipiis.create_time between #{settlementQueryVo.signingTimeStart} and #{settlementQueryVo.signingTimeEnd}
+        </if>
+    </select>
+
+    <select id="getOtherExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportOtherExcelDto">
+        SELECT
+            ipi.signing_time as signingTime,
+            ipi.order_no as orderNo,
+            ipi.company_name as companyName,
+            ipi.dept_name as deptName,
+            ipi.agreement_name as agreementName,
+            io.entry_status as entryStatus,
+            ipi.license_no as licenseNo,
+            (ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums) as receivableAmount,
+            ipi.product_name as productName,
+            iocui.name AS insuredPerson,
+            ipi.jq_premium as jqPremium,
+            ipi.jq_other_costs_proportion as jqSuperviseCostsProportion,
+            ipi.jq_policy_no as jqPolicyNo,
+            ior1.start_date as jqStartDate,
+            ipi.sy_premium as syPremium,
+            ipi.sy_other_costs_proportion as syqSuperviseCostsProportion,
+            ipi.sy_policy_no as syPolicyNo,
+            ior2.start_date as syStartDate,
+            ipi.tax_premium as taxPremium,
+            ipi.create_time as createTime,
+            ipi.contact_person as contactPerson
+        FROM ins_ply_income ipi
+        LEFT JOIN ins_order io ON ipi.order_no = io.order_no
+        LEFT JOIN ins_orders_car_user_info iocui ON ipi.order_no = iocui.order_no and iocui.policy_person_type = '3'
+        LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
+        LEFT JOIN ins_orders_risk ior2 ON ipi.order_no = ior2.order_no and ior2.risk_code = '0510'
+        WHERE
+            1=1
+        <if test="receivableQueryVo.licenseNo != null and receivableQueryVo.licenseNo != ''">
+            and ipi.licenseNo = #{receivableQueryVo.licenseNo}
+        </if>
+        <if test="receivableQueryVo.orderNo != null and receivableQueryVo.orderNo != ''">
+            and ipi.order_no = #{receivableQueryVo.orderNo}
+        </if>
+        <if test="receivableQueryVo.companyId != null and receivableQueryVo.companyId != ''">
+            and ipi.company_id = #{receivableQueryVo.companyId}
+        </if>
+        <if test="receivableQueryVo.deptId != null and receivableQueryVo.deptId != ''">
+            and ipi.dept_id = #{receivableQueryVo.deptId}
+        </if>
+        <if test="receivableQueryVo.agreementId != null and receivableQueryVo.agreementId != ''">
+            and ipi.agreement_id = #{receivableQueryVo.agreementId}
+        </if>
+        <if test="receivableQueryVo.signingTimeStart != null and receivableQueryVo.signingTimeStart != ''">
+            and ipi.signing_time between #{receivableQueryVo.signingTimeStart} and #{receivableQueryVo.signingTimeEnd}
+        </if>
+    </select>
+
+    <select id="getOtherJyExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportOtherJyExcelDto">
+        SELECT
+            ipi.signing_time as signingTime,
+            ipi.order_no as orderNo,
+            ipi.company_name as companyName,
+            ipi.dept_name as deptName,
+            ipi.agreement_name as agreementName,
+            io.entry_status as entryStatus,
+            ipi.license_no as licenseNo,
+            (ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums) as receivableAmount,
+            ipi.product_name as productName,
+            iocui.name AS insuredPerson,
+            ipi.jy_premium as jyPremium,
+            ipi.jy_other_costs_proportion as jySuperviseCostsProportion,
+            ipi.jy_policy_no as jyPolicyNo,
+            ior1.start_date as jqStartDate,
+            ior2.start_date as syStartDate,
+            ipi.create_time as createTime
+        FROM ins_ply_income ipi
+        LEFT JOIN ins_order io ON ipi.order_no = io.order_no
+        LEFT JOIN ins_orders_car_user_info iocui ON ipi.order_no = iocui.order_no and iocui.policy_person_type = '3'
+        LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
+        LEFT JOIN ins_orders_risk ior2 ON ipi.order_no = ior2.order_no and ior2.risk_code = '0510'
+        WHERE
+        1=1
+        <if test="receivableQueryVo.licenseNo != null and receivableQueryVo.licenseNo != ''">
+            and ipi.licenseNo = #{receivableQueryVo.licenseNo}
+        </if>
+        <if test="receivableQueryVo.orderNo != null and receivableQueryVo.orderNo != ''">
+            and ipi.order_no = #{receivableQueryVo.orderNo}
+        </if>
+        <if test="receivableQueryVo.companyId != null and receivableQueryVo.companyId != ''">
+            and ipi.company_id = #{receivableQueryVo.companyId}
+        </if>
+        <if test="receivableQueryVo.deptId != null and receivableQueryVo.deptId != ''">
+            and ipi.dept_id = #{receivableQueryVo.deptId}
+        </if>
+        <if test="receivableQueryVo.agreementId != null and receivableQueryVo.agreementId != ''">
+            and ipi.agreement_id = #{receivableQueryVo.agreementId}
+        </if>
+        <if test="receivableQueryVo.signingTimeStart != null and receivableQueryVo.signingTimeStart != ''">
+            and ipi.signing_time between #{receivableQueryVo.signingTimeStart} and #{receivableQueryVo.signingTimeEnd}
+        </if>
+    </select>
+
+    <select id="getOtherSettlementExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportOtherSettlementExcelDto">
+        select
+        ipiis.id as settlementId,
+        ipiis.invoice_id as invoiceId,
+        ipi.company_name as companyName,
+        ipii.invoice_type as invoiceType,
+        ipii.invoice_party as invoiceParty,
+        ipii.tax_point as taxPoint,
+        ipiis.actual_received_amount as actualReceivedAmount,
+        ipiis.receive_payment_date as receivePaymentDate,
+        ipiis.create_by as createBy,
+        ipiis.create_time as createTime
+        FROM
+        ins_ply_income_invoice_settlement ipiis
+        LEFT JOIN ins_ply_income_invoice ipii ON ipii.id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
+        WHERE
+        1=1
+        <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
+            AND ipiis.id IN
+            <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
+                #{settlementId}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
+            AND ipi.invoice_type IN
+            <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
+                #{invoiceType}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getOtherSettlementDetailExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportOtherSettlementDetailExcelDto">
+        select
+        ipiis.id as settlementId, -- 结算记录编号
+        ipiis.invoice_id as invoiceId, -- 开票记录编号
+        ipi.company_name as companyName,  -- 保险公司
+        ipi.signing_time as signingTime, -- 签单时间
+        ipii.status as status, -- 状态
+        ipi.license_no as licenseNo, -- 车牌号
+        io.product_name as productName, -- 险种
+        ipii.invoice_type as invoiceType, -- 应收项
+        ipii.invoice_party as invoiceParty, -- 开票方
+        ipii.tax_point as taxPoint, -- 税点
+        (ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums) as receivableOtherCosts, -- 应收跟单费
+        ipi.jq_premium as jqPremium, -- 交强保费
+        ipi.jq_other_costs_proportion as jqOtherCostsProportion, -- 交强手续费比例
+        ipi.jq_policy_no as jqPolicyNo, -- 交强保单号
+        ipi.sy_premium as syPremium, -- 商业保费
+        ipi.sy_other_costs_proportion as syOtherCostsProportion, -- 商业手续费比例
+        ipi.sy_policy_no as syPolicyNo, -- 商业保单号
+        ipi.tax_premium as taxPremium, -- 车船税
+        ipii.create_by as invoicePerson, -- 开票人
+        ipii.create_time as invoiceTime, -- 开票时间
+        ipiis.create_by as settlementPerson, -- 结算人
+        ipiis.create_time as settlementTime -- 结算时间
+        FROM
+        ins_ply_income_invoice ipii
+        LEFT JOIN ins_ply_income_invoice_settlement ipiis ON ipiis.invoice_id = ipiis.id
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
+        WHERE
+        1=1
+        <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
+            AND ipiis.id IN
+            <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
+                #{settlementId}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
+            AND ipi.invoice_type IN
+            <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
+                #{invoiceType}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
+            AND ipiis.invoice_id = #{settlementQueryVo.invoiceId}
+        </if>
+        <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
+            AND ipi.company_id = #{settlementQueryVo.companyId}
+        </if>
+        <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
+            AND ipi.invoice_party = #{settlementQueryVo.invoiceParty}
+        </if>
+        <if test="settlementQueryVo.settlementPerson != null and settlementQueryVo.settlementPerson != ''">
+            AND ipiis.create_by = #{settlementQueryVo.settlementPerson}
+        </if>
+        <if test="settlementQueryVo.settlementTimeStart != null and settlementQueryVo.settlementTimeStart != ''">
+            AND ipiis.create_time between #{receivableQueryVo.signingTimeStart} and #{receivableQueryVo.signingTimeEnd}
+        </if>
+    </select>
+
+    <select id="getOtherSettlementDetailJyExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportOtherSettlementDetailJyExcelDto">
+        select
+        ipiis.id as settlementId, -- 结算记录编号
+        ipiis.invoice_id as invoiceId, -- 开票记录编号
+        ipi.company_name as companyName,  -- 保险公司
+        ipi.signing_time as signingTime, -- 签单时间
+        ipii.status as status, -- 状态
+        ipi.license_no as licenseNo, -- 车牌号
+        io.product_name as productName, -- 险种
+        ipii.invoice_type as invoiceType, -- 应收项
+        ipii.invoice_party as invoiceParty, -- 开票方
+        ipii.tax_point as taxPoint, -- 税点
+        (ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums) as receivableSuperviseCosts, -- 应收手续费
+        ipi.jy_premium as jqPremium, -- 驾意保费
+        ipi.jy_other_costs_proportion as jqOtherCostsProportion, -- 驾意险跟单费比例
+        ipi.jy_policy_no as jqPolicyNo, -- 交强保单号
+        ipi.sy_policy_no as syPolicyNo, -- 商业保单号
+        ipii.create_by as invoicePerson, -- 开票人
+        ipii.create_time as invoiceTime, -- 开票时间
+        ipiis.create_by as settlementPerson, -- 结算人
+        ipiis.create_time as settlementTime -- 结算时间
+        FROM
+        ins_ply_income_invoice ipii
+        LEFT JOIN ins_ply_income_invoice_settlement ipiis ON ipiis.invoice_id = ipiis.id
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id
+        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
+        WHERE
+        1=1
+        <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
+            AND ipiis.id IN
+            <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
+                #{settlementId}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
+            AND ipi.invoice_type IN
+            <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
+                #{invoiceType}
+            </foreach>
+        </if>
+        <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
+            AND ipiis.invoice_id = #{settlementQueryVo.invoiceId}
+        </if>
+        <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
+            AND ipi.company_id = #{settlementQueryVo.companyId}
+        </if>
+        <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
+            AND ipi.invoice_party = #{settlementQueryVo.invoiceParty}
+        </if>
+        <if test="settlementQueryVo.settlementPerson != null and settlementQueryVo.settlementPerson != ''">
+            AND ipiis.create_by = #{settlementQueryVo.settlementPerson}
+        </if>
+        <if test="settlementQueryVo.settlementTimeStart != null and settlementQueryVo.settlementTimeStart != ''">
+            AND ipiis.create_time between #{settlementQueryVo.signingTimeStart} and #{settlementQueryVo.signingTimeEnd}
+        </if>
     </select>
 
     <select id="getReceivableCompany" resultType="com.jzg.commons.entity.po.EsmInsCompany">
@@ -140,4 +619,125 @@
             </foreach>
     </select>
 
+    <!-- 基础结果集映射 -->
+    <resultMap id="BaseResultMap" type="com.jzg.commons.entity.finance.dto.CompanySuperviseSettlementReportDto">
+        <result column="company_id" property="companyId"/>
+        <result column="company_name" property="companyName"/>
+        <result column="total_receivable" property="totalReceivable"/>
+        <result column="supervise_fee" property="superviseFee"/>
+        <result column="invoiced_amount" property="invoicedAmount"/>
+        <result column="settled_amount" property="settledAmount"/>
+        <result column="un_invoiced_amount" property="unInvoicedAmount"/>
+        <result column="un_settled_amount" property="unSettledAmount"/>
+    </resultMap>
+
+    <!-- 获取根级保险公司(parent_id为0) -->
+    <select id="selectRootCompanies" resultMap="BaseResultMap">
+        SELECT
+            eic.id as company_id,
+            eic.name as company_name,
+            COALESCE(SUM(ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium), 0) as total_receivable,
+            COALESCE(SUM(ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums), 0) as supervise_fee,
+--             COALESCE(SUM(fee_summary.total_commission), 0) as 佣金总和,
+            COALESCE(SUM(invoice_summary.total_invoice), 0) as invoiced_amount,
+--             COALESCE(SUM(fee_summary.total_commission) - SUM(invoice_summary.total_invoice), 0) as un_invoiced_amount,
+            COALESCE(SUM(invoice_summary.settled_invoice), 0) as settled_amount,
+            COALESCE(SUM(invoice_summary.unsettled_invoice), 0) as un_settled_amount
+        FROM
+            esm_ins_company eic
+            LEFT JOIN ins_ply_income ipi ON eic.id = ipi.company_id
+            LEFT JOIN (
+            SELECT
+            ipiil.income_id,
+            SUM(ipii.receivable_supervise_premium) as total_invoice,
+            SUM(CASE WHEN ipii.status = 1 THEN ipii.receivable_supervise_premium ELSE 0 END) as settled_invoice,
+            SUM(CASE WHEN ipii.status = 0 THEN ipii.receivable_supervise_premium ELSE 0 END) as unsettled_invoice
+            FROM ins_ply_income_invoice_link ipiil
+            LEFT JOIN ins_ply_income_invoice ipii
+            ON ipii.id = ipiil.invoice_id
+            AND ipii.invoice_type IN
+                <if test="settlementReportQueryVo.invoiceTypes != null and settlementReportQueryVo.invoiceTypes.size() > 0">
+                <foreach item="item" collection="settlementReportQueryVo.invoiceTypes" separator="," open="(" close=")" index="">
+                    #{item}
+                </foreach>
+                </if>
+            GROUP BY ipiil.income_id
+            ) invoice_summary ON invoice_summary.income_id = ipi.id
+--             LEFT JOIN (
+--             SELECT
+--             ifo.order_no,
+--             SUM(DISTINCT (ifo.jq_commission_premium + ifo.sy_commission_premium + ifo.jy_commission_premium)) as total_commission
+--             FROM ins_fee_orders ifo
+--             GROUP BY ifo.order_no
+--             ) fee_summary ON ipi.order_no = fee_summary.order_no
+        WHERE
+            eic.parent_id = 0
+        GROUP BY
+            eic.id,
+            eic.name;
+    </select>
+
+    <!-- 获取子公司 -->
+    <select id="selectChildrenByParentId" resultMap="BaseResultMap">
+        SELECT
+            eic.id as company_id,
+            eic.name as company_name,
+            COALESCE(SUM(ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium), 0) as total_receivable,
+            COALESCE(SUM(ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums), 0) as supervise_fee,
+            COALESCE(SUM(invoice_summary.total_invoice), 0) as invoiced_amount,
+--             COALESCE(SUM(fee_summary.total_commission) - SUM(invoice_summary.total_invoice), 0) as un_invoiced_amount,
+            COALESCE(SUM(invoice_summary.settled_invoice), 0) as settled_amount,
+            COALESCE(SUM(invoice_summary.unsettled_invoice), 0) as un_settled_amount
+        FROM
+            esm_ins_company eic
+                LEFT JOIN ins_ply_income ipi ON eic.id = ipi.company_id
+                LEFT JOIN (
+                SELECT
+                    ipiil.income_id,
+                    SUM(ipii.receivable_supervise_premium) as total_invoice,
+                    SUM(CASE WHEN ipii.status = 1 THEN ipii.receivable_supervise_premium ELSE 0 END) as settled_invoice,
+                    SUM(CASE WHEN ipii.status = 0 THEN ipii.receivable_supervise_premium ELSE 0 END) as unsettled_invoice
+                FROM ins_ply_income_invoice_link ipiil
+                         LEFT JOIN ins_ply_income_invoice ipii
+                                   ON ipii.id = ipiil.invoice_id
+                                       AND ipii.invoice_type IN
+                                        <if test="invoiceTypes != null and !invoiceTypes.isEmpty()">
+                                            <foreach item="item" collection="invoiceTypes" open="(" separator="," close=")">
+                                                #{item}
+                                            </foreach>
+                                        </if>
+                GROUP BY ipiil.income_id
+            ) invoice_summary ON invoice_summary.income_id = ipi.id
+--                 LEFT JOIN (
+--                 SELECT
+--                     ifo.order_no,
+--                     SUM(DISTINCT (ifo.jq_commission_premium + ifo.sy_commission_premium + ifo.jy_commission_premium)) as total_commission
+--                 FROM ins_fee_orders ifo
+--                 GROUP BY ifo.order_no
+--             ) fee_summary ON ipi.order_no = fee_summary.order_no
+        WHERE
+            eic.parent_id = #{parentId}
+        GROUP BY
+            eic.id,
+            eic.name;
+    </select>
+
+
+    <select id="getSuperviseAmount" resultType="com.jzg.commons.entity.finance.dto.InvoiceAmountDto">
+        SELECT
+            eic.id AS companyId,
+            eic.name AS companyName,
+            COALESCE(SUM(ifo.jq_commission_premium + ifo.sy_commission_premium + ifo.jy_commission_premium), 0) AS superviseAmount
+        FROM
+            esm_ins_company eic
+                LEFT JOIN
+            ptl_agreement pa ON pa.company_id = CAST(eic.id AS CHAR) COLLATE utf8mb4_general_ci  -- 统一为pa的排序规则
+                LEFT JOIN
+            ins_fee_orders ifo ON pa.id = ifo.agreement_id
+        GROUP BY
+            eic.id, eic.name
+        ORDER BY
+            eic.id;
+    </select>
+
 </mapper>