فهرست منبع

Merge remote-tracking branch 'origin/test' into test

wks 2 سال پیش
والد
کامیت
f5e58197ce
20فایلهای تغییر یافته به همراه1149 افزوده شده و 250 حذف شده
  1. 3 1
      src/main/java/com/ydtech/modules/fnc/service/impl/InsPlySettleServiceImpl.java
  2. 1 1
      src/main/java/com/ydtech/modules/inv/controller/InvAccountController.java
  3. 1 2
      src/main/java/com/ydtech/modules/inv/controller/InvAccountIncoiceController.java
  4. 19 2
      src/main/java/com/ydtech/modules/inv/controller/invAccountExcelController.java
  5. 5 0
      src/main/java/com/ydtech/modules/inv/model/InvAccountExcel.java
  6. 63 31
      src/main/java/com/ydtech/modules/inv/service/impl/InvAccountExcelServiceImpl.java
  7. 54 51
      src/main/java/com/ydtech/modules/inv/service/impl/InvAccountIncoiceServiceImpl.java
  8. 12 8
      src/main/java/com/ydtech/modules/inv/service/impl/InvAccountOperateServiceImpl.java
  9. 58 43
      src/main/java/com/ydtech/modules/inv/utils/EasyExcelUtils.java
  10. 15 4
      src/main/java/com/ydtech/modules/report/controller/ReportController.java
  11. 4 0
      src/main/java/com/ydtech/modules/report/dao/ReportInsurancePolicyMapper.java
  12. 57 0
      src/main/java/com/ydtech/modules/report/model/vo/PayApplyDeptReportListResVo.java
  13. 4 3
      src/main/java/com/ydtech/modules/report/model/vo/PayApplyDeptReportReqVo.java
  14. 4 35
      src/main/java/com/ydtech/modules/report/model/vo/PayApplyDeptReportResVo.java
  15. 4 1
      src/main/java/com/ydtech/modules/report/model/vo/PayApplyUserReportReqVo.java
  16. 1 0
      src/main/java/com/ydtech/modules/report/model/vo/PayApplyUserReportResVo.java
  17. 28 1
      src/main/java/com/ydtech/modules/report/service/ReportService.java
  18. 329 3
      src/main/java/com/ydtech/modules/report/service/impl/ReportServiceImpl.java
  19. 487 64
      src/main/resources/mapper/modules/report/ReportInsurancePolicyMapper.xml
  20. BIN
      资金申请单模板.xlsx

+ 3 - 1
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlySettleServiceImpl.java

@@ -301,7 +301,9 @@ public class InsPlySettleServiceImpl extends ServiceImpl<InsPlySettleMapper, Ins
 
         List<InsPlySettleReportResVo> insPlySettleReportResVoList = baseMapper.getInsPlySettleReport(insPlySettleReportReqVo);
         if(insPlySettleReportResVoList.size()==0){
-            throw new SystemException("未查询到有效数据!");
+            if(StringUtils.isNotEmpty(insPlySettleReportReqVo.getIsDrilling())&&"1".equals(insPlySettleReportReqVo.getIsDrilling())){
+                throw new SystemException("已经是最底层机构,无法继续下钻!");
+            }
         }
         insPlySettleReportResVoList.stream().forEach(item->{
             EsmInsCompany esmInsCompany =esmInsCompanyService.getById(item.getCompanyId());

+ 1 - 1
src/main/java/com/ydtech/modules/inv/controller/InvAccountController.java

@@ -37,7 +37,7 @@ public class InvAccountController {
     }
 
     @PostMapping("accountExcel")
-    @ApiOperation("费用支出明细导出")
+    @ApiOperation("账户信息导出")
     public HttpResult accountExcel(@RequestBody InvAccountQueryVo invAccountQueryVo) {
         return invAccountService.selectAccountList(invAccountQueryVo);
     }

+ 1 - 2
src/main/java/com/ydtech/modules/inv/controller/InvAccountIncoiceController.java

@@ -43,8 +43,7 @@ public class InvAccountIncoiceController {
      */
     @Resource
     private InvAccountIncoiceService invAccountIncoiceService;
-    @Autowired
-    private InvAccountOpService invAccountOpService;
+
 
 
     @PostMapping("excel")

+ 19 - 2
src/main/java/com/ydtech/modules/inv/controller/invAccountExcelController.java

@@ -56,10 +56,10 @@ public class invAccountExcelController {
         for (Map.Entry<String, Object> entry:entProfit.entrySet()){
             entAmount = entAmount.add(new BigDecimal(entry.getValue().toString()));
         }
-        if (String.valueOf(outAmount).equals("1000")){
+        if (!String.valueOf(outAmount).equals("100")){
             throw new SystemException("支出金额未完全分配");
         }
-        if (String.valueOf(entAmount).equals("1000")){
+        if (!String.valueOf(entAmount).equals("100")){
             throw new SystemException("收入金额未完全分配");
         }
 
@@ -81,6 +81,23 @@ public class invAccountExcelController {
     @PostMapping("update")
     @ApiOperation("修改资金模板信息")
     public HttpResult updateAccount(@RequestBody InvAccountExcel invAccountExcel) {
+        JSONObject outProfit = invAccountExcel.getOutProfit();
+        JSONObject entProfit = invAccountExcel.getEntProfit();
+        BigDecimal outAmount = new BigDecimal(0);
+        BigDecimal entAmount = new BigDecimal(0);
+        for (Map.Entry<String, Object> entry:outProfit.entrySet()){
+            outAmount = outAmount.add(new BigDecimal(entry.getValue().toString()));
+        }
+        for (Map.Entry<String, Object> entry:entProfit.entrySet()){
+            entAmount = entAmount.add(new BigDecimal(entry.getValue().toString()));
+        }
+        if (!String.valueOf(outAmount).equals("100")){
+            throw new SystemException("支出金额未完全分配");
+        }
+        if (!String.valueOf(entAmount).equals("100")){
+            throw new SystemException("收入金额未完全分配");
+        }
+
         if (invAccountExcel.getExcelAccountOperateId() != null) {
             if (invAccountExcel.getTransferFlag().equals("1")) {
                 BaseController baseController = new BaseController();

+ 5 - 0
src/main/java/com/ydtech/modules/inv/model/InvAccountExcel.java

@@ -74,6 +74,11 @@ public class InvAccountExcel implements Serializable {
     @NotBlank
     private String applySector;
 
+
+    @ApiModelProperty(value = "板块")
+    @TableField(exist = false)
+    private String plate;
+
     /**
      * 收款单位信息
      */

+ 63 - 31
src/main/java/com/ydtech/modules/inv/service/impl/InvAccountExcelServiceImpl.java

@@ -14,14 +14,8 @@ import com.ydtech.core.page.PageRequest;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.inv.dao.InvAccountExcelMapper;
-import com.ydtech.modules.inv.model.InvAccount;
-import com.ydtech.modules.inv.model.InvAccountCard;
-import com.ydtech.modules.inv.model.InvAccountExcel;
-import com.ydtech.modules.inv.model.InvAccountOperate;
-import com.ydtech.modules.inv.service.InvAccountCardService;
-import com.ydtech.modules.inv.service.InvAccountExcelService;
-import com.ydtech.modules.inv.service.InvAccountOperateService;
-import com.ydtech.modules.inv.service.InvAccountService;
+import com.ydtech.modules.inv.model.*;
+import com.ydtech.modules.inv.service.*;
 import com.ydtech.modules.inv.utils.EasyExcelUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -52,20 +46,31 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
     @Autowired
     private EasyExcelUtils easyExcelUtils;
 
+    @Autowired
+    private InvAccountService insAccountService;
+
+    @Autowired
+    private InvAccountOpService insAccountOpService;
+
+    @Autowired
+    private InvAccountProfitService insAccountProfitService;
+
+
     @Value("${upload.file.path}")
     String uploadFilePath;
 
     @Override
     public HttpResult excelAccount(List<String> idList) {
         List<InvAccountExcel> insAccountExcels = insAccountExcelMapper.selectBatchIds(idList);
+        List<InvAccountProfit> list = insAccountProfitService.list();
         if (!insAccountExcels.isEmpty()) {
             File folder = new File(uploadFilePath);
-            if (folder.exists()){
-                return HttpResult.ok("", easyExcelUtils.downAccountExcel(uploadFilePath, insAccountExcels));
-            }else {
-                if (folder.mkdirs()){
-                    return HttpResult.ok("", easyExcelUtils.downAccountExcel(uploadFilePath, insAccountExcels));
-                }else {
+            if (folder.exists()) {
+                return HttpResult.ok("", easyExcelUtils.downAccountExcel(uploadFilePath, insAccountExcels,list));
+            } else {
+                if (folder.mkdirs()) {
+                    return HttpResult.ok("", easyExcelUtils.downAccountExcel(uploadFilePath, insAccountExcels,list));
+                } else {
                     throw new SystemException("文件导出失败");
                 }
             }
@@ -83,7 +88,7 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
         Page page = PageRequest.buildPageRequest(pageRequest);
         IPage<InvAccountExcel> invAccountExcelIPage = insAccountExcelMapper.selectExcelAccount(page, invAccountExcel);
         List<InvAccountExcel> records = invAccountExcelIPage.getRecords();
-        for (InvAccountExcel record:records){
+        for (InvAccountExcel record : records) {
             StringBuilder a = new StringBuilder();
             String[] split = record.getPayMethod().split(",");
             for (String i : split) {
@@ -110,6 +115,8 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
 
         InvAccountCard outAccountCard = invAccountCardService.getById(invAccountExcel.getOutCardNum());
         InvAccountCard enterAccountCard = invAccountCardService.getById(invAccountExcel.getEnterCardNum());
+        InvAccount outAccount = insAccountService.getById(outAccountCard.getAccountId());
+        InvAccount enterAccount = insAccountService.getById(enterAccountCard.getAccountId());
 
 
         //修改转账状态
@@ -123,7 +130,7 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
             if (insAccountCards.isEmpty()) {
                 throw new RuntimeException("转账失败");
             }
-            if (!invAccountCardService.updateBatchById(insAccountCards)){
+            if (!invAccountCardService.updateBatchById(insAccountCards)) {
                 throw new RuntimeException("转账失败");
             }
 
@@ -131,8 +138,8 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
             List<InvAccountOperate> list = new ArrayList<>();
             JSONObject outProfit = invAccountExcel.getOutProfit();
             JSONObject entProfit = invAccountExcel.getEntProfit();
-            InvAccountExcel out = outJsonUtil(invAccountExcel, outProfit);
-            InvAccountExcel ent = entJsonUtil(invAccountExcel, entProfit);
+            InvAccountExcel out = outJsonUtil(invAccountExcel, outProfit, outAccount, outAccountCard);
+            InvAccountExcel ent = entJsonUtil(invAccountExcel, entProfit, enterAccount, enterAccountCard);
 
 
             //支出信息
@@ -140,7 +147,7 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
             //收入信息
             list.add(insertRevenueAccountOperate(ent));
 
-            if (!insAccountOperateService.saveBatch(list)){
+            if (!insAccountOperateService.saveBatch(list)) {
                 throw new RuntimeException("添加转账信息失败");
             }
             //重新将值赋值回去方便编辑
@@ -149,11 +156,11 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
         } else {
             //内转外部转账
             List<InvAccountCard> invAccounts = enterDeTransfer(outAccountCard, enterAccountCard, invAccountExcel);
-            if (!invAccountCardService.saveBatch(invAccounts)){
+            if (!invAccountCardService.saveBatch(invAccounts)) {
                 throw new RuntimeException("添加转账信息失败");
             }
             JSONObject outProfit = invAccountExcel.getOutProfit();
-            InvAccountExcel out = outJsonUtil(invAccountExcel, outProfit);
+            InvAccountExcel out = outJsonUtil(invAccountExcel, outProfit, outAccount, outAccountCard);
             insAccountOperateService.save(insertOutAccountOperate(out));
 
             //重新将值赋值回去方便编辑
@@ -164,23 +171,48 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
         return HttpResult.ok("", insAccountExcelMapper.updateById(invAccountExcel));
     }
 
-    private InvAccountExcel outJsonUtil(InvAccountExcel invAccountExcel, JSONObject outProfit) {
+    private InvAccountExcel outJsonUtil(InvAccountExcel invAccountExcel, JSONObject outProfit, InvAccount outAccount, InvAccountCard outCard) {
         JSONObject jsonObject = new JSONObject();
-        for (Map.Entry<String, Object> entry : outProfit.entrySet()){
-            BigDecimal multiply = new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountExcel.getApplyAmount())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
-            String string = multiply.negate().toString();
-            jsonObject.put(entry.getKey(), string);
+        List<InvAccountOp> list = new ArrayList<>();
+
+        for (Map.Entry<String, Object> entry : outProfit.entrySet()) {
+            if (Integer.parseInt(entry.getValue().toString()) != 0) {
+                InvAccountOp invAccountOp = new InvAccountOp();
+                invAccountOp.setAccountId(outAccount.getAccountId());
+                invAccountOp.setAccountName(outAccount.getAccountName());
+                invAccountOp.setCardNum(outCard.getBankCardNum());
+                invAccountOp.setCardName(outCard.getBankName());
+                invAccountOp.setProfit(entry.getKey());
+                invAccountOp.setMoney(new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountExcel.getApplyAmount())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).negate().toString());
+                BigDecimal multiply = new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountExcel.getApplyAmount())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).negate();
+                jsonObject.put(entry.getKey(), multiply);
+                list.add(invAccountOp);
+            }
         }
+        insAccountOpService.saveBatch(list);
         invAccountExcel.setOutProfit(jsonObject);
         return invAccountExcel;
     }
-    private InvAccountExcel entJsonUtil(InvAccountExcel invAccountExcel, JSONObject outProfit) {
+
+    private InvAccountExcel entJsonUtil(InvAccountExcel invAccountExcel, JSONObject outProfit, InvAccount entAccount, InvAccountCard entCard) {
         JSONObject jsonObject = new JSONObject();
-        for (Map.Entry<String, Object> entry : outProfit.entrySet()){
-            BigDecimal multiply = new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountExcel.getApplyAmount())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
-            jsonObject.put(entry.getKey(), multiply);
+        List<InvAccountOp> list = new ArrayList<>();
+        for (Map.Entry<String, Object> entry : outProfit.entrySet()) {
+            if (Integer.parseInt(entry.getValue().toString()) != 0) {
+                InvAccountOp invAccountOp = new InvAccountOp();
+                invAccountOp.setAccountId(entAccount.getAccountId());
+                invAccountOp.setAccountName(entAccount.getAccountName());
+                invAccountOp.setCardNum(entCard.getBankCardNum());
+                invAccountOp.setCardName(entCard.getBankName());
+                invAccountOp.setProfit(entry.getKey());
+                invAccountOp.setMoney(new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountExcel.getApplyAmount())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).toString());
+                BigDecimal multiply = new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountExcel.getApplyAmount())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
+                jsonObject.put(entry.getKey(), multiply);
+                list.add(invAccountOp);
+            }
         }
-        invAccountExcel.setOutProfit(jsonObject);
+        insAccountOpService.saveBatch(list);
+        invAccountExcel.setEntProfit(jsonObject);
         return invAccountExcel;
     }
 

+ 54 - 51
src/main/java/com/ydtech/modules/inv/service/impl/InvAccountIncoiceServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.util.ObjectUtils;
 import java.io.File;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -77,6 +78,10 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
     @Override
     public HttpResult updateInvAccountIncoice(InvAccountIncoice invAccountIncoice) {
         InvAccountIncoice invAccountIncoice1 = invAccountIncoiceMapper.selectById(invAccountIncoice.getInvoiceId());
+        InvAccount account = invAccountService.getById(invAccountIncoice1.getAccountId());
+        InvAccountCard entCard = invAccountCardService.getById(invAccountIncoice1.getRevBankCardNum());
+        InvAccountCard outCard = invAccountCardService.getById(invAccountIncoice1.getOutBankCardNum());
+        List<InvAccountOp> list = new ArrayList<>();
 
         if (new BigDecimal(invAccountIncoice1.getInvoiceMoney()).subtract(new BigDecimal(invAccountIncoice1.getPayoutMoney()).add(new BigDecimal(invAccountIncoice.getPayoutMoney()))).compareTo(new BigDecimal("0")) < 0) {
             throw new SystemException("进账金额大于开票金额");
@@ -87,74 +92,78 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
         //进账金额
         String payoutMoney = new BigDecimal(invAccountIncoice.getPayoutMoney()).toString();
         invAccountIncoice1.setPayoutMoney(new BigDecimal(invAccountIncoice1.getPayoutMoney()).add(new BigDecimal(payoutMoney)).toString());
-        invAccountIncoice1.setNotPayoutMoney(new BigDecimal(invAccountIncoice1.getInvoiceMoney()).subtract(new BigDecimal(payoutMoney)).toString());
+        invAccountIncoice1.setNotPayoutMoney(new BigDecimal(invAccountIncoice1.getInvoiceMoney()).subtract(new BigDecimal(invAccountIncoice1.getPayoutMoney())).toString());
         invAccountIncoice1.setPayoutTime(invAccountIncoice.getPayoutTime());
 
         if (invAccountIncoice1.getNotPayoutMoney().equals("0")) {
             invAccountIncoice1.setClearFlag("1");
         }
 
-
+        String fundFlow = invAccountIncoice1.getOtherUnit() + "→" + invAccountIncoice1.getInvoiceBy();
         //修改发票增加卡的收入
         InvAccountOperate invAccountOperate = new InvAccountOperate();
         invAccountOperate.setEnterCardId(bankCardNum);
         invAccountOperate.setApplyAmount(payoutMoney);
         invAccountOperate.setRevenueOutlay("0");
-        invAccountOperate.setFundFlow(invAccountIncoice.getFundFlow());
+        invAccountOperate.setFundFlow(fundFlow);
         invAccountOperate.setPayMethod(invAccountIncoice.getPayMethod());
         invAccountOperate.setCompany(invAccountIncoice1.getOtherUnit());
         invAccountOperate.setFundUse(invAccountIncoice.getFundUse());
-        invAccountOperate.setRemark(invAccountIncoice.getRemark());
         invAccountOperate.setFundFen(invAccountIncoice.getFundFen());
         invAccountOperate.setInvoiceId(invAccountIncoice1.getInvoiceId());
+        invAccountOperate.setCreateTime(LocalDateTime.now());
         //计算收入百分比
         JSONObject entProfit = invAccountIncoice.getEntProfit();
         JSONObject jsonObject = new JSONObject();
         for (Map.Entry<String, Object> entry : entProfit.entrySet()) {
-            BigDecimal multiply = new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountIncoice.getPayoutMoney())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
-            jsonObject.put(entry.getKey(), multiply);
+            if (Integer.parseInt(entry.getValue().toString()) != 0) {
+                BigDecimal multiply = new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountIncoice.getPayoutMoney())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
+                jsonObject.put(entry.getKey(), multiply);
+                InvAccountOp invAccountOp = new InvAccountOp();
+                invAccountOp.setAccountId(invAccountIncoice1.getAccountId());
+                invAccountOp.setAccountName(account.getAccountName());
+                invAccountOp.setCardNum(entCard.getBankCardNum());
+                invAccountOp.setCardName(entCard.getBankName());
+                invAccountOp.setProfit(entry.getKey());
+                invAccountOp.setMoney(new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountIncoice.getPayoutMoney())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).toString());
+                invAccountOp.setInvoiceId(invAccountIncoice1.getInvoiceId());
+                list.add(invAccountOp);
+            }
         }
         invAccountOperate.setOutProfit(jsonObject);
         invAccountOperate.setEnterCardId(invAccountIncoice.getRevBankCardNum());
 
-        InvAccount account = invAccountService.getById(invAccountIncoice1.getAccountId());
-        InvAccountCard entCard = invAccountCardService.getById(invAccountIncoice1.getRevBankCardNum());
-        InvAccountCard outCard = invAccountCardService.getById(invAccountIncoice1.getOutBankCardNum());
-
-
-        List<InvAccountOp> list = new ArrayList<>();
-        for (Map.Entry<String, Object> entry:invAccountOperate.getOutProfit().entrySet()){
-            InvAccountOp invAccountOp = new InvAccountOp();
-            invAccountOp.setAccountId(invAccountIncoice1.getAccountId());
-            invAccountOp.setAccountName(account.getAccountName());
-            invAccountOp.setCardNum(entCard.getBankCardNum());
-            invAccountOp.setCardName(entCard.getBankName());
-            invAccountOp.setProfit(entry.getKey());
-            invAccountOp.setMoney(entry.getValue().toString());
-            invAccountOp.setInvoiceId(invAccountIncoice1.getInvoiceId());
-            list.add(invAccountOp);
-        }
-
 
 
         //支出操作
         InvAccountOperate outInvAccountOperate = new InvAccountOperate();
-        outInvAccountOperate.setEnterCardId(invAccountIncoice1.getOutBankCardNum());
+        outInvAccountOperate.setEnterCardId(bankCardNum);
         outInvAccountOperate.setApplyAmount(payoutMoney);
         outInvAccountOperate.setRevenueOutlay("1");
-        outInvAccountOperate.setFundFlow(invAccountIncoice.getFundFlow());
+        outInvAccountOperate.setFundFlow(fundFlow);
         outInvAccountOperate.setPayMethod(invAccountIncoice.getPayMethod());
         outInvAccountOperate.setCompany(invAccountIncoice1.getOtherUnit());
         outInvAccountOperate.setFundUse(invAccountIncoice.getFundUse());
         outInvAccountOperate.setFundFen(invAccountIncoice.getFundFen());
-        outInvAccountOperate.setRemark(invAccountIncoice.getRemark());
         outInvAccountOperate.setInvoiceId(invAccountIncoice1.getInvoiceId());
+        outInvAccountOperate.setCreateTime(LocalDateTime.now());
         //计算支出百分比
         JSONObject outProfit = invAccountIncoice.getOutProfit();
         JSONObject outJsonObject = new JSONObject();
         for (Map.Entry<String, Object> entry : outProfit.entrySet()) {
-            BigDecimal multiply = new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountIncoice.getPayoutMoney())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
-            outJsonObject.put(entry.getKey(), multiply.negate());
+            if (Integer.parseInt(entry.getValue().toString()) != 0) {
+                BigDecimal multiply = new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountIncoice.getPayoutMoney())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).negate();
+                outJsonObject.put(entry.getKey(), multiply.negate());
+                InvAccountOp invAccountOp = new InvAccountOp();
+                invAccountOp.setAccountId(invAccountIncoice1.getAccountId());
+                invAccountOp.setAccountName(account.getAccountName());
+                invAccountOp.setCardNum(outCard.getBankCardNum());
+                invAccountOp.setCardName(outCard.getBankName());
+                invAccountOp.setProfit(entry.getKey());
+                invAccountOp.setMoney(new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(invAccountIncoice.getPayoutMoney())).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).negate().toString());
+                invAccountOp.setInvoiceId(invAccountIncoice1.getInvoiceId());
+                list.add(invAccountOp);
+            }
         }
         outInvAccountOperate.setOutProfit(outJsonObject);
         invAccountOperate.setEnterCardId(invAccountIncoice.getOutBankCardNum());
@@ -164,21 +173,6 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
         invAccountOperateList.add(invAccountOperate);
 
 
-        for (Map.Entry<String, Object> entry:outInvAccountOperate.getOutProfit().entrySet()){
-            InvAccountOp invAccountOp = new InvAccountOp();
-            invAccountOp.setAccountId(invAccountIncoice1.getAccountId());
-            invAccountOp.setAccountName(account.getAccountName());
-            invAccountOp.setCardNum(outCard.getBankCardNum());
-            invAccountOp.setCardName(outCard.getBankName());
-            invAccountOp.setProfit(entry.getKey());
-            invAccountOp.setMoney(entry.getValue().toString());
-            invAccountOp.setInvoiceId(invAccountIncoice1.getInvoiceId());
-            list.add(invAccountOp);
-        }
-
-
-        invAccountOpService.saveBatch(list);
-
 
         //支出卡号
         String outBankCardNum = invAccountIncoice1.getOutBankCardNum();
@@ -194,13 +188,14 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
         InvAccount outInvAccount = invAccountService.getById(outInvAccountCard.getAccountId());
 
         //转账
-        if (outInvAccount.getOuterFlag().equals("0")){
+        if (outInvAccount.getOuterFlag().equals("0")) {
             if (revInvAccount.getOuterFlag().equals("0")) {
                 InvAccountExcel invAccountExcel = new InvAccountExcel();
                 invAccountExcel.setApplyAmount(invAccountIncoice.getPayoutMoney());
                 List<InvAccountCard> invAccountCards = insideTransfer(outInvAccountCard, revInvAccountCard, invAccountExcel);
                 invAccountCardService.updateBatchById(invAccountCards);
                 invAccountOperateService.saveBatch(invAccountOperateList);
+                invAccountOpService.saveBatch(list);
 
             } else {
                 InvAccountExcel invAccountExcel = new InvAccountExcel();
@@ -209,12 +204,20 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
                 List<InvAccountCard> invAccountCards = enterDeTransfer(outInvAccountCard, revInvAccountCard, invAccountExcel);
                 invAccountCardService.updateBatchById(invAccountCards);
                 invAccountOperateService.saveBatch(invAccountOperateList);
+                invAccountOpService.saveBatch(list);
             }
-        }else {
+        } else {
             InvAccountOperate invAccountOperate1 = new InvAccountOperate();
             invAccountOperate1.setOutCardNum(invAccountIncoice1.getOutBankCardNum());
             invAccountOperate1.setEnterCardId(invAccountIncoice1.getRevBankCardNum());
-            invAccountOperate1.setApplyAmount(invAccountIncoice.getPayoutMoney());
+            invAccountOperate1.setApplyAmount(payoutMoney);
+            invAccountOperate1.setRevenueOutlay("0");
+            invAccountOperate1.setFundFlow(fundFlow);
+            invAccountOperate1.setPayMethod(invAccountIncoice.getPayMethod());
+            invAccountOperate1.setCompany(invAccountIncoice1.getOtherUnit());
+            invAccountOperate1.setFundUse(invAccountIncoice.getFundUse());
+            invAccountOperate1.setFundFen(invAccountIncoice.getFundFen());
+            invAccountOperate1.setInvoiceId(invAccountIncoice1.getInvoiceId());
             invAccountOperateService.insert(invAccountOperate1);
         }
 
@@ -315,12 +318,12 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
             }
         });
         File folder = new File(uploadFilePath);
-        if (folder.exists()){
+        if (folder.exists()) {
             return EasyExcelUtils.downExcel(uploadFilePath, InvAccountIncoice.class, invAccountIncoices);
-        }else {
-            if (folder.mkdirs()){
+        } else {
+            if (folder.mkdirs()) {
                 return EasyExcelUtils.downExcel(uploadFilePath, InvAccountIncoice.class, invAccountIncoices);
-            }else {
+            } else {
                 throw new SystemException("文件导出失败");
             }
 

+ 12 - 8
src/main/java/com/ydtech/modules/inv/service/impl/InvAccountOperateServiceImpl.java

@@ -17,6 +17,8 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Date;
@@ -105,14 +107,16 @@ public class InvAccountOperateServiceImpl extends ServiceImpl<InvAccountOperateM
         List<InvAccountOp> list = new ArrayList<>();
         if (invAccountOperate.getOutProfit()!=null){
             for (Map.Entry<String, Object> entry:invAccountOperate.getOutProfit().entrySet()){
-                InvAccountOp invAccountOp = new InvAccountOp();
-                invAccountOp.setAccountId(enterAccount.getAccountId());
-                invAccountOp.setAccountName(account.getAccountName());
-                invAccountOp.setCardNum(invAccount.getBankCardNum());
-                invAccountOp.setCardName(invAccount.getBankName());
-                invAccountOp.setProfit(entry.getKey());
-                invAccountOp.setMoney(entry.getValue().toString());
-                list.add(invAccountOp);
+                if (Integer.parseInt(entry.getValue().toString()) != 0){
+                    InvAccountOp invAccountOp = new InvAccountOp();
+                    invAccountOp.setAccountId(enterAccount.getAccountId());
+                    invAccountOp.setAccountName(account.getAccountName());
+                    invAccountOp.setCardNum(invAccount.getBankCardNum());
+                    invAccountOp.setCardName(invAccount.getBankName());
+                    invAccountOp.setProfit(entry.getKey());
+                    invAccountOp.setMoney(new BigDecimal(entry.getValue().toString()).multiply(new BigDecimal(invAccountOperate.getApplyAmount())).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString());
+                    list.add(invAccountOp);
+                }
             }
         }
         invAccountOpService.saveBatch(list);

+ 58 - 43
src/main/java/com/ydtech/modules/inv/utils/EasyExcelUtils.java

@@ -19,6 +19,7 @@ import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import static cn.com.zfc.day018.ZipMultiFile.zipFiles;
 
@@ -63,7 +64,7 @@ public class EasyExcelUtils {
         head2.add("开户银行");
         List<String> head3 = ListUtils.newArrayList();
         head3.add("银行卡余额");
-        list.add(0,head);
+        list.add(0, head);
         list.add(1, head1);
         list.add(2, head2);
         list.add(3, head3);
@@ -78,22 +79,21 @@ public class EasyExcelUtils {
     }
 
 
-
     private static List<List<Object>> dataList(List<InvAccount> invAccounts, List<InvAccountOp> invAccountOpList, List<InvAccountProfit> invAccountProfitList) {
         List<List<Object>> list = ListUtils.newArrayList();
         invAccounts.forEach(invAccount -> {
             List<Object> data = ListUtils.newArrayList();
             invAccount.getInvAccountCardList().forEach(invAccountCard -> {
                 if (invAccountCard.getBankCardNum() != null) {
-                    data.add(invAccount.getOuterFlag().equals("0")?"内部账户":"外部账户");
+                    data.add(invAccount.getOuterFlag().equals("0") ? "内部账户" : "外部账户");
                     data.add(invAccount.getAccountName());
                     data.add(invAccountCard.getBankName());
                     data.add(invAccountCard.getBalance());
 
                     invAccountProfitList.forEach(invAccountProfitList1 -> {
                         String a = "0";
-                        for (InvAccountOp invAccountProfit :  invAccountOpList){
-                            if (invAccountProfitList1.getProfitEng().equals(invAccountProfit.getProfit())&&invAccountCard.getBankCardNum().equals(invAccountProfit.getCardNum())) {
+                        for (InvAccountOp invAccountProfit : invAccountOpList) {
+                            if (invAccountProfitList1.getProfitEng().equals(invAccountProfit.getProfit()) && invAccountCard.getBankCardNum().equals(invAccountProfit.getCardNum())) {
                                 a = new BigDecimal(a).add(new BigDecimal(invAccountProfit.getMoney())).toString();
                             }
                         }
@@ -108,7 +108,6 @@ public class EasyExcelUtils {
     }
 
 
-
     /**
      * 不创建对象的写
      */
@@ -137,8 +136,10 @@ public class EasyExcelUtils {
         head5.add("分项");
         List<String> head6 = ListUtils.newArrayList();
         head6.add("支出金额");
+        List<String> head7 = ListUtils.newArrayList();
+        head7.add("转账类型");
 
-        list.add(0,head);
+        list.add(0, head);
         list.add(1, head1);
         list.add(2, head2);
         list.add(3, head3);
@@ -155,8 +156,7 @@ public class EasyExcelUtils {
     }
 
 
-
-    private static List<List<Object>> operatedataList( List<InvAccountOperate> invAccountOperates , List<InvAccountProfit> invAccountProfitList) {
+    private static List<List<Object>> operatedataList(List<InvAccountOperate> invAccountOperates, List<InvAccountProfit> invAccountProfitList) {
         List<List<Object>> list = ListUtils.newArrayList();
         invAccountOperates.forEach(invAccountOperate -> {
             List<Object> data = ListUtils.newArrayList();
@@ -167,10 +167,11 @@ public class EasyExcelUtils {
             data.add(invAccountOperate.getFundUse());
             data.add(invAccountOperate.getFundFen());
             data.add(invAccountOperate.getApplyAmount());
+            data.add(invAccountOperate.getRevenueOutlay().equals("0")?"收入":"支出");
             invAccountProfitList.forEach(invAccountProfit -> {
-                if (invAccountOperate.getOutProfit() != null){
-                    for (Map.Entry<String, Object> entry:invAccountOperate.getOutProfit().entrySet()){
-                        if (entry.getKey().equals(invAccountProfit.getProfitEng())){
+                if (invAccountOperate.getOutProfit() != null) {
+                    for (Map.Entry<String, Object> entry : invAccountOperate.getOutProfit().entrySet()) {
+                        if (entry.getKey().equals(invAccountProfit.getProfitEng())) {
                             data.add(entry.getValue());
                         }
                     }
@@ -182,15 +183,6 @@ public class EasyExcelUtils {
     }
 
 
-
-
-
-
-
-
-
-
-
     public static String downExcel(String uploadFilePath, String fileName, Class clz, List<?> list) {
 
         String file = fileName + System.currentTimeMillis() + ".xlsx";
@@ -224,32 +216,55 @@ public class EasyExcelUtils {
     /**
      * 导出资金申请模板
      */
-    public String downAccountExcel(String uploadFilePath, List<InvAccountExcel> invAccountExcel) {
+    public String downAccountExcel(String uploadFilePath, List<InvAccountExcel> invAccountExcel,List<InvAccountProfit> invAccountProfit) {
         // 加载模板
         String templateFile = "资金申请单模板.xlsx";
         List<InvAccountExcel> list = new ArrayList<>();
         // 获取工作表并填充
         for (InvAccountExcel excel : invAccountExcel) {
-                // 写入文件
-                Date date = new Date();
-                String file = date.getTime() + ".xlsx";
-                String fileName = uploadFilePath + file;
-                excel.setExcelApplyTime(new SimpleDateFormat("yyyy-MM-dd").format(excel.getApplyTime()));
-                String payMethod = excel.getPayMethod();
-                String[] split = payMethod.split(",");
-                StringBuilder a = new StringBuilder();
-                for (String i : split) {
-                    a.append(InvPayMethodEnum.getNameByCode(i)).append(",");
+            // 写入文件
+            Date date = new Date();
+            String file = date.getTime() + ".xlsx";
+            String fileName = uploadFilePath + file;
+            excel.setExcelApplyTime(new SimpleDateFormat("yyyy-MM-dd").format(excel.getApplyTime()));
+            String payMethod = excel.getPayMethod();
+            String[] split = payMethod.split(",");
+            StringBuilder a = new StringBuilder();
+            for (String i : split) {
+                a.append(InvPayMethodEnum.getNameByCode(i)).append(",");
+            }
+
+            StringBuilder stringBuffer = new StringBuilder();
+
+            Map<String, List<InvAccountProfit>> collect = invAccountProfit.stream().collect(
+                    Collectors.groupingBy(
+                            InvAccountProfit::getProfitEng
+                    ));
+
+            for (Map.Entry<String, Object> entry : excel.getEntProfit().entrySet()) {
+                if (Integer.parseInt(entry.getValue().toString()) != 0) {
+                    stringBuffer.append(collect.get(entry.getKey()).get(0).getProfitName()).append("   ").append(entry.getValue()).append("%");
+                }
+            }
+            stringBuffer.append("→");
+
+            for (Map.Entry<String, Object> entry : excel.getOutProfit().entrySet()) {
+                if (Integer.parseInt(entry.getValue().toString()) != 0) {
+                    stringBuffer.append(collect.get(entry.getKey()).get(0).getProfitName()).append("    ").append(entry.getValue()).append("%");
                 }
-                excel.setPayMethod(a.toString());
-                // 生成工作簿对象
-                ExcelWriterBuilder workBookWriter = EasyExcel.write(fileName, InvAccountExcel.class)
-                        .withTemplate(templateFile);
-
-                workBookWriter.sheet().doFill(excel);
-                excel.setUplodePath(file);
-                excel.setPayMethod(payMethod);
-                list.add(excel);
+            }
+            excel.setPlate(stringBuffer.toString());
+
+
+            excel.setPayMethod(a.toString());
+            // 生成工作簿对象
+            ExcelWriterBuilder workBookWriter = EasyExcel.write(fileName, InvAccountExcel.class)
+                    .withTemplate(templateFile);
+
+            workBookWriter.sheet().doFill(excel);
+            excel.setUplodePath(file);
+            excel.setPayMethod(payMethod);
+            list.add(excel);
         }
         insAccountExcelService.updateBatchById(list);
 
@@ -257,8 +272,8 @@ public class EasyExcelUtils {
         for (int i = 0; i < list.size(); i++) {
             srcFiles[i] = new File(uploadFilePath + list.get(i).getUplodePath());
         }
-        String a = LocalDate.now()+".zip";
-        File zipFile = new File(uploadFilePath+a);
+        String a = LocalDate.now() + ".zip";
+        File zipFile = new File(uploadFilePath + a);
         // 调用压缩方法
         zipFiles(srcFiles, zipFile);
 

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

@@ -222,19 +222,30 @@ public class ReportController extends BaseController {
     @PostMapping("/getPayApplyUserReport")
     @ApiOperation(value = "报表-应付分销费和手续费统计-查询")
     public HttpResult<BasePageResult<PayApplyUserReportResVo>> getPayApplyUserReport(@RequestBody PayApplyUserReportReqVo payApplyUserReportReqVo) {
-        BasePageResult<PayApplyUserReportResVo> quoteResult = reportService.getPayApplyUserReportData(payApplyUserReportReqVo);
+        BasePageResult<PayApplyUserReportResVo> quoteResult = new BasePageResult<PayApplyUserReportResVo>();
+        if("0".equals(payApplyUserReportReqVo.getIsDrilling())){
+            quoteResult = reportService.getPayApplyUserReportData(payApplyUserReportReqVo);
+        }else if("1".equals(payApplyUserReportReqVo.getIsDrilling())){//下钻查询
+            quoteResult=reportService.drilPayApplyUserReportData(payApplyUserReportReqVo);
+        }
         return HttpResult.ok("success", quoteResult);
     }
     @PostMapping("/exportPayApplyUserReport")
     @ApiOperation(value = "报表-应付统计分销费和手续费清单-导出清单")
     public HttpResult<String> exportPayApplyUserReport(@RequestBody PayApplyUserReportReqVo payApplyUserReportReqVo) {
-        return reportService.exportPayApplyUserReportData(payApplyUserReportReqVo);
+        String result="";
+        if("0".equals(payApplyUserReportReqVo.getIsDrilling())){
+            result = reportService.exportPayApplyUserReportData(payApplyUserReportReqVo);
+        }else if("1".equals(payApplyUserReportReqVo.getIsDrilling())){//下钻查询
+            result= reportService.exportDrilPayApplyUserReportData(payApplyUserReportReqVo);
+        }
+        return HttpResult.ok("", result);
     }
 
     @PostMapping("/exportPayApplyUserReporttListData")
     @ApiOperation(value = "报表-应付统计分销费和手续费清单-导出清单明细")
     public HttpResult<String> exportPayApplyUserReportListData(@RequestBody PayApplyUserReportReqVo payApplyUserReportReqVo) {
-        return reportService.exportPayApplyUserReportData(payApplyUserReportReqVo);
+        return reportService.exportPayApplyUserReportListData(payApplyUserReportReqVo);
     }
 
     /*--------------------------------------------------------------------------*/
@@ -253,7 +264,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);
 
     }
 }

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

@@ -29,11 +29,15 @@ public interface ReportInsurancePolicyMapper extends BaseMapper<ReportInsuranceP
 
     List<PayApplyUserReportResVo> queryPayApplyUserReportData(@Param("reportReqVo") PayApplyUserReportReqVo reqVo);
 
+    List<PayApplyUserReportListResVo>  queryPayApplyUserReportList(@Param("reportReqVo") PayApplyUserReportReqVo reqVo);
+
     Long queryPayApplyUserReportDataCount(@Param("reportReqVo") PayApplyUserReportReqVo reqVo);
 
     Page<PayApplyDeptReportResVo> queryPayApplyDeptReportData(@Param("page") Page page, @Param("reportReqVo") PayApplyDeptReportReqVo reqVo);
 
     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;
+
 
 }

+ 4 - 1
src/main/java/com/ydtech/modules/report/model/vo/PayApplyUserReportReqVo.java

@@ -48,7 +48,10 @@ public class PayApplyUserReportReqVo {
 
     @ApiModelProperty(value = "是否下钻查询  1 下钻 0非下钻查询")
     private String isDrilling;
-
+    @ApiModelProperty(value = "下钻查询类型  1 团队下钻 0机构下钻  2返回上层")
+    private String drilType;
+    @ApiModelProperty(value = "机构下钻返回时 需要查询的机构层级    总部机构层级为空时,赋值为X")
+    private String drilFlag;
     @ApiModelProperty(value = "是否返回上层  1 返回上层 0非返回上层")
     private String isReturnBack;
 }

+ 1 - 0
src/main/java/com/ydtech/modules/report/model/vo/PayApplyUserReportResVo.java

@@ -59,6 +59,7 @@ public class PayApplyUserReportResVo {
      * 机构Id
      */
     @ExcelIgnore
+    @TableField(value = "institutionId")
     private String institutionId;
     /**
      * 团队Id

+ 28 - 1
src/main/java/com/ydtech/modules/report/service/ReportService.java

@@ -131,12 +131,32 @@ public interface ReportService {
      */
     public BasePageResult<PayApplyUserReportResVo> getPayApplyUserReportData(PayApplyUserReportReqVo reqDto);
 
+    /**
+     * 页获取应付分销费和手续费统计清单数据
+     * @param reqDto
+     * @return
+     */
+    public BasePageResult<PayApplyUserReportResVo> drilPayApplyUserReportData(PayApplyUserReportReqVo reqDto);
+
+    /**
+     * 导出应付统计分销费和手续费清单数据
+     * @param reqDto
+     * @return
+     */
+    public String exportPayApplyUserReportData(PayApplyUserReportReqVo reqDto);
     /**
      * 导出应付统计分销费和手续费清单数据
      * @param reqDto
      * @return
      */
-    public HttpResult<String> exportPayApplyUserReportData(PayApplyUserReportReqVo reqDto);
+    public String exportDrilPayApplyUserReportData(PayApplyUserReportReqVo reqDto);
+
+    /**
+     * 导出应付统计分销费和手续费清单明细数据
+     * @param reqDto
+     * @return
+     */
+    public HttpResult<String> exportPayApplyUserReportListData(PayApplyUserReportReqVo reqDto) ;
 
     /**
      * 分页获取应付管理费统计清单数据
@@ -151,4 +171,11 @@ public interface ReportService {
      * @return
      */
     public HttpResult<String> exportPayApplyDeptReportData(PayApplyDeptReportReqVo reqDto);
+
+    /**
+     * 报表-应付统计管理费-导出清单
+     * @param payApplyDeptReportReqVo
+     * @return
+     */
+    public HttpResult<String> exportPayApplyDeptReportListData(PayApplyDeptReportReqVo payApplyDeptReportReqVo);
 }

+ 329 - 3
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;
@@ -1176,25 +1178,283 @@ public class ReportServiceImpl implements ReportService {
         page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
         Page<PayApplyUserReportResVo> payApplyReportResVoPage = reportInsurancePolicyMapper.queryPayApplyUserReportData(page,
                 reqDto);
+        payApplyReportResVoPage.getRecords().stream().forEach(item->{
+            item.setInstitutionId(reqDto.getDeptId());
+            SysDept sysDept1=sysDeptService.getById(reqDto.getDeptId());
+            item.setInstitution(sysDept1.getName());
+            if(StringUtils.isNotEmpty(reqDto.getTeamCode())){
+                item.setDeptId(reqDto.getTeamCode());
+                SysDept sysDept2=sysDeptService.getById(reqDto.getTeamCode());
+                if(sysDept2!=null){
+                    item.setDeptname(sysDept2.getName());
+                }
+            }
+            if(StringUtils.isNotEmpty(reqDto.getUserId())){
+                SysUser sysUser=sysUserService.getById(reqDto.getUserId());
+                if(sysUser!=null){
+                    item.setUsername(sysUser.getName());
+                }
+            }
+        });
         Long total = reportInsurancePolicyMapper.queryPayApplyUserReportDataCount(reqDto);
         payApplyReportResVoPage.setTotal(total);
         return new BasePageResult<>(reqDto.getPageNum(), reqDto.getPageSize(),
                 payApplyReportResVoPage.getTotal(), payApplyReportResVoPage.getPages()
                 , payApplyReportResVoPage.getRecords());
     }
+    @Override
+    public BasePageResult<PayApplyUserReportResVo> drilPayApplyUserReportData(PayApplyUserReportReqVo reqDto) {
+        Page<InsOrders> page = new Page<>(reqDto.getPageNum(), reqDto.getPageSize());
+        page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
+        //返回上层时 调整查询条件
+        if(StringUtils.isNotEmpty(reqDto.getIsReturnBack())&&"1".equals(reqDto.getIsReturnBack())){
+            if(StringUtils.isNotEmpty(reqDto.getTeamCode())) {
+                reqDto.setDeptId(reqDto.getTeamCode());
+            }
+            reqDto.setDrilType("2");
+            //如果是机构返回上层时,需要找上级的上级去查询
+            SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+            SysDept sysDept1=sysDeptService.getById(sysDept.getParentId());
+            if(sysDept1==null){
+                throw new SystemException("已经到最上层,不能继续返回!");
+            }
+            String flag="";
+            SysDept sysDept2=sysDeptService.getById(sysDept1.getParentId());
+            if(sysDept2==null){
+                reqDto.setDeptId(sysDept1.getId());
+                flag="X";
+            }else{
+                reqDto.setDeptId(sysDept2.getId());
+                flag=sysDept1.getComlevel();
+            }
+            reqDto.setDrilFlag(flag);
+        }else if(StringUtils.isNotEmpty(reqDto.getIsDrilling())&&"1".equals(reqDto.getIsDrilling())){
+            if(StringUtils.isNotEmpty(reqDto.getTeamCode())){
+                //如果团队不为空,则为团队下钻  查询到业务员
+                reqDto.setDrilType("1");
+            }else{
+                //如果团队为空,则为机构下钻,查询下一级机构
+                reqDto.setDrilType("0");
+                SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+                String flag="";
+                if(StringUtils.isNotEmpty(sysDept.getComlevel())){
+                    flag=sysDept.getComlevel();
+                }else{
+                    flag="X";
+                }
+                reqDto.setDrilFlag(flag);
+            }
+        }
+        Page<PayApplyUserReportResVo> payApplyReportResVoPage = reportInsurancePolicyMapper.queryPayApplyUserReportData(page,
+                reqDto);
+        payApplyReportResVoPage.getRecords().stream().forEach(item->{
+            //如果返回业务员时
+            if(StringUtils.isNotEmpty(item.getUsername())){
+                SysDept sysDept1=sysDeptService.getById(reqDto.getDeptId());
+                item.setInstitutionId(reqDto.getDeptId());
+                item.setInstitution(sysDept1.getName());
+                SysDept sysDept2=sysDeptService.getById(reqDto.getTeamCode());
+                item.setDeptId(reqDto.getTeamCode());
+                item.setDeptname(sysDept2.getName());
+            }else{
+                //如果返回团队时
+                if(StringUtils.isNotEmpty(item.getDeptId())){
+                    SysDept sysDept1=sysDeptService.getById(item.getDeptId());
+                    item.setDeptname(sysDept1.getName());
+                    item.setDeptId(item.getDeptId());
+                    SysDept sysDept2=sysDeptService.getById(reqDto.getDeptId());
+                    item.setInstitutionId(reqDto.getDeptId());
+                    item.setInstitution(sysDept2.getName());
+                }else{
+                    //不下钻到团队时,按返回机构赋值
+                    if(StringUtils.isNotEmpty(item.getInstitutionId())){
+                        item.setInstitutionId(item.getInstitutionId());
+                        SysDept sysDept=sysDeptService.getById(item.getInstitutionId());
+                        if(sysDept!=null){
+                            item.setInstitution(sysDept.getName());
+                        }
+                    }else {
+                        item.setInstitutionId(reqDto.getDeptId());
+                        SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+                        if(sysDept!=null){
+                            item.setInstitution(sysDept.getName());
+                        }
+                    }
 
+                }
+            }
+        });
+        Long total = reportInsurancePolicyMapper.queryPayApplyUserReportDataCount(reqDto);
+        payApplyReportResVoPage.setTotal(total);
+        return new BasePageResult<>(reqDto.getPageNum(), reqDto.getPageSize(),
+                payApplyReportResVoPage.getTotal(), payApplyReportResVoPage.getPages()
+                , payApplyReportResVoPage.getRecords());
+    }
+
+    @Override
+    public String exportPayApplyUserReportData(PayApplyUserReportReqVo reqDto) {
+        List<PayApplyUserReportResVo> payApplyUserReportResVoList = reportInsurancePolicyMapper.queryPayApplyUserReportData(reqDto);
+        payApplyUserReportResVoList.stream().forEach(item->{
+            item.setInstitutionId(reqDto.getDeptId());
+            SysDept sysDept1=sysDeptService.getById(reqDto.getDeptId());
+            item.setInstitution(sysDept1.getName());
+            if(StringUtils.isNotEmpty(reqDto.getTeamCode())){
+                item.setDeptId(reqDto.getTeamCode());
+                SysDept sysDept2=sysDeptService.getById(reqDto.getTeamCode());
+                if(sysDept2!=null){
+                    item.setDeptname(sysDept2.getName());
+                }
+            }
+            if(StringUtils.isNotEmpty(reqDto.getUserId())){
+                SysUser sysUser=sysUserService.getById(reqDto.getUserId());
+                if(sysUser!=null){
+                    item.setUsername(sysUser.getName());
+                }
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadFilePath, PayApplyUserReportResVo.class, payApplyUserReportResVoList);
+    }
     @Override
-    public HttpResult<String> exportPayApplyUserReportData(PayApplyUserReportReqVo reqDto) {
+    public String exportDrilPayApplyUserReportData(PayApplyUserReportReqVo reqDto) {
+        //返回上层时 调整查询条件
+        if(StringUtils.isNotEmpty(reqDto.getIsReturnBack())&&"1".equals(reqDto.getIsReturnBack())){
+            if(StringUtils.isNotEmpty(reqDto.getTeamCode())) {
+                reqDto.setDeptId(reqDto.getTeamCode());
+            }
+            reqDto.setDrilType("2");
+            //如果是机构返回上层时,需要找上级的上级去查询
+            SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+            SysDept sysDept1=sysDeptService.getById(sysDept.getParentId());
+            if(sysDept1==null){
+                throw new SystemException("已经到最上层,不能继续返回!");
+            }
+            String flag="";
+            SysDept sysDept2=sysDeptService.getById(sysDept1.getParentId());
+            if(sysDept2==null){
+                reqDto.setDeptId(sysDept1.getId());
+                flag="X";
+            }else{
+                reqDto.setDeptId(sysDept2.getId());
+                flag=sysDept1.getComlevel();
+            }
+            reqDto.setDrilFlag(flag);
+        }else if(StringUtils.isNotEmpty(reqDto.getIsDrilling())&&"1".equals(reqDto.getIsDrilling())){
+            if(StringUtils.isNotEmpty(reqDto.getTeamCode())){
+                //如果团队不为空,则为团队下钻  查询到业务员
+                reqDto.setDrilType("1");
+            }else{
+                //如果团队为空,则为机构下钻,查询下一级机构
+                reqDto.setDrilType("0");
+                SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+                String flag="";
+                if(StringUtils.isNotEmpty(sysDept.getComlevel())){
+                    flag=sysDept.getComlevel();
+                }else{
+                    flag="X";
+                }
+                reqDto.setDrilFlag(flag);
+            }
+        }
         List<PayApplyUserReportResVo> payApplyUserReportResVoList = reportInsurancePolicyMapper.queryPayApplyUserReportData(reqDto);
-        String s = EasyExcelUtils.downExcel(uploadFilePath, PayApplyUserReportResVo.class, payApplyUserReportResVoList);
+        payApplyUserReportResVoList.stream().forEach(item->{
+            //如果返回业务员时
+            if(StringUtils.isNotEmpty(item.getUsername())){
+                SysDept sysDept1=sysDeptService.getById(reqDto.getDeptId());
+                item.setInstitutionId(reqDto.getDeptId());
+                item.setInstitution(sysDept1.getName());
+                SysDept sysDept2=sysDeptService.getById(reqDto.getTeamCode());
+                item.setDeptId(reqDto.getTeamCode());
+                item.setDeptname(sysDept2.getName());
+            }else{
+                //如果返回团队时
+                if(StringUtils.isNotEmpty(item.getDeptId())){
+                    SysDept sysDept1=sysDeptService.getById(item.getDeptId());
+                    item.setDeptname(sysDept1.getName());
+                    item.setDeptId(item.getDeptId());
+                    SysDept sysDept2=sysDeptService.getById(reqDto.getDeptId());
+                    item.setInstitutionId(reqDto.getDeptId());
+                    item.setInstitution(sysDept2.getName());
+                }else{
+                    //不下钻到团队时,按返回机构赋值
+                    if(StringUtils.isNotEmpty(item.getInstitutionId())){
+                        item.setInstitutionId(item.getInstitutionId());
+                        SysDept sysDept=sysDeptService.getById(item.getInstitutionId());
+                        if(sysDept!=null){
+                            item.setInstitution(sysDept.getName());
+                        }
+                    }else {
+                        item.setInstitutionId(reqDto.getDeptId());
+                        SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+                        if(sysDept!=null){
+                            item.setInstitution(sysDept.getName());
+                        }
+                    }
+
+                }
+            }
+        });
+        return EasyExcelUtils.downExcel(uploadFilePath, PayApplyUserReportResVo.class, payApplyUserReportResVoList);
+    }
+    @Override
+    public HttpResult<String> exportPayApplyUserReportListData(PayApplyUserReportReqVo reqDto) {
+        List<PayApplyUserReportListResVo> payApplyUserReportResVoList = reportInsurancePolicyMapper.queryPayApplyUserReportList(reqDto);
+        String s = EasyExcelUtils.downExcel(uploadFilePath, PayApplyUserReportListResVo.class, payApplyUserReportResVoList);
         return HttpResult.ok("", s);
     }
+
     @Override
     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 +1464,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);
     }
 }

+ 487 - 64
src/main/resources/mapper/modules/report/ReportInsurancePolicyMapper.xml

@@ -755,6 +755,7 @@
 
     <resultMap id="PayApplyUserReportDataMap" type="com.ydtech.modules.report.model.vo.PayApplyUserReportResVo">
         <result property="institution" column="institution" jdbcType="VARCHAR"/>
+        <result property="institutionId" column="institutionId" jdbcType="VARCHAR"/>
         <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
         <result property="username" column="username" jdbcType="VARCHAR"/>
         <result property="waitPayCostsPremiums" column="wait_pay_costs_premiums" jdbcType="DECIMAL"/>
@@ -767,10 +768,68 @@
 
 
     <select id="queryPayApplyUserReportData"  resultMap="PayApplyUserReportDataMap">
-        SELECT deptid,
-            <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
-                userid,
+        SELECT
+        <!--下钻查询时拼接-->
+        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+            <!--按团队下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                p.`username`,p.userid userId,
             </if>
+            <!--按机构下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                <!--下钻的是五级机构时,下钻到团队-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    p.deptid,
+                </if>
+                <!--下钻的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    substr(p.deptid,1,11) institutionId,
+                </if>
+                <!--下钻的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    substr(p.deptid,1,8) institutionId,
+                </if>
+                <!--下钻的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    substr(p.deptid,1,6) institutionId,
+                </if>
+                <!--下钻的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    substr(p.deptid,1,4) institutionId,
+                </if>
+                <!--下钻的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    substr(p.deptid,1,2) institutionId,
+                </if>
+            </if>
+            <!--返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                <!--返回的是五级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    substr(p.deptid,1,11) institutionId,
+                </if>
+                <!--返回的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    substr(p.deptid,1,8) institutionId,
+                </if>
+                <!--返回的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    substr(p.deptid,1,6) institutionId,
+                </if>
+                <!--返回的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    substr(p.deptid,1,4) institutionId,
+                </if>
+                <!--返回的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    substr(p.deptid,1,2) institutionId,
+                </if>
+                <!--返回的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    substr(p.deptid,1,1) institutionId,
+                </if>
+            </if>
+        </if>
           SUM( CASE feetype  WHEN '1'  THEN totalfee  ELSE 0  END )  AS sum_costs_premiums,
           SUM( CASE feetype  WHEN '1'  THEN paidfee  ELSE 0  END )  AS paid_costs_premiums,
           SUM( CASE feetype  WHEN '1'  THEN totalfee-paidfee  ELSE 0  END )  AS wait_pay_costs_premiums,
@@ -778,39 +837,221 @@
           SUM( CASE feetype  WHEN '2'  THEN paidfee  ELSE 0  END )  AS paid_retail_premiums,
           SUM( CASE feetype  WHEN '2'  THEN totalfee-paidfee  ELSE 0  END )  AS wait_pay_retail_premiums
         FROM report_payable_basedata  p WHERE 1=1
-        <choose>
-            <!--条件中团队不为空时,直接拼接团队-->
-            <when test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
-                and p.deptid = #{reportReqVo.teamCode}
-            </when>
-            <!--条件中团队为空时,使用机构模糊查询-->
-            <otherwise>
-                <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
-                    and p.deptid like #{reportReqVo.deptId}"%"
+        <!--下钻查询时拼接-->
+        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+            <!--按团队下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+                    and p.deptid = #{reportReqVo.teamCode}
                 </if>
-            </otherwise>
-        </choose>
-        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
-            and p.userId = #{reportReqVo.userId}
+            </if>
+            <!--按机构下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                <!--下钻的是五级机构时,下钻到团队-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    and p.deptid in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    and substr(p.deptid,1,11) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    and substr(p.deptid,1,8) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    and substr(p.deptid,1,6) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    and substr(p.deptid,1,4) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    and substr(p.deptid,1,2) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+            </if>
+            <!--返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                <!--返回的是五级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    and substr(p.deptid,1,8)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    and substr(p.deptid,1,6)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    and substr(p.deptid,1,4)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    and substr(p.deptid,1,2)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    and substr(p.deptid,1,1)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    and substr(p.deptid,1,1)  = #{reportReqVo.deptId}
+                </if>
+            </if>
         </if>
+        <!--非下钻查询时拼接-->
+        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '0'.toString()">
+            <choose>
+                <!--条件中团队不为空时,直接拼接团队-->
+                <when test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+                    and p.deptid = #{reportReqVo.teamCode}
+                </when>
+                <!--条件中团队为空时,使用机构模糊查询-->
+                <otherwise>
+                    <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
+                        and p.deptid like #{reportReqVo.deptId}"%"
+                    </if>
+                </otherwise>
+            </choose>
+            <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
+                and p.userid = #{reportReqVo.userId}
+            </if>
+        </if>
+        <!--通用查询条件拼接-->
         <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
-            and p.inscompany = #{reportReqVo.insCompany}
+            and p.company_id = #{reportReqVo.insCompany}
         </if>
         <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
             and p.signdate  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
         </if>
-        group by deptid
-        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
-            ,userid
+        <!--下钻查询时拼接-->
+        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+            <!--按团队下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                group by p.`username`,p.userid order by p.`username`
+            </if>
+            <!--按机构下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                <!--下钻的是五级机构时,下钻到团队-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    group by  p.deptid  order by p.deptid
+                </if>
+                <!--下钻的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    group by  substr(p.deptid,1,11) order by    substr(p.deptid,1,11)
+                </if>
+                <!--下钻的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    group by  substr(p.deptid,1,8) order by    substr(p.deptid,1,8)
+                </if>
+                <!--下钻的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    group by  substr(p.deptid,1,6) order by    substr(p.deptid,1,6)
+                </if>
+                <!--下钻的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    group by  substr(p.deptid,1,4) order by    substr(p.deptid,1,4)
+                </if>
+                <!--下钻的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    group by  substr(p.deptid,1,2) order by    substr(p.deptid,1,2)
+                </if>
+            </if>
+            <!--返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                <!--返回的是五级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    group by substr(p.deptid,1,11)   order by substr(p.deptid,1,11)
+                </if>
+                <!--返回的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    group by substr(p.deptid,1,8)   order by substr(p.deptid,1,8)
+                </if>
+                <!--返回的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    group by substr(p.deptid,1,6)   order by substr(p.deptid,1,6)
+                </if>
+                <!--返回的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    group by substr(p.deptid,1,4)   order by substr(p.deptid,1,4)
+                </if>
+                <!--返回的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    group by substr(p.deptid,1,2)   order by substr(p.deptid,1,2)
+                </if>
+                <!--返回的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    group by substr(p.deptid,1,1)   order by substr(p.deptid,1,1)
+                </if>
+            </if>
         </if>
     </select>
     <select id="queryPayApplyUserReportDataCount" resultType="Long">
         select
         count(1)
         from (
-        SELECT deptid,
-        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
-            userid,
+        SELECT
+        <!--下钻查询时拼接-->
+        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+            <!--按团队下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                p.`username`,p.userid userId,
+            </if>
+            <!--按机构下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                <!--下钻的是五级机构时,下钻到团队-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    p.deptid,
+                </if>
+                <!--下钻的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    substr(p.deptid,1,11) institutionId,
+                </if>
+                <!--下钻的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    substr(p.deptid,1,8) institutionId,
+                </if>
+                <!--下钻的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    substr(p.deptid,1,6) institutionId,
+                </if>
+                <!--下钻的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    substr(p.deptid,1,4) institutionId,
+                </if>
+                <!--下钻的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    substr(p.deptid,1,2) institutionId,
+                </if>
+            </if>
+            <!--返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                <!--返回的是五级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    substr(p.deptid,1,11) institutionId,
+                </if>
+                <!--返回的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    substr(p.deptid,1,8) institutionId,
+                </if>
+                <!--返回的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    substr(p.deptid,1,6) institutionId,
+                </if>
+                <!--返回的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    substr(p.deptid,1,4) institutionId,
+                </if>
+                <!--返回的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    substr(p.deptid,1,2) institutionId,
+                </if>
+                <!--返回的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    substr(p.deptid,1,1) institutionId,
+                </if>
+            </if>
         </if>
         SUM( CASE feetype  WHEN '1'  THEN totalfee  ELSE 0  END )  AS sum_costs_premiums,
         SUM( CASE feetype  WHEN '1'  THEN paidfee  ELSE 0  END )  AS paid_costs_premiums,
@@ -819,30 +1060,154 @@
         SUM( CASE feetype  WHEN '2'  THEN paidfee  ELSE 0  END )  AS paid_retail_premiums,
         SUM( CASE feetype  WHEN '2'  THEN totalfee-paidfee  ELSE 0  END )  AS wait_pay_retail_premiums
         FROM report_payable_basedata  p WHERE 1=1
-        <choose>
-            <!--条件中团队不为空时,直接拼接团队-->
-            <when test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
-                and p.deptid = #{reportReqVo.teamCode}
-            </when>
-            <!--条件中团队为空时,使用机构模糊查询-->
-            <otherwise>
-                <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
-                    and p.deptid like #{reportReqVo.deptId}"%"
+        <!--下钻查询时拼接-->
+        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+            <!--按团队下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+                    and p.deptid = #{reportReqVo.teamCode}
                 </if>
-            </otherwise>
-        </choose>
-        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
-            and p.userId = #{reportReqVo.userId}
+            </if>
+            <!--按机构下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                <!--下钻的是五级机构时,下钻到团队-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    and p.deptid in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    and substr(p.deptid,1,11) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    and substr(p.deptid,1,8) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    and substr(p.deptid,1,6) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    and substr(p.deptid,1,4) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+                <!--下钻的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    and substr(p.deptid,1,2) in (SELECT id FROM `sys_dept`  WHERE parent_id= #{reportReqVo.deptId} )
+                </if>
+            </if>
+            <!--返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                <!--返回的是五级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    and substr(p.deptid,1,8)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    and substr(p.deptid,1,6)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    and substr(p.deptid,1,4)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    and substr(p.deptid,1,2)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    and substr(p.deptid,1,1)  = #{reportReqVo.deptId}
+                </if>
+                <!--返回的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    and substr(p.deptid,1,1)  = #{reportReqVo.deptId}
+                </if>
+            </if>
+        </if>
+        <!--非下钻查询时拼接-->
+        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '0'.toString()">
+            <choose>
+                <!--条件中团队不为空时,直接拼接团队-->
+                <when test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+                    and p.deptid = #{reportReqVo.teamCode}
+                </when>
+                <!--条件中团队为空时,使用机构模糊查询-->
+                <otherwise>
+                    <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
+                        and p.deptid like #{reportReqVo.deptId}"%"
+                    </if>
+                </otherwise>
+            </choose>
+            <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
+                and p.userid = #{reportReqVo.userId}
+            </if>
         </if>
+        <!--通用查询条件拼接-->
         <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
-            and p.inscompany = #{reportReqVo.insCompany}
+            and p.company_id = #{reportReqVo.insCompany}
         </if>
         <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
             and p.signdate  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
         </if>
-        group by deptid
-        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
-            ,userid
+        <!--下钻查询时拼接-->
+        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+            <!--按团队下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                group by p.`username`,p.userid order by p.`username`
+            </if>
+            <!--按机构下钻时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                <!--下钻的是五级机构时,下钻到团队-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    group by  p.deptid  order by p.deptid
+                </if>
+                <!--下钻的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    group by  substr(p.deptid,1,11) order by    substr(p.deptid,1,11)
+                </if>
+                <!--下钻的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    group by  substr(p.deptid,1,8) order by    substr(p.deptid,1,8)
+                </if>
+                <!--下钻的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    group by  substr(p.deptid,1,6) order by    substr(p.deptid,1,6)
+                </if>
+                <!--下钻的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    group by  substr(p.deptid,1,4) order by    substr(p.deptid,1,4)
+                </if>
+                <!--下钻的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    group by  substr(p.deptid,1,2) order by    substr(p.deptid,1,2)
+                </if>
+            </if>
+            <!--返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                <!--返回的是五级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
+                    group by substr(p.deptid,1,11)   order by substr(p.deptid,1,11)
+                </if>
+                <!--返回的是四级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
+                    group by substr(p.deptid,1,8)   order by substr(p.deptid,1,8)
+                </if>
+                <!--返回的是三级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
+                    group by substr(p.deptid,1,6)   order by substr(p.deptid,1,6)
+                </if>
+                <!--返回的是二级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
+                    group by substr(p.deptid,1,4)   order by substr(p.deptid,1,4)
+                </if>
+                <!--返回的是一级机构时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
+                    group by substr(p.deptid,1,2)   order by substr(p.deptid,1,2)
+                </if>
+                <!--返回的是总部时-->
+                <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
+                    group by substr(p.deptid,1,1)   order by substr(p.deptid,1,1)
+                </if>
+            </if>
         </if>
         ) as s
     </select>
@@ -893,38 +1258,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>

BIN
资金申请单模板.xlsx