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

报表添加 应付统计(管理费)

li.pengfei 2 лет назад
Родитель
Сommit
43841c3c5a

+ 1 - 1
src/main/java/com/ydtech/modules/report/controller/ReportController.java

@@ -253,7 +253,7 @@ public class ReportController extends BaseController {
     @PostMapping("/exportPayApplyDeptReportListData")
     @ApiOperation(value = "报表-应付统计管理费-导出清单明细")
     public HttpResult<String> exportPayApplyDeptReportListData(@RequestBody PayApplyDeptReportReqVo payApplyDeptReportReqVo) {
-        return reportService.exportPayApplyDeptReportData(payApplyDeptReportReqVo);
+        return reportService.exportPayApplyDeptReportListData(payApplyDeptReportReqVo);
 
     }
 }

+ 2 - 0
src/main/java/com/ydtech/modules/report/dao/ReportInsurancePolicyMapper.java

@@ -35,5 +35,7 @@ public interface ReportInsurancePolicyMapper extends BaseMapper<ReportInsuranceP
 
     List<PayApplyDeptReportResVo> queryPayApplyDeptReportData(@Param("reportReqVo") PayApplyDeptReportReqVo reqVo);
 
+    List<PayApplyDeptReportListResVo> exportPayApplyDeptReportListData(@Param("reportReqVo") PayApplyDeptReportReqVo reqVo);
+
     Long queryPayApplyDeptReportDataCount(@Param("reportReqVo") PayApplyDeptReportReqVo reqVo);
 }

+ 57 - 0
src/main/java/com/ydtech/modules/report/model/vo/PayApplyDeptReportListResVo.java

@@ -0,0 +1,57 @@
+package com.ydtech.modules.report.model.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@TableName(autoResultMap = true)
+public class PayApplyDeptReportListResVo {
+    @ExcelProperty(value = "订单号")
+    @TableField("orderno")
+    private String orderno;
+    @ExcelProperty(value = "保单号")
+    @TableField("policyno")
+    private String policyno;
+    @ExcelProperty(value = "险种")
+    @TableField("riskcode")
+    private String riskcode;
+    @ExcelProperty(value = "车牌")
+    @TableField("licenseno")
+    private String licenseno;
+    @ExcelProperty(value = "机构等级")
+    @TableField("comlevel")
+    private String comlevel;
+
+    @ExcelProperty(value = "机构代码")
+    @TableField("comcode")
+    private String comcode;
+    @ExcelProperty(value = "管理费比例")
+    @TableField("keeprate")
+    private double keeprate;
+    @ExcelProperty(value = "追加费比例")
+    @TableField("addrate")
+    private double addrate;
+    @ExcelProperty(value = "管理费金额")
+    @TableField("keepamount")
+    private double keepamount;
+    @ExcelProperty(value = "追加费金额")
+    @TableField("addamount")
+    private double addamount;
+    @ExcelProperty(value = "审核状态")
+    @TableField("auditstatus")
+    private String auditstatus;
+    @ExcelProperty(value = "结算状态")
+    @TableField("settlestatus")
+    private String settlestatus;
+    @ExcelProperty(value = "保险公司")
+    @TableField("inscompany")
+    private String inscompany;
+    @ExcelProperty(value = "签单日期")
+    @TableField("signDate")
+    private String signDate;
+
+}

+ 4 - 3
src/main/java/com/ydtech/modules/report/model/vo/PayApplyDeptReportReqVo.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.time.LocalDate;
+import java.util.List;
 
 /**
  * @Author: CXP
@@ -39,9 +40,9 @@ public class PayApplyDeptReportReqVo {
     @Min(value = 1, message = "页数最小为1")
     private int pageNum;
 
-    @ApiModelProperty(value = "是否下钻查询  1 下钻 0非下钻查询")
+    @ApiModelProperty(value = "是否下钻查询  1 下钻  0 正常查询  2 返回上层")
     private String isDrilling;
 
-    @ApiModelProperty(value = "是否返回上层  1 返回上层 0非返回上层")
-    private String isReturnBack;
+    @ApiModelProperty(value = "需要分组的保险公司列表")
+    private List<String> groupInsCompanyArr;
 }

+ 4 - 35
src/main/java/com/ydtech/modules/report/model/vo/PayApplyDeptReportResVo.java

@@ -18,56 +18,25 @@ public class PayApplyDeptReportResVo {
     @TableField(value = "institution")
     private String institution;
 
-    @ExcelProperty(value = "团队名称")
-    @TableField(value = "deptname")
-    private String deptname;
-
-    @ExcelProperty(value = "业务员名称")
-    @TableField(value = "username")
-    private String username;
-
-    @ExcelProperty(value = "待付手续费")
+    @ExcelProperty(value = "待付管理费")
     @TableField(value = "wait_pay_costs_premiums")
     private BigDecimal waitPayCostsPremiums;
 
 
-    @ExcelProperty(value = "已付手续费")
+    @ExcelProperty(value = "已付管理费")
     @TableField(value = "paid_costs_premiums")
     private BigDecimal paidCostsPremiums;
 
 
-    @ExcelProperty(value = "手续费合计")
+    @ExcelProperty(value = "管理费合计")
     @TableField(value = "sum_costs_premiums")
     private BigDecimal sumCostsPremiums;
 
-
-    @ExcelProperty(value = "待付分销费")
-    @TableField(value = "wait_pay_retail_premiums")
-    private BigDecimal waitPayRetailPremiums;
-
-    @ExcelProperty(value = "已付分销费")
-    @TableField(value = "paid_retail_premiums")
-    private BigDecimal paidRetailPremiums;
-
-
-    @ExcelProperty(value = "总分销费")
-    @TableField(value = "sum_retail_premiums")
-    private BigDecimal sumRetailPremiums;
-
     /**
      * 机构Id
      */
     @ExcelIgnore
     private String institutionId;
-    /**
-     * 团队Id
-     */
-    @ExcelIgnore
-    private String deptId;
-    /**
-     * 人员Id
-     */
-    @ExcelIgnore
-    private String userId;
+
 
 }

+ 7 - 0
src/main/java/com/ydtech/modules/report/service/ReportService.java

@@ -151,4 +151,11 @@ public interface ReportService {
      * @return
      */
     public HttpResult<String> exportPayApplyDeptReportData(PayApplyDeptReportReqVo reqDto);
+
+    /**
+     * 报表-应付统计管理费-导出清单
+     * @param payApplyDeptReportReqVo
+     * @return
+     */
+    public HttpResult<String> exportPayApplyDeptReportListData(PayApplyDeptReportReqVo payApplyDeptReportReqVo);
 }

+ 116 - 1
src/main/java/com/ydtech/modules/report/service/impl/ReportServiceImpl.java

@@ -2,6 +2,7 @@ package com.ydtech.modules.report.service.impl;
 
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageHelper;
 import com.ydtech.aop.exception.DescribeException;
@@ -12,6 +13,7 @@ import com.ydtech.modules.admin.model.SysDept;
 import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.service.SysDeptService;
 import com.ydtech.modules.admin.service.SysUserService;
+import com.ydtech.modules.esm.model.EsmInsCompany;
 import com.ydtech.modules.ins.utils.ExcelStyleLeftUtil;
 import com.ydtech.modules.ins.utils.ExcelStyleUtil;
 import com.ydtech.modules.ins.utils.ExcelUtils2;
@@ -1193,8 +1195,55 @@ public class ReportServiceImpl implements ReportService {
     public BasePageResult<PayApplyDeptReportResVo> getPayApplyDeptReportData(PayApplyDeptReportReqVo reqDto) {
         Page<InsOrders> page = new Page<>(reqDto.getPageNum(), reqDto.getPageSize());
         page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
+        List<String> comStr=new ArrayList<>();
+        if(StringUtils.isNotEmpty(reqDto.getIsDrilling())&&"1".equals(reqDto.getIsDrilling())){//下钻时查询下级所有机构
+            LambdaQueryWrapper<SysDept> lqw1 = new LambdaQueryWrapper<>();
+            lqw1.eq(SysDept::getParentId, reqDto.getDeptId());
+            List<SysDept> sysDeptList=sysDeptService.list(lqw1);
+            if(sysDeptList!=null&&sysDeptList.size()>0){
+                sysDeptList.stream().forEach(item->{
+                    comStr.add(item.getId());
+                });
+            }else{
+                throw new SystemException("已经到最底层,不能继续下钻!");
+            }
+        }else if(StringUtils.isNotEmpty(reqDto.getIsDrilling())&&"2".equals(reqDto.getIsDrilling())){//返回时 查询上级的上级的所有下级
+            SysDept sysDept1=sysDeptService.getById(reqDto.getDeptId());
+            if("1".equals(sysDept1.getComlevel())||"0".equals(sysDept1.getComlevel())){
+                throw new SystemException("已经到最顶层,不能继续返回!");
+            }else if("2".equals(sysDept1.getComlevel())){//如果是二级 往上找一级
+                SysDept sysDept2=sysDeptService.getById(sysDept1.getParentId());
+                comStr.add(sysDept2.getId());
+            }else{//找上级的上级的所有下级
+                SysDept sysDept2=sysDeptService.getById(sysDept1.getParentId());
+                SysDept sysDept3=sysDeptService.getById(sysDept2.getParentId());
+                LambdaQueryWrapper<SysDept> lqw1 = new LambdaQueryWrapper<>();
+                lqw1.eq(SysDept::getParentId, sysDept3.getId());
+                List<SysDept> sysDeptList=sysDeptService.list(lqw1);
+                if(sysDeptList!=null&&sysDeptList.size()>0){
+                    sysDeptList.stream().forEach(item->{
+                        comStr.add(item.getId());
+                    });
+                }else{
+                    throw new SystemException("机构数据有误,请联系管理员!");
+                }
+            }
+        }else{//正常查询时
+            comStr.add(reqDto.getDeptId());
+        }
+        reqDto.setGroupInsCompanyArr(comStr);
         Page<PayApplyDeptReportResVo> payApplyDeptReportResVoPage = reportInsurancePolicyMapper.queryPayApplyDeptReportData(page,
                 reqDto);
+
+        if(payApplyDeptReportResVoPage.getRecords().size()==0){
+            if(StringUtils.isNotEmpty(reqDto.getIsDrilling())&&"1".equals(reqDto.getIsDrilling())){
+                throw new SystemException("已经是最底层机构,无法继续下钻!");
+            }
+        }
+        payApplyDeptReportResVoPage.getRecords().stream().forEach(item->{
+            SysDept sysDept1=sysDeptService.getById(item.getInstitutionId());
+            item.setInstitution(sysDept1.getName());
+        });
         Long total = reportInsurancePolicyMapper.queryPayApplyDeptReportDataCount(reqDto);
         payApplyDeptReportResVoPage.setTotal(total);
         return new BasePageResult<>(reqDto.getPageNum(), reqDto.getPageSize(),
@@ -1204,8 +1253,74 @@ public class ReportServiceImpl implements ReportService {
 
     @Override
     public HttpResult<String> exportPayApplyDeptReportData(PayApplyDeptReportReqVo reqDto) {
+        List<String> comStr=new ArrayList<>();
+        if(StringUtils.isNotEmpty(reqDto.getIsDrilling())&&"1".equals(reqDto.getIsDrilling())){//下钻时查询下级所有机构
+            LambdaQueryWrapper<SysDept> lqw1 = new LambdaQueryWrapper<>();
+            lqw1.eq(SysDept::getParentId, reqDto.getDeptId());
+            List<SysDept> sysDeptList=sysDeptService.list(lqw1);
+            if(sysDeptList!=null&&sysDeptList.size()>0){
+                sysDeptList.stream().forEach(item->{
+                    comStr.add(item.getId());
+                });
+            }else{
+                throw new SystemException("已经到最底层,不能继续下钻!");
+            }
+        }else if(StringUtils.isNotEmpty(reqDto.getIsDrilling())&&"2".equals(reqDto.getIsDrilling())){//返回时 查询上级的上级的所有下级
+            SysDept sysDept1=sysDeptService.getById(reqDto.getDeptId());
+            if("1".equals(sysDept1.getComlevel())||"0".equals(sysDept1.getComlevel())){
+                throw new SystemException("已经到最顶层,不能继续返回!");
+            }else if("2".equals(sysDept1.getComlevel())){//如果是二级 往上找一级
+                SysDept sysDept2=sysDeptService.getById(sysDept1.getParentId());
+                comStr.add(sysDept2.getId());
+            }else{//找上级的上级的所有下级
+                SysDept sysDept2=sysDeptService.getById(sysDept1.getParentId());
+                SysDept sysDept3=sysDeptService.getById(sysDept2.getParentId());
+                LambdaQueryWrapper<SysDept> lqw1 = new LambdaQueryWrapper<>();
+                lqw1.eq(SysDept::getParentId, sysDept3.getId());
+                List<SysDept> sysDeptList=sysDeptService.list(lqw1);
+                if(sysDeptList!=null&&sysDeptList.size()>0){
+                    sysDeptList.stream().forEach(item->{
+                        comStr.add(item.getId());
+                    });
+                }else{
+                    throw new SystemException("机构数据有误,请联系管理员!");
+                }
+            }
+        }else{//正常查询时
+            comStr.add(reqDto.getDeptId());
+        }
+        reqDto.setGroupInsCompanyArr(comStr);
         List<PayApplyDeptReportResVo> payApplyUserReportResVoList = reportInsurancePolicyMapper.queryPayApplyDeptReportData(reqDto);
-        String s = EasyExcelUtils.downExcel(uploadFilePath, PayApplyUserReportResVo.class, payApplyUserReportResVoList);
+        if(payApplyUserReportResVoList.size()==0){
+            if(StringUtils.isNotEmpty(reqDto.getIsDrilling())&&"1".equals(reqDto.getIsDrilling())){
+                throw new SystemException("已经是最底层机构,无法继续下钻!");
+            }
+        }
+        payApplyUserReportResVoList.stream().forEach(item->{
+            SysDept sysDept1=sysDeptService.getById(item.getInstitutionId());
+            item.setInstitution(sysDept1.getName());
+        });
+        String s = EasyExcelUtils.downExcel(uploadFilePath, PayApplyDeptReportResVo.class, payApplyUserReportResVoList);
+        return HttpResult.ok("", s);
+    }
+
+
+    @Override
+    public HttpResult<String> exportPayApplyDeptReportListData(PayApplyDeptReportReqVo payApplyDeptReportReqVo) {
+        List<PayApplyDeptReportListResVo> payApplyDeptReportListData = reportInsurancePolicyMapper.exportPayApplyDeptReportListData(payApplyDeptReportReqVo);
+        payApplyDeptReportListData.stream().forEach(item->{
+            if("0".equals(item.getAuditstatus())){
+                item.setAuditstatus("未审核");
+            }else if("1".equals(item.getAuditstatus())){
+                item.setAuditstatus("已审核");
+            }
+            if ("0".equals(item.getSettlestatus())){
+                item.setSettlestatus("未结算");
+            }else if("1".equals(item.getSettlestatus())){
+                item.setSettlestatus("已结算");
+            }
+        });
+        String s = EasyExcelUtils.downExcel(uploadFilePath, PayApplyDeptReportListResVo.class, payApplyDeptReportListData);
         return HttpResult.ok("", s);
     }
 }

+ 82 - 24
src/main/resources/mapper/modules/report/ReportInsurancePolicyMapper.xml

@@ -893,38 +893,96 @@
     </select>
     <!--===========================================分割线=======报表管理费=================================================-->
     <resultMap id="PayApplyDeptReportDataMap" type="com.ydtech.modules.report.model.vo.PayApplyDeptReportResVo">
-        <result property="institution" column="institution" jdbcType="VARCHAR"/>
-        <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
-        <result property="username" column="username" jdbcType="VARCHAR"/>
+        <result property="institutionId" column="institutionId" jdbcType="VARCHAR"/>
         <result property="waitPayCostsPremiums" column="wait_pay_costs_premiums" jdbcType="DECIMAL"/>
         <result property="paidCostsPremiums" column="paid_costs_premiums" jdbcType="DECIMAL"/>
         <result property="sumCostsPremiums" column="sum_costs_premiums" jdbcType="DECIMAL"/>
-        <result property="waitPayRetailPremiums" column="wait_pay_retail_premiums" jdbcType="DECIMAL"/>
-        <result property="paidRetailPremiums" column="paid_retail_premiums" jdbcType="DECIMAL"/>
-        <result property="sumRetailPremiums" column="sum_retail_premiums" jdbcType="DECIMAL"/>
     </resultMap>
     <select id="queryPayApplyDeptReportData"  resultMap="PayApplyDeptReportDataMap">
-        SELECT
-        count(distinct policyno) policy_count,
-        SUM(p.`sumpremium`) sumpremium,
-        SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
-        SUM(p.`other_costs_premiums`) other_costs_premiums,
-        SUM(p.`sum_costs_premiums`) sum_costs_premiums
-        FROM
-        report_payable_basedata p WHERE 1=1
+        SELECT comcode as institutionId,
+        sum( t.keepamount + t.addamount ) AS sum_costs_premiums,
+        sum( CASE WHEN settlestatus = '1' THEN t.keepamount + t.addamount ELSE 0 END ) AS paid_costs_premiums ,
+        sum( t.keepamount + t.addamount ) - sum( CASE WHEN settlestatus = '1' THEN t.keepamount + t.addamount ELSE 0 END ) as wait_pay_costs_premiums
+        FROM ins_deptfee  t WHERE 1=1
+        <if test="reportReqVo.groupInsCompanyArr != null and reportReqVo.groupInsCompanyArr != ''">
+            and t.comcode in
+            <foreach collection="reportReqVo.groupInsCompanyArr" item="comcode" open="("
+                     separator=","  close=")">
+                      #{comcode}
+            </foreach>
+        </if>
+        <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
+            and t.inscompany = #{reportReqVo.insCompany}
+        </if>
+        <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
+            and t.signdate  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
+        </if>
+        group by comcode
     </select>
     <select id="queryPayApplyDeptReportDataCount" resultType="Long">
-        select
-        count(1)
-        from (
+        select count(1) from (
+        SELECT comcode as institutionId,
+        sum( t.keepamount + t.addamount ) AS sum_costs_premiums,
+        sum( CASE WHEN settlestatus = '1' THEN t.keepamount + t.addamount ELSE 0 END ) AS paid_costs_premiums ,
+        sum( t.keepamount + t.addamount ) - sum( CASE WHEN settlestatus = '1' THEN t.keepamount + t.addamount ELSE 0 END ) as wait_pay_costs_premiums
+        FROM ins_deptfee  t WHERE 1=1
+        <if test="reportReqVo.groupInsCompanyArr != null and reportReqVo.groupInsCompanyArr != ''">
+            and t.comcode in
+            <foreach collection="reportReqVo.groupInsCompanyArr" item="comcode" open="("
+                     separator=","  close=")">
+                #{comcode}
+            </foreach>
+        </if>
+        <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
+            and t.inscompany = #{reportReqVo.insCompany}
+        </if>
+        <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
+            and t.signdate  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
+        </if>
+        group by comcode
+        ) as s
+    </select>
+
+    <resultMap id="PayApplyDeptReportListResMap" type="com.ydtech.modules.report.model.vo.PayApplyDeptReportListResVo">
+        <result column="orderno" property="orderno" />
+        <result column="policyno" property="policyno" />
+        <result column="riskcode" property="riskcode" />
+        <result column="licenseno" property="licenseno" />
+        <result column="comlevel" property="comlevel" />
+        <result column="comcode" property="comcode" />
+        <result column="keeprate" property="keeprate" />
+        <result column="addrate" property="addrate" />
+        <result column="keepamount" property="keepamount" />
+        <result column="addamount" property="addamount" />
+        <result column="auditstatus" property="auditstatus" />
+        <result column="settlestatus" property="settlestatus" />
+        <result column="inscompany" property="inscompany" />
+        <result column="signDate" property="signDate" />
+    </resultMap>
+
+    <select id="exportPayApplyDeptReportListData" resultMap="PayApplyDeptReportListResMap">
         SELECT
-        count(distinct policyno) policy_count,
-        SUM(p.`sumpremium`) sumpremium,
-        SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
-        SUM(p.`other_costs_premiums`) other_costs_premiums,
-        SUM(p.`sum_costs_premiums`) sum_costs_premiums
+        p.orderno,
+        p.policyno,
+        p.riskcode,
+        p.licenseno,
+        p.comlevel,
+        p.comcode,
+        p.keeprate,
+        p.addrate,
+        p.keepamount,
+        p.addamount,
+        p.auditstatus,
+        p.settlestatus,
+        p.inscompany,
+        p.signDate
         FROM
-        report_payable_basedata p WHERE 1=1
-        ) as s
+        ins_deptfee p WHERE 1=1
+        <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
+            and p.comcode = #{reportReqVo.deptId}
+        </if>
+        <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
+            and p.inscompany = #{reportReqVo.insCompany}
+        </if>
     </select>
 </mapper>