Ver Fonte

Merge remote-tracking branch 'origin/master'

yumeng há 2 anos atrás
pai
commit
b347a2817d
13 ficheiros alterados com 1634 adições e 1668 exclusões
  1. 1059 1051
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java
  2. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyInfoMapper.java
  3. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml
  4. 2 7
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICreateSheetService.java
  5. 82 83
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CreateSheetServiceImpl.java
  6. 69 71
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyInfoServiceImpl.java
  7. 12 13
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java
  8. 29 51
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java
  9. 6 10
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/IntranetSettlementMapper.xml
  10. 187 218
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml
  11. 2 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml
  12. 182 158
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java
  13. 2 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java

Diff do ficheiro suprimidas por serem muito extensas
+ 1059 - 1051
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java


+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyInfoMapper.java

@@ -89,7 +89,7 @@ public interface CwjsPolicyInfoMapper extends BaseMapper<CwjsPolicyInfo> {
 
     List<JSONObject> getSettlementNoPictureAccountAgentList(@Param("productId") String productId,
                                                             @Param("projectId") String projectId,
-                                                            @Param("uploadYears") String uploadYears,
+                                                            @Param("endTime") String endTime,
                                                             @Param("accountIds") List<String> accountIds);
 
 

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml

@@ -523,7 +523,7 @@
             WHERE
                 c.del_flag = 0
               AND c.product_id = #{productId}
-              AND c.upload_years = #{uploadYears}
+              AND c.upload_years = DATE_FORMAT(#{endTime}, '%Y-%m')
             GROUP BY
                 c.account_id
         )

+ 2 - 7
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICreateSheetService.java

@@ -1,23 +1,18 @@
 package org.jeecg.ctop.finance.policy.service;
 
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.IService;
 import org.apache.poi.hssf.usermodel.HSSFCellStyle;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
 
 import java.util.List;
-import java.util.Map;
 
 /**
- *
  * @author jeecg-boot
  * 2021-07-27
  * @version V1.0
  */
 public interface ICreateSheetService {
 
-    void createBytedance(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList,String uploadYears);
+    void createBytedance(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList, String startTime, String endTime);
 
-    void createKuaiShou(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList,String uploadYears);
+    void createKuaiShou(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList, String startTime, String endTime);
 }

+ 82 - 83
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CreateSheetServiceImpl.java

@@ -1,32 +1,31 @@
 package org.jeecg.ctop.finance.policy.service.impl;
 
-import cn.com.ctop.common.module.mapper.SysUserMapper;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.jeecg.common.system.entity.SysUser;
-import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
-import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
 import org.jeecg.ctop.finance.policy.service.ICreateSheetService;
-import org.jeecg.ctop.finance.policy.service.ICwjsPolicyInfoService;
 import org.jeecg.ctop.finance.policy.utils.Check;
-import org.jeecg.ctop.finance.settlement.entity.vo.*;
+import org.jeecg.ctop.finance.settlement.entity.vo.SheetBytedanceVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.SheetKuaiShouVo;
 import org.jeecg.ctop.finance.settlement.mapper.ReportSettlementMapper;
 import org.jeecg.ctop.finance.utils.SettlementUtil;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
- *
  * @author jeecg-boot
  * 2021-07-27
  * @version V1.0
@@ -38,15 +37,15 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
     private ReportSettlementMapper reportSettlementMapper;
 
 
-    public void createBytedance(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList,String uploadYears){
-        DecimalFormat sf  = new DecimalFormat("#.####");//保留四位小数
+    public void createBytedance(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList, String startTime, String endTime) {
+        DecimalFormat sf = new DecimalFormat("#.####");//保留四位小数
         //2:创建sheet 设置sheet名称
         HSSFSheet sheet = wb.createSheet("汇总页");
         //3:添加 第一行单元格
         HSSFRow row0 = sheet.createRow(0);
         HSSFCell cell0 = row0.createCell(0);
         //设置 第一行 表头
-        cell0.setCellValue(uploadYears+"-头条结算单汇总");
+        cell0.setCellValue(startTime + "~" + endTime + "-头条结算单汇总");
         CellRangeAddress region = new CellRangeAddress(0, 0, 0, 10);
         sheet.addMergedRegion(region);//合并行
         cell0.setCellStyle(style);
@@ -118,21 +117,21 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
         sheet.autoSizeColumn(0, true);
         List<SheetBytedanceVo> resultList = new ArrayList<>(accountIdList.size());
         //获取当前年月的 第一天 和 最后一天
-        Map<String,String> timeMap = SettlementUtil.getFirstAndLastDayOfMonth(uploadYears);
+//        Map<String, String> timeMap = SettlementUtil.getFirstAndLastDayOfMonth(uploadYears);
         //查看账户数据
-        List<Map<String,Object>> list = reportSettlementMapper.getAccountTransactionDayBytedanceSheet(accountIdList,uploadYears);
-        for (Map<String,Object> map : list) {
+        List<Map<String, Object>> list = reportSettlementMapper.getAccountTransactionDayBytedanceSheet(accountIdList, startTime, endTime);
+        for (Map<String, Object> map : list) {
             SheetBytedanceVo voSource = new SheetBytedanceVo();
-            voSource.setAgentId(map.get("agentId")+"");
-            voSource.setAgentName(map.get("agentName")+"");
-            voSource.setAccountId(map.get("accountId")+"");
-            voSource.setAccountName(map.get("accountName")+"");
+            voSource.setAgentId(map.get("agentId") + "");
+            voSource.setAgentName(map.get("agentName") + "");
+            voSource.setAccountId(map.get("accountId") + "");
+            voSource.setAccountName(map.get("accountName") + "");
 
             //政策所有时间点
             List<String> policyDaysList = new ArrayList<>();
-            if (!Check.isNull(map.get("productName"))){
+            if (!Check.isNull(map.get("productName"))) {
                 //查询 头条利润表  返点类型和比列
-                List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName")+"",null,"1",timeMap.get("startTime"),timeMap.get("endTime"));
+                List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName") + "", map.get("productName") + "", null, "1", startTime, endTime);
                 List listPolicyTIme = new ArrayList();
                 for (Map<String, Object> rate : rateMap) {
                     listPolicyTIme.add(rate.get("policyStartDate"));
@@ -142,56 +141,56 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                 List<Object> times = SettlementUtil.sortlistTest(listPolicyTIme);
                 // 使用政策的时间段 拼接 开始 和 截至 时间
                 List<Map<String, String>> arrayList = new ArrayList<>();
-                for ( int i = 0; i < times.size(); i++) {
+                for (int i = 0; i < times.size(); i++) {
                     HashMap<String, String> mapTime = new HashMap<>();
                     mapTime.put("startDate", times.get(i).toString());
-                    mapTime.put("endDate",  times.size() < 2 ? times.get(i).toString() : times.get(i + 1).toString());
+                    mapTime.put("endDate", times.size() < 2 ? times.get(i).toString() : times.get(i + 1).toString());
                     i += 1;
                     arrayList.add(mapTime);
                 }
                 for (Map<String, String> stringMap : arrayList) {
                     SheetBytedanceVo vo = new SheetBytedanceVo();
                     //使用政策 返点类型和比例
-                    Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName")+"",map.get("productName")+"",null,"1",stringMap.get("startDate"),stringMap.get("endDate"));
-                    if (!Check.isNull(policyRateMap)){
-                        if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 0){
+                    Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName") + "", map.get("productName") + "", null, "1", stringMap.get("startDate"), stringMap.get("endDate"));
+                    if (!Check.isNull(policyRateMap)) {
+                        if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 0) {
                             vo.setRebateType("返现");//返点类型
-                        }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 1){
+                        } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 1) {
                             vo.setRebateType("返货");
-                        }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 2){
+                        } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 2) {
                             vo.setRebateType("返现+返货");
-                        }else if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 3){
+                        } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 3) {
                             vo.setRebateType("服务费");
                         }
-                        vo.setRebateRate(policyRateMap.getOrDefault("rebateRate","")+"%");//返点比列
-                    }else {
+                        vo.setRebateRate(policyRateMap.getOrDefault("rebateRate", "") + "%");//返点比列
+                    } else {
                         vo.setRebateType("");
                     }
                     // 时间段内 账户流水 信息
-                    List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(map.get("accountId")+"",stringMap.get("startDate"),stringMap.get("endDate"));
+                    List<Map<String, Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
                     listAccount.removeAll(Collections.singleton(null));
-                    vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost","")+"");//总消耗
-                    vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost","")+"");//现金消耗
-                    vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost","")+"");//赠款消耗
-                    vo.setBalance(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("balance","")+"");//日终结余
-                    vo.setFrozen(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("frozen","")+"");//冻结
-                    vo.setIncome(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("income","")+"");//总存入
-                    vo.setSharedWalletCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("sharedWalletCost","")+"");//共享钱包支出
-                    vo.setTransferIn(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferIn","")+"");//总转入
-                    vo.setTransferOut(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferOut","")+"");//总转出
-                    BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
-                    vo.setTime(stringMap.get("startDate")+"----"+stringMap.get("endDate"));
+                    vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost", "") + "");//总消耗
+                    vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost", "") + "");//现金消耗
+                    vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost", "") + "");//赠款消耗
+                    vo.setBalance(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("balance", "") + "");//日终结余
+                    vo.setFrozen(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("frozen", "") + "");//冻结
+                    vo.setIncome(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("income", "") + "");//总存入
+                    vo.setSharedWalletCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("sharedWalletCost", "") + "");//共享钱包支出
+                    vo.setTransferIn(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferIn", "") + "");//总转入
+                    vo.setTransferOut(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferOut", "") + "");//总转出
+                    BeanUtils.copyProperties(voSource, vo, SettlementUtil.getNullPropertyNames(voSource));
+                    vo.setTime(stringMap.get("startDate") + "----" + stringMap.get("endDate"));
                     resultList.add(vo);
-                    policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"),stringMap.get("endDate")));
+                    policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"), stringMap.get("endDate")));
                 }
 
             }
 
             //不使用政策 的时间段
             // 获取两个日期之间 所有的 时间 年-月-日
-            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(timeMap.get("startTime"),timeMap.get("endTime"));
+            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(startTime, endTime);
             // 时间差集(所有时间段 - 使用政策的时间段)
-            List<String>  reduceList = betweenDaysList.stream().filter(item -> !policyDaysList.contains(item)).collect(Collectors.toList());
+            List<String> reduceList = betweenDaysList.stream().filter(item -> !policyDaysList.contains(item)).collect(Collectors.toList());
             //差集拼接  开始 和 结束时间
             List<Map<String, String>> stringList = SettlementUtil.getTime(reduceList);
             for (Map<String, String> stringMap : stringList) {
@@ -201,19 +200,19 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                 vo.setRebateType("");//返点类型
                 vo.setRebateRate("");//返点比列
                 //账户流水 信息
-                List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(map.get("accountId")+"",stringMap.get("startDate"),stringMap.get("endDate"));
+                List<Map<String, Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
                 listAccount.removeAll(Collections.singleton(null));
-                vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost","")+"");//总消耗
-                vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost","")+"");//现金消耗
-                vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost","")+"");//赠款消耗
-                vo.setBalance(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("balance","")+"");//日终结余
-                vo.setFrozen(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("frozen","")+"");//冻结
-                vo.setIncome(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("income","")+"");//总存入
-                vo.setSharedWalletCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("sharedWalletCost","")+"");//共享钱包支出
-                vo.setTransferIn(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferIn","")+"");//总转入
-                vo.setTransferOut(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferOut","")+"");//总转出
-                BeanUtils.copyProperties(voSource,vo, SettlementUtil.getNullPropertyNames(voSource));
-                vo.setTime((!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate")+"----"+stringMap.get("endDate") : ""));
+                vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost", "") + "");//总消耗
+                vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost", "") + "");//现金消耗
+                vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost", "") + "");//赠款消耗
+                vo.setBalance(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("balance", "") + "");//日终结余
+                vo.setFrozen(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("frozen", "") + "");//冻结
+                vo.setIncome(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("income", "") + "");//总存入
+                vo.setSharedWalletCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("sharedWalletCost", "") + "");//共享钱包支出
+                vo.setTransferIn(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferIn", "") + "");//总转入
+                vo.setTransferOut(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferOut", "") + "");//总转出
+                BeanUtils.copyProperties(voSource, vo, SettlementUtil.getNullPropertyNames(voSource));
+                vo.setTime((!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate") + "----" + stringMap.get("endDate") : ""));
                 resultList.add(vo);
             }
         }
@@ -225,7 +224,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
             sheet.autoSizeColumn(0, true);
             sheet.autoSizeColumn(i + 1, true);
             //创建单元格并且添加数据
-            row.createCell(0).setCellValue(uploadYears);
+            row.createCell(0).setCellValue(startTime + "~" + endTime);
             row.createCell(1).setCellValue(vo.getAccountName());
             row.createCell(2).setCellValue(vo.getAccountId());
             row.createCell(3).setCellValue(vo.getAgentName());
@@ -241,20 +240,20 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
             row.createCell(13).setCellValue(vo.getRebateType());
             row.createCell(14).setCellValue(vo.getRebateRate());
             row.createCell(15).setCellValue(vo.getTime());
-           // row.setRowStyle(style);
+            // row.setRowStyle(style);
         }
     }
 
     @Override
-    public void createKuaiShou(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList, String uploadYears) {
-        DecimalFormat sf  = new DecimalFormat("#.####");//保留四位小数
+    public void createKuaiShou(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList, String startTime, String endTime) {
+        DecimalFormat sf = new DecimalFormat("#.####");//保留四位小数
         //2:创建sheet 设置sheet名称
         HSSFSheet sheet = wb.createSheet("汇总页");
         //3:添加 第一行单元格
         HSSFRow row0 = sheet.createRow(0);
         HSSFCell cell0 = row0.createCell(0);
         //设置 第一行 表头
-        cell0.setCellValue(uploadYears+"-快手结算单汇总");
+        cell0.setCellValue(startTime + "~" + endTime + "-快手结算单汇总");
         CellRangeAddress region = new CellRangeAddress(0, 0, 0, 10);
         sheet.addMergedRegion(region);//合并行
         cell0.setCellStyle(style);
@@ -340,19 +339,19 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
         List<SheetKuaiShouVo> resultList = new ArrayList<>(accountIdList.size());
         //查询该时段 快手 数据
         //获取当前年月的 第一天 和 最后一天
-        Map<String,String> timeMap = SettlementUtil.getFirstAndLastDayOfMonth(uploadYears);
-        List<Map<String,Object>> accountList = reportSettlementMapper.getProfitKuaiShouAccountCostSheet(accountIdList,timeMap.get("startTime"),timeMap.get("endTime"));
-        for (Map<String,Object> map : accountList) {
+//        Map<String,String> timeMap = SettlementUtil.getFirstAndLastDayOfMonth(uploadYears);
+        List<Map<String, Object>> accountList = reportSettlementMapper.getProfitKuaiShouAccountCostSheet(accountIdList, startTime, endTime);
+        for (Map<String, Object> map : accountList) {
             SheetKuaiShouVo voSource = new SheetKuaiShouVo();
-            voSource.setAccountId(map.get("accountId")+"");
-            voSource.setKsId(map.get("ksId")+"");
-            voSource.setAccountName(map.get("accountName")+"");
+            voSource.setAccountId(map.get("accountId") + "");
+            voSource.setKsId(map.get("ksId") + "");
+            voSource.setAccountName(map.get("accountName") + "");
 
             //政策所有时间点
             List<String> policyDaysList = new ArrayList<>();
             if (!Check.isNull(map.get("productName"))) {
                 //查询 快手利润表  返点类型和比列
-                List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName") + "", null,"2", timeMap.get("startTime"),timeMap.get("endTime"));
+                List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName") + "", map.get("productName") + "", null, "2", startTime, endTime);
                 List listPolicyTIme = new ArrayList();
                 for (Map<String, Object> rate : rateMap) {
                     listPolicyTIme.add(rate.get("policyStartDate"));
@@ -363,7 +362,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                 List<Object> times = SettlementUtil.sortlistTest(listPolicyTIme);
                 // 使用政策的时间段 拼接 开始 和 截至 时间
                 List<Map<String, String>> arrayList = new ArrayList<>();
-                if (!Check.isNull(times)){
+                if (!Check.isNull(times)) {
                     for (int i = 0; i < times.size(); i++) {
                         HashMap<String, String> mapTime = new HashMap<>();
                         mapTime.put("startDate", times.get(i).toString());
@@ -376,7 +375,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                 for (Map<String, String> stringMap : arrayList) {
                     SheetKuaiShouVo vo = new SheetKuaiShouVo();
                     //使用政策 返点类型和比例
-                    Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName")+"",map.get("productName") + "", null,"2",stringMap.get("startDate"), stringMap.get("endDate"));
+                    Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName") + "", map.get("productName") + "", null, "2", stringMap.get("startDate"), stringMap.get("endDate"));
                     if (!Check.isNull(policyRateMap)) {
                         if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 0) {
                             vo.setRebateType("返现");//返点类型
@@ -384,7 +383,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                             vo.setRebateType("返货");
                         } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 2) {
                             vo.setRebateType("返现+返货");
-                        }else if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 3){
+                        } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 3) {
                             vo.setRebateType("服务费");
                         }
                         vo.setRebateRate(policyRateMap.getOrDefault("rebateRate", "") + "%");//返点比列
@@ -393,7 +392,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                     }
 
                     // 时间段内 账户流水 信息
-                    List<SheetKuaiShouVo>  listInfo = reportSettlementMapper.getTransactionDayKuaiShouSheet(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
+                    List<SheetKuaiShouVo> listInfo = reportSettlementMapper.getTransactionDayKuaiShouSheet(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
 
                     listInfo.removeAll(Collections.singleton(null));
                     vo.setDailyCharge(listInfo.stream().filter(v -> !Check.isNull(v.getDailyCharge())).map(SheetKuaiShouVo::getDailyCharge).reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -404,7 +403,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                     vo.setDailyTransferIn(listInfo.stream().filter(v -> !Check.isNull(v.getDailyTransferIn())).map(SheetKuaiShouVo::getDailyTransferIn).reduce(BigDecimal.ZERO, BigDecimal::add));
                     vo.setDailyTransferOut(listInfo.stream().filter(v -> !Check.isNull(v.getDailyTransferOut())).map(SheetKuaiShouVo::getDailyTransferOut).reduce(BigDecimal.ZERO, BigDecimal::add));
                     //vo.setBalance(listInfo.stream().filter(v -> !Check.isNull(v.getBalance())).map(SheetKuaiShouVo::getBalance).reduce(BigDecimal.ZERO, BigDecimal::add));
-                    vo.setBalance(Check.isNull(listInfo) ? new BigDecimal(0) : listInfo.stream().filter(v ->!Check.isNull(v.getBalance())).min((u1,u2) -> u1.getBalance().compareTo(u2.getBalance())).get().getBalance());
+                    vo.setBalance(Check.isNull(listInfo) ? new BigDecimal(0) : listInfo.stream().filter(v -> !Check.isNull(v.getBalance())).min((u1, u2) -> u1.getBalance().compareTo(u2.getBalance())).get().getBalance());
                     vo.setRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getRealRecharged())).map(SheetKuaiShouVo::getRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
                     vo.setContractRebateRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getContractRebateRealRecharged())).map(SheetKuaiShouVo::getContractRebateRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
                     vo.setDirectRebateRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getDirectRebateRealRecharged())).map(SheetKuaiShouVo::getDirectRebateRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -417,7 +416,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
 
             //不使用政策 的时间段
             // 获取两个日期之间 所有的 时间 年-月-日
-            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(timeMap.get("startTime"),timeMap.get("endTime"));
+            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(startTime, endTime);
             // 时间差集(所有时间段 - 使用政策的时间段)
             List<String> reduceList = betweenDaysList.stream().filter(item -> !policyDaysList.contains(item)).collect(Collectors.toList());
             //差集拼接  开始 和 结束时间
@@ -429,7 +428,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                 vo.setRebateType("");//返点类型
                 vo.setRebateRate("");//返点比列
                 // 时间段内 账户流水 信息
-                List<SheetKuaiShouVo>  listInfo = reportSettlementMapper.getTransactionDayKuaiShouSheet(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
+                List<SheetKuaiShouVo> listInfo = reportSettlementMapper.getTransactionDayKuaiShouSheet(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
                 listInfo.removeAll(Collections.singleton(null));
                 vo.setDailyCharge(listInfo.stream().filter(v -> !Check.isNull(v.getDailyCharge())).map(SheetKuaiShouVo::getDailyCharge).reduce(BigDecimal.ZERO, BigDecimal::add));
                 vo.setFlowDailyCharge(listInfo.stream().filter(v -> !Check.isNull(v.getFlowDailyCharge())).map(SheetKuaiShouVo::getFlowDailyCharge).reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -439,7 +438,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
                 vo.setDailyTransferIn(listInfo.stream().filter(v -> !Check.isNull(v.getDailyTransferIn())).map(SheetKuaiShouVo::getDailyTransferIn).reduce(BigDecimal.ZERO, BigDecimal::add));
                 vo.setDailyTransferOut(listInfo.stream().filter(v -> !Check.isNull(v.getDailyTransferOut())).map(SheetKuaiShouVo::getDailyTransferOut).reduce(BigDecimal.ZERO, BigDecimal::add));
                 //vo.setBalance(listInfo.stream().filter(v -> !Check.isNull(v.getBalance())).map(SheetKuaiShouVo::getBalance).reduce(BigDecimal.ZERO, BigDecimal::add));
-                vo.setBalance(Check.isNull(listInfo) ? new BigDecimal(0) : listInfo.stream().filter(v ->!Check.isNull(v.getBalance())).min((u1,u2) -> u1.getBalance().compareTo(u2.getBalance())).get().getBalance());
+                vo.setBalance(Check.isNull(listInfo) ? new BigDecimal(0) : listInfo.stream().filter(v -> !Check.isNull(v.getBalance())).min((u1, u2) -> u1.getBalance().compareTo(u2.getBalance())).get().getBalance());
                 vo.setRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getRealRecharged())).map(SheetKuaiShouVo::getRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
                 vo.setContractRebateRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getContractRebateRealRecharged())).map(SheetKuaiShouVo::getContractRebateRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
                 vo.setDirectRebateRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getDirectRebateRealRecharged())).map(SheetKuaiShouVo::getDirectRebateRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -456,7 +455,7 @@ public class CreateSheetServiceImpl implements ICreateSheetService {
             sheet.autoSizeColumn(0, true);
             sheet.autoSizeColumn(i + 1, true);
             //创建单元格并且添加数据
-            row.createCell(0).setCellValue(uploadYears);
+            row.createCell(0).setCellValue(startTime + "~" + endTime);
             row.createCell(1).setCellValue(vo.getKsId());
             row.createCell(2).setCellValue(vo.getAccountId());
             row.createCell(3).setCellValue(vo.getAccountName());

+ 69 - 71
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyInfoServiceImpl.java

@@ -1,18 +1,16 @@
 package org.jeecg.ctop.finance.policy.service.impl;
 
-import android.widget.RelativeLayout;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
-import cn.com.ctop.common.module.mapper.ProductMapper;
 import cn.com.ctop.common.module.mapper.SysUserMapper;
 import cn.com.ctop.common.module.service.ISysUserService;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.entity.SysUser;
-import org.jeecg.common.util.DateUtils;
 import org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog;
 import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
 import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
@@ -26,13 +24,17 @@ import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import javax.annotation.Resource;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * 政策信息表
+ *
  * @author jeecg-boot
  * 2021-07-27
  * @version V1.0
@@ -59,23 +61,21 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     private CwjsProfitMapper cwjsProfitMapper;
 
     /**
-     *
-     * @description: 查看政策列表
-     *  已通过的政策 按照 产品名称 拆分多条
-     *
      * @param policyInfo
+     * @description: 查看政策列表
+     * 已通过的政策 按照 产品名称 拆分多条
      * @return: java.util.List<org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo>
      * @author: zianY
      * @time: 2022/3/29
      */
     @Override
-    public List<CwjsPolicyInfo> queryPageList(CwjsPolicyInfo policyInfo){
+    public List<CwjsPolicyInfo> queryPageList(CwjsPolicyInfo policyInfo) {
 
         List<CwjsPolicyInfo> policyInfoList = policyInfoMapper.selectPolicyInfos(policyInfo);
         List<CwjsPolicyInfo> result = new ArrayList<>();
         //1.过滤所有已通过审核的政策到结果表中
-        policyInfoList.forEach(policy->{
-            if(policy.getApprovedStatus() == 3){
+        policyInfoList.forEach(policy -> {
+            if (policy.getApprovedStatus() == 3) {
                 JSONArray policyProductName = new JSONArray();
                 policyProductName.add(policy.getProductName());
                 policy.setPolicyProductName(policyProductName);
@@ -83,47 +83,48 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
             }
         });
         policyInfoList.removeAll(result);
-        Map<Integer,CwjsPolicyInfo> map = new HashMap<>();
+        Map<Integer, CwjsPolicyInfo> map = new HashMap<>();
         //2.未通过审核的政策需要通过政策id来进行聚合,把产品名称放到同一个列表里
-        policyInfoList.forEach(policy->{
-            if(map.containsKey(policy.getId())){
+        policyInfoList.forEach(policy -> {
+            if (map.containsKey(policy.getId())) {
                 map.get(policy.getId()).getPolicyProductName().add(policy.getProductName());
-            }else{
+            } else {
                 JSONArray policyProductName = new JSONArray();
                 policyProductName.add(policy.getProductName());
                 policy.setPolicyProductName(policyProductName);
-                map.put(policy.getId(),policy);
+                map.put(policy.getId(), policy);
             }
         });
         //3.遍历聚合完成后的map,每一个key对应一条不通过的政策的数据,放入到结果集返回
         Set<Integer> keys = map.keySet();
-        for(Integer key : keys){
+        for (Integer key : keys) {
             result.add(map.get(key));
         }
         return result;
     }
 
     @Override
-    public List<JSONObject> getAllSale(){
+    public List<JSONObject> getAllSale() {
         return policyInfoMapper.getAllSale();
     }
 
     @Override
-    public List<JSONObject> getAllSaleAndMeidaManager(){
+    public List<JSONObject> getAllSaleAndMeidaManager() {
         return policyInfoMapper.getAllSaleAndMeidaManager();
     }
 
     /**
      * 查询 所有 运营
+     *
      * @return
      */
     @Override
-    public List<Map<String,Object>> getAllOperationUser(){
+    public List<Map<String, Object>> getAllOperationUser() {
         return policyInfoMapper.getAllOperationUser();
     }
 
     @Override
-    public List<JSONObject> getAllSaleByUserId(String userId){
+    public List<JSONObject> getAllSaleByUserId(String userId) {
         return policyInfoMapper.getAllSaleByUserId(userId);
     }
 
@@ -132,14 +133,14 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     private SysUserMapper userMapper;
 
     @Override
-    public List<JSONObject> getAllSubordinate2(String userId){
+    public List<JSONObject> getAllSubordinate2(String userId) {
         List<SysUser> allList = userMapper.selectAllUser();
         List<SysUser> mulUserList = treeCategoryData(allList, userId);
         List<JSONObject> users = new ArrayList<>();
         mulUserList.forEach(mulUser -> {
             JSONObject jo = new JSONObject();
-            jo.put("userId",mulUser.getId());
-            jo.put("userName",mulUser.getRealname());
+            jo.put("userId", mulUser.getId());
+            jo.put("userName", mulUser.getRealname());
             users.add(jo);
         });
         return users;
@@ -147,7 +148,7 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
 
 
     @Override
-    public List<String> getAllSubordinate(String userId){
+    public List<String> getAllSubordinate(String userId) {
         List<SysUser> allList = userMapper.selectAllUser();
         List<SysUser> mulUserList = treeCategoryData(allList, userId);
         List<String> userIds = new ArrayList<>();
@@ -155,12 +156,13 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
         mulUserList.forEach(mulUser -> userIds.add(mulUser.getId()));
         return userIds;
     }
+
     public List<SysUser> treeCategoryData(List<SysUser> allList, String leaderId) {
         List<SysUser> mapList = new ArrayList<>();
         for (SysUser vo : allList) {
-            if (leaderId.equals(vo.getLeaderId())){
+            if (leaderId.equals(vo.getLeaderId())) {
                 mapList.add(vo);
-                mapList.addAll(treeCategoryData(allList,vo.getId()));
+                mapList.addAll(treeCategoryData(allList, vo.getId()));
             }
         }
         return mapList;
@@ -168,7 +170,7 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     }
 
     @Override
-    public boolean isExistCwjsPolicyInfo(CwjsPolicyInfo policyInfo){
+    public boolean isExistCwjsPolicyInfo(CwjsPolicyInfo policyInfo) {
         CwjsPolicyInfo cwjsPolicyInfoEntity = new CwjsPolicyInfo();
         cwjsPolicyInfoEntity.setAdvertiserName(policyInfo.getAdvertiserName());
         cwjsPolicyInfoEntity.setProductName(policyInfo.getProductName());
@@ -177,30 +179,29 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
         cwjsPolicyInfoEntity.setPolicyStartDate(policyInfo.getPolicyStartDate());
         cwjsPolicyInfoEntity.setPolicyEndDate(policyInfo.getPolicyEndDate());
         List<CwjsPolicyInfo> cwjsPolicyInfos = policyInfoMapper.selectPolicyInfos(policyInfo);
-        if(Check.isNull(cwjsPolicyInfos)){
+        if (Check.isNull(cwjsPolicyInfos)) {
             return false;
-        }else {
+        } else {
             return true;
         }
     }
 
     @Override
-    public void updatePolicyInfoById(CwjsPolicyInfo policyInfo){
+    public void updatePolicyInfoById(CwjsPolicyInfo policyInfo) {
         policyInfoMapper.updatePolicyInfoById(policyInfo);
     }
 
 
-
     @Override
     public void automaticConveyBossExamine(CwjsPolicyInfo cwjsPolicyInfo) {
         cwjsPolicyInfo.setApprovedStatus(2);
-        cwjsPolicyInfo.setApprovedProgress("4aba62011120ac565c7f2b9f8f4aa96b");	//设置 boss 为审核人员
+        cwjsPolicyInfo.setApprovedProgress("4aba62011120ac565c7f2b9f8f4aa96b");    //设置 boss 为审核人员
         JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("4aba62011120ac565c7f2b9f8f4aa96b");
         StringBuilder text = new StringBuilder();
         text.append("您有一条销售政策需要审核,该客户为:");
         text.append(cwjsPolicyInfo.getCompanyName());
         text.append(",请及时登录助手平台-销售政策页面进行审核,谢谢!");
-        corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
+        corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId, text.toString());
         CwjsPolicyApprovalLog policyApprovalLog = new CwjsPolicyApprovalLog();
         policyApprovalLog.setPolicyId(cwjsPolicyInfo.getId());
         policyApprovalLog.setCreateUserId(cwjsPolicyInfo.getLoginUserId());
@@ -212,6 +213,7 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
 
     /**
      * 查询 政策审核记录
+     *
      * @param policyId
      * @return
      */
@@ -220,12 +222,12 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
         List<JSONObject> policyApprovalList = policyInfoMapper.getPolicyApprovalLogByPolicyId(policyId);
         //不显示审核意见
         for (JSONObject object : policyApprovalList) {
-            if (object.getString("approvalContent").length() > 4){
-                object.put("approvalContent","审核"+(object.getString("approvalStatus").equals("0") ? "成功" : "失败"));
+            if (object.getString("approvalContent").length() > 4) {
+                object.put("approvalContent", "审核" + (object.getString("approvalStatus").equals("0") ? "成功" : "失败"));
             }
         }
 
-        return Result.successMsg("政策审核记录查询成功",policyApprovalList);
+        return Result.successMsg("政策审核记录查询成功", policyApprovalList);
     }
 
     @Override
@@ -240,28 +242,28 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     }
 
 
-
     /**
      * 政策作废
-     * @param policyId 政策id
+     *
+     * @param policyId  政策id
      * @param delReason 作废原因
      * @return
      */
     @Override
-    public Result toVoidpolicy(String policyId,String delReason) {
+    public Result toVoidpolicy(String policyId, String delReason) {
         CwjsPolicyInfo cwjsPolicyInfo = policyInfoMapper.selectById(policyId);
         // 1:待审核 2:审核中 3:审核通过4:审核拒绝
-        if (Check.isNull(cwjsPolicyInfo) || cwjsPolicyInfo.getApprovedStatus() !=3){
+        if (Check.isNull(cwjsPolicyInfo) || cwjsPolicyInfo.getApprovedStatus() != 3) {
             return Result.errorMsg("政策不存在或政策还在审核,审核中的政策无法作废。");
         }
         //修改政策状态及作废原因
-        policyInfoMapper.updatePolicyToVOidById(policyId,delReason);
+        policyInfoMapper.updatePolicyToVOidById(policyId, delReason);
         //删除政策关联的产品信息
         //cwjsPolicyProductMapper.deleteProductsByPolicyId(Integer.valueOf(policyId));
         //删除该政策利润表记录
         cwjsProfitMapper.delSlettmentReportByPolicyId(policyId);
 
-        JSONObject examineUser = policyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getCreateUserId(),"分公司总经理");
+        JSONObject examineUser = policyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getCreateUserId(), "分公司总经理");
         List<String> userList = new ArrayList<>();
         userList.add(examineUser.getString("leaderId"));
         userList.add(examineUser.getString("directorId"));
@@ -270,12 +272,12 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
             //给销售总监发送
             JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId(userId);
             StringBuilder text = new StringBuilder();
-            text.append(cwjsPolicyInfo.getCreateUserName()+"创建的政策,客户为:"+cwjsPolicyInfo.getCompanyName());
+            text.append(cwjsPolicyInfo.getCreateUserName() + "创建的政策,客户为:" + cwjsPolicyInfo.getCompanyName());
             text.append(",该销售政策已作废。");
-            corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
+            corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId, text.toString());
         }
 
-        return Result.successMsg("政策作废成功",null);
+        return Result.successMsg("政策作废成功", null);
     }
 
     @Autowired
@@ -287,33 +289,29 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     @Resource
     private ReportSettlementMapper reportSettlementMapper;
 
-   @Override
+    @Override
     public Result getSettlementNoPictureAccountList(SettlementFileParamsVo paramsVo) {
-       SysUser user = userService.getById(paramsVo.getUserId());
-       //查询账户数量
-       List<String>accountIds = reportSettlementService.getAccountId(paramsVo,user);
-
-       if (Check.isNull(accountIds)){
-           return Result.errorMsg("未上传结算单账户列表查询为空。");
-       }
-
-
-       //过滤消耗为0 的账户 1-头条 2-快手
-       if (paramsVo.getMediaId().equals(1)){
-           accountIds = reportSettlementMapper.getAccountIdBytedanceRepeat(accountIds,paramsVo.getUploadYears());
-       }else if (paramsVo.getMediaId().equals(2)){
-           accountIds = reportSettlementMapper.getAccountIdKuaiShouRepeat(accountIds,paramsVo.getUploadYears());
-       }
-
-       //过滤以上传的账户
-       //List<JSONObject> list = policyInfoMapper.getSettlementNoPictureAccountList(productId,projectId,uploadYears,mediaIds);
+        SysUser user = userService.getById(paramsVo.getUserId());
+        //查询账户数量
+        List<String> accountIds = reportSettlementService.getAccountId(paramsVo, user);
 
+        if (Check.isNull(accountIds)) {
+            return Result.errorMsg("未上传结算单账户列表查询为空。");
+        }
+        //过滤消耗为0 的账户 1-头条 2-快手
+        if (paramsVo.getMediaId().equals(1)) {
+            accountIds = reportSettlementMapper.getAccountIdBytedanceRepeat(accountIds, paramsVo.getStartTime(), paramsVo.getEndTime());
+        } else if (paramsVo.getMediaId().equals(2)) {
+            accountIds = reportSettlementMapper.getAccountIdKuaiShouRepeat(accountIds, paramsVo.getStartTime(), paramsVo.getEndTime());
+        }
+        //过滤以上传的账户
+        //List<JSONObject> list = policyInfoMapper.getSettlementNoPictureAccountList(productId,projectId,uploadYears,mediaIds);
 
 
-       PageHelper.startPage(paramsVo.getPageNo(), paramsVo.getPageSize());
-       List<JSONObject> list = policyInfoMapper.getSettlementNoPictureAccountAgentList(paramsVo.getProductId(),paramsVo.getProjectId(),paramsVo.getUploadYears(),accountIds);
-       PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
-       return Result.successMsg("未上传结算单账户查询成功。",pageInfo);
+        PageHelper.startPage(paramsVo.getPageNo(), paramsVo.getPageSize());
+        List<JSONObject> list = policyInfoMapper.getSettlementNoPictureAccountAgentList(paramsVo.getProductId(), paramsVo.getProjectId(), paramsVo.getEndTime(), accountIds);
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
+        return Result.successMsg("未上传结算单账户查询成功。", pageInfo);
     }
 
     @Override

+ 12 - 13
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java

@@ -36,13 +36,13 @@ public class ExportReportController {
     //结算单-日期修改-master
     @ApiOperation(value = "财务结算-结算单导出-头条", notes = "财务结算-结算单导出-头条")
     @GetMapping(value = "/settlementReportBytedance")
-    public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) throws Exception{
+    public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) throws Exception {
         SysUser user = userService.getById(paramsVo.getUserId());
-        String date = paramsVo.getUploadYears();
-        if(null == date||date.equals("")){
-            paramsVo.setUploadYears(DateUtils.formatDate(new Date(),"yyyy-MM"));
+        String date = paramsVo.getStartTime();
+        if (null == date || date.equals("")) {
+            return Result.errorMsg("请选择日期");
         }
-        return reportSettlementService.settlementReportBytedance(paramsVo,response,user);
+        return reportSettlementService.settlementReportBytedance(paramsVo, response, user);
     }
 
 
@@ -50,26 +50,25 @@ public class ExportReportController {
     @GetMapping(value = "/settlementReportKuaiShou")
     public Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
         SysUser user = userService.getById(paramsVo.getUserId());
-        String date = paramsVo.getUploadYears();
-        if(null == date||date.equals("")){
-            paramsVo.setUploadYears(DateUtils.formatDate(new Date(),"yyyy-MM"));
+        String date = paramsVo.getStartTime();
+        if (null == date || date.equals("")) {
+            return Result.errorMsg("请选择日期");
         }
-        return reportSettlementService.settlementReportKuaiShou(paramsVo,response,user);
+        return reportSettlementService.settlementReportKuaiShou(paramsVo, response, user);
     }
 
 
-
     @ApiOperation(value = "财务结算-利润表导出-头条", notes = "财务结算-利润表导出-头条")
     @GetMapping(value = "/porfitReportBytedance")
     public Result porfitReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-        return reportSettlementService.porfitReportBytedance(paramsVo,response);
+        return reportSettlementService.porfitReportBytedance(paramsVo, response);
     }
 
 
     @ApiOperation(value = "财务结算-利润表导出-快手", notes = "财务结算-利润表导出-快手")
     @GetMapping(value = "/porfitReportKuaiShou")
     public Result porfitReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-        return reportSettlementService.porfitReportKuaiShou(paramsVo,response);
+        return reportSettlementService.porfitReportKuaiShou(paramsVo, response);
     }
 
 
@@ -81,7 +80,7 @@ public class ExportReportController {
 
     @ApiOperation(value = "财务结算-给运营发送消息-demo", notes = "财务结算-给运营发送消息-demo")
     @GetMapping(value = "/sendMessageToOperateDemo")
-    public Result sendMessageToOperateDemo(@RequestParam(value = "userId",required = false) String userId) {
+    public Result sendMessageToOperateDemo(@RequestParam(value = "userId", required = false) String userId) {
         return reportSettlementService.sendMessageToOperateDemo(userId);
 
     }

+ 29 - 51
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -1,6 +1,6 @@
 package org.jeecg.ctop.finance.settlement.mapper;
 
-import io.lettuce.core.dynamic.annotation.Param;
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo;
@@ -12,9 +12,7 @@ import java.util.Set;
 
 
 /**
- *
  * @description:
- *
  * @return:
  * @author: zianY
  * @time: 2021/7/28 17:07
@@ -22,106 +20,86 @@ import java.util.Set;
 public interface ReportSettlementMapper {
 
     /**
-     *获取头条 账户 日流水信息 根据账户id 和 年月 查询数据
-     * @param
-     * @return
+     * 获取头条 账户 日流水信息 根据账户id 和 年月 查询数据
      */
     List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance(SettlementFileParamsVo paramsVo);
 
-    List<Map<String,Object>> getAccountTransactionDayBytedanceSheet(@Param("accountIds") List<String> accountIds,@Param("uploadYears")String uploadYears);
-
-
-
-
+    List<Map<String, Object>> getAccountTransactionDayBytedanceSheet(@Param("accountIds") List<String> accountIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
     /**
      * 获取快手 账户 日流水信息 根据账户id 和 年月 查询数据
-     * @param paramsVo
-     * @return
      */
     List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShou(SettlementFileParamsVo paramsVo);
+
     //获取快手 账户 日流水信息  代理商维度
     List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShouAgent(SettlementFileParamsVo paramsVo);
+
     // 获取快手 结算单 账户 和 代理商 维度
     List<SettlementReportKuaiShouVo> getTransactionDayKuaiShouAgentAndAccount(SettlementFileParamsVo paramsVo);
 
-    List<SheetKuaiShouVo> getTransactionDayKuaiShouSheet(@Param("accountId")String accountId, @Param("startTime")String startTime , @Param("endTime")String endTime);
-
+    List<SheetKuaiShouVo> getTransactionDayKuaiShouSheet(@Param("accountId") String accountId, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
 
     /**
      * 查询 账户id
-     * @return
      */
-   List<String> getAccountIdBytedance(@Param("sales") Set<String> sales, @Param("mediaId")String mediaId, @Param("advertiserId")String advertiserId, @Param("productId")String productId,@Param("projectId")String projectId);
-   List<String> getAccountIdBytedanceRepeat(@Param("accountIds") List<String> accountIds,@Param("uploadYears")String uploadYears);
-   List<String> getAccountIdKuaiShouRepeat(@Param("accountIds") List<String> accountIds,@Param("uploadYears")String uploadYears);
+    List<String> getAccountIdBytedance(@Param("sales") Set<String> sales, @Param("mediaId") String mediaId, @Param("advertiserId") String advertiserId, @Param("productId") String productId, @Param("projectId") String projectId);
+
+    List<String> getAccountIdBytedanceRepeat(@Param("accountIds") List<String> accountIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    List<String> getAccountIdKuaiShouRepeat(@Param("accountIds") List<String> accountIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
     /**
      * 查询 头条 账户 图片
-     * @param accountId
-     * @return
      */
-   List<String> getAccountImagesBytedance(@Param("accountId") String accountId,@Param("uploadYears")String uploadYears);
+    List<String> getAccountImagesBytedance(@Param("accountId") String accountId, @Param("time") String time);
 
 
     /**
      * 查询 头条利润表 总花费
-     * @return
      */
-    List<Map<String,Object>> getProfitBytedanceAccount(@Param("startTime") String startTime,@Param("endTime") String endTime);
-    Map<String,Object> getProfitBytedanceAccountCost(@Param("accountId") String accountId,@Param("startTime") String startTime,@Param("endTime") String endTime);
+    List<Map<String, Object>> getProfitBytedanceAccount(@Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    Map<String, Object> getProfitBytedanceAccountCost(@Param("accountId") String accountId, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
-    List<Map<String,Object>> getProfitBytedanceCost(@Param("accountId") String accountId,@Param("startTime") String startTime,@Param("endTime") String endTime);
+    List<Map<String, Object>> getProfitBytedanceCost(@Param("accountId") String accountId, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
     /**
      * 查询 快手 利润表 所有账户
-     * @param
-     * @return
      */
-    List<Map<String,Object>> getProfitKuaiShouAgentAccount(@Param("startTime")String startTime ,@Param("endTime")String endTime);
-    Map<String,Object> getProfitKuaiShouAccountCost(@Param("accountId")String accountId,@Param("startTime")String startTime ,@Param("endTime")String endTime);
-    List<Map<String,Object>> getProfitKuaiShouAccountCostSheet(@Param("accountIds")List<String> accountIds,@Param("startTime")String startTime ,@Param("endTime")String endTime);
-    //快手 利润表 账户 时间段内的数据信息
-    List<Map<String,Object>> getProfitKuaiShouCost(@Param("accountId")String accountId,@Param("startTime")String startTime ,@Param("endTime")String endTime);
+    List<Map<String, Object>> getProfitKuaiShouAgentAccount(@Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    Map<String, Object> getProfitKuaiShouAccountCost(@Param("accountId") String accountId, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
+    List<Map<String, Object>> getProfitKuaiShouAccountCostSheet(@Param("accountIds") List<String> accountIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
+    //快手 利润表 账户 时间段内的数据信息
+    List<Map<String, Object>> getProfitKuaiShouCost(@Param("accountId") String accountId, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
 
     /**
      * 查询 头条利润表  返点类型和比列
-     * @param
-     * @return
      */
-    List<Map<String,Object>> getProfitBytedance(@Param("advertiserName") String advertiserName,@Param("productName") String productName,@Param("saleId") String saleId,@Param("mediaType") String mediaType,@Param("startTime")String startTime,@Param("endTime")String endTime);
-
-    Map<String,Object> getProfitRebate(@Param("advertiserName") String advertiserName,@Param("productName") String productName,@Param("saleId") String saleId,@Param("mediaType") String mediaType,@Param("startTime")String startTime,@Param("endTime")String endTime);
-
-    Map<String,Object> getProfitReportSale(String accountId);
-
-    Map<String,Object> getProfitBytedanceOperate(String accountId);
-
-    Map<String,Object> getProfitReportOperateAndArea(String accountId);
-
+    List<Map<String, Object>> getProfitBytedance(@Param("advertiserName") String advertiserName, @Param("productName") String productName, @Param("saleId") String saleId, @Param("mediaType") String mediaType, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
+    Map<String, Object> getProfitRebate(@Param("advertiserName") String advertiserName, @Param("productName") String productName, @Param("saleId") String saleId, @Param("mediaType") String mediaType, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
+    Map<String, Object> getProfitReportSale(String accountId);
 
+    Map<String, Object> getProfitBytedanceOperate(String accountId);
 
+    Map<String, Object> getProfitReportOperateAndArea(String accountId);
 
 
     /**
      * 查询 所有已绑定用户的运营人员id
-     * @return
      */
-    List<Map<String,Object>> getAccountOperateUserId();
+    List<Map<String, Object>> getAccountOperateUserId();
 
     /**
      * 查询运营人员 绑定的账户 以及产品
-     * @return
      */
-    List<Map<String,Object>> getAccountAndProductByOperate(String userId);
-
-
+    List<Map<String, Object>> getAccountAndProductByOperate(String userId);
 
 
 }

+ 6 - 10
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/IntranetSettlementMapper.xml

@@ -31,11 +31,11 @@
                           and account_id = #{accountId}
                     ) t
                 WHERE
-                    DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
+                    t.date >= DATE_FORMAT( #{startTime}, '%Y%m%d' )
+                    and t.date &lt;= DATE_FORMAT(#{endTime}, '%Y%m%d' )
                 ORDER BY
                     t.date
-                    LIMIT 31
-            ) a
+             ) a
                 LEFT JOIN (
                 SELECT
                     t.*,
@@ -61,16 +61,12 @@
                         LEFT JOIN `jeecg-boot`.ctop_user_allocation c ON t.accountIdF = c.account_id
                         LEFT JOIN `jeecg-boot`.ctop_kuaishou_advertiser_base_info base ON base.account_id = t.accountIdF
                 WHERE
-                    DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
+                    DATE_FORMAT( t.date, '%Y-%m-%d' ) >= #{startTime}
+                    AND DATE_FORMAT( t.date, '%Y-%m-%d' ) &lt;= #{endTime}
                 ORDER BY
                     date
-                    LIMIT 31
-            ) b ON a.accountId = b.accountIdF
+             ) b ON a.accountId = b.accountIdF
                 AND a.date = b.date
-            LIMIT 31
-
     </select>
-
-
 </mapper>
 

+ 187 - 218
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml

@@ -5,35 +5,42 @@
     <!-- 获取头条 账户 日流水信息 -->
     <select id="getAccountTransactionDayBytedance"
             resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo">
-        select t.*,c.auth_name as accountName from (select id,
-        advertiser_id,
-        date,DATE_FORMAT(date,'%Y-%m') as uploadYears,
-        balance,cash_cost,cost,frozen,income,reward_cost,shared_wallet_cost,transfer_in,transfer_out,create_time,
-        (
-        SELECT
-        DISTINCT ag.agent_id
-        from
-        ctop_cwjs_agent_info ag
-        LEFT JOIN ctop_agent_account ac on ag.agent_id = ac.agent_id
-        where ag.`status` = 0
-        and ag.enabled = 0
-        and ac.account_id = #{accountId} limit 1) as agentId,
-        (
-        SELECT
-        DISTINCT ag.name
-        from
-        ctop_cwjs_agent_info ag
-        LEFT JOIN ctop_agent_account ac on ag.agent_id = ac.agent_id
-        where ag.`status` = 0
-        and ag.enabled = 0
-        and ac.account_id = #{accountId} limit 1) as agentName
-         from
-        ctop_account_transaction_day
-        where cost >0
-        and advertiser_id = #{accountId}
-            )t
-      LEFT JOIN ctop_user_allocation c on t.advertiser_id = c.account_id
-        where uploadYears = #{uploadYears}
+        select t.*, c.auth_name as accountName
+        from (
+                 select id,
+                        advertiser_id,
+                     date,
+                     DATE_FORMAT(date, '%Y-%m') as uploadYears,
+                     balance, cash_cost, cost, frozen, income, reward_cost, shared_wallet_cost, transfer_in, transfer_out, create_time,
+                     (
+                     SELECT
+                     DISTINCT ag.agent_id
+                     from
+                     ctop_cwjs_agent_info ag
+                     LEFT JOIN ctop_agent_account ac on ag.agent_id = ac.agent_id
+                     where ag.`status` = 0
+                     and ag.enabled = 0
+                     and ac.account_id =
+                        #{accountId} limit 1) as agentId,
+                     (
+                     SELECT
+                     DISTINCT ag.name
+                     from
+                     ctop_cwjs_agent_info ag
+                     LEFT JOIN ctop_agent_account ac on ag.agent_id = ac.agent_id
+                     where ag.`status` = 0
+                     and ag.enabled = 0
+                     and ac.account_id =
+                        #{accountId} limit 1) as agentName
+                 from
+                     ctop_account_transaction_day
+                 where cost
+                     >0
+                   and advertiser_id = #{accountId}
+             ) t
+                 LEFT JOIN ctop_user_allocation c on t.advertiser_id = c.account_id
+        where date >= #{startTime}
+          AND date &lt;= #{endTime}
         ORDER BY date
     </select>
     <!-- 获取头条 账户 日流水信息 汇总页数据 -->
@@ -59,8 +66,6 @@
         productId,
         (SELECT pd.product_name from ctop_project pr, ctop_product pd WHERE ua.project_id = pr.id and pr.product_id =
         pd.id) productName
-
-
         FROM
         ctop_account_transaction_day t
         LEFT JOIN (SELECT DISTINCT account_id,agent_id from ctop_agent_account where 1 = 1
@@ -76,7 +81,8 @@
         LEFT JOIN ctop_user_allocation ua on ua.account_id = t.advertiser_id
         WHERE
         t.cost > 0
-        AND DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
+        AND t.date >= #{startTime}
+        AND t.date &lt;= #{endTime}
         <if test='accountIds != null and accountIds.size() > 0'>
             AND t.advertiser_id in
             <foreach collection="accountIds" item="item" separator=","
@@ -128,8 +134,9 @@
         ctop_account_transaction_day
         WHERE
         cost > 0
-        <if test="uploadYears !=null and uploadYears != ''">
-            AND DATE_FORMAT( date, '%Y-%m' ) = #{uploadYears}
+        <if test="endTime !=null and startTime != ''">
+            AND date >= #{startTime}
+            AND date &lt;= #{endTime}
         </if>
         <if test='accountIds !=null and accountIds.size() >0'>
             AND advertiser_id in
@@ -150,8 +157,9 @@
         ctop_kuaishou_daily_agent
         WHERE
         total_charged_in_yuan > 0
-        <if test="uploadYears !=null and uploadYears != ''">
-            AND DATE_FORMAT( date_time, '%Y-%m' ) = #{uploadYears}
+        <if test="endTime !=null and startTime != ''">
+            AND date_time >= #{startTime}
+            AND date_time &lt;= #{endTime}
         </if>
         <if test='accountIds != null and accountIds.size() > 0'>
             AND account_id in
@@ -167,32 +175,32 @@
 
     <!-- 查询 头条 账户 图片-->
     <select id="getAccountImagesBytedance" resultType="java.lang.String">
-        SELECT
-        file_url as fileUrl
-        FROM
-        ctop_cwjs_settlement_file_info
+        SELECT file_url as fileUrl
+        FROM ctop_cwjs_settlement_file_info
         where del_flag = 0
-        AND account_id = #{accountId}
-        AND upload_years = #{uploadYears}
+          AND account_id = #{accountId}
+          AND upload_years = DATE_FORMAT(#{time}, '%Y-%m')
     </select>
 
     <!-- 获取快手 账户 日流水信息  账户维度-->
     <select id="getAccountTransactionDayKuaiShou"
             resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
-        select t.*,c.auth_name as accountName,
-               base.user_id as ksId from (select id,
-                                                           advertiser_id,
-                                                        date,DATE_FORMAT(date,'%Y-%m') as uploadYears,
-                                                        daily_charge,real_charged,contract_rebate_real_charged,direct_rebate_real_charged,
-                                                        daily_transfer_in,daily_transfer_out,balance,
-                                                        real_recharged,contract_rebate_real_recharged,direct_rebate_real_recharged,
-                                                      create_time
-                                                    from
-                                                        `application`.kuaishou_advertiser_fund_daily_flows
-                                                    where advertiser_id = #{accountId}
-                                                   )t
-                                                       LEFT JOIN ctop_user_allocation c on t.account_id = c.account_id
-                                                       LEFT JOIN ctop_kuaishou_advertiser_base_info base on base.account_id = t.account_id
+        select t.*,
+               c.auth_name  as accountName,
+               base.user_id as ksId
+        from (select id,
+                     advertiser_id,
+                  date, DATE_FORMAT(date, '%Y-%m') as uploadYears,
+                  daily_charge, real_charged, contract_rebate_real_charged, direct_rebate_real_charged,
+                  daily_transfer_in, daily_transfer_out, balance,
+                  real_recharged, contract_rebate_real_recharged, direct_rebate_real_recharged,
+                  create_time
+              from
+                  `application`.kuaishou_advertiser_fund_daily_flows
+              where advertiser_id = #{accountId}
+             ) t
+                 LEFT JOIN ctop_user_allocation c on t.account_id = c.account_id
+                 LEFT JOIN ctop_kuaishou_advertiser_base_info base on base.account_id = t.account_id
         where uploadYears = #{uploadYears}
     </select>
 
@@ -200,13 +208,10 @@
     <select id="getAccountTransactionDayKuaiShouAgent"
             resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
 
-        SELECT
-            t.*
-        FROM
-            (
-                SELECT
-                    account_id,
-                    date_time AS date,
+        SELECT t.*
+        FROM (
+                 SELECT account_id,
+                        date_time AS date,
 		DATE_FORMAT( date_time, '%Y-%m' ) AS uploadYears,
 		user_id AS ksId,
 		total_charged_in_yuan AS dailyCharge,
@@ -215,30 +220,23 @@
 		(real_charged_in_yuan + total_rebate_real_charged_in_yuan + credit_real_charged_in_yuan) as realCharged,
 		account_name as accountName,
 		create_time
-                FROM
-                    ctop_kuaishou_daily_agent
-                WHERE
-                    account_id = #{accountId}
-            ) t
-        WHERE
-            t.uploadYears = #{uploadYears}
-        ORDER BY
-            t.date
+                 FROM
+                     ctop_kuaishou_daily_agent
+                 WHERE
+                     account_id = #{accountId}
+             ) t
+        WHERE t.uploadYears = #{uploadYears}
+        ORDER BY t.date
     </select>
 
     <!-- 获取快手 账户 日流水信息  代理商 和 账户 维度-->
     <select id="getTransactionDayKuaiShouAgentAndAccount"
             resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
-        SELECT
-            *
-        FROM
-            (
-                SELECT
-                    t.*
-                FROM
-                    (
-                        SELECT
-                            date_time as date,
+        SELECT *
+        FROM (
+                 SELECT t.*
+                 FROM (
+                          SELECT date_time as date,
                             account_id AS accountId,
                             total_charged_in_yuan as dailyCharge,
                             contract_rebate_real_charged_in_yuan as contractRebateRealCharged,
@@ -246,49 +244,42 @@
                             ( real_charged_in_yuan + total_rebate_real_charged_in_yuan + credit_real_charged_in_yuan ) realCharged,
                             account_name AS accountName,
                             user_id AS ksId
-                        FROM
-                            ctop_kuaishou_daily_agent
-                        WHERE
-                           total_charged_in_yuan >0
-                          and account_id = #{accountId}
-                    ) t
-                WHERE
-                    DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
-                ORDER BY
-                    t.date
-                    LIMIT 31
-            ) a
-                LEFT JOIN (
-                SELECT
-                    t.*,
-                    c.auth_name AS accountNameF,
-                    base.user_id AS ksIdF
-                FROM
-                    (
-                        SELECT
-                            advertiser_id AS accountIdF,
-                            date,
-                            daily_transfer_in as dailyTransferIn,
-                            daily_transfer_out as dailyTransferOut,
-                            balance as balance,
-                            real_recharged as realRecharged,
-                            contract_rebate_real_recharged as contractRebateRealRecharged,
-                            direct_rebate_real_recharged as directRebateRealRecharged
-                        FROM
-                           `application`.kuaishou_advertiser_fund_daily_flows
-                        WHERE
-                            advertiser_id = #{accountId}
-                    ) t
-                        LEFT JOIN ctop_user_allocation c ON t.accountIdF = c.account_id
-                        LEFT JOIN ctop_kuaishou_advertiser_base_info base ON base.account_id = t.accountIdF
-                WHERE
-                    DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
-                ORDER BY
-                    date
-                    LIMIT 31
-            ) b ON a.accountId = b.accountIdF
-                AND a.date = b.date
-            LIMIT 31
+                          FROM
+                              ctop_kuaishou_daily_agent
+                          WHERE
+                              total_charged_in_yuan
+                              >0
+                            and account_id = #{accountId}
+                      ) t
+                 WHERE DATE_FORMAT(t.date, '%Y-%m') = #{uploadYears}
+                 ORDER BY t.date LIMIT 31
+             ) a
+                 LEFT JOIN (
+            SELECT t.*,
+                   c.auth_name  AS accountNameF,
+                   base.user_id AS ksIdF
+            FROM (
+                     SELECT advertiser_id AS accountIdF,
+                         date,
+                         daily_transfer_in as dailyTransferIn,
+                         daily_transfer_out as dailyTransferOut,
+                         balance as balance,
+                         real_recharged as realRecharged,
+                         contract_rebate_real_recharged as contractRebateRealRecharged,
+                         direct_rebate_real_recharged as directRebateRealRecharged
+                     FROM
+                         `application`.kuaishou_advertiser_fund_daily_flows
+                     WHERE
+                         advertiser_id = #{accountId}
+                 ) t
+                     LEFT JOIN ctop_user_allocation c ON t.accountIdF = c.account_id
+                     LEFT JOIN ctop_kuaishou_advertiser_base_info base ON base.account_id = t.accountIdF
+            WHERE DATE_FORMAT(t.date, '%Y-%m') = #{uploadYears}
+            ORDER BY
+                date
+                LIMIT 31
+        ) b ON a.accountId = b.accountIdF
+            AND a.date = b.date LIMIT 31
 
     </select>
 
@@ -445,29 +436,21 @@
 
     <!-- 查询 利润表  销售人员姓名 -->
     <select id="getProfitReportSale" resultType="java.util.LinkedHashMap">
-        ( SELECT
-        p.sale_id AS saleId,
-        y.realname AS saleName
-        FROM
-        ctop_user_allocation u
-        LEFT JOIN ctop_project p ON u.project_id = p.id
-        LEFT JOIN sys_user y ON y.id = p.sale_id
-        WHERE
-        u.account_id = #{accountId}
-        LIMIT 1
+        (SELECT p.sale_id  AS saleId,
+                y.realname AS saleName
+         FROM ctop_user_allocation u
+                  LEFT JOIN ctop_project p ON u.project_id = p.id
+                  LEFT JOIN sys_user y ON y.id = p.sale_id
+         WHERE u.account_id = #{accountId} LIMIT 1
         )
         UNION ALL
         (
-        SELECT
-        f.create_user_id,
-        u.realname AS saleName
-        FROM
-        ctop_cwjs_settlement_info f
-        LEFT JOIN sys_user u ON u.id = f.create_user_id
-        WHERE
-        f.del_flag = 0
-        AND f.account_id = #{accountId}
-        LIMIT 1
+            SELECT f.create_user_id,
+                   u.realname AS saleName
+            FROM ctop_cwjs_settlement_info f
+                     LEFT JOIN sys_user u ON u.id = f.create_user_id
+            WHERE f.del_flag = 0
+              AND f.account_id = #{accountId} LIMIT 1
         )
         LIMIT 1
     </select>
@@ -545,6 +528,7 @@
     <!-- 查询 快手 利润表 总花费 结算单-->
     <select id="getProfitKuaiShouAccountCostSheet" resultType="java.util.LinkedHashMap">
         SELECT
+        d.date_time as 'time',
         d.account_id as accountId,
         (SELECT ua.auth_name from ctop_user_allocation ua where ua.account_id = d.account_id) as accountName,
         d.user_id AS ksId,
@@ -650,45 +634,37 @@
 
     <!--  查询 所有已绑定用户的运营人员id -->
     <select id="getAccountOperateUserId" resultType="java.util.LinkedHashMap">
-        SELECT user_id userId,user_name userName
+        SELECT user_id userId, user_name userName
         from ctop_user_allocation
         GROUP BY user_id
     </select>
 
     <!-- 查询运营人员 绑定的账户 以及产品 -->
     <select id="getAccountAndProductByOperate" resultType="java.util.LinkedHashMap">
-        SELECT
-            c.user_id as userId,
-            c.user_name as userName,
-            c.account_id as accountId,
-            c.project_id as projectId,
-            p.product_id as productId,
-            d.product_name as productName
-        FROM
-            ctop_user_allocation c
-                LEFT JOIN ctop_project p ON c.project_id = p.id
-                LEFT JOIN ctop_product d ON p.product_id = d.id
-        WHERE
-            c.account_status = 0
-        AND p.product_id IS NOT NULL
-	AND c.user_id = #{userId}
+        SELECT c.user_id      as userId,
+               c.user_name    as userName,
+               c.account_id   as accountId,
+               c.project_id   as projectId,
+               p.product_id   as productId,
+               d.product_name as productName
+        FROM ctop_user_allocation c
+                 LEFT JOIN ctop_project p ON c.project_id = p.id
+                 LEFT JOIN ctop_product d ON p.product_id = d.id
+        WHERE c.account_status = 0
+          AND p.product_id IS NOT NULL
+          AND c.user_id = #{userId}
     </select>
 
 
     <!-- 获取快手 账户 日流水信息  代理商 和 账户 结算单 -汇总页-->
     <select id="getTransactionDayKuaiShouSheet"
             resultType="org.jeecg.ctop.finance.settlement.entity.vo.SheetKuaiShouVo">
-        SELECT
-            *,
-            IFNULL(b.balance1,0) as balance
-        FROM
-            (
-                SELECT
-                    t.*
-                FROM
-                    (
-                        SELECT
-                            date_time as date,
+        SELECT *,
+               IFNULL(b.balance1, 0) as balance
+        FROM (
+                 SELECT t.*
+                 FROM (
+                          SELECT date_time as date,
                             account_id AS accountId,
                             total_charged_in_yuan as dailyCharge,
                             contract_rebate_real_charged_in_yuan as contractRebateRealCharged,
@@ -696,52 +672,45 @@
                             ( real_charged_in_yuan + total_rebate_real_charged_in_yuan + credit_real_charged_in_yuan ) realCharged,
                             account_name AS accountName,
                             user_id AS ksId
-                        FROM
-                            ctop_kuaishou_daily_agent
-                        WHERE
-                            total_charged_in_yuan >0
-                          and account_id = #{accountId}
-                    ) t
-                WHERE
-                   t.date &gt;= #{startTime}
-                  AND t.date &lt;= #{endTime}
-                ORDER BY
-                    t.date
-                    LIMIT 31
-            ) a
-                LEFT JOIN (
-                SELECT
-                    t.*,
-                    c.auth_name AS accountNameF,
-                    base.user_id AS ksIdF
-                FROM
-                    (
-                        SELECT
-                            advertiser_id AS accountIdF,
-                             daily_charge as flowDailyCharge,
-                            date,
-                            daily_transfer_in as dailyTransferIn,
-                            daily_transfer_out as dailyTransferOut,
-                            IFNULL(balance,0) as balance1,
-                            real_recharged as realRecharged,
-                            contract_rebate_real_recharged as contractRebateRealRecharged,
-                            direct_rebate_real_recharged as directRebateRealRecharged
-                        FROM
-                             `application`.kuaishou_advertiser_fund_daily_flows
-                        WHERE
-                            advertiser_id = #{accountId}
-                    ) t
-                        LEFT JOIN ctop_user_allocation c ON t.accountIdF = c.account_id
-                        LEFT JOIN ctop_kuaishou_advertiser_base_info base ON base.account_id = t.accountIdF
-                WHERE
-                   t.date &gt;= #{startTime}
-                  AND t.date &lt;= #{endTime}
-                ORDER BY
-                    date
-                    LIMIT 31
-            ) b ON a.accountId = b.accountIdF
-                AND a.date = b.date
-            LIMIT 31
+                          FROM
+                              ctop_kuaishou_daily_agent
+                          WHERE
+                              total_charged_in_yuan
+                              >0
+                            and account_id = #{accountId}
+                      ) t
+                 WHERE t.date &gt;= #{startTime}
+                   AND t.date &lt;= #{endTime}
+                 ORDER BY t.date LIMIT 31
+             ) a
+                 LEFT JOIN (
+            SELECT t.*,
+                   c.auth_name  AS accountNameF,
+                   base.user_id AS ksIdF
+            FROM (
+                     SELECT advertiser_id AS accountIdF,
+                            daily_charge  as flowDailyCharge,
+                         date,
+                         daily_transfer_in as dailyTransferIn,
+                         daily_transfer_out as dailyTransferOut,
+                         IFNULL(balance, 0) as balance1,
+                         real_recharged as realRecharged,
+                         contract_rebate_real_recharged as contractRebateRealRecharged,
+                         direct_rebate_real_recharged as directRebateRealRecharged
+                     FROM
+                         `application`.kuaishou_advertiser_fund_daily_flows
+                     WHERE
+                         advertiser_id = #{accountId}
+                 ) t
+                     LEFT JOIN ctop_user_allocation c ON t.accountIdF = c.account_id
+                     LEFT JOIN ctop_kuaishou_advertiser_base_info base ON base.account_id = t.accountIdF
+            WHERE t.date &gt;= #{startTime}
+              AND t.date &lt;= #{endTime}
+            ORDER BY
+                date
+                LIMIT 31
+        ) b ON a.accountId = b.accountIdF
+            AND a.date = b.date LIMIT 31
 
     </select>
 

+ 2 - 2
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml

@@ -210,8 +210,8 @@
         <if test="projectId !=null and projectId != ''">
             AND u.project_id = #{projectId}
         </if>
-       <if test="uploadYears !=null and uploadYears != ''">
-            AND c.upload_years = #{uploadYears}
+       <if test="endTime !=null and endTime != ''">
+            AND c.upload_years = DATE_FORMAT(#{endTime}, '%Y-%m')
         </if>
     </select>
 

+ 182 - 158
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java

@@ -5,24 +5,32 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.ImportParams;
 import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
-import cn.com.ctop.common.module.entity.SysLog;
 import cn.com.ctop.common.module.entity.UserAllocation;
-import cn.com.ctop.common.module.mapper.*;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.mapper.SysLogMapper;
+import cn.com.ctop.common.module.mapper.SysRoleMapper;
+import cn.com.ctop.common.module.mapper.SysUserMapper;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
-import cn.com.ctop.common.module.utils.ImageUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
+import org.apache.poi.hssf.usermodel.HSSFDataFormat;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.usermodel.HSSFPatriarch;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.ClientAnchor;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.entity.SysUser;
-import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.ctop.finance.policy.entity.CwjsCompanySubject;
 import org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog;
@@ -35,12 +43,15 @@ import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyProductMapper;
 import org.jeecg.ctop.finance.policy.service.ICreateSheetService;
 import org.jeecg.ctop.finance.policy.service.impl.CwjsSaleAssistantInfoServiceImpl;
 import org.jeecg.ctop.finance.policy.utils.Check;
-import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSlettementReport;
-import org.jeecg.ctop.finance.settlement.entity.vo.*;
+import org.jeecg.ctop.finance.settlement.entity.vo.PolicyImportVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.ProfitReportBytedanceVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.ProfitReportKuaiShouVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo;
 import org.jeecg.ctop.finance.settlement.mapper.CwjsProfitMapper;
 import org.jeecg.ctop.finance.settlement.mapper.ReportSettlementMapper;
-import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
 import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
 import org.jeecg.ctop.finance.utils.SettlementUtil;
 import org.jeecg.ctop.finance.utils.createExcelByTemplate;
@@ -53,16 +64,25 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletResponse;
-import javax.swing.*;
 import java.awt.*;
 import java.awt.image.BufferedImage;
-import java.io.*;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 
@@ -97,6 +117,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     public List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance() {
         return reportSettlementMapper.getAccountTransactionDayBytedance(null);
     }
+
     @Override
     public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response, SysUser user) {
         try {
@@ -118,9 +139,9 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
 
             //查询 账户id
-            List<String> accountIdList = this.getAccountId(paramsVo,user);
+            List<String> accountIdList = this.getAccountId(paramsVo, user);
 
-            if (Check.isNull(accountIdList)){
+            if (Check.isNull(accountIdList)) {
                 return Result.errorMsg("该广告主和产品下无法查询到绑定的账户信息");
             }
 
@@ -128,9 +149,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
 
             //设置第一个sheet页 汇总页
-            createSheetService.createBytedance(wb,style,accountIdList,paramsVo.getUploadYears());
-
-
+            createSheetService.createBytedance(wb, style, accountIdList, paramsVo.getStartTime(), paramsVo.getEndTime());
 
 
             for (int k = 0; k < accountIdList.size(); k++) {
@@ -139,7 +158,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
                 //获取账户 日流水数据  根据账户id 和 年月 查询数据
                 List<SettlementReportBytedanceVo> settlementList = reportSettlementMapper.getAccountTransactionDayBytedance(paramsVo);
-                if (Check.isNull(settlementList)){
+                if (Check.isNull(settlementList)) {
                     num++;
                     continue;
                 }
@@ -154,7 +173,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 HSSFRow row0 = sheet.createRow(0);
                 HSSFCell cell0 = row0.createCell(0);
                 //设置 第一行 表头
-                cell0.setCellValue(paramsVo.getUploadYears()+"-头条结算单");
+                cell0.setCellValue(paramsVo.getStartTime() + "~" + paramsVo.getEndTime() + "-头条结算单");
                 CellRangeAddress region = new CellRangeAddress(0, 0, 0, 10);
                 sheet.addMergedRegion(region);//合并行
                 cell0.setCellStyle(style);
@@ -238,9 +257,9 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 }
 
                 //查询 图片 url
-                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId,paramsVo.getUploadYears());
+                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId, paramsVo.getEndTime());
 
-                if (!Check.isNull(imageUrlList)){
+                if (!Check.isNull(imageUrlList)) {
                     for (int j = 0; j < imageUrlList.size(); j++) {
                         //先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray
                         ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
@@ -253,11 +272,11 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                         Image imageTookittitle = Toolkit.getDefaultToolkit().createImage(url);
                         BufferedImage bufferImg = createExcelByTemplate.toBufferedImage(imageTookittitle);
                         ImageIO.write(bufferImg, imagePath.substring(imagePath.lastIndexOf(".") + 1), byteArrayOut);
-                        int startIndex = settlementList.size() +6;
-                        int hight = (int)Math.round(bufferImg.getHeight() / 28.35 / (sheet.getDefaultRowHeightInPoints() / 28.35));
-                        int width = (int)Math.round(bufferImg.getWidth() / (96/2.54) / ((sheet.getColumnWidthInPixels(settlementList.size()) / (96 / 2.54))));
+                        int startIndex = settlementList.size() + 6;
+                        int hight = (int) Math.round(bufferImg.getHeight() / 28.35 / (sheet.getDefaultRowHeightInPoints() / 28.35));
+                        int width = (int) Math.round(bufferImg.getWidth() / (96 / 2.54) / ((sheet.getColumnWidthInPixels(settlementList.size()) / (96 / 2.54))));
                         //anchor主要用于设置图片的属性
-                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex+(5*j)+hight*j, (short) width, startIndex+(5*j)+hight*(j+1));
+                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex + (5 * j) + hight * j, (short) width, startIndex + (5 * j) + hight * (j + 1));
                         //HSSFClientAnchor anchor2 = new HSSFClientAnchor(0, 0, 255, 255, (short) 5, settlementList.size() + 40, (short) 10, 40 * 2);
                         anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
                         //插入图片
@@ -267,7 +286,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
             }
 
-            if(accountIdList.size() == num){
+            if (accountIdList.size() == num) {
                 return Result.errorMsg("暂无账户流水数据");
             }
 
@@ -276,7 +295,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             response.setHeader("Pragma", "no-cache");
             response.setHeader("Cache-Control", "no-cache");
             response.setDateHeader("Expires", 0);
-            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(paramsVo.getUploadYears()+"-头条结算单.xlsx", "UTF-8"));
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(paramsVo.getStartTime() + "~" + paramsVo.getEndTime() + "-头条结算单.xlsx", "UTF-8"));
             OutputStream output = response.getOutputStream();
             BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
             wb.write(bufferedOutPut);
@@ -289,53 +308,67 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         }
         return null;
     }
+
     /**
      * @param paramsVo
      * @param user
      * @return
      */
     @Override
-    public List<String> getAccountId(SettlementFileParamsVo paramsVo,SysUser user) {
+    public List<String> getAccountId(SettlementFileParamsVo paramsVo, SysUser user) {
         String uploadYears = paramsVo.getUploadYears();
+        String startTime = paramsVo.getStartTime();
         //1:区分媒体(头条:1 快手:2)
         Integer mediaId = paramsVo.getMediaId();
         String roleCode = roleMapper.getRoleCodeByUserId(user.getId());
-        Set<String>sales = new HashSet<>();
+        Set<String> sales = new HashSet<>();
         List<String> userIds = new ArrayList<>();
-        List<UserAllocation>allocations ;
-        if("admin".equals(roleCode)|| "finance".equals(roleCode)){
+        List<UserAllocation> allocations;
+        if ("admin".equals(roleCode) || "finance".equals(roleCode)) {
             //查询所有可用的账户
             sales = null;
-        }else {
+        } else {
             //查询 销售及助理 关联对应的人员
             userIds = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(user.getId());
-            if (Check.isNull(userIds)){
+            if (Check.isNull(userIds)) {
                 userIds.add(user.getId());
             }
             sales.addAll(new HashSet<>(userIds));
         }
         //查询财务模块中已上传的账户
-        List<String> settlementAccountList = reportSettlementMapper.getAccountIdBytedance(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId(),paramsVo.getProjectId());
+        List<String> settlementAccountList = reportSettlementMapper.getAccountIdBytedance(sales, String.valueOf(mediaId), paramsVo.getAdvertiserId(), paramsVo.getProductId(), paramsVo.getProjectId());
         //查询已绑定账户
-        allocations = userAllocationMapper.getAccountInfoBySalesId(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId(),paramsVo.getProjectId());
-        return mergeAccountId(settlementAccountList,allocations,uploadYears);
+        allocations = userAllocationMapper.getAccountInfoBySalesId(sales, String.valueOf(mediaId), paramsVo.getAdvertiserId(), paramsVo.getProductId(), paramsVo.getProjectId());
+        return mergeAccountId(settlementAccountList, allocations, uploadYears, startTime);
     }
 
     //账户处理
-    private List<String> mergeAccountId(List<String> settlementAccountList, List<UserAllocation> allocations,String downloadYear) {
-        List<String>salesAccount = new ArrayList<>();
+    private List<String> mergeAccountId(List<String> settlementAccountList, List<UserAllocation> allocations, String downloadYear, String startTime) {
+        List<String> salesAccount = new ArrayList<>();
         // 账户状态 0 启动 1 禁用
-        for(UserAllocation allocation : allocations){
-            if(allocation.getAccountStatus() == 0){
-                salesAccount.add(allocation.getAccountId()+"");
+        for (UserAllocation allocation : allocations) {
+            if (allocation.getAccountStatus() == 0) {
+                salesAccount.add(allocation.getAccountId() + "");
             }
-            if(allocation.getAccountStatus() == 1){
+            if (allocation.getAccountStatus() == 1) {
                 //被关停的账户
-                Long updateDateNum = Long.parseLong(DateUtils.formatDate(allocation.getUpdateTime(),"yyyyMM"));
-                downloadYear = downloadYear.replace("-","");
-                Long downloadYearNum = Long.parseLong(downloadYear);
-                if(updateDateNum >= downloadYearNum){
-                    salesAccount.add(allocation.getAccountId()+"");
+                Long updateDateNum = Long.parseLong(DateUtils.formatDate(allocation.getUpdateTime(), "yyyyMM"));
+                if (!Check.isNull(downloadYear)) {
+                    downloadYear = downloadYear.replace("-", "");
+                    Long downloadYearNum = Long.parseLong(downloadYear);
+                    if (updateDateNum >= downloadYearNum) {
+                        salesAccount.add(allocation.getAccountId() + "");
+                    }
+                } else if (!Check.isNull(startTime)) {
+                    try {
+                        Long startTimeNum = Long.parseLong(DateUtils.formatDate(startTime, "yyyyMM"));
+                        if (updateDateNum >= startTimeNum) {
+                            salesAccount.add(allocation.getAccountId() + "");
+                        }
+                    } catch (ParseException e) {
+                        e.printStackTrace();
+                    }
+
                 }
             }
         }
@@ -366,22 +399,22 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             style.setFont(font);
 
             //查询 需要导出的数据的账户id
-            List<String> accountIdList = this.getAccountId(paramsVo,user);
+            List<String> accountIdList = this.getAccountId(paramsVo, user);
 
 
-            if (Check.isNull(accountIdList)){
+            if (Check.isNull(accountIdList)) {
                 return Result.errorMsg("该广告主和产品下无法查询到绑定的快手账户信息");
             }
             //设置第一个sheet 汇总页-快手
-            createSheetService.createKuaiShou(wb,style,accountIdList,paramsVo.getUploadYears());
+            createSheetService.createKuaiShou(wb, style, accountIdList, paramsVo.getStartTime(), paramsVo.getEndTime());
             int num = 0;
             for (int k = 0; k < accountIdList.size(); k++) {
                 String accountId = accountIdList.get(k);
                 paramsVo.setAccountId(accountId);
 
-               // List<SettlementReportKuaiShouVo> settlementList = reportSettlementMapper.getTransactionDayKuaiShouAgentAndAccount(paramsVo);
+                // List<SettlementReportKuaiShouVo> settlementList = reportSettlementMapper.getTransactionDayKuaiShouAgentAndAccount(paramsVo);
                 List<SettlementReportKuaiShouVo> settlementList = intranetSettlementService.getTransactionDayKuaiShouAgentAndAccountIntranet(paramsVo);
-                if (Check.isNull(settlementList)){
+                if (Check.isNull(settlementList)) {
                     num++;
                     continue;
                 }
@@ -396,7 +429,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 HSSFRow row0 = sheet.createRow(0);
                 HSSFCell cell0 = row0.createCell(0);
                 //设置 第一行 表头
-                cell0.setCellValue(paramsVo.getUploadYears()+"-快手结算单");
+                cell0.setCellValue(paramsVo.getStartTime() + "~" + paramsVo.getEndTime() + "-快手结算单");
                 CellRangeAddress region = new CellRangeAddress(0, 0, 0, 10);
                 sheet.addMergedRegion(region);//合并行
                 cell0.setCellStyle(style);
@@ -486,11 +519,10 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 }
 
 
-
                 //查询 图片 url
-                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId,paramsVo.getUploadYears());
+                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId, paramsVo.getEndTime());
 
-                if (!Check.isNull(imageUrlList)){
+                if (!Check.isNull(imageUrlList)) {
                     for (int j = 0; j < imageUrlList.size(); j++) {
                         //先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray
                         ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
@@ -504,10 +536,10 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                         BufferedImage bufferImg = createExcelByTemplate.toBufferedImage(imageTookittitle);
                         ImageIO.write(bufferImg, imagePath.substring(imagePath.lastIndexOf(".") + 1), byteArrayOut);
                         //anchor主要用于设置图片的属性
-                        int startIndex = settlementList.size()+7;
-                        int hight = (int)Math.round(bufferImg.getHeight() / 28.35 / (sheet.getDefaultRowHeightInPoints() / 28.35));
-                        int width = (int)Math.round(bufferImg.getWidth() / (96/2.54) / ((sheet.getColumnWidthInPixels(settlementList.size()) / (96 / 2.54))));
-                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex+(5*j)+hight*j, (short) width, startIndex+(5*j)+hight*(j+1));
+                        int startIndex = settlementList.size() + 7;
+                        int hight = (int) Math.round(bufferImg.getHeight() / 28.35 / (sheet.getDefaultRowHeightInPoints() / 28.35));
+                        int width = (int) Math.round(bufferImg.getWidth() / (96 / 2.54) / ((sheet.getColumnWidthInPixels(settlementList.size()) / (96 / 2.54))));
+                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex + (5 * j) + hight * j, (short) width, startIndex + (5 * j) + hight * (j + 1));
 
                         //HSSFClientAnchor anchor2 = new HSSFClientAnchor(0, 0, 255, 255, (short) 5, settlementList.size() + 40, (short) 10, 40 * 2);
                         anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
@@ -518,7 +550,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
             }
 
-            if(accountIdList.size() == num){
+            if (accountIdList.size() == num) {
                 return Result.errorMsg("暂无数据");
             }
 
@@ -527,7 +559,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             response.setHeader("Pragma", "no-cache");
             response.setHeader("Cache-Control", "no-cache");
             response.setDateHeader("Expires", 0);
-            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(paramsVo.getUploadYears()+"-快手结算单.xlsx", "UTF-8"));
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(paramsVo.getStartTime() + "~" + paramsVo.getEndTime() + "-快手结算单.xlsx", "UTF-8"));
             OutputStream output = response.getOutputStream();
             BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
             wb.write(bufferedOutPut);
@@ -542,10 +574,9 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     }
 
     /**
-     *
-     * @description: 财务结算 利润表导出 头条
      * @param paramsVo
      * @param response
+     * @description: 财务结算 利润表导出 头条
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
@@ -553,38 +584,38 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     public Result porfitReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
         try {
             //查询 头条利润表 时间段内 所有 账户
-            List<Map<String,Object>> list = reportSettlementMapper.getProfitBytedanceAccount(paramsVo.getStartTime(),paramsVo.getEndTime());
-            if (Check.isNull(list)){
+            List<Map<String, Object>> list = reportSettlementMapper.getProfitBytedanceAccount(paramsVo.getStartTime(), paramsVo.getEndTime());
+            if (Check.isNull(list)) {
                 return Result.errorMsg("暂无数据");
             }
             List<ProfitReportBytedanceVo> resultList = new ArrayList<>(list.size());
             for (Map<String, Object> mapList : list) {
 
                 //查看账户数据
-                Map<String,Object> map = reportSettlementMapper.getProfitBytedanceAccountCost(mapList.get("accountId").toString(),paramsVo.getStartTime(),paramsVo.getEndTime());
+                Map<String, Object> map = reportSettlementMapper.getProfitBytedanceAccountCost(mapList.get("accountId").toString(), paramsVo.getStartTime(), paramsVo.getEndTime());
 
                 ProfitReportBytedanceVo voSource = new ProfitReportBytedanceVo();
-                voSource.setAccountId(map.get("accountId")+"");
+                voSource.setAccountId(map.get("accountId") + "");
 
-                voSource.setAdvertiserName(!Check.isNull(map.get("advertiserName")) ? map.getOrDefault("advertiserName","")+"" : "" );//广告主名称
+                voSource.setAdvertiserName(!Check.isNull(map.get("advertiserName")) ? map.getOrDefault("advertiserName", "") + "" : "");//广告主名称
                 //产品名称
-                voSource.setProductName(!Check.isNull(map.get("productName")) ? map.getOrDefault("productName","")+"" : "" );
+                voSource.setProductName(!Check.isNull(map.get("productName")) ? map.getOrDefault("productName", "") + "" : "");
 
 
                 //查询销售
-                Map<String,Object> slaeMap = reportSettlementMapper.getProfitReportSale(map.get("accountId")+"");
-                voSource.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName","")+"");//销售
+                Map<String, Object> slaeMap = reportSettlementMapper.getProfitReportSale(map.get("accountId") + "");
+                voSource.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName", "") + "");//销售
                 //查询运营
-                Map<String,Object> operateMap = reportSettlementMapper.getProfitReportOperateAndArea(map.get("accountId")+"");
-                if (!Check.isNull(operateMap)){
-                    voSource.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
-                    voSource.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
+                Map<String, Object> operateMap = reportSettlementMapper.getProfitReportOperateAndArea(map.get("accountId") + "");
+                if (!Check.isNull(operateMap)) {
+                    voSource.setOperateName(operateMap.getOrDefault("operateName", "") + "");//运营
+                    voSource.setOperateArea(operateMap.getOrDefault("operateArea", "") + "");//运营所属区域
                 }
                 //政策所有时间点
                 List<String> policyDaysList = new ArrayList<>();
-                if (!Check.isNull(map.get("productName"))){
+                if (!Check.isNull(map.get("productName"))) {
                     //查询 头条利润表  返点类型和比列
-                    List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName")+"",slaeMap.get("saleId")+"","1",paramsVo.getStartTime(),paramsVo.getEndTime());
+                    List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName") + "", map.get("productName") + "", slaeMap.get("saleId") + "", "1", paramsVo.getStartTime(), paramsVo.getEndTime());
                     List listPolicyTIme = new ArrayList();
                     for (Map<String, Object> rate : rateMap) {
                         listPolicyTIme.add(rate.get("policyStartDate"));
@@ -594,10 +625,10 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     List<Object> times = SettlementUtil.sortlistTest(listPolicyTIme);
                     // 使用政策的时间段 拼接 开始 和 截至 时间
                     List<Map<String, String>> arrayList = new ArrayList<>();
-                    for ( int i = 0; i < times.size(); i++) {
+                    for (int i = 0; i < times.size(); i++) {
                         HashMap<String, String> mapTime = new HashMap<>();
                         mapTime.put("startDate", times.get(i).toString());
-                        mapTime.put("endDate",  times.size() < 2 ? times.get(i).toString() : times.get(i + 1).toString());
+                        mapTime.put("endDate", times.size() < 2 ? times.get(i).toString() : times.get(i + 1).toString());
                         i += 1;
                         arrayList.add(mapTime);
                     }
@@ -606,64 +637,64 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     for (Map<String, String> stringMap : arrayList) {
                         ProfitReportBytedanceVo vo = new ProfitReportBytedanceVo();
                         //使用政策 返点类型和比例
-                        Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName")+"",map.get("productName")+"",slaeMap.get("saleId")+"","1",stringMap.get("startDate"),stringMap.get("endDate"));
-                        if (!Check.isNull(policyRateMap)){
-                            if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 0){
+                        Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName") + "", map.get("productName") + "", slaeMap.get("saleId") + "", "1", stringMap.get("startDate"), stringMap.get("endDate"));
+                        if (!Check.isNull(policyRateMap)) {
+                            if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 0) {
                                 vo.setRebateType("返现");//返点类型
-                            }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 1){
+                            } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 1) {
                                 vo.setRebateType("返货");
-                            }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 2){
+                            } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 2) {
                                 vo.setRebateType("返现+返货");
-                            }else if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 3){
+                            } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 3) {
                                 vo.setRebateType("服务费");
                             }
-                            vo.setRebateRate(policyRateMap.getOrDefault("rebateRate","")+"%");//返点比列
-                        }else {
+                            vo.setRebateRate(policyRateMap.getOrDefault("rebateRate", "") + "%");//返点比列
+                        } else {
                             vo.setRebateType("");
                         }
                         // 时间段内 账户流水 信息
-                        List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(map.get("accountId")+"",stringMap.get("startDate"),stringMap.get("endDate"));
+                        List<Map<String, Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
                         listAccount.removeAll(Collections.singleton(null));
-                        vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost","")+"");//总消耗
-                        vo.setCost(String.format("%.3f",new Double(vo.getCost())));
-                        vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost","")+"");//现金消耗
-                        vo.setCashCost(String.format("%.3f",new Double(vo.getCashCost())));
-                        vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost","")+"");//赠款消耗
-                        vo.setRewardCost(String.format("%.3f",new Double(vo.getRewardCost())));
-                        BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
-                        vo.setTime(stringMap.get("startDate")+"----"+stringMap.get("endDate"));
+                        vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost", "") + "");//总消耗
+                        vo.setCost(String.format("%.3f", new Double(vo.getCost())));
+                        vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost", "") + "");//现金消耗
+                        vo.setCashCost(String.format("%.3f", new Double(vo.getCashCost())));
+                        vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost", "") + "");//赠款消耗
+                        vo.setRewardCost(String.format("%.3f", new Double(vo.getRewardCost())));
+                        BeanUtils.copyProperties(voSource, vo, SettlementUtil.getNullPropertyNames(voSource));
+                        vo.setTime(stringMap.get("startDate") + "----" + stringMap.get("endDate"));
                         resultList.add(vo);
-                        policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"),stringMap.get("endDate")));
+                        policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"), stringMap.get("endDate")));
                     }
 
                 }
 
                 //不使用政策 的时间段
                 // 获取两个日期之间 所有的 时间 年-月-日
-                List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(paramsVo.getStartTime(),paramsVo.getEndTime());
+                List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(paramsVo.getStartTime(), paramsVo.getEndTime());
                 // 时间差集(所有时间段 - 使用政策的时间段)
-                List<String>  reduceList = betweenDaysList.stream().filter(item -> !policyDaysList.contains(item)).collect(Collectors.toList());
+                List<String> reduceList = betweenDaysList.stream().filter(item -> !policyDaysList.contains(item)).collect(Collectors.toList());
                 //差集拼接  开始 和 结束时间
                 List<Map<String, String>> stringList = SettlementUtil.getTime(reduceList);
                 for (Map<String, String> stringMap : stringList) {
                     ProfitReportBytedanceVo vo = new ProfitReportBytedanceVo();
                     // 不使用 政策 则 返点为空
                     //政策 返点类型和比例
-                   /* Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("productName")+"",stringMap.get("startDate"),stringMap.get("endDate"));
-                  */
+                    /* Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("productName")+"",stringMap.get("startDate"),stringMap.get("endDate"));
+                     */
                     vo.setRebateType("");//返点类型
                     vo.setRebateRate("");//返点比列
                     //账户流水 信息
-                    List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(map.get("accountId")+"",stringMap.get("startDate"),stringMap.get("endDate"));
+                    List<Map<String, Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
                     listAccount.removeAll(Collections.singleton(null));
-                    vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost","")+"");//总消耗
-                    vo.setCost(String.format("%.3f",new Double(vo.getCost())));
-                    vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost","")+"");//现金消耗
-                    vo.setCashCost(String.format("%.3f",new Double(vo.getCashCost())));
-                    vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost","")+"");//赠款消耗
-                    vo.setRewardCost(String.format("%.3f",new Double(vo.getRewardCost())));
-                    BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
-                    vo.setTime((!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate")+"----"+stringMap.get("endDate") : ""));
+                    vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost", "") + "");//总消耗
+                    vo.setCost(String.format("%.3f", new Double(vo.getCost())));
+                    vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost", "") + "");//现金消耗
+                    vo.setCashCost(String.format("%.3f", new Double(vo.getCashCost())));
+                    vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost", "") + "");//赠款消耗
+                    vo.setRewardCost(String.format("%.3f", new Double(vo.getRewardCost())));
+                    BeanUtils.copyProperties(voSource, vo, SettlementUtil.getNullPropertyNames(voSource));
+                    vo.setTime((!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate") + "----" + stringMap.get("endDate") : ""));
                     resultList.add(vo);
                 }
             }
@@ -685,10 +716,9 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     }
 
     /**
-     *
-     * @description: 财务结算 利润表导出 快手
      * @param paramsVo
      * @param response
+     * @description: 财务结算 利润表导出 快手
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
@@ -697,18 +727,18 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
         try {
             //查询 快手利润表  时间段内的 所有账户
-            List<Map<String,Object>> list = reportSettlementMapper.getProfitKuaiShouAgentAccount(paramsVo.getStartTime(),paramsVo.getEndTime());
-            if (Check.isNull(list)){
+            List<Map<String, Object>> list = reportSettlementMapper.getProfitKuaiShouAgentAccount(paramsVo.getStartTime(), paramsVo.getEndTime());
+            if (Check.isNull(list)) {
                 return Result.errorMsg("暂无数据");
             }
             List<ProfitReportKuaiShouVo> resultList = new ArrayList<>(list.size());
             for (Map<String, Object> mapList : list) {
 
                 //查询账户数据信息
-               Map<String,Object> map = reportSettlementMapper.getProfitKuaiShouAccountCost(mapList.get("account_id").toString(),paramsVo.getStartTime(),paramsVo.getEndTime());
+                Map<String, Object> map = reportSettlementMapper.getProfitKuaiShouAccountCost(mapList.get("account_id").toString(), paramsVo.getStartTime(), paramsVo.getEndTime());
                 ProfitReportKuaiShouVo voSource = new ProfitReportKuaiShouVo();
                 voSource.setAccountId(map.getOrDefault("accountId", "") + "");//账户id
-                voSource.setProductName( !Check.isNull(map.get("productName")) ? map.getOrDefault("productName", "") + "" : "");//产品名称
+                voSource.setProductName(!Check.isNull(map.get("productName")) ? map.getOrDefault("productName", "") + "" : "");//产品名称
                 voSource.setKsId(map.getOrDefault("ksId", "") + "");//快手id
                 voSource.setAdvertiserName(!Check.isNull(map.get("advertiserName")) ? map.getOrDefault("advertiserName", "") + "" : "");//广告主名称
 
@@ -726,7 +756,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 List<String> policyDaysList = new ArrayList<>();
                 if (!Check.isNull(map.get("productName"))) {
                     //查询 快手利润表  返点类型和比列
-                    List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName") + "", slaeMap.get("saleId")+"","2", paramsVo.getStartTime(), paramsVo.getEndTime());
+                    List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName") + "", map.get("productName") + "", slaeMap.get("saleId") + "", "2", paramsVo.getStartTime(), paramsVo.getEndTime());
                     List listPolicyTIme = new ArrayList();
                     for (Map<String, Object> rate : rateMap) {
                         listPolicyTIme.add(rate.get("policyStartDate"));
@@ -736,8 +766,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     //政策时间 去重 排序
                     List<Object> times = SettlementUtil.sortlistTest(listPolicyTIme);
                     // 使用政策的时间段 拼接 开始 和 截至 时间
-                     List<Map<String, String>> arrayList = new ArrayList<>();
-                    if (!Check.isNull(times)){
+                    List<Map<String, String>> arrayList = new ArrayList<>();
+                    if (!Check.isNull(times)) {
                         for (int i = 0; i < times.size(); i++) {
                             HashMap<String, String> mapTime = new HashMap<>();
                             mapTime.put("startDate", times.get(i).toString());
@@ -750,7 +780,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     for (Map<String, String> stringMap : arrayList) {
                         ProfitReportKuaiShouVo vo = new ProfitReportKuaiShouVo();
                         //使用政策 返点类型和比例
-                        Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName")+"",map.get("productName") + "", slaeMap.get("saleId")+"","2",stringMap.get("startDate"), stringMap.get("endDate"));
+                        Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName") + "", map.get("productName") + "", slaeMap.get("saleId") + "", "2", stringMap.get("startDate"), stringMap.get("endDate"));
                         if (!Check.isNull(policyRateMap)) {
                             if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 0) {
                                 vo.setRebateType("返现");//返点类型
@@ -758,7 +788,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                                 vo.setRebateType("返货");
                             } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 2) {
                                 vo.setRebateType("返现+返货");
-                            }else if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 3){
+                            } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 3) {
                                 vo.setRebateType("服务费");
                             }
                             vo.setRebateRate(policyRateMap.getOrDefault("rebateRate", "") + "%");//返点比列
@@ -823,10 +853,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
 
     /**
-     *
-     * @description: 给运营发送消息
-     *
      * @param
+     * @description: 给运营发送消息
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
@@ -837,27 +865,27 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         int productNum = 0;
         int accountNum = 0;
         String productInfo = null;
-        String message =  "{0},您好!您{1}月份有{2}个产品的账户需要进行媒体后台消耗截图上传,共计{3}个账户。产品分别为:{4}。请及时上传,多谢配合!";
+        String message = "{0},您好!您{1}月份有{2}个产品的账户需要进行媒体后台消耗截图上传,共计{3}个账户。产品分别为:{4}。请及时上传,多谢配合!";
         //查询所有 运营绑定的账户
-        List<Map<String,Object>> userList = reportSettlementMapper.getAccountOperateUserId();
+        List<Map<String, Object>> userList = reportSettlementMapper.getAccountOperateUserId();
         for (Map<String, Object> userMap : userList) {
-             String userId = userMap.get("userId").toString();
+            String userId = userMap.get("userId").toString();
             //查询运营下的 账户 和 产品信息
-            List<Map<String,Object>> productList = reportSettlementMapper.getAccountAndProductByOperate(userId);
-            if (Check.isNull(productList)){
+            List<Map<String, Object>> productList = reportSettlementMapper.getAccountAndProductByOperate(userId);
+            if (Check.isNull(productList)) {
                 continue;
             }
             //产品名称
             List product = productList.stream().map(map -> map.get("productName")).distinct().collect(Collectors.toList());
             productNum = product.size();
             accountNum = productList.size();
-            productInfo = StringUtils.join(product.toArray(),"、");
+            productInfo = StringUtils.join(product.toArray(), "、");
             //发送微信通知
-            JSONObject jsonObject =  mailLogMapper.getWChatIdByUserId(userId);
-            String msg = MessageFormat.format(message,userMap.get("userName").toString(),month,productNum,accountNum,productInfo);
-            corpWexinUtils.sendMessageByWeChatId(jsonObject,msg);
+            JSONObject jsonObject = mailLogMapper.getWChatIdByUserId(userId);
+            String msg = MessageFormat.format(message, userMap.get("userName").toString(), month, productNum, accountNum, productInfo);
+            corpWexinUtils.sendMessageByWeChatId(jsonObject, msg);
         }
-        return Result.successMsg("成功",null);
+        return Result.successMsg("成功", null);
     }
 
     @Override
@@ -867,28 +895,28 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         int productNum = 0;
         int accountNum = 0;
         String productInfo = null;
-        String message =  "{0},您好!您{1}月份有{2}个产品的账户需要进行媒体后台消耗截图上传,共计{3}个账户。产品分别为:{4}。请及时上传,多谢配合!";
+        String message = "{0},您好!您{1}月份有{2}个产品的账户需要进行媒体后台消耗截图上传,共计{3}个账户。产品分别为:{4}。请及时上传,多谢配合!";
 
         //查询所有 运营绑定的账户
-        List<Map<String,Object>> userList = reportSettlementMapper.getAccountOperateUserId();
+        List<Map<String, Object>> userList = reportSettlementMapper.getAccountOperateUserId();
         for (Map<String, Object> userMap : userList) {
-             String realUserId = userMap.get("userId").toString();
+            String realUserId = userMap.get("userId").toString();
             //查询运营下的 账户 和 产品信息
-            List<Map<String,Object>> productList = reportSettlementMapper.getAccountAndProductByOperate(realUserId);
-            if (Check.isNull(productList)){
+            List<Map<String, Object>> productList = reportSettlementMapper.getAccountAndProductByOperate(realUserId);
+            if (Check.isNull(productList)) {
                 continue;
             }
             //产品名称
             List product = productList.stream().map(map -> map.get("productName")).distinct().collect(Collectors.toList());
             productNum = product.size();
             accountNum = productList.size();
-            productInfo = StringUtils.join(product.toArray(),"、");
+            productInfo = StringUtils.join(product.toArray(), "、");
             //发送微信通知
-            JSONObject jsonObject =  mailLogMapper.getWChatIdByUserId(Check.isNull(userId) ? "f990f815ecef43fab9cbe1bb22bb6d63" : userId);
-            String msg = MessageFormat.format(message,userMap.get("userName").toString(),month,productNum,accountNum,productInfo);
-            corpWexinUtils.sendMessageByWeChatId(jsonObject,msg);
+            JSONObject jsonObject = mailLogMapper.getWChatIdByUserId(Check.isNull(userId) ? "f990f815ecef43fab9cbe1bb22bb6d63" : userId);
+            String msg = MessageFormat.format(message, userMap.get("userName").toString(), month, productNum, accountNum, productInfo);
+            corpWexinUtils.sendMessageByWeChatId(jsonObject, msg);
         }
-        return Result.successMsg("发送微信通知成功-test",null);
+        return Result.successMsg("发送微信通知成功-test", null);
     }
 
     @Resource
@@ -900,11 +928,11 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     @Override
     public void cwjsPRofit(CwjsPolicyInfo cwjsPolicyInfo) {
         // 获取两个日期之间 所有的 时间 年-月-日
-        List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(cwjsPolicyInfo.getPolicyStartDate(),cwjsPolicyInfo.getPolicyEndDate());
+        List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(cwjsPolicyInfo.getPolicyStartDate(), cwjsPolicyInfo.getPolicyEndDate());
         //查看 政策下的产品
         List<CwjsPolicyProduct> productList = cwjsPolicyProductMapper.queryProductsByPolicyId(cwjsPolicyInfo.getId());
-        if (!Check.isNull(productList)){
-            if (!Check.isNull(betweenDaysList)){
+        if (!Check.isNull(productList)) {
+            if (!Check.isNull(betweenDaysList)) {
                 List<CtopCwjsSlettementReport> reportList = new ArrayList<>();
                 for (CwjsPolicyProduct product : productList) {
                     for (String day : betweenDaysList) {
@@ -933,7 +961,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         policyApprovalLogMapper.insert(policyApprovalLog);
 
 
-
     }
 
     @Resource
@@ -959,10 +986,10 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             }
 
             for (PolicyImportVo importVo : importResult.getList()) {
-                if (cn.com.ctop.common.module.utils.Check.isNull(importVo.getCompanyName())){
+                if (cn.com.ctop.common.module.utils.Check.isNull(importVo.getCompanyName())) {
                     continue;
                 }
-                if (cn.com.ctop.common.module.utils.Check.isNull(importVo.getPolicyProductName())){
+                if (cn.com.ctop.common.module.utils.Check.isNull(importVo.getPolicyProductName())) {
                     continue;
                 }
                 List<String> productNameList = Arrays.asList(importVo.getPolicyProductName().split("-"));
@@ -989,16 +1016,16 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
                 CwjsPolicyInfo policy = cwjsPolicyInfoMapper.getPolicyInfo(cwjsPolicyInfo);
 
-                if (cn.com.ctop.common.module.utils.Check.isNull(policy)){
+                if (cn.com.ctop.common.module.utils.Check.isNull(policy)) {
                     cwjsPolicyInfoMapper.insert(cwjsPolicyInfo);
                     policy = cwjsPolicyInfoMapper.getPolicyInfo(cwjsPolicyInfo);
                 }
 
                 //查看 政策下的产品
                 List<CwjsPolicyProduct> productList = cwjsPolicyProductMapper.queryProductsByPolicyId(policy.getId());
-                List proList = productList.stream().map(CwjsPolicyProduct:: getPolicyProductName).collect(Collectors.toList());
+                List proList = productList.stream().map(CwjsPolicyProduct::getPolicyProductName).collect(Collectors.toList());
                 for (String str : productNameList) {
-                    if (!proList.contains(str)){
+                    if (!proList.contains(str)) {
                         //新增产品
                         CwjsPolicyProduct policyProduct = new CwjsPolicyProduct();
                         policyProduct.setPolicyId(policy.getId());
@@ -1018,7 +1045,4 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     }
 
 
-
-
-
 }

+ 2 - 2
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java

@@ -217,9 +217,9 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
         }else {
             //过滤消耗为0 的账户 1-头条 2-快手
             if (paramsVo.getMediaId().equals(1)){
-                accountIds = reportSettlementMapper.getAccountIdBytedanceRepeat(accountIds,paramsVo.getUploadYears());
+                accountIds = reportSettlementMapper.getAccountIdBytedanceRepeat(accountIds,paramsVo.getStartTime(),paramsVo.getEndTime());
             }else if (paramsVo.getMediaId().equals(2)){
-                accountIds = reportSettlementMapper.getAccountIdKuaiShouRepeat(accountIds,paramsVo.getUploadYears());
+                accountIds = reportSettlementMapper.getAccountIdKuaiShouRepeat(accountIds,paramsVo.getStartTime(),paramsVo.getEndTime());
             }
             map.put("accountNum",accountIds.size()+"");
         }