wuhp пре 2 година
родитељ
комит
4d38272218

+ 14 - 1
src/main/java/com/ydtech/modules/admin/controller/financialReceivables/FinancialReceivablesController.java

@@ -47,12 +47,25 @@ public class FinancialReceivablesController {
         return HttpResult.ok(insPlyIncomeService.queryDateByType(financialReceivablesQueryVo));
         return HttpResult.ok(insPlyIncomeService.queryDateByType(financialReceivablesQueryVo));
     }
     }
 
 
+    /**
+     *  @version
+     *  @author: whp
+     *  @Date: 2024/8/7 9:20
+     *  @Description:  私有 车险
+     */
+    @PostMapping("/queryPrivateCar")
+    @ApiModelProperty(value = "私有车险列表")
+    public HttpResult<FinancialReceivablesAllVo> queryPrivateCar(@RequestBody FinancialReceivablesQueryVo financialReceivablesQueryVo) {
+        return HttpResult.ok(insPlyIncomeService.queryPrivateCar(financialReceivablesQueryVo));
+    }
+
 
 
     @PostMapping("/queryDateByTypeByMonth")
     @PostMapping("/queryDateByTypeByMonth")
-    @ApiModelProperty(value = "获取平台私有数据列表")
+    @ApiModelProperty(value = "获取详情列表")
     public HttpResult<FinancialReceivablesAllMonthVo> queryDateByTypeByMonth(@RequestBody FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
     public HttpResult<FinancialReceivablesAllMonthVo> queryDateByTypeByMonth(@RequestBody FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
         return HttpResult.ok(insPlyIncomeService.queryDateByTypeByMonth(financialReceivablesQueryVo));
         return HttpResult.ok(insPlyIncomeService.queryDateByTypeByMonth(financialReceivablesQueryVo));
     }
     }
+
     /**
     /**
      *
      *
      * @param insPlyIncomeVo
      * @param insPlyIncomeVo

+ 2 - 2
src/main/java/com/ydtech/modules/admin/model/report/financialReceivables/FinancialReceivablesAllMonthVo.java

@@ -31,12 +31,12 @@ public class FinancialReceivablesAllMonthVo {
     private  String  wsSumAmount;
     private  String  wsSumAmount;
 
 
     @ApiModelProperty("数据列表")
     @ApiModelProperty("数据列表")
-    private List<FinancialReceivablesMonthVo> list =new ArrayList<>();
+    private List<FinancialReceivablesMonthSignleVo> list =new ArrayList<>();
 
 
     public FinancialReceivablesAllMonthVo() {
     public FinancialReceivablesAllMonthVo() {
     }
     }
 
 
-    public FinancialReceivablesAllMonthVo(String ysSumAmount, String  yisSumAmount,String  wsSumAmount,  String yearAndMonth, List<FinancialReceivablesMonthVo> list) {
+    public FinancialReceivablesAllMonthVo(String ysSumAmount, String  yisSumAmount,String  wsSumAmount,  String yearAndMonth, List<FinancialReceivablesMonthSignleVo> list) {
         this.ysSumAmount = ysSumAmount;
         this.ysSumAmount = ysSumAmount;
         this.yisSumAmount = yisSumAmount;
         this.yisSumAmount = yisSumAmount;
         this.wsSumAmount = wsSumAmount;
         this.wsSumAmount = wsSumAmount;

+ 23 - 0
src/main/java/com/ydtech/modules/admin/model/report/financialReceivables/FinancialReceivablesMonthSignleVo.java

@@ -0,0 +1,23 @@
+package com.ydtech.modules.admin.model.report.financialReceivables;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@ApiModel("应收月份查询参数")
+public class FinancialReceivablesMonthSignleVo {
+
+    @ApiModelProperty("公司名称")
+    private  String  companyName;
+
+    @ApiModelProperty("地区名称")
+    private  String  areaName;
+
+
+    @ApiModelProperty("数据列表")
+    private List<FinancialReceivablesMonthVo> list =new ArrayList<>();
+}

+ 46 - 2
src/main/java/com/ydtech/modules/admin/model/report/financialReceivables/FinancialReceivablesMonthVo.java

@@ -4,6 +4,10 @@ package com.ydtech.modules.admin.model.report.financialReceivables;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
 /**
  *  @version 
  *  @version 
@@ -13,6 +17,7 @@ import lombok.Data;
  */
  */
 @Data
 @Data
 @ApiModel("应收月份返回参数")
 @ApiModel("应收月份返回参数")
+@NoArgsConstructor
 public class FinancialReceivablesMonthVo {
 public class FinancialReceivablesMonthVo {
 
 
     @ApiModelProperty("年份")
     @ApiModelProperty("年份")
@@ -27,10 +32,10 @@ public class FinancialReceivablesMonthVo {
     @ApiModelProperty("应收")
     @ApiModelProperty("应收")
     private String  commissionFeevalue;
     private String  commissionFeevalue;
 
 
-    @ApiModelProperty("收")
+    @ApiModelProperty("收")
     private String  noInvoicCommissionFeevalue;
     private String  noInvoicCommissionFeevalue;
 
 
-    @ApiModelProperty("收")
+    @ApiModelProperty("收")
     private String  readyCommissionFeevalue;
     private String  readyCommissionFeevalue;
 
 
     @ApiModelProperty("开票未结算")
     @ApiModelProperty("开票未结算")
@@ -39,4 +44,43 @@ public class FinancialReceivablesMonthVo {
     @ApiModelProperty("未开票金额")
     @ApiModelProperty("未开票金额")
     private String  noSettlementAmount;
     private String  noSettlementAmount;
 
 
+    @ApiModelProperty("手续费应收")
+    private String  handlingReceivable;
+
+    @ApiModelProperty("跟单应收")
+    private String  documentaryReceivable;
+
+    @ApiModelProperty("合作公司id")
+    private String  partnerCompaniesId;
+
+    @ApiModelProperty("地区编号")
+    private String  subPartnerCompaniesId;
+
+    @ApiModelProperty("保险公司名称")
+    private String  insuranceCompany;
+
+
+    @ApiModelProperty("未开票手续费")
+    private String  unlicensedHandlingFee;
+
+    @ApiModelProperty("未结算手续费")
+    private String  unsettledHandlingFees;
+
+    @ApiModelProperty("是否是手续费")
+    private String  isHand;
+
+
+
+
+    public FinancialReceivablesMonthVo(String yearAndMonth, String companyName, String areaName, String commissionFeevalue, String noInvoicCommissionFeevalue, String readyCommissionFeevalue, String settlementAmount, String noSettlementAmount) {
+        this.yearAndMonth = yearAndMonth;
+        this.companyName = companyName;
+        this.areaName = areaName;
+        this.commissionFeevalue = commissionFeevalue;
+        this.noInvoicCommissionFeevalue = noInvoicCommissionFeevalue;
+        this.readyCommissionFeevalue = readyCommissionFeevalue;
+        this.settlementAmount = settlementAmount;
+        this.noSettlementAmount = noSettlementAmount;
+    }
+
 }
 }

+ 3 - 0
src/main/java/com/ydtech/modules/admin/model/report/financialReceivables/FinancialReceivablesQueryMonthVo.java

@@ -26,4 +26,7 @@ public class FinancialReceivablesQueryMonthVo {
 
 
     @ApiModelProperty("前台不需要传递后台使用")
     @ApiModelProperty("前台不需要传递后台使用")
     private String endDate;
     private String endDate;
+
+    @ApiModelProperty("是否是非车")
+    private String isNoCar;
 }
 }

+ 4 - 0
src/main/java/com/ydtech/modules/admin/model/report/financialReceivables/FinancialReceivablesQueryVo.java

@@ -26,4 +26,8 @@ public class FinancialReceivablesQueryVo {
 
 
     @ApiModelProperty("前台不需要传递后台使用")
     @ApiModelProperty("前台不需要传递后台使用")
     private String endDate;
     private String endDate;
+
+    @ApiModelProperty("是否是非车  0  不是 1 是")
+    private String  isNotCar;
+
 }
 }

+ 10 - 2
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -177,12 +177,20 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
      *  @Date: 2024/8/5 10:06
      *  @Date: 2024/8/5 10:06
      *  @Description:  查询月份的统计数据
      *  @Description:  查询月份的统计数据
      */
      */
-    FinancialReceivablesAllMonthVo queryDateByTypeByMonth(FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
+    FinancialReceivablesAllMonthVo queryDateByTypeByMonth(@Param("vo") FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
     /**
     /**
      *  @version
      *  @version
      *  @author: hxl
      *  @author: hxl
      *  @Date: 2024/8/5 10:32
      *  @Date: 2024/8/5 10:32
      *  @Description:  查询月份统计集合数据
      *  @Description:  查询月份统计集合数据
      */
      */
-    List<FinancialReceivablesMonthVo> queryDateByTypeByMonthList(FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
+    List<FinancialReceivablesMonthVo> queryDateByTypeByMonthList(@Param("vo") FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
+
+    List<FinancialReceivablesMonthVo> queryDateByTypeByMonthOtherList(@Param("vo") FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
+
+    List<FinancialReceivablesMonthVo> queryPlatHanding(@Param("vo") FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
+
+
+    List<FinancialReceivablesVo> queryPrivateCar(@Param("vo") FinancialReceivablesQueryVo financialReceivablesQueryVo);
+
 }
 }

+ 8 - 0
src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java

@@ -195,4 +195,12 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
      *  @Description:
      *  @Description:
      */
      */
     FinancialReceivablesAllMonthVo queryDateByTypeByMonth(FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
     FinancialReceivablesAllMonthVo queryDateByTypeByMonth(FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
+    /**
+     *  @version
+     *  @author: whp
+     *  @Date: 2024/8/7 9:20
+     *  @Description:  私有 车险
+     */
+    FinancialReceivablesAllVo queryPrivateCar(FinancialReceivablesQueryVo financialReceivablesQueryVo);
+
 }
 }

+ 155 - 12
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
+import com.alipay.api.domain.VehicleIovData;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
@@ -61,6 +62,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.math.MathContext;
+import java.math.RoundingMode;
 import java.nio.file.Files;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.Paths;
@@ -70,6 +73,8 @@ import java.time.LocalTime;
 import java.time.YearMonth;
 import java.time.YearMonth;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -192,6 +197,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
         insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
         insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
         insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
         insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
         insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
+        insPlyIncome.setReceivableAmount(insFeeOrderNew.getNoOtherCostsPremiums());
         insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoOtherCostsPremiums());
         insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoOtherCostsPremiums());
         insPlyIncome.setNoOtherCostsPremium(insFeeOrderNew.getNoOtherCostsPremiums());
         insPlyIncome.setNoOtherCostsPremium(insFeeOrderNew.getNoOtherCostsPremiums());
         insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion());
         insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion());
@@ -216,7 +222,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if (StringUtils.isNotEmpty(noPolicyno)) {
         if (StringUtils.isNotEmpty(noPolicyno)) {
             insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
             insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
         }
         }
-
 //        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
 //        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
         //add by hxl  2024-07-31  修改插入结算表中险种信息错误的bug  将大订单中的险种信息改为小订单的险种信息
         //add by hxl  2024-07-31  修改插入结算表中险种信息错误的bug  将大订单中的险种信息改为小订单的险种信息
         this.saveRiskCode(insAreaCompany.getProductid(), insPlyIncome);
         this.saveRiskCode(insAreaCompany.getProductid(), insPlyIncome);
@@ -245,7 +250,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());
         insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());
         this.getDeptId(insPlyIncome);
         this.getDeptId(insPlyIncome);
         this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
         this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
-
+        insPlyIncome.setReceivableAmount(insFeeOrderNew.getNoSuperviseCostsPremiums());
         baseMapper.insert(insPlyIncome);
         baseMapper.insert(insPlyIncome);
         InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
         InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
         insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
         insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
@@ -309,6 +314,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
         insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
         insPlyIncome.setUserId(insFeeOrderNew.getUserId());
         insPlyIncome.setUserId(insFeeOrderNew.getUserId());
         insPlyIncome.setInsuredName(order.getInsuredname());
         insPlyIncome.setInsuredName(order.getInsuredname());
+        insPlyIncome.setReceivableAmount(otherAmount);
         this.getDeptId(insPlyIncome);
         this.getDeptId(insPlyIncome);
         this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
         this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
 
 
@@ -354,6 +360,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
         insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
         insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
         insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
         insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
         insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
+        insPlyIncome.setReceivableAmount(handlingAmount);
         this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
         this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
         this.getDeptId(insPlyIncome);
         this.getDeptId(insPlyIncome);
         baseMapper.insert(insPlyIncome);
         baseMapper.insert(insPlyIncome);
@@ -3302,6 +3309,35 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
 
 
         return new FinancialReceivablesAllVo(ptSumAmount.toString(),sySumAmount.toString(),year+"",list);
         return new FinancialReceivablesAllVo(ptSumAmount.toString(),sySumAmount.toString(),year+"",list);
     }
     }
+    /**
+     *  @version
+     *  @author: whp
+     *  @Date: 2024/8/7
+     *  @Description:  私有 车险
+     */
+    @Override
+    public FinancialReceivablesAllVo queryPrivateCar(FinancialReceivablesQueryVo financialReceivablesQueryVo) {
+        int year =0;
+        if(StringUtils.isBlank(financialReceivablesQueryVo.getYear())){
+            Calendar cale = Calendar.getInstance();
+            year = cale.get(Calendar.YEAR);
+        }else{
+            year = Integer.parseInt(financialReceivablesQueryVo.getYear());
+        }
+
+        FinancialReceivablesAllVo resultVo = new FinancialReceivablesAllVo();
+//      私有总金额
+        financialReceivablesQueryVo.setBeginDate(SliceUpDateUtil.getYearBeginDateStr(year)+" 00:00:00");
+        financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getYearEndDateStr(year)+" 23:59:59");
+//      私有应收
+        BigDecimal syAmount = baseMapper.queryDateByTypeSumAmount(financialReceivablesQueryVo);
+        resultVo.setSySumAmount(syAmount.toString());
+        resultVo.setYear(year+"");
+
+        List<FinancialReceivablesVo> result=  baseMapper.queryPrivateCar(financialReceivablesQueryVo);
+        resultVo.setList(result);
+        return resultVo;
+    }
     /**
     /**
      *  @version
      *  @version
      *  @author: hxl
      *  @author: hxl
@@ -3311,30 +3347,137 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Override
     @Override
     public FinancialReceivablesAllMonthVo queryDateByTypeByMonth(FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
     public FinancialReceivablesAllMonthVo queryDateByTypeByMonth(FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
         //检查参数
         //检查参数
-        if(StringUtils.isBlank(financialReceivablesQueryVo.getType())){
+        if (StringUtils.isBlank(financialReceivablesQueryVo.getType())) {
             throw new SystemException("应收类型不能为空,1为平台2为私有,默认传1");
             throw new SystemException("应收类型不能为空,1为平台2为私有,默认传1");
         }
         }
         //检查参数
         //检查参数
-        if(StringUtils.isBlank(financialReceivablesQueryVo.getYearAndMonth())){
+        if (StringUtils.isBlank(financialReceivablesQueryVo.getYearAndMonth())) {
             throw new SystemException("月份不能为空");
             throw new SystemException("月份不能为空");
         }
         }
         String yearAndMonth = financialReceivablesQueryVo.getYearAndMonth();
         String yearAndMonth = financialReceivablesQueryVo.getYearAndMonth();
         int year = Integer.parseInt(yearAndMonth.split("-")[0]);
         int year = Integer.parseInt(yearAndMonth.split("-")[0]);
         int month = Integer.parseInt(yearAndMonth.split("-")[1]);
         int month = Integer.parseInt(yearAndMonth.split("-")[1]);
 
 
-        financialReceivablesQueryVo.setBeginDate(SliceUpDateUtil.getStartOfMonth(year,month));
-        financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getEndOfMonth(year,month));
+        financialReceivablesQueryVo.setBeginDate(SliceUpDateUtil.getStartOfMonth(year, month));
+        financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getEndOfMonth(year, month));
         //查询总数
         //查询总数
-        FinancialReceivablesAllMonthVo  vo= baseMapper.queryDateByTypeByMonth(financialReceivablesQueryVo);
+        FinancialReceivablesAllMonthVo vo = baseMapper.queryDateByTypeByMonth(financialReceivablesQueryVo);
+//      第二层数据
+        List<FinancialReceivablesMonthSignleVo> resultData = vo.getList();
         vo.setYearAndMonth(yearAndMonth);
         vo.setYearAndMonth(yearAndMonth);
-        //查询列表
-        List<FinancialReceivablesMonthVo> list = baseMapper.queryDateByTypeByMonthList(financialReceivablesQueryVo);
 
 
-        //按区域
-        //if()
+        HashMap<String, BigDecimal> amountMap;
+        if ("2".equals(financialReceivablesQueryVo.getType())) {
+             amountMap = this.privateSett(resultData, financialReceivablesQueryVo);
+        } else {
+             amountMap = this.platformSett(resultData, financialReceivablesQueryVo);
+        }
+        vo.setYisSumAmount(amountMap.get("yishouAmount").toString());
+        vo.setYsSumAmount(amountMap.get("yinshouAmount").toString());
+        vo.setWsSumAmount(amountMap.get("weishouAmount").toString());
+        return vo;
+    }
 
 
 
 
 
 
-        return null;
+    private HashMap<String, BigDecimal> platformSett(List<FinancialReceivablesMonthSignleVo> resultData, FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
+        List<BigDecimal> yinShouAmountList = new ArrayList<>();
+        List<BigDecimal> yishouAmountList = new ArrayList<>();
+        List<BigDecimal> weishouAmountList = new ArrayList<>();
+
+        BigDecimal yinshouAmount = new BigDecimal("0.00");
+        BigDecimal yishouAmount = new BigDecimal("0.00");
+        BigDecimal weishouAmount = new BigDecimal("0.00");
+
+        HashMap<String, BigDecimal> resultMap = new HashMap<>();
+
+
+        //平台手续费
+        List<FinancialReceivablesMonthVo> handList = baseMapper.queryPlatHanding(financialReceivablesQueryVo);
+
+        Map<String, FinancialReceivablesMonthVo> collect = handList.stream().collect(Collectors.toMap(FinancialReceivablesMonthVo::getPartnerCompaniesId, Function.identity()));
+
+        handList.stream().filter(item -> collect.containsKey(item.getPartnerCompaniesId()))
+                .forEach(item ->{
+                    FinancialReceivablesMonthVo otherItem = collect.get(item.getPartnerCompaniesId());
+
+                    FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
+                    List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
+                    financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
+                    financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
+                    financialReceivablesMonthVos.add(otherItem);
+                    financialReceivablesMonthVos.add(item);
+                    if("合计".equals(item.getIsHand())){
+                        yinShouAmountList.add(this.stringToBigdecimal(item.getCommissionFeevalue()));
+                        yishouAmountList.add(this.stringToBigdecimal(item.getReadyCommissionFeevalue()));
+                        weishouAmountList.add(this.stringToBigdecimal(item.getNoInvoicCommissionFeevalue()));
+
+                    }
+                    resultData.add(financialReceivablesMonthSignleVo);
+                });
+        yinshouAmount = yinshouAmount.add(yinShouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
+        yishouAmount = yishouAmount.add(yishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
+        weishouAmount = weishouAmount.add(weishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
+        resultMap.put("yinshouAmount",yinshouAmount);
+        resultMap.put("yishouAmount",yishouAmount);
+        resultMap.put("weishouAmount",weishouAmount);
+        return resultMap;
+
+    }
+
+    private HashMap<String, BigDecimal> privateSett(List<FinancialReceivablesMonthSignleVo> resultData, FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
+        List<BigDecimal> yinShouAmountList = new ArrayList<>();
+        List<BigDecimal> yishouAmountList = new ArrayList<>();
+        List<BigDecimal> weishouAmountList = new ArrayList<>();
+
+        BigDecimal yinshouAmount = new BigDecimal("0.00");
+        BigDecimal yishouAmount = new BigDecimal("0.00");
+        BigDecimal weishouAmount = new BigDecimal("0.00");
+
+        HashMap<String, BigDecimal> resultMap = new HashMap<>();
+
+
+        //手续费未接应收
+        List<FinancialReceivablesMonthVo> list = baseMapper.queryDateByTypeByMonthList(financialReceivablesQueryVo);
+        //跟单统计
+        List<FinancialReceivablesMonthVo> otherList = baseMapper.queryDateByTypeByMonthOtherList(financialReceivablesQueryVo);
+
+        Map<String, FinancialReceivablesMonthVo> collect = otherList.stream().collect(Collectors.toMap(FinancialReceivablesMonthVo::getPartnerCompaniesId, Function.identity()));
+        list.stream()
+                .filter(item -> collect.containsKey(item.getPartnerCompaniesId()))
+                .forEach(
+                        item -> {
+                            FinancialReceivablesMonthVo otherItem = collect.get(item.getPartnerCompaniesId());
+                            FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
+                            List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
+                            financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
+                            financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
+//                          合计信息
+                            FinancialReceivablesMonthVo financialReceivablesMonthVo = new FinancialReceivablesMonthVo();
+                            financialReceivablesMonthVo.setCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getCommissionFeevalue()), new BigDecimal(otherItem.getCommissionFeevalue()), null).toString());
+                            financialReceivablesMonthVo.setNoInvoicCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getNoInvoicCommissionFeevalue()), new BigDecimal(otherItem.getNoInvoicCommissionFeevalue()), null).toString());
+                            financialReceivablesMonthVo.setReadyCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getReadyCommissionFeevalue()), new BigDecimal(otherItem.getReadyCommissionFeevalue()), null).toString());
+                            financialReceivablesMonthVo.setSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getSettlementAmount()), new BigDecimal(otherItem.getSettlementAmount()), null).toString());
+                            financialReceivablesMonthVo.setNoSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getNoSettlementAmount()), new BigDecimal(otherItem.getNoSettlementAmount()), null).toString());
+                            financialReceivablesMonthVo.setIsHand("合计");
+                            financialReceivablesMonthVos.add(otherItem);
+                            financialReceivablesMonthVos.add(item);
+                            financialReceivablesMonthVos.add(financialReceivablesMonthVo);
+                            yishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getReadyCommissionFeevalue()));
+                            yinShouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getCommissionFeevalue()));
+                            weishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getNoInvoicCommissionFeevalue()));
+                            resultData.add(financialReceivablesMonthSignleVo);
+                        }
+                );
+        yinshouAmount = yinshouAmount.add(yinShouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
+        yishouAmount = yishouAmount.add(yishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
+        weishouAmount = weishouAmount.add(weishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
+        resultMap.put("yinshouAmount",yinshouAmount);
+        resultMap.put("yishouAmount",yishouAmount);
+        resultMap.put("weishouAmount",weishouAmount);
+        return resultMap;
+    }
+    private BigDecimal stringToBigdecimal(String value) {
+        return new BigDecimal(value).setScale(5, RoundingMode.DOWN);
     }
     }
 }
 }

+ 291 - 5
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -2451,6 +2451,9 @@
             <if test="vo.type !=null  and  vo.type  !=''">
             <if test="vo.type !=null  and  vo.type  !=''">
                 and pa.agreement_type =#{vo.type}
                 and pa.agreement_type =#{vo.type}
             </if>
             </if>
+            <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
+                and a.is_not_car =#{vo.isNotCar}
+            </if>
             <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
             <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
                 AND  a.create_time  BETWEEN #{vo.beginDate} AND #{vo.endDate}
                 AND  a.create_time  BETWEEN #{vo.beginDate} AND #{vo.endDate}
             </if>
             </if>
@@ -2529,14 +2532,14 @@
             resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesAllMonthVo">
             resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesAllMonthVo">
         SELECT
         SELECT
             SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
             SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
-            SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "ysSumAmount",
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
             SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
             SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
         FROM
         FROM
             ins_ply_income a
             ins_ply_income a
-                LEFT JOIN
+            LEFT JOIN
             ptl_agreement pa ON pa.id = a.agreement_id
             ptl_agreement pa ON pa.id = a.agreement_id
-        where
         <where>
         <where>
+            1=1
             <if test="vo.type !=null  and  vo.type  !=''">
             <if test="vo.type !=null  and  vo.type  !=''">
                 and pa.agreement_type =#{vo.type}
                 and pa.agreement_type =#{vo.type}
             </if>
             </if>
@@ -2545,11 +2548,294 @@
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>
-    <select id="queryDateByTypeByMonthList"
-            resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
 
 
+    <select id="queryDateByTypeByMonthList"  resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
+        SELECT
+            a.subPathner,
+            sa.area_cname as "areaName",
+            eic.namesimple as "companyName",
+            a.handlingReceivable  as "commissionFeevalue",
+            a.partnerCompaniesId  as "partnerCompaniesId",
+            a.companyId as "companyId",
+            IFNULL(a.settleAmount ,0 )   as "settlementAmount",
+            a.unlicensedHandlingFee  as "noSettlementAmount",
+            IFNULL(a.unlicensedHandlingFee ,0 ) + IFNULL(a.settleAmount,0 ) as  "noInvoicCommissionFeevalue",
+            "手续费" as  "isHand",
+            IFNULL(a.handlingReceivable ,0 ) - IFNULL((IFNULL(a.unlicensedHandlingFee ,0 ) + IFNULL(a.settleAmount,0 )),0 ) as  "readyCommissionFeevalue"
+        FROM
+            (SELECT
+                 SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
+                 a.company_id as "companyId",
+                 a.partner_companies_id as "partnerCompaniesId",
+                 sum( a.commission_feevalue ) as "handlingReceivable",
+                 SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "unlicensedHandlingFee",
+                 MAX(b.noSettHandlingFee) AS "settleAmount"
+             FROM
+                 ins_ply_income a
+                     LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                     LEFT JOIN (
+                     SELECT
+                         sum(a.commission_feevalue)  as "invoicAmount",
+                         IFNULL(sum(a.commission_feevalue) ,0 ) - IFNULL(max(b.settlementAmount) ,0 ) as  "noSettHandlingFee",
+                         a.signdate,
+                         a.task_id as "taskId" ,
+                        a.partner_companies_id  as "subPathner"
+                     FROM
+                         ins_ply_income a
+                             LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                             LEFT JOIN (
+                             select sum(settlement_amount) as "settlementAmount", a.task_id  as "taskId" from settlement_documentary_fees   a
+                             <where>
+                                 a.task_id IS NOT NULL
+                                 and a.settlement_status ='2'
+                                 <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
+                                     and a.handling_fees_status =#{vo.isNoCar}
+                                 </if>
+                             </where>
+                             GROUP BY  a.task_id
+                         ) b  on  a.task_id=b.taskId
+                     <where>
+                         pa.agreement_type = '2'
+                         AND a.is_not_documentary = '0'
+                         AND a.task_id  is not  null
+                         <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                             AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+                         </if>
+                         <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
+                             and a.is_not_car =#{vo.isNoCar}
+                         </if>
+                     </where>
+                     GROUP BY
+                         a.task_id , a.signdate,a.partner_companies_id
+                 ) b  on  b.subPathner = a.partner_companies_id
+             <where>
+                 pa.agreement_type = '2'
+                 AND a.is_not_documentary = '0'
+                 <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                     AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+                 </if>
+                 <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
+                     and a.is_not_car =#{vo.isNoCar}
+                 </if>
+             </where>
+             GROUP BY
+        a.partner_companies_id ,a.company_id) a
+        LEFT JOIN esm_ins_company  eic  on eic.id = a.companyId
+        LEFT JOIN sys_area  sa  on sa.area_code = a.subPathner
+    </select>
+
+
+    <select id="queryDateByTypeByMonthOtherList"  resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
+        SELECT
+            a.partner_companies_id,
+            sa.area_cname as "areaName",
+            eic.namesimple as "companyName",
+            sum(a.other_feevalue) as "commissionFeevalue",
+            IFNULL(max(b.invoicedSettledAmount) ,0 ) as "readyCommissionFeevalue",
+            sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 ) as "noInvoicCommissionFeevalue",
+            IFNULL(max(b.invoicedNotSettledAmount) ,0 )  as "settlementAmount",
+            sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 )-IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "noSettlementAmount",
+            SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
+            "跟单费" as  "isHand",
+            a.company_id AS "companyId"
+        FROM
+            ins_ply_income a
+                LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                LEFT JOIN (
+                SELECT
+                    a.partner_companies_id,
+                    sum(a.invoiced_settled_amount)  as  "invoicedSettledAmount",
+                    sum(a.Invoiced_not_settled_amount)  as  "invoicedNotSettledAmount"
+                FROM
+                    settlement_documentary_fees a
+                <where>
+                    a.settlement_sum_id IS NOT NULL
+                    AND settlement_status = '1'
+                    <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                        AND  a.signing_time  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+                    </if>
+                    <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
+                        and a.is_not_car =#{vo.isNoCar}
+                    </if>
+                </where>
+                GROUP BY
+                    a.partner_companies_id
+            )  b  on b.partner_companies_id =a.partner_companies_id
+                LEFT JOIN esm_ins_company  eic  on eic.id = a.company_Id
+                LEFT JOIN sys_area  sa  on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
+        <where>
+            pa.agreement_type = '2'
+            AND a.is_not_documentary = '1'
+            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            </if>
+            <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
+                and a.is_not_car =#{vo.isNoCar}
+            </if>
+        </where>
+        group by
+            a.partner_companies_id,a.company_id,sa.area_cname
+    </select>
+
+
+    <select id="queryPlatHanding"  resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
+        SELECT
+            1  as  orderNumber,
+            '手续费' AS isHand,
+            sa.area_cname AS areaName,
+            eic.namesimple AS companyName,
+            a.partner_companies_id AS partnerCompaniesId,
+            SUM(a.commission_feevalue) AS commissionFeevalue,
+            SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
+            SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue"
+        FROM
+            ins_ply_income a
+                LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
+                LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
+        <where>
+            pa.agreement_type = '1'
+            AND a.is_not_documentary = '1'
+            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            </if>
+            <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
+                and a.is_not_car =#{vo.isNoCar}
+            </if>
+        </where>
+        GROUP BY
+            a.partner_companies_id, eic.namesimple, sa.area_cname
 
 
+        UNION ALL
 
 
+        SELECT
+            2  as  orderNumber,
+            '跟单费' AS isHand,
+            sa.area_cname AS areaName,
+            eic.namesimple AS companyName,
+            a.partner_companies_id AS partnerCompaniesId,
+            SUM(a.other_feevalue) AS commissionFeevalue,
+            SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
+            SUM(CASE WHEN a.handling_fees_status = '1' THEN a.other_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.other_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue"
+        FROM
+            ins_ply_income a
+                LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
+                LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
+        <where>
+            pa.agreement_type = '1'
+            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            </if>
+            <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
+                and a.is_not_car =#{vo.isNoCar}
+            </if>
+        </where>
+        GROUP BY
+            a.partner_companies_id, eic.namesimple, sa.area_cname
+        UNION ALL
+        SELECT
+            3  as  orderNumber,
+            '合计' AS isHand,
+            sa.area_cname AS areaName,
+            eic.namesimple AS companyName,
+            a.partner_companies_id AS partnerCompaniesId,
+            SUM(a.all_fee_value) AS commissionFeevalue,
+            SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
+            SUM(CASE WHEN a.handling_fees_status = '1' THEN a.all_fee_value ELSE 0 END) AS "readyCommissionFeevalue",
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.all_fee_value ELSE 0 END) AS "noInvoicCommissionFeevalue"
+        FROM
+            ins_ply_income a
+                LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
+                LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
+        <where>
+            pa.agreement_type = '1'
+            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            </if>
+            <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
+                and a.is_not_car =#{vo.isNoCar}
+            </if>
+        </where>
+        GROUP BY
+            a.partner_companies_id, eic.namesimple, sa.area_cname
+        ORDER BY
+            companyName,
+            areaName,
+            orderNumber;
+    </select>
 
 
+    <select id="queryPrivateCar" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
+        SELECT
+            DATE_FORMAT( a.signdate, '%Y-%m' )  as "yearAndMonth" ,
+            sum(a.all_fee_value)  as "commissionFeevalue",
+            IFNULL(max(b.readyCommissionFeevalue),0) + IFNULL(max(c.readyCommissionFeevalue1),0)  as  "noInvoicCommissionFeevalue",
+            sum(a.all_fee_value) -(IFNULL(max(b.readyCommissionFeevalue),0) + IFNULL(max(c.readyCommissionFeevalue1),0)) as "readyCommissionFeevalue",
+            (IFNULL(max(b.inSettlementAmount),0) -IFNULL(sum(b.readyCommissionFeevalue),0)) +IFNULL(max(c.settlementAmount),0)  as "settlementAmount",
+            IFNULL(max(c.noInvoicCommissionFeevalue),0)  + ((SUM( CASE WHEN a.handling_fees_status = '0' and a.is_not_documentary ='0' THEN a.all_fee_value ELSE 0 END ))) as "noSettlementAmount"
+        FROM
+            ins_ply_income a
+                LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                left join (
+                SELECT
+                    SUM( CASE WHEN settlement_status = '2' THEN a.settlement_amount ELSE 0 END )  as "readyCommissionFeevalue",
+                    SUM( CASE WHEN settlement_status = '1' THEN a.settlement_amount ELSE 0 END )  as "inSettlementAmount",
+                    a.task_id AS "taskId"
+                FROM
+                    settlement_documentary_fees a
+                <where>
+                    a.task_id IS NOT NULL
+                    <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
+                        and a.is_not_car =#{vo.isNotCar}
+                    </if>
+                </where>
+                GROUP BY
+                    a.task_id
+            )  b   on  b .taskId =a.task_id
+                left  join (
+                SELECT
+                    DATE_FORMAT( a.signing_time, '%Y-%m' ) as "singDateYear",
+                    sum( a.invoiced_settled_amount ) AS "readyCommissionFeevalue1",
+                    sum( a.Invoiced_not_settled_amount ) AS "settlementAmount",
+                    SUM( CASE WHEN settlement_status = '1' THEN a.settlement_amount ELSE 0 END )  as "invoiceAmount",
+                    IFNULL(sum(b.otherallFeeValue),0) -sum( a.invoiced_settled_amount ) as "noInvoicCommissionFeevalue",
+                    IFNULL(sum(b.otherallFeeValue),0) -sum( a.invoiced_settled_amount ) - SUM( CASE WHEN settlement_status = '1' THEN a.settlement_amount ELSE 0 END ) as "noSettlementAmount"
+                FROM
+                    settlement_documentary_fees a
+                        left join  (
+                        select sum(a.all_fee_value) as "otherallFeeValue", DATE_FORMAT( a.signdate, '%Y-%m' ) as "singDateYear"  from  ins_ply_income a
+                        LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                        <where>
+                            pa.agreement_type= '2'
+                            and a.is_not_documentary='1'
+                            <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
+                                and a.is_not_car =#{vo.isNotCar}
+                            </if>
+                            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+                            </if>
+                        </where>
+
+                        GROUP BY DATE_FORMAT( a.signdate, '%Y-%m' )
+                    )  b  on b.singDateYear = DATE_FORMAT( a.signing_time, '%Y-%m' )
+                <where>
+                    a.settlement_sum_id IS NOT NULL
+                    AND settlement_status = '1'
+                </where>
+                GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
+            )  c  on  c.singDateYear=DATE_FORMAT( a.signdate, '%Y-%m' )
+        <where>
+            pa.agreement_type ='2'
+            <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
+                and a.is_not_car =#{vo.isNotCar}
+            </if>
+            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            </if>
+        </where>
+        GROUP BY DATE_FORMAT( a.signdate, '%Y-%m' )
     </select>
     </select>
 </mapper>
 </mapper>