Explorar o código

Merge branch 'test'

# Conflicts:
#	jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java
songyh %!s(int64=4) %!d(string=hai) anos
pai
achega
f548cf1bcc
Modificáronse 52 ficheiros con 2397 adicións e 848 borrados
  1. 7 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 13 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java
  3. 95 95
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/DemoController.java
  4. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml
  5. 8 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java
  6. 8 12
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementController.java
  7. 2 6
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java
  8. 2 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementFileInfo.java
  9. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementInfo.java
  10. 27 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/CtopCwjsSlettementReport.java
  11. 28 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/CwjsProfitMapper.java
  12. 19 10
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java
  13. 3 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java
  14. 10 3
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementInfoMapper.java
  15. 27 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/CwjsProfitMapper.xml
  16. 380 42
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml
  17. 18 11
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml
  18. 9 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementInfoMapper.xml
  19. 10 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/IReportSettlementService.java
  20. 3 5
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementFileInfoService.java
  21. 4 5
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementInfoService.java
  22. 395 92
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java
  23. 13 28
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java
  24. 125 21
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java
  25. 205 20
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java
  26. 42 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/createExcelByTemplate.java
  27. 37 0
      jeecg-boot-finance/src/test/java/org/jeecg/modules/finance/FinanceTest.java
  28. 6 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  29. 21 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  30. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  31. 91 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  32. 5 6
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java
  33. 23 13
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java
  34. 3 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyGender.java
  35. 16 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/NewMonitorInfo.java
  36. 4 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyGenderMapper.java
  37. 24 18
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java
  38. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KsNewPlanReportMapper.xml
  39. 92 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyGenderMapper.xml
  40. 27 8
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml
  41. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyGenderService.java
  42. 6 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java
  43. 113 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyGenderServiceImpl.java
  44. 181 134
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java
  45. 21 35
      jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml
  46. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceNewPlanReportMapper.xml
  47. 24 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  48. 31 202
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  49. 1 40
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  50. 203 11
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  51. 0 2
      jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java
  52. 2 2
      jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-test.yml

+ 7 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -214,6 +214,13 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/cwjsPolicyInfo/**", "anon");
         filterChainDefinitionMap.put("/explores/**", "anon");
 
+
+        filterChainDefinitionMap.put("/exportReportController/**", "anon");
+        //filterChainDefinitionMap.put("/settLementController/**", "anon");
+        //filterChainDefinitionMap.put("/settLementFileController/**", "anon");
+        //filterChainDefinitionMap.put("/ctop/projectMember/**", "anon");
+
+
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);
         filterMap.put("jwt", new JwtFilter());

+ 13 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java

@@ -149,6 +149,18 @@ public class CwjsPolicyInfoController {
 			 CwjsCompanyApprovalUser nextApprovalUser = companyApprovalUserMapper.queryByCompanySubjectIdAndLevel(companySubjectId, cwjsCompanyApprovalUser.getLevel() + 1);
 			 if(!Check.isNull(cwjsCompanyApprovalUser) && Check.isNull(nextApprovalUser)){//没有下一个审核人员,是终审
 				cwjsPolicyInfoEntity.setApprovedStatus(3);
+
+				 /**
+				  * 终审通过后 添加 起始时间
+				  */
+
+
+
+
+
+
+
+
 			}else{	//不是终审
 				cwjsPolicyInfoEntity.setApprovedStatus(2);
 				cwjsPolicyInfoEntity.setApprovedProgress(nextApprovalUser.getApprovalUserId());	//设置一下个人为审核人员
@@ -269,7 +281,7 @@ public class CwjsPolicyInfoController {
 		pageInfo.setTotal(cwjsPolicyInfoList.size());
 		pageInfo.setPageSize(pageSize);
 		pageInfo.setPageNum(pageNo);
-		return Result.successMsg("成功",pageInfo);
+		return Result.successMsg("成功",pageInfo);
 	}
 
 

+ 95 - 95
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/DemoController.java

@@ -1,95 +1,95 @@
-package org.jeecg.ctop.finance.policy.controller;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
-import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-
-/**
- *
- * @description: demo
- *
- * @author: zian Y
- * @time: 2021/7/26
- */
-@RestController
-@RequestMapping("/finance/policy")
-@Api(tags="头条-财务结算-demo")
-@Slf4j
-public class DemoController {
-
-
-    @Autowired
-    private ISettlementInfoService settlementInfoService;
-
-
-    @ApiOperation(value="demo", notes="demo")
-    @GetMapping(value = "/demo")
-    public String queryPageList() {
-
-        return "this is test controller!";
-    }
-
-
-
-    /**
-     * @description:测试 注解 @Dict  返回类型 为 IPage
-     *
-     * @return: org.jeecg.common.api.vo.Result<com.baomidou.mybatisplus.core.metadata.IPage<org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo>>
-     * @author: zianY
-     * @time: 2021/7/28 18:36
-     */
-    @ApiOperation(value="test", notes="test")
-    @GetMapping(value = "/test")
-    public Result<IPage<ctopCwjsSettlementInfo>> test(ctopCwjsSettlementInfo SettlementInfoPojo,
-                                                      @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-                                                      @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-                                                      HttpServletRequest req) {
-        QueryWrapper<ctopCwjsSettlementInfo> queryWrapper = QueryGenerator.initQueryWrapper(SettlementInfoPojo, req.getParameterMap());
-        Page<ctopCwjsSettlementInfo> page = new Page<>(pageNo, pageSize);
-        IPage<ctopCwjsSettlementInfo> list = settlementInfoService.page(page, queryWrapper);
-        return Result.successMsg("chenggong.",list);
-    }
-
-
-    /**
-     *
-     * @description:  注解 @Dict 返回类型 为 PageInfo
-
-     * @return: org.jeecg.common.api.vo.Result<com.github.pagehelper.PageInfo<org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo>>
-     * @author: zianY
-     * @time: 2021/7/28 20:35
-     */
-   /* @ApiOperation(value="test2", notes="test2")
-    @GetMapping(value = "/test2")
-    public Result<PageInfo<ctopCwjsSettlementInfo>> test2(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-                        @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
-        PageHelper.startPage(pageNo,pageSize);
-        List<ctopCwjsSettlementInfo> list = settlementInfoService.getSettlementList(null,pageNo,pageSize);
-        PageInfo<ctopCwjsSettlementInfo> pageInfo = new PageInfo<>(list);
-        return Result.successMsg("chenggong.",pageInfo);
-    }
-*/
-
-
-
-
-
-}
+//package org.jeecg.ctop.finance.policy.controller;
+//
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.baomidou.mybatisplus.core.metadata.IPage;
+//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+//import com.github.pagehelper.PageHelper;
+//import com.github.pagehelper.PageInfo;
+//import io.swagger.annotations.Api;
+//import io.swagger.annotations.ApiOperation;
+//import lombok.extern.slf4j.Slf4j;
+//import org.jeecg.common.api.vo.Result;
+//import org.jeecg.common.system.query.QueryGenerator;
+//import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
+//import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.GetMapping;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//
+//import org.springframework.web.bind.annotation.RequestParam;
+//import org.springframework.web.bind.annotation.RestController;
+//
+//import javax.servlet.http.HttpServletRequest;
+//import java.util.List;
+//
+///**
+// *
+// * @description: demo
+// *
+// * @author: zian Y
+// * @time: 2021/7/26
+// */
+//@RestController
+//@RequestMapping("/finance/policy")
+//@Api(tags="头条-财务结算-demo")
+//@Slf4j
+//public class DemoController {
+//
+//
+//    @Autowired
+//    private ISettlementInfoService settlementInfoService;
+//
+//
+//    @ApiOperation(value="demo", notes="demo")
+//    @GetMapping(value = "/demo")
+//    public String queryPageList() {
+//
+//        return "this is test controller!";
+//    }
+//
+//
+//
+//    /**
+//     * @description:测试 注解 @Dict  返回类型 为 IPage
+//     *
+//     * @return: org.jeecg.common.api.vo.Result<com.baomidou.mybatisplus.core.metadata.IPage<org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo>>
+//     * @author: zianY
+//     * @time: 2021/7/28 18:36
+//     */
+//    @ApiOperation(value="test", notes="test")
+//    @GetMapping(value = "/test")
+//    public Result<IPage<ctopCwjsSettlementInfo>> test(ctopCwjsSettlementInfo SettlementInfoPojo,
+//                                                      @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+//                                                      @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+//                                                      HttpServletRequest req) {
+//        QueryWrapper<ctopCwjsSettlementInfo> queryWrapper = QueryGenerator.initQueryWrapper(SettlementInfoPojo, req.getParameterMap());
+//        Page<ctopCwjsSettlementInfo> page = new Page<>(pageNo, pageSize);
+//        IPage<ctopCwjsSettlementInfo> list = settlementInfoService.page(page, queryWrapper);
+//        return Result.successMsg("chenggong.",list);
+//    }
+//
+//
+//    /**
+//     *
+//     * @description:  注解 @Dict 返回类型 为 PageInfo
+//
+//     * @return: org.jeecg.common.api.vo.Result<com.github.pagehelper.PageInfo<org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo>>
+//     * @author: zianY
+//     * @time: 2021/7/28 20:35
+//     */
+//   /* @ApiOperation(value="test2", notes="test2")
+//    @GetMapping(value = "/test2")
+//    public Result<PageInfo<ctopCwjsSettlementInfo>> test2(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+//                        @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
+//        PageHelper.startPage(pageNo,pageSize);
+//        List<ctopCwjsSettlementInfo> list = settlementInfoService.getSettlementList(null,pageNo,pageSize);
+//        PageInfo<ctopCwjsSettlementInfo> pageInfo = new PageInfo<>(list);
+//        return Result.successMsg("chenggong.",pageInfo);
+//    }
+//*/
+//
+//
+//
+//
+//
+//}

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

@@ -97,7 +97,7 @@
           AND t2.role_id = t3.id
           AND t1.STATUS = 1
           AND t1.del_flag = 0
-          AND t3.role_code LIKE '%peration%'
+          AND t3.role_name LIKE '%运营%'
 
     </select>
 

+ 8 - 2
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java

@@ -65,8 +65,14 @@ public class ExportReportController {
 
     @ApiOperation(value = "财务结算-给运营发送消息", notes = "财务结算-给运营发送消息")
     @GetMapping(value = "/sendMessageToOperate")
-    public Result sendMessageToOperate(@RequestParam(value = "userId",required = false) String userId) {
-        return reportSettlementService.sendMessageToOperate(userId);
+    public Result sendMessageToOperate() {
+        return reportSettlementService.sendMessageToOperate();
+    }
+
+    @ApiOperation(value = "财务结算-给运营发送消息-demo", notes = "财务结算-给运营发送消息-demo")
+    @GetMapping(value = "/sendMessageToOperateDemo")
+    public Result sendMessageToOperateDemo(@RequestParam(value = "userId",required = false) String userId) {
+        return reportSettlementService.sendMessageToOperateDemo(userId);
 
     }
 

+ 8 - 12
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementController.java

@@ -1,14 +1,10 @@
 package org.jeecg.ctop.finance.settlement.controller;
 
-import cn.com.ctop.common.module.service.impl.SysUserServiceImpl;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.checkerframework.checker.units.qual.A;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
 import org.jeecg.ctop.finance.policy.service.impl.CwjsPolicyInfoServiceImpl;
-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.CtopCwjsSettlementInfo;
 
 
 import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
@@ -46,9 +42,9 @@ public class SettlementController {
 
     @ApiOperation(value="财务结算-账户列表查询", notes="财务结算-账户列表查询")
     @GetMapping(value = "/getSettlementList")
-    public Result getSettlementList(ctopCwjsSettlementInfo settlementInfo,
-                                                                      @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-                                                                      @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
+    public Result getSettlementList(CtopCwjsSettlementInfo settlementInfo,
+                                    @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+                                    @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
         //查询用户角色
         String roleCode = sysRoleService.getRoleCodeByUserId(settlementInfo.getCreateUserId());
         //普通用户
@@ -83,7 +79,7 @@ public class SettlementController {
 
     @ApiOperation(value="财务结算-上传账户", notes="财务结算-上传账户")
     @PostMapping("/settlementAccountImport")
-    public Result settlementAccountImport(ctopCwjsSettlementInfo settlementInfo,@RequestParam("file") MultipartFile files) {
+    public Result settlementAccountImport(CtopCwjsSettlementInfo settlementInfo, @RequestParam("file") MultipartFile files) {
         if (files.isEmpty()){
             return Result.errorMsg("附件不能为空!");
         }
@@ -107,7 +103,7 @@ public class SettlementController {
         if ("admin".equals(roleCode)){
             //查询所有销售 && 媒介
             List allSaleList = cwjsPolicyInfoService.getAllSaleAndMeidaManager();
-            return Result.successMsg("查询所有销售和媒介用户",allSaleList);
+            return Result.successMsg("查询所有销售和媒介用户",allSaleList);
 
         }else if ("saleDirector".equals(roleCode) || //销售总监
                 "kuaishou_operations_director".equals(roleCode) || //快手运营总监
@@ -121,7 +117,7 @@ public class SettlementController {
             ids = materialReportOverViewService.recursiveQuerySubordinate(userId);
         }
         List<Map<String,Object>> list = settlementInfoService.getUserByIds(ids);
-        return Result.successMsg("查询用户",list);
+        return Result.successMsg("查询用户",list);
     }
 
 
@@ -130,7 +126,7 @@ public class SettlementController {
     @GetMapping("/getAllOperationUser")
     public Result getAllOperationUser() {
         List<Map<String,Object>> list = cwjsPolicyInfoService.getAllOperationUser();
-        return Result.successMsg("查询运营用户列表",list);
+        return Result.successMsg("查询运营用户列表",list);
     }
 
 

+ 2 - 6
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java

@@ -5,19 +5,15 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.ctop.finance.policy.utils.Check;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementFileInfo;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
+import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementFileInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.service.ISettlementFileInfoService;
-import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
 import org.jeecg.modules.ctop.service.IMaterialReportOverViewService;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -97,7 +93,7 @@ public class SettlementFileController {
 
     @ApiOperation(value="结算单-账户截图上传", notes="结算单-账户截图上传")
     @PostMapping(value = "/insertAccountImages")
-    public Result insertAccountImages(@RequestBody ctopCwjsSettlementFileInfo settlementFileInfo) {
+    public Result insertAccountImages(@RequestBody CtopCwjsSettlementFileInfo settlementFileInfo) {
         if (Check.isNull(settlementFileInfo.getSettlementList())){
             return Result.errorMsg("账户截图不能为空!");
         }

+ 2 - 2
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementFileInfo.java

@@ -16,7 +16,7 @@ import java.util.List;
  **/
 
 @Data
-public class ctopCwjsSettlementFileInfo implements Serializable {
+public class CtopCwjsSettlementFileInfo implements Serializable {
 
     @TableId(type = IdType.AUTO)
     /**
@@ -107,6 +107,6 @@ public class ctopCwjsSettlementFileInfo implements Serializable {
     private Date updateTime;
 
     @TableField(exist = false)
-    private List<ctopCwjsSettlementFileInfo> settlementList;
+    private List<CtopCwjsSettlementFileInfo> settlementList;
 
 }

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementInfo.java

@@ -17,7 +17,7 @@ import java.util.Set;
  **/
 
 @Data
-public class ctopCwjsSettlementInfo implements Serializable {
+public class CtopCwjsSettlementInfo implements Serializable {
 
     @TableId(type = IdType.AUTO)
     /**

+ 27 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/CtopCwjsSlettementReport.java

@@ -0,0 +1,27 @@
+package org.jeecg.ctop.finance.settlement.entity.pojo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * 财务结算 计算利润表
+ * zian Y
+ **/
+
+@Data
+public class CtopCwjsSlettementReport implements Serializable {
+
+    private Long id;
+    private Integer policyId;
+    private String advertiserName;
+    private String productName;
+    private String policyDate;
+    private Integer mediaType;
+    private String createUserId;
+}

+ 28 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/CwjsProfitMapper.java

@@ -0,0 +1,28 @@
+package org.jeecg.ctop.finance.settlement.mapper;
+
+import io.lettuce.core.dynamic.annotation.Param;
+import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSlettementReport;
+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 java.util.List;
+import java.util.Map;
+
+
+/**
+ *
+ * @description:
+ *
+ * @return:
+ * @author: zianY
+ */
+public interface CwjsProfitMapper {
+
+
+    void replaceCwjsSlettementProfit(List<CtopCwjsSlettementReport> list);
+
+
+
+
+}

+ 19 - 10
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -1,8 +1,6 @@
 package org.jeecg.ctop.finance.settlement.mapper;
 
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import io.lettuce.core.dynamic.annotation.Param;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
 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;
@@ -34,6 +32,10 @@ public interface ReportSettlementMapper {
      * @return
      */
     List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShou(SettlementFileParamsVo paramsVo);
+    //获取快手 账户 日流水信息  代理商维度
+    List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShouAgent(SettlementFileParamsVo paramsVo);
+    // 获取快手 结算单 账户 和 代理商 维度
+    List<SettlementReportKuaiShouVo> getTransactionDayKuaiShouAgentAndAccount(SettlementFileParamsVo paramsVo);
 
 
     /**
@@ -47,28 +49,35 @@ public interface ReportSettlementMapper {
      * @param accountId
      * @return
      */
-   List<String> getAccountImagesBytedance(String accountId);
+   List<String> getAccountImagesBytedance(@Param("accountId") String accountId,@Param("uploadYears")String uploadYears);
 
 
     /**
      * 查询 头条利润表 总花费
      * @return
      */
-    List<Map<String,Object>> getProfitBytedanceCost(String uploadYears);
+    List<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);
 
     /**
-     * 查询 快手 利润表 总花费
-     * @param uploadYears
+     * 查询 快手 利润表 所有账户
+     * @param
      * @return
      */
-    List<Map<String,Object>> getProfitKuaiShou(String uploadYears);
+    List<Map<String,Object>> getProfitKuaiShouAccountCost(@Param("accountId")String accountId,@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 productId
+     * 查询 头条利润表  返点类型和比列
+     * @param
      * @return
      */
-    Map<String,Object> getProfitBytedanceSale(String productId);
+    List<Map<String,Object>> getProfitBytedance(@Param("productName") String productName,@Param("mediaType") String mediaType,@Param("startTime")String startTime,@Param("endTime")String endTime);
+
+    Map<String,Object> getProfitRebate(@Param("productName") String productName,@Param("startTime")String startTime,@Param("endTime")String endTime);
+
+    Map<String,Object> getProfitBytedanceSale(String accountId);
 
     Map<String,Object> getProfitBytedanceOperate(String accountId);
 

+ 3 - 4
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java

@@ -2,8 +2,7 @@ package org.jeecg.ctop.finance.settlement.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import io.lettuce.core.dynamic.annotation.Param;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementFileInfo;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
+import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementFileInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 
 import java.util.List;
@@ -18,7 +17,7 @@ import java.util.Map;
  * @author: zianY
  * @time: 2021/7/28 17:07
  */
-public interface SettlementFileInfoMapper extends BaseMapper<ctopCwjsSettlementFileInfo> {
+public interface SettlementFileInfoMapper extends BaseMapper<CtopCwjsSettlementFileInfo> {
 
     /**
      *查询 财务结算-结算单列表
@@ -49,5 +48,5 @@ public interface SettlementFileInfoMapper extends BaseMapper<ctopCwjsSettlementF
      * @param accountId
      * @return
      */
-    Map<String,String> getSettlementAccount(String accountId);
+    Map<String,String> getSettlementAccount(@Param("accountId")String accountId,@Param("mediaId") String mediaId);
 }

+ 10 - 3
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementInfoMapper.java

@@ -2,7 +2,7 @@ package org.jeecg.ctop.finance.settlement.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import io.lettuce.core.dynamic.annotation.Param;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
+import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
 
 import java.util.List;
 import java.util.Map;
@@ -17,14 +17,14 @@ import java.util.Set;
  * @author: zianY
  * @time: 2021/7/28 17:07
  */
-public interface SettlementInfoMapper extends BaseMapper<ctopCwjsSettlementInfo> {
+public interface SettlementInfoMapper extends BaseMapper<CtopCwjsSettlementInfo> {
 
     /**
      *查询 财务结算-账户列表
      * @param settlementInfo
      * @return
      */
-    List<ctopCwjsSettlementInfo> getSettlementList(ctopCwjsSettlementInfo settlementInfo);
+    List<CtopCwjsSettlementInfo> getSettlementList(CtopCwjsSettlementInfo settlementInfo);
 
     /**
      *修改财务结算账户状态
@@ -34,6 +34,13 @@ public interface SettlementInfoMapper extends BaseMapper<ctopCwjsSettlementInfo>
     void updSettlementStatusById(@Param("id") Long id, @Param("status") Integer status);
 
     /**
+     * 根据账户id 查看财务账户
+     * @param accountId
+     * @return
+     */
+   CtopCwjsSettlementInfo getSettlementByAccountId(String accountId);
+
+    /**
      * 删除财务结算账户
      * @param id
      */

+ 27 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/CwjsProfitMapper.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.ctop.finance.settlement.mapper.CwjsProfitMapper">
+
+
+    <insert id="replaceCwjsSlettementProfit">
+            replace into ctop_cwjs_slettement_report(
+            advertiser_name,
+            product_name,
+            policy_date,
+            create_user_id,
+            media_type,
+            policy_id
+            )
+            values
+            <foreach collection="list" item="l" separator=",">
+                (#{l.advertiserName},
+                #{l.productName},
+                #{l.policyDate},
+                #{l.createUserId},
+                #{l.mediaType},
+                #{l.policyId})
+            </foreach>
+    </insert>
+
+
+</mapper>

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

@@ -44,14 +44,14 @@
         ctop_cwjs_settlement_file_info
         where del_flag = 0
         AND account_id = #{accountId}
-
+        AND upload_years = #{uploadYears}
     </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,
@@ -73,54 +73,283 @@
 
 
 
+    <!-- 获取快手 账户 日流水信息  代理商维度-->
+    <select id="getAccountTransactionDayKuaiShouAgent" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
 
-    <!-- 查询 头条利润表 总花费-->
-    <select id="getProfitBytedanceCost" resultType="java.util.LinkedHashMap">
         SELECT
-            d.advertiser_id AS accountId,
-            SUM( d.cost ) AS cost,
-            SUM( d.cash_cost ) AS cashCost,
-            SUM( d.reward_cost ) rewardCost,
-            cwjs.product_id as productId,
-            p.product_name AS productName
-        FROM
-            ctop_account_transaction_day d
-                LEFT JOIN ctop_cwjs_settlement_info cwjs ON d.advertiser_id = cwjs.account_id
-                LEFT JOIN ctop_product p ON cwjs.product_id = p.id
+            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,
+		contract_rebate_real_charged_in_yuan AS contractRebateRealCharged,
+		direct_rebate_real_charged_in_yuan as directRebateRealCharged,
+		(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
-            cwjs.del_flag = 0
-        <if test="uploadYears !=null and uploadYears != ''">
-            AND DATE_FORMAT(d.date,'%Y-%m') = #{uploadYears}
-        </if>
+            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,
+                            account_id AS accountId,
+                            total_charged_in_yuan as dailyCharge,
+                            contract_rebate_real_charged_in_yuan as contractRebateRealCharged,
+                            direct_rebate_real_charged_in_yuan as directRebateRealCharged,
+                            ( 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
+                            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
+                            account_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
+                            ctop_kuaishou_daily_flows
+                        WHERE
+                            account_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>
+
+
+
+
+
+    <!-- 查询 头条利润表 所用账户-->
+    <select id="getProfitBytedanceAccountCost" resultType="java.util.LinkedHashMap">
+      <!--  SELECT
+        d.advertiser_id AS accountId,
+        SUM( d.cost ) AS cost,
+        SUM( d.cash_cost ) AS cashCost,
+        SUM( d.reward_cost ) rewardCost,
+        pd.id as productId,
+        pd.product_name AS productName
+        FROM
+        ctop_account_transaction_day d
+        LEFT JOIN ctop_user_allocation u ON d.advertiser_id = u.account_id
+        LEFT JOIN ctop_project p ON u.project_id = p.id
+        LEFT JOIN ctop_product pd on pd.id = p.product_id
+        where (u.media_id = 1 or u.media_id = 3)
+            <if test="accountId !=null and accountId != ''">
+                AND d.advertiser_id = #{accountId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND d.date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND d.date &lt;= #{endTime}
+            </if>
         GROUP BY
             d.advertiser_id;
+-->
+
+        SELECT
+        d.advertiser_id AS accountId,
+        SUM( d.cost ) AS cost,
+        SUM( d.cash_cost ) AS cashCost,
+        SUM( d.reward_cost ) rewardCost,
+        p.id AS productId,
+        p.product_name AS productName
+        FROM
+        ctop_account_transaction_day d,
+        ctop_cwjs_settlement_info c,
+        ctop_product p
+        WHERE
+        d.advertiser_id = c.account_id
+        AND c.product_id = p.id
+        <if test="accountId !=null and accountId != ''">
+            AND d.advertiser_id = #{accountId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            AND d.date &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            AND d.date &lt;= #{endTime}
+        </if>
+        GROUP BY
+        d.advertiser_id;
 
     </select>
 
 
+    <!-- 查询 头条利润表 总花费-->
+    <select id="getProfitBytedanceCost" resultType="java.util.LinkedHashMap">
+       <!-- SELECT
+        d.advertiser_id AS accountId,
+        SUM( d.cost ) AS cost,
+        SUM( d.cash_cost ) AS cashCost,
+        SUM( d.reward_cost ) rewardCost,
+        pd.id as productId,
+        pd.product_name AS productName
+        FROM
+        ctop_account_transaction_day d
+        LEFT JOIN ctop_user_allocation u ON d.advertiser_id = u.account_id
+        LEFT JOIN ctop_project p ON u.project_id = p.id
+        LEFT JOIN ctop_product pd on pd.id = p.product_id
+        where (u.media_id = 1 or u.media_id = 3)
+            <if test="accountId !=null and accountId != ''">
+                AND d.advertiser_id = #{accountId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND d.date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND d.date &lt;= #{endTime}
+            </if>
+-->
+
+        SELECT
+        d.advertiser_id AS accountId,
+        SUM( d.cost ) AS cost,
+        SUM( d.cash_cost ) AS cashCost,
+        SUM( d.reward_cost ) rewardCost
+        FROM
+        ctop_account_transaction_day d
+        <if test="accountId !=null and accountId != ''">
+            AND d.advertiser_id = #{accountId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            AND d.date &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            AND d.date &lt;= #{endTime}
+        </if>
+
+    </select>
+
+
+
+    <!-- 查询 头条利润表  返点类型和比列-->
+    <select id="getProfitBytedance" resultType="java.util.LinkedHashMap">
 
-    <!-- 查询 头条利润表  销售人员姓名 以及 返点类型和比列-->
-    <select id="getProfitBytedanceSale" resultType="java.util.LinkedHashMap">
         SELECT
         pp.create_user_id,
-        su.realname AS saleName,
         cp.rebate_type AS rebateType,
         cp.rebate_rate AS rebateRate,
         cp.approved_status AS approvedStatus,
         cp.policy_start_date as policyStartDate,
-        DATE_FORMAT(cp.policy_start_date,'%Y-%m') as policyStart,
         cp.policy_end_date as policyEndDate,
-        DATE_FORMAT(cp.policy_end_date,'%Y-%m') as policyEnd
+        cp.create_time as createTime
         FROM
         ctop_cwjs_policy_product pp
-        LEFT JOIN sys_user su ON pp.create_user_id = su.id
         LEFT JOIN ctop_cwjs_policy_info cp ON cp.id = pp.policy_id
         WHERE
         pp.del_flag = 0
         AND cp.del_flag = 0
-        <if test="productId !=null and productId != ''">
-            AND pp.id = #{productId}
+        and cp.approved_status = 3
+        <if test="mediaType !=null and mediaType != ''">
+            AND cp.media_type = #{mediaType}
+        </if>
+        <if test="productName !=null and productName != ''">
+            AND pp.policy_product_name = #{productName}
         </if>
+        <if test="startTime !=null and startTime != ''">
+            AND  (cp.policy_start_date &gt;= #{startTime} or cp.policy_start_date &lt;= #{endTime})
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            AND (cp.policy_end_date &gt;= #{startTime} or cp.policy_end_date &lt;= #{endTime})
+        </if>
+    </select>
+
+
+    <!-- 查询 利润表  返点类型和比列-->
+    <select id="getProfitRebate" resultType="java.util.LinkedHashMap">
+        SELECT
+        p.id,
+        p.rebate_type AS rebateType,
+        p.rebate_rate AS rebateRate
+        FROM
+        ctop_cwjs_slettement_report r
+        LEFT JOIN ctop_cwjs_policy_info p ON r.policy_id = p.id
+        WHERE
+        p.del_flag = 0
+        <if test="productName !=null and productName != ''">
+            AND r.product_name = #{productName}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            AND  r.policy_date &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            AND r.policy_date &lt;= #{endTime}
+        </if>
+        GROUP BY
+        p.id
+        limit 1
+
+
+
+
+    </select>
+
+
+    <!-- 查询 头条利润表  销售人员姓名 -->
+    <select id="getProfitBytedanceSale" resultType="java.util.LinkedHashMap">
+
+        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
+        <if test="accountId !=null and accountId != ''">
+            AND f.account_id = #{accountId}
+        </if>
+        limit 1
 
 
     </select>
@@ -129,7 +358,7 @@
 
     <!-- 查询 头条利润表  广告主和运营和运营所属区域-->
     <select id="getProfitBytedanceOperate" resultType="java.util.LinkedHashMap">
-        select
+        <!--select
         u.advertiser_id,
         u.advertiser_name as advertiserName,
         u.user_id,
@@ -143,41 +372,134 @@
               <if test="accountId !=null and accountId != ''">
                   AND u.account_id = #{accountId}
               </if>
-          </where>
+          </where>-->
+        SELECT
+        c.create_user_id AS operateUserId,
+        p.user_name AS operateName,
+        IFNULL( p.nick_name, '' ) AS operateArea,
+        d.NAME AS advertiserName
+        FROM
+        ctop_cwjs_settlement_file_info c
+        LEFT JOIN user_company p on c.create_user_id = p.user_id
+        LEFT JOIN ctop_advertiser d on d.id = c.advertiser_id
+        where c.del_flag = 0
+        <if test="accountId !=null and accountId != ''">
+            AND c.account_id = #{accountId}
+        </if>
+        limit 1
+
     </select>
 
 
 <!-- 查询 快手 利润表 总花费-->
-    <select id="getProfitKuaiShou" resultType="java.util.LinkedHashMap">
-        SELECT
+    <select id="getProfitKuaiShouAccountCost" resultType="java.util.LinkedHashMap">
+        <!--SELECT
             d.account_id AS accountId,
             SUM( d.daily_charge ) AS cost,
             SUM( d.real_charged ) AS cashCost,
-            cwjs.product_id as productId,
-            p.product_name AS productName
+            pd.id as productId,
+            pd.product_name AS productName
         FROM
             ctop_kuaishou_daily_flows d
-                LEFT JOIN ctop_cwjs_settlement_info cwjs ON d.account_id = cwjs.account_id
-                LEFT JOIN ctop_product p ON cwjs.product_id = p.id
-        WHERE
-            cwjs.del_flag = 0
-        <if test="uploadYears !=null and uploadYears != ''">
-          and DATE_FORMAT(d.date,'%Y-%m') = #{uploadYears}
+        LEFT JOIN ctop_user_allocation u ON d.account_id = u.account_id
+        LEFT JOIN ctop_project p ON u.project_id = p.id
+        LEFT JOIN ctop_product pd on pd.id = p.product_id
+        where (u.media_id = 2 or u.media_id = 4)
+        <if test="accountId !=null and accountId != ''">
+            AND d.account_id = #{accountId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            AND d.date &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            AND d.date &lt;= #{endTime}
         </if>
         GROUP BY
-            d.account_id;
+            d.account_id;-->
+
+        SELECT
+        d.account_id as accountId,
+        d.user_id AS ksId,
+        SUM(d.total_charged_in_yuan) AS cost,
+        SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)) as cashCost,
+        c.product_id as productId,
+        (SELECT p.product_name from ctop_product p where p.id = c.product_id) AS productName,
+        (SELECT d.name as advertiserName from ctop_advertiser d where d.id = c.advertiser_id) advertiserName
+        FROM
+        ctop_kuaishou_daily_agent d
+        RIGHT JOIN	ctop_cwjs_settlement_info c
+        on d.account_id = c.account_id
+        and c.kuai_shou_id = d.user_id
+        <where>
+            <if test="accountId !=null and accountId != ''">
+                AND d.account_id = #{accountId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND d.date_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND d.date_time &lt;= #{endTime}
+            </if>
+        </where>
+
+        GROUP BY d.account_id
     </select>
 
 
+<!-- 查询 快手 利润表 总花费-->
+    <select id="getProfitKuaiShouCost" resultType="java.util.LinkedHashMap">
+        <!--SELECT
+        d.account_id AS accountId,
+        SUM( d.daily_charge ) AS cost,
+        SUM( d.real_charged ) AS cashCost,
+        pd.id as productId,
+        pd.product_name AS productName
+        FROM
+        ctop_kuaishou_daily_flows d
+        LEFT JOIN ctop_user_allocation u ON d.account_id = u.account_id
+        LEFT JOIN ctop_project p ON u.project_id = p.id
+        LEFT JOIN ctop_product pd on pd.id = p.product_id
+        where (u.media_id = 2 or u.media_id = 4)
+        <if test="accountId !=null and accountId != ''">
+            AND d.account_id = #{accountId}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            AND d.date &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            AND d.date &lt;= #{endTime}
+        </if>-->
+        SELECT
+        d.account_id,
+        d.user_id AS ksId,
+        SUM(d.total_charged_in_yuan) AS cost,
+        SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)) as cashCost
+        FROM
+        ctop_kuaishou_daily_agent d
+        <where>
+            <if test="accountId !=null and accountId != ''">
+                AND d.account_id = #{accountId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND d.date_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND d.date_time &lt;= #{endTime}
+            </if>
+        </where>
+
+
+    </select>
+
 
 
     <!-- 查询 快手 利润表  广告主和运营和运营所属区域-->
     <select id="getProfitKuaiShouOperate" resultType="java.util.LinkedHashMap">
-        select
+       <!-- select
         u.advertiser_id,
         u.account_id,
         b.user_id as ksId,
-        u.advertiser_name as advertiserName,
+        d.name as advertiserName,
         u.user_id,
         u.user_name as operateName,
         u.auth_name,
@@ -186,11 +508,27 @@
         ctop_user_allocation u
         LEFT JOIN ctop_kuaishou_advertiser_base_info b on u.account_id = b.account_id
         LEFT JOIN user_company p on p.user_id = u.user_id
+        LEFT JOIN ctop_advertiser d on u.advertiser_id = d.id
     <where>
         <if test="accountId !=null and accountId != ''">
             AND u.account_id = #{accountId}
         </if>
-    </where>
+    </where>-->
+
+        SELECT
+        c.create_user_id AS operateUserId,
+        p.user_name AS operateName,
+        IFNULL( p.nick_name, '' ) AS operateArea,
+        d.NAME AS advertiserName
+        FROM
+        ctop_cwjs_settlement_file_info c
+        LEFT JOIN user_company p on c.create_user_id = p.user_id
+        LEFT JOIN ctop_advertiser d on d.id = c.advertiser_id
+        where c.del_flag = 0
+            <if test="accountId !=null and accountId != ''">
+                AND c.account_id = #{accountId}
+            </if>
+            limit 1
     </select>
 
 

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

@@ -108,7 +108,9 @@
         cwjs.create_user_id as saleUserId,
         ( SELECT su.realname FROM sys_user su WHERE su.id = cwjs.create_user_id LIMIT 1 ) saleUserName,
         f.create_user_id as operateUserId,
-        ( SELECT su.realname FROM sys_user su WHERE su.id = f.create_user_id LIMIT 1 ) operateUserName
+        ( SELECT su.realname FROM sys_user su WHERE su.id = f.create_user_id LIMIT 1 ) operateUserName,
+        cwjs.create_time,
+        cwjs.update_time
         FROM ctop_cwjs_settlement_file_info f
         LEFT JOIN ctop_cwjs_settlement_info cwjs on f.account_id = cwjs.account_id
         where f.del_flag = 0
@@ -155,8 +157,8 @@
                     #{item}
                 </foreach>
             </if>
-
         </where>
+        ORDER BY t.update_time DESC,t.projectId
     </select>
 
 
@@ -177,19 +179,20 @@
     <select id="getAccountNumAndImgNum" resultType="java.util.Map">
         SELECT * from
                      (
-                         SELECT
-                                COUNT(account_id) as accountNum
-                         FROM
-                             ctop_cwjs_settlement_info
-                            where del_flag = 0
+                    SELECT
+                    COUNT(c.account_id) as accountNum
+                    FROM
+                    ctop_cwjs_settlement_info c
+                    LEFT JOIN ctop_user_allocation u on c.account_id = u.account_id
+                    where del_flag = 0
                         <if test="advertiserId !=null and advertiserId != ''">
-                            AND advertiser_id = #{advertiserId}
+                            AND c.advertiser_id = #{advertiserId}
                         </if>
                         <if test="productId !=null and productId != ''">
-                            AND product_id = #{productId}
+                            AND c.product_id = #{productId}
                         </if>
                         <if test="mediaId !=null and mediaId != ''">
-                            AND media_id = #{mediaId}
+                            AND c.media_id = #{mediaId}
                         </if>
                          ) t1,
                      (
@@ -207,6 +210,9 @@
                         <if test="mediaId !=null and mediaId != ''">
                             AND media_id = #{mediaId}
                         </if>
+                           <if test="uploadYears !=null and uploadYears != ''">
+                            AND upload_years = #{uploadYears}
+                        </if>
                      ) t2
     </select>
 
@@ -223,8 +229,9 @@
             ctop_user_allocation u
         WHERE
             f.account_id = u.account_id
-          AND u.account_status = 0
+          -- AND u.account_status = 0
           AND u.account_id = #{accountId}
+          and f.media_id = #{mediaId}
             LIMIT 1
 
     </select>

+ 9 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementInfoMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper">
 
     <!-- 查询 财务结算-账户列表-->
-    <select id="getSettlementList" resultType="org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo">
+    <select id="getSettlementList" resultType="org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo">
         SELECT * from (
         SELECT
             id,
@@ -73,6 +73,14 @@
     </update>
 
 
+    <!-- 根据账户id 查看财务账户 -->
+    <select id="getSettlementByAccountId" resultType="org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo">
+        select * from ctop_cwjs_settlement_info
+        WHERE del_flag = 0
+          and account_id = #{accountId}
+    </select>
+
+
     <!-- 删除财务结算账户 -->
     <update id="deleteSettlementById">
         UPDATE ctop_cwjs_settlement_info

+ 10 - 4
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/IReportSettlementService.java

@@ -1,11 +1,9 @@
 package org.jeecg.ctop.finance.settlement.service;
 
-import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
+import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
@@ -28,6 +26,14 @@ public interface IReportSettlementService {
 
 
 
-    Result sendMessageToOperate(String userId);
+    Result sendMessageToOperate();
+    Result sendMessageToOperateDemo(String userId);
+
+
+
+
+
+    void cwjsPRofit(CwjsPolicyInfo cwjsPolicyInfo);
+
 
 }

+ 3 - 5
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementFileInfoService.java

@@ -3,21 +3,19 @@ package org.jeecg.ctop.finance.settlement.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.github.pagehelper.PageInfo;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementFileInfo;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
+import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementFileInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 
-import java.util.List;
 import java.util.Map;
 
-public interface ISettlementFileInfoService extends IService<ctopCwjsSettlementFileInfo> {
+public interface ISettlementFileInfoService extends IService<CtopCwjsSettlementFileInfo> {
 
     Result<PageInfo<Map<String,String>>> getSettlementSheetList(SettlementFileParamsVo paramsVo, Integer pageNo, Integer pageSize);
 
 
     Result deleteSettlementFile(SettlementFileParamsVo paramsVo);
 
-    Result insertAccountImages(ctopCwjsSettlementFileInfo settlementFileInfo);
+    Result insertAccountImages(CtopCwjsSettlementFileInfo settlementFileInfo);
 
     Result getAccountNumAndImgNum(SettlementFileParamsVo paramsVo);
 

+ 4 - 5
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementInfoService.java

@@ -2,23 +2,22 @@ package org.jeecg.ctop.finance.settlement.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-public interface ISettlementInfoService extends IService<ctopCwjsSettlementInfo> {
+public interface ISettlementInfoService extends IService<CtopCwjsSettlementInfo> {
 
-    Result getSettlementList(ctopCwjsSettlementInfo settlementInfo, Integer pageNo, Integer pageSize);
+    Result getSettlementList(CtopCwjsSettlementInfo settlementInfo, Integer pageNo, Integer pageSize);
 
     Result updSettlementStatusById(Long id,Integer status);
 
     Result deleteSettlementById(Long id);
 
-    Result settlementAccountImport(ctopCwjsSettlementInfo settlementInfo,MultipartFile file);
+    Result settlementAccountImport(CtopCwjsSettlementInfo settlementInfo, MultipartFile file);
 
 
     List<Map<String,Object>> getUserByIds(Set userIds);

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

@@ -4,7 +4,9 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 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;
@@ -14,25 +16,35 @@ 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.ctop.finance.policy.entity.CwjsPolicyInfo;
+import org.jeecg.ctop.finance.policy.entity.CwjsPolicyProduct;
+import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyProductMapper;
 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.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;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 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.net.URL;
 import java.net.URLEncoder;
 import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
+import java.util.*;
 import java.util.List;
-import java.util.Map;
 import java.util.stream.Collectors;
 
 
@@ -48,6 +60,9 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     @Resource
     private MailLogMapper mailLogMapper;
 
+    @Resource
+    private CwjsProfitMapper cwjsProfitMapper;
+
 
     @Override
     public List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance() {
@@ -76,7 +91,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             List<String> accountIdList = reportSettlementMapper.getAccountIdBytedance(paramsVo);
 
             if (Check.isNull(accountIdList)){
-                return Result.errorMsg("该广告主和产品下无法查询到绑定的账户信息");
+                return Result.errorMsg("该广告主和产品下无法查询到绑定的账户信息");
             }
 
             int num = 0;
@@ -189,21 +204,27 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     row.createCell(12).setCellValue(vo.getFrozen());
                 }
 
-                //先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray
-                ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+
 
                 //查询 图片 url
-                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId);
+                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId,paramsVo.getUploadYears());
 
                 if (!Check.isNull(imageUrlList)){
                     for (int j = 0; j < imageUrlList.size(); j++) {
+                        //先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray
+                        ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
                         String imagePath = imageUrlList.get(j);
                         //通过图片网络地址 获取输入流
-                        InputStream is = createExcelByTemplate.getInputStreamByUrl(imagePath);
+                       /* InputStream is = createExcelByTemplate.getInputStreamByUrl(imagePath);
                         BufferedImage bufferImg = ImageIO.read(is);
+*/
+                        URL url = new URL(imagePath);
+                        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;
                         //anchor主要用于设置图片的属性
-                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 2, settlementList.size() + 6 +(j*40), (short) 10, 90*(j+1));
+                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex+(5*j)+50*j, (short) 25, startIndex+(5*j)+50*(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);
                         //插入图片
@@ -214,7 +235,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             }
 
             if(accountIdList.size() == num){
-                return Result.errorMsg("暂无数据");
+                return Result.errorMsg("暂无账户流水数据");
             }
 
             response.setCharacterEncoding("UTF-8");
@@ -222,7 +243,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.getUploadYears()+"-头条结算单.xlsx", "UTF-8"));
             OutputStream output = response.getOutputStream();
             BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
             wb.write(bufferedOutPut);
@@ -257,11 +278,11 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             font.setFontHeightInPoints((short) 12);//设置字体大小
             style.setFont(font);
 
-            //查询 账户id
+            //查询 需要导出的数据的账户id
             List<String> accountIdList = reportSettlementMapper.getAccountIdBytedance(paramsVo);
 
             if (Check.isNull(accountIdList)){
-                return Result.errorMsg("该广告主和产品下无法查询到绑定的快手账户信息");
+                return Result.errorMsg("该广告主和产品下无法查询到绑定的快手账户信息");
             }
 
             int num = 0;
@@ -272,7 +293,15 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 paramsVo.setAccountId(accountId);
 
                 //获取账户 日流水数据  根据账户id 和 年月 查询数据
-                List<SettlementReportKuaiShouVo> settlementList = reportSettlementMapper.getAccountTransactionDayKuaiShou(paramsVo);
+               /* List<SettlementReportKuaiShouVo> settlementList = new ArrayList<>();
+                //查询账户维度
+                settlementList = reportSettlementMapper.getAccountTransactionDayKuaiShou(paramsVo);
+                if (Check.isNull(settlementList)){
+                    //查询代理商维度
+                    settlementList = reportSettlementMapper.getAccountTransactionDayKuaiShouAgent(paramsVo);
+                }
+*/
+                List<SettlementReportKuaiShouVo> settlementList = reportSettlementMapper.getTransactionDayKuaiShouAgentAndAccount(paramsVo);
                 if (Check.isNull(settlementList)){
                     num++;
                     continue;
@@ -298,23 +327,23 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
                 //5:创建第2行的单元格
                 HSSFCell cell = row.createCell(0);     //第一个单元格
-                cell.setCellValue("   日期   ");         //设定值
+                cell.setCellValue("日期");         //设定值
                 cell.setCellStyle(style);          //内容居中
 
                 cell = row.createCell(1);
-                cell.setCellValue("      账户快手ID      ");
+                cell.setCellValue("账户快手ID");
                 cell.setCellStyle(style);
 
                 cell = row.createCell(2);
-                cell.setCellValue("      广告主账户ID      ");
+                cell.setCellValue("广告主账户ID");
                 cell.setCellStyle(style);
 
                 cell = row.createCell(3);
-                cell.setCellValue("      日总花费      ");
+                cell.setCellValue("日总花费");
                 cell.setCellStyle(style);
 
                 cell = row.createCell(4);
-                cell.setCellValue("      充值花费      ");
+                cell.setCellValue("充值花费");
                 cell.setCellStyle(style);
 
                 cell = row.createCell(5);
@@ -350,8 +379,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 cell.setCellStyle(style);
 
 
-
-
                 for (int i = 0; i < settlementList.size(); i++) {
                     SettlementReportKuaiShouVo vo = settlementList.get(i);
                     //创建行 (表头占0-1行 所以 从 2开始)
@@ -374,23 +401,27 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     row.createCell(12).setCellValue(vo.getBalance());
                 }
 
-                //先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray
-                ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+
 
                 //查询 图片 url
-                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId);
+                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId,paramsVo.getUploadYears());
 
                 if (!Check.isNull(imageUrlList)){
                     for (int j = 0; j < imageUrlList.size(); j++) {
+                        //先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray
+                        ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
                         String imagePath = imageUrlList.get(j);
                         //通过图片网络地址 获取输入流
-                        InputStream is = createExcelByTemplate.getInputStreamByUrl(imagePath);
+                       /* InputStream is = createExcelByTemplate.getInputStreamByUrl(imagePath);
                         BufferedImage bufferImg = ImageIO.read(is);
+                        */
+                        URL url = new URL(imagePath);
+                        Image imageTookittitle = Toolkit.getDefaultToolkit().createImage(url);
+                        BufferedImage bufferImg = createExcelByTemplate.toBufferedImage(imageTookittitle);
                         ImageIO.write(bufferImg, imagePath.substring(imagePath.lastIndexOf(".") + 1), byteArrayOut);
                         //anchor主要用于设置图片的属性
                         int startIndex = settlementList.size()+7;
-
-                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 2, startIndex+(5*j)+50*j, (short) 10, startIndex+(5*j)+50*(j+1));
+                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 0, startIndex+(5*j)+50*j, (short) 25, startIndex+(5*j)+50*(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);
                         //插入图片
@@ -401,7 +432,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             }
 
             if(accountIdList.size() == num){
-                return Result.errorMsg("暂无数据");
+                return Result.errorMsg("暂无数据");
             }
 
             response.setCharacterEncoding("UTF-8");
@@ -409,7 +440,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.getUploadYears()+"-快手结算单.xlsx", "UTF-8"));
             OutputStream output = response.getOutputStream();
             BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
             wb.write(bufferedOutPut);
@@ -426,7 +457,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
 
 
-
+    @Resource
+    private SettlementInfoMapper settlementInfoMapper;
     /**
      *
      * @description: 财务结算 利润表导出 头条
@@ -439,47 +471,118 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     public Result porfitReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
 
         try {
-            //查询 头条利润表 总花费
-            List<Map<String,Object>> list = reportSettlementMapper.getProfitBytedanceCost(paramsVo.getUploadYears());
+            //查询 头条利润表 时间段内 所有 账户
+            List<Map<String,Object>> list = reportSettlementMapper.getProfitBytedanceAccountCost(null,paramsVo.getStartTime(),paramsVo.getEndTime());
             if (Check.isNull(list)){
-                return Result.errorMsg("暂无数据");
+                return Result.errorMsg("暂无数据");
             }
             List<ProfitReportBytedanceVo> resultList = new ArrayList<>(list.size());
             for (Map<String, Object> map : list) {
-                ProfitReportBytedanceVo vo = new ProfitReportBytedanceVo();
-                vo.setCost(map.getOrDefault("cost","")+"");//总消耗
-                vo.setCashCost(map.getOrDefault("cashCost","")+"");//现金消耗
-                vo.setRewardCost(map.getOrDefault("rewardCost","")+"");//赠款消耗
-                vo.setProductName(map.getOrDefault("productName","")+"");//产品名称
-                //查询 头条利润表  销售人员姓名 以及 返点类型和比列
-                Map<String,Object> slaeMap = reportSettlementMapper.getProfitBytedanceSale(map.get("productId")+"");
-                if (!Check.isNull(slaeMap)){
-                    vo.setSaleName(slaeMap.getOrDefault("saleName","")+"");//销售
-                    // 当前查询时间 与 销售政策 开始 截至时间 是否匹配
-                    if (SettlementUtil.isEffectiveDate(paramsVo.getUploadYears(),slaeMap.get("policyStart")+"",slaeMap.get("policyEnd")+"")){
-                        //销售政策状态 为 通过 显示 返点类型 和 返点比列
-                        if (StringUtils.equals(slaeMap.getOrDefault("approvedStatus","")+"","3")){
-                            vo.setRebateType(slaeMap.getOrDefault("rebateType","")+"");//返点类型
-                            vo.setRebateRate(slaeMap.getOrDefault("rebateRate","")+"");//返点比列
+              /*  //查看该账户 状态信息
+                QueryWrapper<CtopCwjsSettlementInfo> settlementAccountQw = new QueryWrapper<>();
+                settlementAccountQw.eq("account_id",map.get("accountId"));
+                //账户状态 0-开 1-关
+                settlementAccountQw.eq("status",0);
+                //(0,正常,1已删除)
+                settlementAccountQw.eq("del_flag",0);
+                List<CtopCwjsSettlementInfo> settlementAccountList =  settlementInfoMapper.selectList(settlementAccountQw);
+                if (Check.isNull(settlementAccountList)){
+                    continue;
+                }*/
+
+                ProfitReportBytedanceVo voSource = new ProfitReportBytedanceVo();
+                //查询销售
+                Map<String,Object> slaeMap = reportSettlementMapper.getProfitBytedanceSale(map.get("accountId")+"");
+                voSource.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName","")+"");//销售
+
+                //产品名称
+                voSource.setProductName(map.getOrDefault("productName","")+"");
+
+                Map<String,Object> operateMap = reportSettlementMapper.getProfitBytedanceOperate(map.get("accountId")+"");
+                if (!Check.isNull(operateMap)){
+                    voSource.setAdvertiserName(operateMap.getOrDefault("advertiserName","")+"");//广告主名称
+                    voSource.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
+                    voSource.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
+                }
+
+                //查询 头条利润表  返点类型和比列
+                List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("productName")+"","1",paramsVo.getStartTime(),paramsVo.getEndTime());
+                List listPolicyTIme = new ArrayList();
+                for (Map<String, Object> rate : rateMap) {
+                    listPolicyTIme.add(rate.get("policyStartDate"));
+                    listPolicyTIme.add(rate.get("policyEndDate"));
+                }
+                //政策时间 去重 排序
+                List<Object> times = SettlementUtil.sortlistTest(listPolicyTIme);
+                // 使用政策的时间段 拼接 开始 和 截至 时间
+                List<Map<String, String>> arrayList = new ArrayList<>();
+                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.get(i+1).toString());
+                    i += 1;
+                    arrayList.add(mapTime);
+                }
+
+                //政策所有时间点
+                List<String> policyDaysList = new ArrayList<>();
+                for (Map<String, String> stringMap : arrayList) {
+                    ProfitReportBytedanceVo vo = new ProfitReportBytedanceVo();
+                    //使用政策 返点类型和比例
+                    Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("productName")+"",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){
+                            vo.setRebateType("返货");
+                        }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 2){
+                            vo.setRebateType("返现+返货");
                         }
+                        vo.setRebateRate(policyRateMap.getOrDefault("rebateRate","")+"%");//返点比列
+                    }else {
+                        vo.setRebateType("");
                     }
+                    // 时间段内 账户流水 信息
+                    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","")+"");//赠款消耗
+                    BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
+                    resultList.add(vo);
+                    policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"),stringMap.get("endDate")));
                 }
 
-                Map<String,Object> operateMap = reportSettlementMapper.getProfitBytedanceOperate(map.get("accountId")+"");
-                if (!Check.isNull(operateMap)){
-                    vo.setAdvertiserName(operateMap.getOrDefault("advertiserName","")+"");//广告主名称
-                    vo.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
-                    vo.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
+                //不使用政策 的时间段
+                // 获取两个日期之间 所有的 时间 年-月-日
+                List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(paramsVo.getStartTime(),paramsVo.getEndTime());
+                // 时间差集(所有时间段 - 使用政策的时间段)
+                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"));
+                  */
+                    vo.setRebateType("");//返点类型
+                    vo.setRebateRate("");//返点比列
+                    //账户流水 信息
+                    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","")+"");//赠款消耗
+                    BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
+                    resultList.add(vo);
                 }
-                resultList.add(vo);
             }
-
             Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("头条利润单", "头条利润单"), ProfitReportBytedanceVo.class, resultList);
-
             try {
                 response.setCharacterEncoding("UTF-8");
                 response.setHeader("content-Type", "application/vnd.ms-excel");
-                response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("头条利润单.xls", "UTF-8"));
+                response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("头条利润单.xlsx", "UTF-8"));
                 workbook.write(response.getOutputStream());
             } catch (IOException e) {
                 throw new RuntimeException(e);
@@ -507,40 +610,116 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     public Result porfitReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
 
         try {
-            //查询 快手利润表 总花费
-            List<Map<String,Object>> list = reportSettlementMapper.getProfitKuaiShou(paramsVo.getUploadYears());
+            //查询 快手利润表  时间段内的 所有账户
+            List<Map<String,Object>> list = reportSettlementMapper.getProfitKuaiShouAccountCost(null,paramsVo.getStartTime(),paramsVo.getEndTime());
             if (Check.isNull(list)){
-                return Result.errorMsg("暂无数据");
+                return Result.errorMsg("暂无数据");
             }
             List<ProfitReportKuaiShouVo> resultList = new ArrayList<>(list.size());
             for (Map<String, Object> map : list) {
-                ProfitReportKuaiShouVo vo = new ProfitReportKuaiShouVo();
-                vo.setAccountId(map.getOrDefault("accountId","")+"");//账户id
-                vo.setCost(map.getOrDefault("cost","")+"");//总消耗
-                vo.setCashCost(map.getOrDefault("cashCost","")+"");//现金消耗
-                vo.setProductName(map.getOrDefault("productName","")+"");//产品名称
-                //查询  销售人员姓名 以及 返点类型和比列
-                Map<String,Object> slaeMap = reportSettlementMapper.getProfitBytedanceSale(map.get("productId")+"");
-                if (!Check.isNull(slaeMap)){
-                    vo.setSaleName(slaeMap.getOrDefault("saleName","")+"");//销售
-                    // 当前查询时间 与 销售政策 开始 截至时间 是否匹配
-                    if (SettlementUtil.isEffectiveDate(paramsVo.getUploadYears(),slaeMap.get("policyStart")+"",slaeMap.get("policyEnd")+"")){
-                        //销售政策状态 为 通过 显示 返点类型 和 返点比列
-                        if (StringUtils.equals(slaeMap.getOrDefault("approvedStatus","")+"","3")){
-                            vo.setRebateType(slaeMap.getOrDefault("rebateType","")+"");//返点类型
-                            vo.setRebateRate(slaeMap.getOrDefault("rebateRate","")+"");//返点比列
-                        }
-                    }
+              /*  //查看该账户 状态信息
+                QueryWrapper<CtopCwjsSettlementInfo> settlementAccountQw = new QueryWrapper<>();
+                settlementAccountQw.eq("account_id",map.get("accountId"));
+                //账户状态 0-开 1-关
+                settlementAccountQw.eq("status",0);
+                //(0,正常,1已删除)
+                settlementAccountQw.eq("del_flag",0);
+                List<CtopCwjsSettlementInfo> settlementAccountList =  settlementInfoMapper.selectList(settlementAccountQw);
+                if (Check.isNull(settlementAccountList)){
+                    continue;
                 }
+*/
+                ProfitReportKuaiShouVo voSource = new ProfitReportKuaiShouVo();
+
+                voSource.setAccountId(map.getOrDefault("accountId","")+"");//账户id
+                voSource.setProductName(map.getOrDefault("productName","")+"");//产品名称
+                voSource.setKsId(map.getOrDefault("ksId","")+"");//快手id
+                voSource.setAdvertiserName(map.getOrDefault("advertiserName","")+"");//广告主名称
+
+                //查询销售
+                Map<String,Object> slaeMap = reportSettlementMapper.getProfitBytedanceSale(map.get("accountId")+"");
+                voSource.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName","")+"");//销售
 
                 Map<String,Object> operateMap = reportSettlementMapper.getProfitKuaiShouOperate(map.get("accountId")+"");
                 if (!Check.isNull(operateMap)){
-                    vo.setKsId(operateMap.getOrDefault("ksId","")+"");//快手id
-                    vo.setAdvertiserName(operateMap.getOrDefault("advertiserName","")+"");//广告主名称
-                    vo.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
-                    vo.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
+                    voSource.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
+                    voSource.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
+                }
+
+                //查询 快手利润表  返点类型和比列
+                List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("productName")+"","2",paramsVo.getStartTime(),paramsVo.getEndTime());
+                List listPolicyTIme = new ArrayList();
+                for (Map<String, Object> rate : rateMap) {
+                    listPolicyTIme.add(rate.get("policyStartDate"));
+                    listPolicyTIme.add(rate.get("policyEndDate"));
+                }
+
+                //政策时间 去重 排序
+                List<Object> times = SettlementUtil.sortlistTest(listPolicyTIme);
+                // 使用政策的时间段 拼接 开始 和 截至 时间
+                List<Map<String, String>> arrayList = new ArrayList<>();
+                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.get(i+1).toString());
+                    i += 1;
+                    arrayList.add(mapTime);
                 }
-                resultList.add(vo);
+
+                //政策所有时间点
+                List<String> policyDaysList = new ArrayList<>();
+                for (Map<String, String> stringMap : arrayList) {
+                    ProfitReportKuaiShouVo vo = new ProfitReportKuaiShouVo();
+                    //使用政策 返点类型和比例
+                    Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("productName")+"",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){
+                            vo.setRebateType("返货");
+                        }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 2){
+                            vo.setRebateType("返现+返货");
+                        }
+                        vo.setRebateRate(policyRateMap.getOrDefault("rebateRate","")+"%");//返点比列
+                    }else {
+                        vo.setRebateType("");
+                    }
+
+
+                    // 时间段内 账户流水 信息
+                    List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitKuaiShouCost(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","")+"");//现金消耗
+                    BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
+                    resultList.add(vo);
+                    policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"),stringMap.get("endDate")));
+                }
+
+                //不使用政策 的时间段
+                // 获取两个日期之间 所有的 时间 年-月-日
+                List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(paramsVo.getStartTime(),paramsVo.getEndTime());
+                // 时间差集(所有时间段 - 使用政策的时间段)
+                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) {
+                    ProfitReportKuaiShouVo vo = new ProfitReportKuaiShouVo();
+                    // 不使用 政策 则 返点为空
+                    //政策 返点类型和比例
+                    /* 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.getProfitKuaiShouCost(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","")+"");//现金消耗
+                    BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
+                    resultList.add(vo);
+                }
+
             }
 
             Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("快手利润单", "快手利润单"), ProfitReportKuaiShouVo.class, resultList);
@@ -567,22 +746,23 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
      *
      * @description: 给运营发送消息
      *
-     * @param userId
+     * @param
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
     @Override
-    public Result sendMessageToOperate(String userId) {
-        int month = Calendar.getInstance().get(Calendar.MONTH) + 1;
+    public Result sendMessageToOperate() {
+        //上个月份
+        int month = Calendar.getInstance().get(Calendar.MONTH);
         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();
         for (Map<String, Object> userMap : userList) {
-             userId = userMap.get("userId").toString();
+             String userId = userMap.get("userId").toString();
             //查询运营下的 账户 和 产品信息
             List<Map<String,Object>> productList = reportSettlementMapper.getAccountAndProductByOperate(userId);
             if (Check.isNull(productList)){
@@ -595,19 +775,142 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             productInfo = StringUtils.join(product.toArray(),"、");
 
             //发送微信通知
-            JSONObject jsonObject =  mailLogMapper.getWChatIdByUserId("f990f815ecef43fab9cbe1bb22bb6d63");
+            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);
+    }
+
+    @Override
+    public Result sendMessageToOperateDemo(String userId) {
+        //上个月份
+        int month = Calendar.getInstance().get(Calendar.MONTH);
+        int productNum = 0;
+        int accountNum = 0;
+        String productInfo = null;
+        String message =  "{0},您好!您{1}月份有{2}个产品的账户需要进行媒体后台消耗截图上传,共计{3}个账户。产品分别为:{4}。请及时上传,多谢配合!";
+
+        //查询所有 运营绑定的账户
+        List<Map<String,Object>> userList = reportSettlementMapper.getAccountOperateUserId();
+        for (Map<String, Object> userMap : userList) {
+             String realUserId = userMap.get("userId").toString();
+            //查询运营下的 账户 和 产品信息
+            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(),"、");
+
+            //发送微信通知
+            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("成功。",null);
+        return Result.successMsg("发送微信通知成功-test",null);
     }
 
 
-    public static void main(String[] args) {
-        String a =  "woshiwoshi{1}woshi{2}111{3}===";
+
+    @Resource
+    private CwjsPolicyProductMapper cwjsPolicyProductMapper;
+
+
+    @Override
+    public void cwjsPRofit(CwjsPolicyInfo cwjsPolicyInfo) {
+
+        // 获取两个日期之间 所有的 时间 年-月-日
+        List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(cwjsPolicyInfo.getPolicyStartDate(),cwjsPolicyInfo.getPolicyEndDate());
+        //查看 政策下的产品
+        List<CwjsPolicyProduct> productList = cwjsPolicyProductMapper.queryProductsByPolicyId(cwjsPolicyInfo.getId());
+        if (!Check.isNull(productList)){
+            if (!Check.isNull(betweenDaysList)){
+                List<CtopCwjsSlettementReport> reportList = new ArrayList<>();
+                for (CwjsPolicyProduct product : productList) {
+                    for (String day : betweenDaysList) {
+                        CtopCwjsSlettementReport report = new CtopCwjsSlettementReport();
+                        report.setPolicyId(cwjsPolicyInfo.getId());
+                        report.setAdvertiserName(cwjsPolicyInfo.getAdvertiserName());
+                        report.setProductName(product.getPolicyProductName());
+                        report.setMediaType(cwjsPolicyInfo.getMediaType());
+                        report.setCreateUserId(cwjsPolicyInfo.getCreateUserId());
+                        report.setPolicyDate(day);
+                        reportList.add(report);
+                    }
+                }
+                cwjsProfitMapper.replaceCwjsSlettementProfit(reportList);
+            }
+        }
+
+
+
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+    public static void main(String[] args) throws Exception{
+       /* String a =  "woshiwoshi{1}woshi{2}111{3}===";
         String b = MessageFormat.format(a,"测试","我","你","结束");
         System.out.println(a);
-        System.out.println(b);
+        System.out.println(b);*/
+
+
+        List list = new ArrayList();
+
+        list.add("2021-07-01");
+       // list.add("2021-07-02");
+        list.add("2021-07-10");
+        list.add("2021-07-05");
+        list.add("2021-07-15");
+
+
+/*
+
+
+        // 获取两个日期之间 所有的 时间 年-月-日
+        List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes("2021-07-01","2021-07-20");
+
+        List<Object> times = SettlementUtil.sortlistTest(list);
+
+        //差集
+        List<String>  reduceList = betweenDaysList.stream().filter(item -> !times.contains(item)).collect(Collectors.toList());
+
+
+        System.out.println(betweenDaysList);
+        System.out.println(times);
+        System.out.println(reduceList);
+
+       List<Map<String,String>> stringList = SettlementUtil.getTime(reduceList);
+
+        System.out.println(stringList);
+
+
+*/
+
+        //String imagePath = "https://media-1301855440.cos.ap-chongqing.myqcloud.com/undefined/2021-08-25/9774099-1-1629874464883.jpg";
+        String imagePath = "https://media-1301855440.cos.ap-chongqing.myqcloud.com/undefined/2021-08-25/9677284-1629874460562.jpg";
+        //通过图片网络地址 获取输入流
+        InputStream is = createExcelByTemplate.getInputStreamByUrl(imagePath);
+        BufferedImage bufferImg = ImageIO.read(is);
+        System.out.println(bufferImg);
+
+
+
     }
 
 }

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

@@ -1,45 +1,30 @@
 package org.jeecg.ctop.finance.settlement.service.serviceImpl;
 
-import cn.afterturn.easypoi.excel.ExcelImportUtil;
-import cn.afterturn.easypoi.excel.entity.ImportParams;
-import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
-import cn.hutool.core.bean.copier.CopyOptions;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
-import org.antlr.v4.runtime.misc.Array2DHashSet;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.ctop.finance.policy.utils.Check;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementFileInfo;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
-import org.jeecg.ctop.finance.settlement.entity.vo.AccountImportVo;
+import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementFileInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.mapper.SettlementFileInfoMapper;
 import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
 import org.jeecg.ctop.finance.settlement.service.ISettlementFileInfoService;
-import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
 import org.jeecg.ctop.finance.utils.SettlementUtil;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.mapping.AccessOptions;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.util.*;
-import java.util.stream.Collectors;
 
 
 @Slf4j
 @Service
-public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInfoMapper, ctopCwjsSettlementFileInfo> implements ISettlementFileInfoService {
+public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInfoMapper, CtopCwjsSettlementFileInfo> implements ISettlementFileInfoService {
 
     @Resource
     private SettlementFileInfoMapper settlementFileInfoMapper;
@@ -130,7 +115,7 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
         List<Map<String,String>> list = settlementFileInfoMapper.getSettlementSheetList(paramsVo);
         for (Map<String, String> map : list) {
             //图片数量
-            QueryWrapper<ctopCwjsSettlementFileInfo> settlementFileInfoQw = new QueryWrapper<>();
+            QueryWrapper<CtopCwjsSettlementFileInfo> settlementFileInfoQw = new QueryWrapper<>();
             //广告主id
             settlementFileInfoQw.eq("advertiser_id",map.get("advertiserId"));
             //产品id
@@ -143,14 +128,14 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
             settlementFileInfoQw.eq("create_user_id",map.get("operateUserId"));
             //(0,正常,1已删除)
             settlementFileInfoQw.eq("del_flag",0);
-            List<ctopCwjsSettlementFileInfo> settlementFileList =  settlementFileInfoMapper.selectList(settlementFileInfoQw);
+            List<CtopCwjsSettlementFileInfo> settlementFileList =  settlementFileInfoMapper.selectList(settlementFileInfoQw);
             map.put("imgNum",Check.isNull(settlementFileList) ? "0" : String.valueOf(settlementFileList.size()));
 
         }
 
 
         PageInfo<Map<String,String>> pageInfo = new PageInfo<>(list);
-        return Result.successMsg("财务结算-结算单列表查询成功", pageInfo);
+        return Result.successMsg("财务结算-结算单列表查询成功", pageInfo);
     }
 
 
@@ -165,7 +150,7 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
     @Override
     public Result deleteSettlementFile(SettlementFileParamsVo paramsVo) {
         settlementFileInfoMapper.deleteSettlementFile(paramsVo);
-        return Result.successMsg("删除成功",null);
+        return Result.successMsg("删除成功",null);
     }
 
 
@@ -177,21 +162,21 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
      */
     @Override
     @Transactional
-    public Result insertAccountImages(ctopCwjsSettlementFileInfo settlementFileInfo) {
+    public Result insertAccountImages(CtopCwjsSettlementFileInfo settlementFileInfo) {
 
-        for (ctopCwjsSettlementFileInfo settlement : settlementFileInfo.getSettlementList()) {
+        for (CtopCwjsSettlementFileInfo settlement : settlementFileInfo.getSettlementList()) {
 
             settlement.setAccountId(SettlementUtil.subAccountName(settlement.getFileName()));
 
-            Map<String,String> map = settlementFileInfoMapper.getSettlementAccount(settlement.getFileName());
+           /* Map<String,String> map = settlementFileInfoMapper.getSettlementAccount(settlement.getAccountId(),String.valueOf(settlementFileInfo.getMediaId()));
             if (Check.isNull(map)){
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                return Result.errorMsg("无法查询到账户【"+settlement.getAccountId()+"】开户信息,请联系销售绑定账户。");
-            }
+                return Result.errorMsg("无法查询到账户【"+settlement.getAccountId()+"】信息,请到账户列表上传正确的账户信息");
+            }*/
             BeanUtils.copyProperties(settlementFileInfo,settlement,SettlementUtil.getNullPropertyNames(settlementFileInfo));
             settlementFileInfoMapper.insert(settlement);
         }
-        return Result.successMsg("账户截图上传成功",null);
+        return Result.successMsg("账户截图上传成功",null);
     }
 
 
@@ -204,7 +189,7 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
     @Override
     public Result getAccountNumAndImgNum(SettlementFileParamsVo paramsVo) {
         Map<String,String> map =  settlementFileInfoMapper.getAccountNumAndImgNum(paramsVo);
-        return Result.successMsg("查询账户数量以及图片数量成功",map);
+        return Result.successMsg("查询账户数量以及图片数量成功",map);
 
     }
 

+ 125 - 21
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java

@@ -3,38 +3,55 @@ package org.jeecg.ctop.finance.settlement.service.serviceImpl;
 import cn.afterturn.easypoi.excel.ExcelImportUtil;
 import cn.afterturn.easypoi.excel.entity.ImportParams;
 import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
+import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
+import cn.com.ctop.alarm.modules.service.impl.RuleAccountTemplateServiceImpl;
+import cn.com.ctop.common.module.entity.SysLog;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.SysLogMapper;
+import cn.com.ctop.common.module.service.impl.UserAllocationServiceImpl;
+import cn.com.ctop.common.module.utils.Check;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import io.lettuce.core.dynamic.annotation.Param;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
+import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.AccountImportVo;
 import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
 import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
-import org.jeecg.ctop.finance.utils.SettlementUtil;
+import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 
 @Slf4j
 @Service
-public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper, ctopCwjsSettlementInfo> implements ISettlementInfoService {
+public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper, CtopCwjsSettlementInfo> implements ISettlementInfoService {
 
     @Resource
     private SettlementInfoMapper settlementInfoMapper;
 
 
+    @Resource
+    SysLogMapper sysLogMapper;
+
+
     /**
      *
      * @description: 查询 财务结算-账户列表
@@ -46,13 +63,16 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
      * @author: zianY
      */
     @Override
-    public Result getSettlementList(ctopCwjsSettlementInfo settlementInfo, Integer pageNo, Integer pageSize) {
+    public Result getSettlementList(CtopCwjsSettlementInfo settlementInfo, Integer pageNo, Integer pageSize) {
         PageHelper.startPage(pageNo, pageSize);
-        List<ctopCwjsSettlementInfo> list = settlementInfoMapper.getSettlementList(settlementInfo);
-        PageInfo<ctopCwjsSettlementInfo> pageInfo = new PageInfo<>(list);
-        return Result.successMsg("财务结算-账户列表查询成功", pageInfo);
+        List<CtopCwjsSettlementInfo> list = settlementInfoMapper.getSettlementList(settlementInfo);
+        PageInfo<CtopCwjsSettlementInfo> pageInfo = new PageInfo<>(list);
+        return Result.successMsg("财务结算-账户列表查询成功", pageInfo);
     }
 
+
+    @Autowired
+    private UserAllocationServiceImpl userAllocationService;
     /**
      * @description: 财务结算-修改账户状态
      * @param id
@@ -62,9 +82,77 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
      */
     @Override
     public Result updSettlementStatusById(Long id, Integer status) {
+        // 修改状态
         settlementInfoMapper.updSettlementStatusById(id,status);
-        return Result.successMsg("财务结算-修改账户状态成功。.", null);
+
+        //同步 状态
+       CtopCwjsSettlementInfo settlementInfo =  settlementInfoMapper.selectById(id);
+
+        UserAllocation userAllocation = userAllocationService.getByAccountId(new Long(settlementInfo.getAccountId()));
+        if (!Check.isNull(userAllocation)){
+            userAllocation.setAccountStatus(status);
+            userAllocationService.editUserAlloCation(userAllocation);
+        }else{
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            SysLog sysLog = new SysLog();
+            sysLog.setLogType(2);
+            sysLog.setLogContent("修改账户状态为==="+status);
+            sysLog.setRequestParam(String.valueOf(status));
+            sysLog.setOperateType(10001);
+            sysLog.setUserid(user.getId());
+            sysLog.setCreateBy(user.getRealname());
+            sysLog.setCreateTime(new Date());
+            sysLogMapper.insert(sysLog);
+        }
+
+        return Result.successMsg("财务结算-修改账户状态成功", null);
+    }
+
+
+/*
+    public Result<UserAllocation> edit(UserAllocation userAllocation) {
+        Result<UserAllocation> result = new Result<>();
+        UserAllocation userAllocationEntity = userAllocationService.getById(userAllocation.getId());
+        if (userAllocationEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = userAllocationService.updateById(userAllocation);
+            Integer accountStatus = userAllocation.getAccountStatus();
+            if (!Check.isNull(accountStatus)) {
+                if (accountStatus == 1) {
+                    QueryWrapper<RuleAccountTemplate> ruleAccountTemplateQueryWrapper = new QueryWrapper<>();
+                    ruleAccountTemplateQueryWrapper.eq("account_id", userAllocationEntity.getAccountId());
+                    RuleAccountTemplate updateRuleAccountTemplate = new RuleAccountTemplate();
+                    updateRuleAccountTemplate.setTemplateStatus(1);
+                    ruleAccountTemplateService.update(updateRuleAccountTemplate, ruleAccountTemplateQueryWrapper);
+                }
+            }
+
+            UserAllocation update = userAllocationService.getById(userAllocation.getId());
+            QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
+            memberQueryWrapper.eq("user_id", update.getUserId());
+            memberQueryWrapper.eq("project_id", update.getProjectId());
+            memberQueryWrapper.last("limit 1");
+            ProjectMember member = memberMapper.selectOne(memberQueryWrapper);
+            if (Check.isNull(member)) {
+                ProjectMember addMember = new ProjectMember();
+                addMember.setProjectId(userAllocationEntity.getProjectId());
+                addMember.setUserId(userAllocationEntity.getUserId());
+                addMember.setUserName(userAllocationEntity.getUserName());
+                String roleCode = sysRoleService.getRoleCodeByUserId(userAllocationEntity.getUserId());
+                if (!Check.isNull(roleCode)) {
+                    addMember.setRoleCode(roleCode);
+                }
+                projectMemberService.save(addMember);
+            }
+
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+        return result;
     }
+    */
 
     /**
      *
@@ -77,7 +165,7 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
     @Override
     public Result deleteSettlementById(Long id) {
         settlementInfoMapper.deleteSettlementById(id);
-        return Result.successMsg("财务结算-删除成功。.", null);
+        return Result.successMsg("财务结算-删除成功", null);
     }
 
 
@@ -92,11 +180,11 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
      * @time: 2021/7/30 16:26
      */
     @Override
-    public Result settlementAccountImport(ctopCwjsSettlementInfo settlementInfo, MultipartFile file) {
+    public Result settlementAccountImport(CtopCwjsSettlementInfo settlementInfo, MultipartFile file) {
 
             try {
-                LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-                settlementInfo.setCreateUserId(user.getId());
+                //LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+                //settlementInfo.setCreateUserId(user.getId());
                 //settlementInfo.setCreateUserId("b161b7d9793942f980dbfe8c931cd1b0");
                 ImportParams importParams = new ImportParams();
                 //表格标题行数
@@ -115,18 +203,34 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
                 importParams.setNeedCheckOrder(true);
                 ExcelImportResult<AccountImportVo> importResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AccountImportVo.class,importParams);
                 if (importResult.getList().size() < 1){
-                    return Result.error("读取Excel失败,数据不能为空,请重新检查数据并导入");
+                    return Result.error("读取Excel失败,数据不能为空,请重新检查数据并导入");
                 }
-                importResult.getList().forEach(importVo -> {
+
+                for (AccountImportVo importVo : importResult.getList()) {
+                    if (Check.isNull(importVo.getAccountId())){
+                        continue;
+                    }
                     BeanUtils.copyProperties(importVo,settlementInfo);
-                    settlementInfoMapper.insert(settlementInfo);
-                });
+                    //根据账户id 查看
+                    CtopCwjsSettlementInfo cwjs = settlementInfoMapper.getSettlementByAccountId(importVo.getAccountId());
+                    if (Check.isNull(cwjs)){
+                       // BeanUtils.copyProperties(importVo,settlementInfo);
+                        settlementInfoMapper.insert(settlementInfo);
+                    }else {
+                        settlementInfo.setId(cwjs.getId());
+                        settlementInfoMapper.updateById(settlementInfo);
+                    }
+
+                }
+
+
+
 
             }catch (Exception e){
                 e.printStackTrace();
                 return Result.error("账户数据上传失败,请使用正确的模板导入!");
             }
-            return Result.successMsg("账户数据上传成功。",null);
+            return Result.successMsg("账户数据上传成功",null);
         }
 
 

+ 205 - 20
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java

@@ -8,11 +8,14 @@ import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
+import java.time.LocalDateTime;
+import java.time.Period;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * zian Y
@@ -24,7 +27,7 @@ public class SettlementUtil {
     public static String getFileNameNoEx(String filename) {
         if ((filename != null) && (filename.length() > 0)) {
             int dot = filename.lastIndexOf('.');
-            if ((dot >-1) && (dot < (filename.length()))) {
+            if ((dot > -1) && (dot < (filename.length()))) {
                 return filename.substring(0, dot);
             }
         }
@@ -34,12 +37,13 @@ public class SettlementUtil {
     /**
      * 格式:123456-1
      * 截取 账户 id
+     *
      * @param str
      * @return
      */
-    public static String subAccountName(String str){
-        if (!Check.isNull(str)){
-            if (str.contains("-")){
+    public static String subAccountName(String str) {
+        if (!Check.isNull(str)) {
+            if (str.contains("-")) {
                 return str.substring(0, str.indexOf("-"));
             }
         }
@@ -51,11 +55,11 @@ public class SettlementUtil {
     /**
      * @Description: 忽略null值/只拷贝非null属性
      */
-    public static String[] getNullPropertyNames (Object source) {
+    public static String[] getNullPropertyNames(Object source) {
         final BeanWrapper src = new BeanWrapperImpl(source);
         java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
         Set<String> emptyNames = new HashSet<String>();
-        for(java.beans.PropertyDescriptor pd : pds) {
+        for (java.beans.PropertyDescriptor pd : pds) {
             Object srcValue = src.getPropertyValue(pd.getName());
             if (srcValue == null) emptyNames.add(pd.getName());
         }
@@ -64,9 +68,9 @@ public class SettlementUtil {
     }
 
 
-
     /**
      * 获取网络图片转成字节流
+     *
      * @param strUrl 完整图片地址
      * @return 图片资源数组
      */
@@ -90,13 +94,14 @@ public class SettlementUtil {
 
     /**
      * 从输入流中获取字节流数据
+     *
      * @param inStream 输入流
-     * @return  图片流
+     * @return 图片流
      */
     private static byte[] readInputStream(InputStream inStream) throws Exception {
         ByteArrayOutputStream outStream = new ByteArrayOutputStream();
         // 设置每次读取缓存区大小
-        byte[] buffer = new byte[1024*10];
+        byte[] buffer = new byte[1024 * 10];
         int len = 0;
         while ((len = inStream.read(buffer)) != -1) {
             outStream.write(buffer, 0, len);
@@ -107,10 +112,11 @@ public class SettlementUtil {
 
     /**
      * 获取日期的年月
+     *
      * @param strDate
      * @return
      */
-    public static int getYearMonth(String strDate)throws Exception{
+    public static int getYearMonth(String strDate) throws Exception {
 
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date date = simpleDateFormat.parse(strDate);
@@ -118,23 +124,23 @@ public class SettlementUtil {
         Calendar cal = Calendar.getInstance();
         cal.setTime(date);//设置时间
         int year = cal.get(Calendar.YEAR);//获取年份
-        int month=cal.get(Calendar.MONTH);//获取月份
-        return year*100+month;//返回年份乘以100加上月份的值,因为月份最多2位数,所以年份乘以100可以获取一个唯一的年月数值
+        int month = cal.get(Calendar.MONTH);//获取月份
+        return year * 100 + month;//返回年份乘以100加上月份的值,因为月份最多2位数,所以年份乘以100可以获取一个唯一的年月数值
     }
 
 
-
     /**
      * 判断当前时间是否在[startTime, endTime]区间
      * 年-月   2021-08
-     * @param nowStrTime 当前时间
+     *
+     * @param nowStrTime   当前时间
      * @param startStrTime 开始时间
-     * @param endStrTime 结束时间
+     * @param endStrTime   结束时间
      * @return
      * @author zian Y
      */
     public static boolean isEffectiveDate(String nowStrTime, String startStrTime, String endStrTime) throws Exception {
-       // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
         Date nowTime = simpleDateFormat.parse(nowStrTime);
         Date startTime = simpleDateFormat.parse(startStrTime);
@@ -158,7 +164,186 @@ public class SettlementUtil {
     }
 
 
+    public static long DateCompare(String s1, String s2) {
+        try {
+
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date d1 = simpleDateFormat.parse(s1);
+            Date d2 = simpleDateFormat.parse(s2);
+            // LocalDateTime d1 = LocalDateTime.parse(s1, DateTimeFormatter.ISO_LOCAL_DATE);
+            //LocalDateTime d2 = LocalDateTime.parse(s2, DateTimeFormatter.ISO_LOCAL_DATE);
+            //排序规则
+            return ((d1.getTime()) - (d2.getTime()));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return 0;
+    }
+
+    public static List<String> sortlistTest(List<String> list) {
+        //去重
+        List<String> newlist = new ArrayList<String>();
+        for (int i = 0; i < list.size(); i++) {
+            if (!newlist.contains(list.get(i))) {
+                newlist.add(list.get(i));
+            }
+        }
+        String tmp;
+        for (int i = 1; i < newlist.size(); i++) {
+            tmp = newlist.get(i);
+            int j = i - 1;
+            for (; j >= 0 && (DateCompare(tmp, newlist.get(j)) < 0); j--) {
+                newlist.set(j + 1, newlist.get(j));
+            }
+            newlist.set(j + 1, tmp);
+        }
+        return newlist;
+    }
+
+
+    /**
+     * 获取 两个日期之间的所有 日期
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    public static List<String> getAllDatesOfTwoTimes(String startDate, String endDate) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<String> dateList = new ArrayList<String>();
+        try {
+            Date dateOne = sdf.parse(startDate);
+            Date dateTwo = sdf.parse(endDate);
+
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(dateOne);
+
+            dateList.add(startDate);
+            while (calendar.getTime().before(dateTwo)) { //倒序时间,顺序after改before其他相应的改动。
+                calendar.add(Calendar.DAY_OF_MONTH, 1);
+                dateList.add(sdf.format(calendar.getTime()));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateList;
+    }
+
+
+    public static List<Map<String, String>> getTime( List<String> list) {
+        //初始化list,且该list中的日期是升序的。
+        //List<String> list = Arrays.asList("2020-11-19","2020-11-20","2020-11-21","2021-07-20");
+       /* List<String> list = Arrays.asList("2021-07-02", "2021-07-03", "2021-07-04", "2021-07-06",
+                "2021-07-07", "2021-07-08", "2021-07-09", "2021-07-11", "2021-07-12",
+                "2021-07-13", "2021-07-14", "2021-07-16", "2021-07-17", "2021-07-18",
+                "2021-07-19", "2021-07-20", "2021-07-21", "2021-07-22", "2021-07-23",
+                "2021-07-24", "2021-07-25", "2021-07-26", "2021-07-27", "2021-07-28",
+                "2021-07-29", "2021-07-30");
+        */
+        List<Map<String, String>> arrayList = new ArrayList<>();
+        int num = 0;
+        for (int i = 0; i < list.size(); i = num) {
+            String start = list.get(i);
+            String end = "";
+            if (i == list.size() - 1) {
+                end = start;
+            }
+            int n = 0;
+            for (int j = i + 1; j < list.size(); j++) {
+                //判断当前日期的后一天与list中该元素的下一个元素是否相等
+                if (getSpecifiedDayAfter(list.get(j - 1)).equals(list.get(j))) {
+                    end = list.get(j);
+                    n++;
+                    num++;
+                    continue;
+                } else {
+                    //list中该元素不是连续的
+                    if (n == 0) {
+                        end = list.get(j - 1);
+                    }
+                    break;
+                }
+            }
+            num = num + 1;
+            HashMap<String, String> map = new HashMap<>();
+            map.put("startDate", start);
+            map.put("endDate", end);
+            arrayList.add(map);
+        }
+
+       // System.out.println(arrayList);
+        return arrayList;
+
 
+}
+
+    /**
+     * 获取当前日期的后一天
+     * @param specifiedDay
+     * @return
+     */
+    public static String getSpecifiedDayAfter(String specifiedDay) {
+        Calendar c = Calendar.getInstance();
+        Date date = null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        c.setTime(date);
+        int day = c.get(Calendar.DATE);
+        c.set(Calendar.DATE, day + 1);
+        String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayAfter;
+    }
+
+    public static void main(String[] args) {
+
+
+
+            List list = new ArrayList();
+
+
+            Map map1 = new HashMap();
+            map1.put("startTime","2021-07-01");
+            map1.put("endTime","2021-07-05");
+
+            Map map2 = new HashMap();
+            map2.put("startTime","2021-07-10");
+            map2.put("endTime","2021-07-15");
+
+
+            list.add("2021-07-01");
+            list.add("2021-07-02");
+            //list.add("2021-07-03");
+            list.add("2021-07-04");
+            list.add("2021-07-05");
+
+
+
+
+            // 获取两个日期之间 所有的 时间 年-月-日
+            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes("2021-07-01","2021-07-10");
+
+            List<Object> times = SettlementUtil.sortlistTest(list);
+
+            //差集
+            List<String>  reduceList = betweenDaysList.stream().filter(item -> !times.contains(item)).collect(Collectors.toList());
+
+
+            System.out.println(betweenDaysList);
+            System.out.println(times);
+            System.out.println(reduceList);
+
+            List<Map<String, String>> stringList = SettlementUtil.getTime(reduceList);
+
+            System.out.println(stringList);
+
+
+
+
+
+    }
 
 
 

+ 42 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/createExcelByTemplate.java

@@ -4,6 +4,9 @@ package org.jeecg.ctop.finance.utils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.util.IOUtils;
 
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
@@ -49,6 +52,45 @@ public class createExcelByTemplate {
         return null;
     }
 
+    /**
+     *
+     * @param image 图片url
+     * @return
+     */
+    public static BufferedImage toBufferedImage(Image image) {
+        if (image instanceof BufferedImage) {
+            return (BufferedImage) image;
+        }
+        // This code ensures that all the pixels in the image are loaded
+        image = new ImageIcon(image).getImage();
+        BufferedImage bimage = null;
+        GraphicsEnvironment ge = GraphicsEnvironment
+                .getLocalGraphicsEnvironment();
+        try {
+            int transparency = Transparency.OPAQUE;
+            GraphicsDevice gs = ge.getDefaultScreenDevice();
+            GraphicsConfiguration gc = gs.getDefaultConfiguration();
+            bimage = gc.createCompatibleImage(image.getWidth(null),
+                    image.getHeight(null), transparency);
+        } catch (HeadlessException e) {
+            // The system does not have a screen
+        }
+        if (bimage == null) {
+            // Create a buffered image using the default color model
+            int type = BufferedImage.TYPE_INT_RGB;
+            bimage = new BufferedImage(image.getWidth(null),
+                    image.getHeight(null), type);
+        }
+        // Copy image to buffered image
+        Graphics g = bimage.createGraphics();
+        // Paint the image onto the buffered image
+        g.drawImage(image, 0, 0, null);
+        g.dispose();
+        return bimage;
+    }
+
+
+
 
 
 }

+ 37 - 0
jeecg-boot-finance/src/test/java/org/jeecg/modules/finance/FinanceTest.java

@@ -2,10 +2,14 @@ package org.jeecg.modules.finance;
 
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
 import com.alibaba.fastjson.JSONObject;
 import org.jeecg.JeecgSystemApplication;
+import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
+import org.jeecg.ctop.finance.policy.service.ICwjsPolicyInfoService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
@@ -57,5 +61,38 @@ public class FinanceTest {
         System.out.println(str);
         System.out.println(str3);
     }
+    @Resource
+    ICwjsPolicyInfoService policyInfoService;
+    @Test
+    public void ICwjsPolicyInfoServiceTest(){
+        CwjsPolicyInfo cwjsPolicyInfo = new CwjsPolicyInfo();
+        cwjsPolicyInfo.setAdvertiserName("厕所");
+        cwjsPolicyInfo.setProductName("厕所");
+        cwjsPolicyInfo.setMediaType(2);
+        cwjsPolicyInfo.setCreateUserId("26bbe90edc5b475ca41ec3f76aa65067");
+        cwjsPolicyInfo.setPolicyStartDate("2021-08-10");
+        cwjsPolicyInfo.setPolicyEndDate("2021-08-15");
+        boolean ok = policyInfoService.isExistCwjsPolicyInfo(cwjsPolicyInfo);
+        System.out.println(ok);
+
+        cwjsPolicyInfo.setPolicyStartDate("2021-08-08");
+        cwjsPolicyInfo.setPolicyEndDate("2021-08-09");
+        System.out.println(policyInfoService.isExistCwjsPolicyInfo(cwjsPolicyInfo));
+
+        cwjsPolicyInfo.setPolicyStartDate("2021-08-08");
+        cwjsPolicyInfo.setPolicyEndDate("2021-08-10");
+        System.out.println(policyInfoService.isExistCwjsPolicyInfo(cwjsPolicyInfo));
+
+        cwjsPolicyInfo.setPolicyStartDate("2021-08-11");
+        cwjsPolicyInfo.setPolicyEndDate("2021-08-12");
+        System.out.println(policyInfoService.isExistCwjsPolicyInfo(cwjsPolicyInfo));
 
+    }
+
+    @Autowired
+    IKuaishouAudienceReportDailyGenderService audienceReportDailyGenderService;
+    @Test
+    public void IKuaishouAudienceReportDailyGenderServiceTest(){
+        audienceReportDailyGenderService.mergeAudienceReportDailyDate("2021-07-20");
+    }
 }

+ 6 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 用户分配
@@ -60,4 +61,9 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     int updateProjectStrategyStatus(@Param("accountId") Long accountId,@Param("projectStrategy") Integer projectStrategy);
 
     List<Long> queryAutomaticAccounts(@Param("projectId") Long projectId);
+
+
+
+    Map<String,Object>getCwjsSettlementByAccountId(String accountId);
+    void updCwjsSettlementStatus(@Param("id") String id, @Param("status") Integer status);
 }

+ 21 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -239,4 +239,25 @@
         AND auto_delivery = 1
     </select>
 
+
+
+
+    <!-- 根据账户id 查看财务账户 -->
+    <select id="getCwjsSettlementByAccountId" resultType="java.util.LinkedHashMap">
+        select * from ctop_cwjs_settlement_info
+        WHERE del_flag = 0
+          and account_id = #{accountId}
+    </select>
+<!-- 修改状态 -->
+    <update id="updCwjsSettlementStatus">
+        UPDATE ctop_cwjs_settlement_info
+        SET STATUS = #{status}
+        WHERE
+            id = #{id}
+
+    </update>
+
+
+
+
 </mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.common.api.vo.Result;
 
 import java.util.List;
 import java.util.Map;
@@ -68,4 +69,8 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     List<Long> queryAutomaticAccounts(Long projectId);
 
+
+
+    Result<UserAllocation> editUserAlloCation(UserAllocation userAllocation);
+
 }

+ 91 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -1,8 +1,14 @@
 package cn.com.ctop.common.module.service.impl;
 
+import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
+import cn.com.ctop.alarm.modules.mapper.RuleAccountTemplateMapper;
+import cn.com.ctop.common.module.entity.SysLog;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.SysLogMapper;
+import cn.com.ctop.common.module.mapper.SysRoleMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
@@ -10,13 +16,15 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.ctop.entity.ProjectMember;
+import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @Description: 用户分配
@@ -217,4 +225,83 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     public List<Long> queryAutomaticAccounts(Long projectId) {
         return userAllocationMapper.queryAutomaticAccounts(projectId);
     }
+
+    @Autowired
+    RuleAccountTemplateMapper ruleAccountTemplateMapper;
+
+    @Autowired
+    SysRoleMapper sysRoleMapper;
+
+    @Autowired
+    ProjectMemberMapper projectMemberMapper;
+
+    @Autowired
+    ProjectMemberMapper memberMapper;
+
+    @Autowired
+    SysLogMapper sysLogMapper;
+
+    @Override
+    public Result<UserAllocation> editUserAlloCation(UserAllocation userAllocation) {
+        Result<UserAllocation> result = new Result<>();
+        UserAllocation userAllocationEntity = userAllocationMapper.selectById(userAllocation.getId());
+        if (userAllocationEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            int ok = userAllocationMapper.updateById(userAllocation);
+            Integer accountStatus = userAllocation.getAccountStatus();
+            if (!Check.isNull(accountStatus)) {
+                if (accountStatus == 1) {
+                    QueryWrapper<RuleAccountTemplate> ruleAccountTemplateQueryWrapper = new QueryWrapper<>();
+                    ruleAccountTemplateQueryWrapper.eq("account_id", userAllocationEntity.getAccountId());
+                    RuleAccountTemplate updateRuleAccountTemplate = new RuleAccountTemplate();
+                    updateRuleAccountTemplate.setTemplateStatus(1);
+                    ruleAccountTemplateMapper.update(updateRuleAccountTemplate, ruleAccountTemplateQueryWrapper);
+                }
+            }
+
+            UserAllocation update = userAllocationMapper.selectById(userAllocation.getId());
+            QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
+            memberQueryWrapper.eq("user_id", update.getUserId());
+            memberQueryWrapper.eq("project_id", update.getProjectId());
+            memberQueryWrapper.last("limit 1");
+            ProjectMember member = memberMapper.selectOne(memberQueryWrapper);
+            if (Check.isNull(member)) {
+                ProjectMember addMember = new ProjectMember();
+                addMember.setProjectId(userAllocationEntity.getProjectId());
+                addMember.setUserId(userAllocationEntity.getUserId());
+                addMember.setUserName(userAllocationEntity.getUserName());
+                String roleCode = sysRoleMapper.getRoleCodeByUserId(userAllocationEntity.getUserId());
+                if (!Check.isNull(roleCode)) {
+                    addMember.setRoleCode(roleCode);
+                }
+                projectMemberMapper.insert(addMember);
+            }
+
+            if (ok == 1) {
+                result.success("修改成功!");
+            }
+
+            //同步 财务结算 状态
+            Map<String,Object> cwjs = userAllocationMapper.getCwjsSettlementByAccountId(String.valueOf(userAllocationEntity.getAccountId()));
+            if (!Check.isNull(cwjs)){
+                userAllocationMapper.updCwjsSettlementStatus(cwjs.get("id").toString(),accountStatus);
+            }
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            SysLog sysLog = new SysLog();
+            sysLog.setLogType(2);
+            sysLog.setLogContent("修改账户状态为==="+accountStatus);
+            sysLog.setRequestParam(String.valueOf(accountStatus));
+            sysLog.setOperateType(10001);
+            sysLog.setUserid(user.getId());
+            sysLog.setCreateBy(user.getRealname());
+            sysLog.setCreateTime(new Date());
+            sysLogMapper.insert(sysLog);
+
+        }
+
+        return result;
+    }
+
+
 }

+ 5 - 6
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java

@@ -8,7 +8,6 @@ import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -276,9 +275,9 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 if (!Check.isNull(creativeJson.getLong("photo_id"))) {
                     createJson.put("photo_id", creativeJson.getLong("photo_id"));  // 视频ID
                 }
-                KuaiShouVideoGet video = videoGetService.getVideoByPhotoId(creativeJson.getLong("photo_id"));
-                if (!Check.isNull(video)) {
-                    createJson.put("creative_material_type", video.getMaterialType());  // 素材类型
+                //     KuaiShouVideoGet video = videoGetService.getVideoByPhotoId(creativeJson.getLong("photo_id"));
+                if (!Check.isNull(creativeJson.getInteger("creative_material_type"))) {
+                    createJson.put("creative_material_type", creativeJson.getInteger("creative_material_type"));  // 素材类型
                 }
                 if (!Check.isNull(creativeJson.getString("action_bar_text"))) {
                     createJson.put("action_bar_text", creativeJson.getString("action_bar_text"));  // 行动号召按钮文案
@@ -631,7 +630,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
             }
         }
         //-------------兴趣行为定向
-        JSONObject behaviorInterest = new JSONObject();
+       /* JSONObject behaviorInterest = new JSONObject();
         JSONObject behavior = new JSONObject();
         JSONObject interest = new JSONObject();
         if (!Check.isNull(unitJson.getJSONArray("keyword"))) {
@@ -660,7 +659,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
         }
         if (!Check.isNull(behaviorInterest)) {
             target.put("behavior_interest", behaviorInterest);
-        }
+        }*/
         return target;
     }
 }

+ 23 - 13
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.controller;
 
+import cn.com.ctop.common.module.service.ISysRoleExtService;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.report.service.IKsNewGroupReportService;
@@ -8,14 +9,13 @@ import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.annotations.Param;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -42,6 +42,9 @@ public class KsNewGroupReportCtrl {
     @Autowired
     NewMonitorService newMonitorService;
 
+    @Resource
+    private ISysRoleExtService sysRoleService;
+
     /**
      * 新建计划、有效计划 chart数据
      */
@@ -68,12 +71,12 @@ public class KsNewGroupReportCtrl {
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
-            JSONObject sumData = newGroupReportService.getSumNewGroupBy(accountIds, startDate, endDate);
-            List<JSONObject> chartData = newGroupReportService.getKsNewGroupGroupByStatDate(accountIds, startDate, endDate);
-            List<JSONObject> listData = newGroupReportService.getKsNewGroupGroupByAccount(accountIds, startDate, endDate, target, order);
-           /* List<JSONObject> chartData = newMonitorService.getKuaiShouGroupMessageGroup(accountIds, startDate, endDate);
+            //JSONObject sumData = newGroupReportService.getSumNewGroupBy(accountIds, startDate, endDate);
             JSONObject sumData = newMonitorService.getKuaiShouGroupSum(accountIds, startDate, endDate);
-            List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);*/
+            //List<JSONObject> chartData = newGroupReportService.getKsNewGroupGroupByStatDate(accountIds, startDate, endDate);
+            List<JSONObject> chartData = newMonitorService.getKuaiShouGroupMessageGroup(accountIds, startDate, endDate);
+            //List<JSONObject> listData = newGroupReportService.getKsNewGroupGroupByAccount(accountIds, startDate, endDate, target, order);
+            List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -145,7 +148,7 @@ public class KsNewGroupReportCtrl {
             excelList.add(temp);
         });
         try {
-            String[] headers = {"账户名称", "账户ID", "账户所属人", "新上推广组", "有效推广组", "最近上新时间"};
+            String[] headers = {"账户名称","账户ID","账户所属人","新上推广组","有效推广组","最近上新时间"};
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
             XSSFWorkbook workbook = new XSSFWorkbook();
@@ -162,11 +165,18 @@ public class KsNewGroupReportCtrl {
     /**
      * 查询所有的快手运营
      */
-    @PostMapping("/report/AllOperator")
-    public Result<List<JSONObject>> getAllOperator() {
+    @GetMapping("/report/AllOperator")
+    public Result<List<JSONObject>> getAllOperator(@Param("userId")String userId,@Param("userName")String userName) {
         Result<List<JSONObject>> result = new Result<>();
+        List<JSONObject> listData=new ArrayList<>();
         try {
-            List<JSONObject> listData = newPlanReportService.getAllOperator();
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (roleCode != null && roleCode.equals("admin")) {
+                listData = newPlanReportService.getAllOperator();
+            }else {
+                listData=newMonitorService.getOperator(userId,userName);
+            }
+
             result.setResult(listData);
             result.setSuccess(true);
         } catch (Exception e) {

+ 3 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyGender.java

@@ -18,5 +18,7 @@ import lombok.experimental.Accessors;
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 @ApiModel(value = "ctop_kuaishou_audience_report_daily_gender对象", description = "人群分析报表")
-public class KuaishouAudienceReportDailyGender  extends KuaishouAudienceReportDaily {
+public class KuaishouAudienceReportDailyGender extends KuaishouAudienceReportDaily {
+
+
 }

+ 16 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/NewMonitorInfo.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class NewMonitorInfo {
+    private String user_id;
+
+    private String user_name;
+
+    private String parent_id;
+
+    private List<NewMonitorInfo> children;
+}

+ 4 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyGenderMapper.java

@@ -17,4 +17,8 @@ public interface KuaishouAudienceReportDailyGenderMapper extends BaseMapper<Kuai
     void replaceBatch(@Param(value = "data") List<KuaishouAudienceReportDailyGender> data);
 
     void replaceBatchNew(@Param(value = "data") List<KuaishouAudienceReportDailyGender> data);
+
+    List<KuaishouAudienceReportDailyGender> selectByStatDate(String statDate);
+
+    void replaceBatchNewMerge(@Param(value = "data") List<KuaishouAudienceReportDailyGender> data);
 }

+ 24 - 18
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java

@@ -1,49 +1,55 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
+import cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
 @Mapper
 public interface NewMonitorMapper {
 
-    List<Map> getKuaiShouGroup(@Param("date")String date);
+    List<Long> getAllAccountId();
 
-    List<Map> getKuaiShouCampaign(@Param("date")String date);
+    List<Map> getKuaiShouGroup(@Param("date") String date, @Param("accountId") String accountId);
 
-    List<Map> getTouTiaoCampaign(@Param("date")String date);
+    List<Map> getKuaiShouCampaign(@Param("date") String date, @Param("accountId") String accountId);
 
-    String getGroupCharge(@Param("unitId")String unitId,@Param("afterDate")String afterDate);
+    List<Map> getTouTiaoCampaign(@Param("date") String date, @Param("accountId") String accountId);
 
-    String getCampaignCharge(@Param("campaignId")String campaignId,@Param("afterDate")String afterDate);
+    BigDecimal getGroupCharge(@Param("unitId") String unitId, @Param("afterDate") String afterDate);
 
-    String getCampaignChargeTouTiao(@Param("campaignId")String campaignId,@Param("afterDate")String afterDate);
+    BigDecimal getCampaignCharge(@Param("campaignId") String campaignId, @Param("afterDate") String afterDate);
 
-    void saveMonitorGroup(@Param("accountId")String accountId,@Param("accountName")String accountName,@Param("operatingName")String operatingName,@Param("unitId")String unitId,@Param("createTime")String createTime,@Param("projectType")String projectType,@Param("effective")String effective);
+    BigDecimal getCampaignChargeTouTiao(@Param("campaignId") String campaignId, @Param("afterDate") String afterDate);
 
-    void saveMonitorCampaign(@Param("accountId")String accountId,@Param("accountName")String accountName,@Param("operatingName")String operatingName,@Param("campaignId")String campaignId,@Param("createTime")String createTime,@Param("projectType")String projectType,@Param("effective")String effective);
+    void saveMonitorGroup(@Param("accountId") String accountId, @Param("accountName") String accountName, @Param("operatingName") String operatingName, @Param("unitId") String unitId, @Param("createTime") String createTime, @Param("projectType") String projectType, @Param("effective") String effective);
 
-    String  getMonitorGroupByUnitId(@Param("unitId")String unitId);
+    void saveMonitorCampaign(@Param("accountId") String accountId, @Param("accountName") String accountName, @Param("operatingName") String operatingName, @Param("campaignId") String campaignId, @Param("createTime") String createTime, @Param("projectType") String projectType, @Param("effective") String effective);
 
-    String  getMonitorPlanByCampaignId(@Param("campaignId")String campaignId);
+    String getMonitorGroupByUnitId(@Param("unitId") String unitId);
 
-    void  updateMonitorGroupByUnitId(@Param("unitId")String unitId,@Param("effective")String effective);
+    String getMonitorPlanByCampaignId(@Param("campaignId") String campaignId);
 
-    void  updateMonitorPlanByCampaignId(@Param("campaignId")String campaignId,@Param("effective")String effective);
+    void updateMonitorGroupByUnitId(@Param("unitId") String unitId, @Param("effective") String effective);
 
-    List<JSONObject> getKuaiShouGroupMessage(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate);
+    void updateMonitorPlanByCampaignId(@Param("campaignId") String campaignId, @Param("effective") String effective);
 
-    JSONObject getKuaiShouGroupSum(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate);
+    List<JSONObject> getKuaiShouGroupMessage(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    List<JSONObject> getKuaiShouGroupMessageGroup(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("group")String group);
+    JSONObject getKuaiShouGroupSum(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    List<JSONObject> getPlanMessage(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("project")String project);
+    List<JSONObject> getKuaiShouGroupMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group);
 
-    JSONObject getPlanSum(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("project")String project);
+    List<JSONObject> getPlanMessage(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
 
-    List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("group")String group,@Param("project")String project);
+    JSONObject getPlanSum(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+
+    List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group, @Param("project") String project);
+
+    List<NewMonitorInfo> getOperator(@Param("userId") String userId);
 }

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KsNewPlanReportMapper.xml

@@ -263,7 +263,8 @@
                 role_code IN (
                               'operator',
                               'kuaishouOperationManager',
-                              'operationAssistant'
+                              'operationAssistant',
+                              'admin'
                 )
     </select>
 

+ 92 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyGenderMapper.xml

@@ -498,4 +498,96 @@
             )
         </foreach>
     </insert>
+
+    <select id="selectByStatDate" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender">
+        select * from ctop_kuaishou_audience_report_daily_gender where stat_date = #{statDate} and project_id is not null and signature is not null
+    </select>
+
+    <insert id="replaceBatchNewMerge">
+        replace into ctop_kuaishou_audience_report_daily_gender_new (
+        project_id,
+        signature,
+        stat_date,
+        gender,
+        aclick,
+        bclick,
+        photo_click_cost,
+        download_started,
+        download_completed,
+        activation,
+        submit,
+        photo_show,
+        photo_click,
+        photo_click_ratio,
+        charge,
+        action_ratio,
+        impression_1k_cost,
+        action_cost,
+        event_pay_first_day,
+        event_pay_purchase_amount_first_day,
+        event_pay_first_day_roi,
+        event_pay,
+        event_pay_purchase_amount,
+        event_pay_roi,
+        event_register,
+        event_register_cost,
+        event_register_ratio,
+        event_jin_jian_app,
+        event_jin_jian_app_cost,
+        event_credit_grant_app,
+        event_credit_grant_app_cost,
+        event_order_paid,
+        event_order_paid_purchase_amount,
+        event_next_day_stay_cost,
+        event_next_day_stay_ratio,
+        event_order_paid_cost,
+        event_next_day_stay,
+        event_app_invoked,
+        event_credit_grant_app_ratio
+        )
+        values
+        <foreach collection="data" item="da" separator=",">
+            (
+            #{da.projectId},
+            #{da.signature},
+            #{da.statDate},
+            #{da.gender},
+            #{da.aclick},
+            #{da.bclick},
+            #{da.photoClickCost},
+            #{da.downloadStarted},
+            #{da.downloadCompleted},
+            #{da.activation},
+            #{da.submit},
+            #{da.photoShow},
+            #{da.photoClick},
+            #{da.photoClickRatio},
+            #{da.charge},
+            #{da.actionRatio},
+            #{da.impression_1kCost},
+            #{da.actionCost},
+            #{da.eventPayFirstDay},
+            #{da.eventPayPurchaseAmountFirstDay},
+            #{da.eventPayFirstDayRoi},
+            #{da.eventPay},
+            #{da.eventPayPurchaseAmount},
+            #{da.eventPayRoi},
+            #{da.eventRegister},
+            #{da.eventRegisterCost},
+            #{da.eventRegisterRatio},
+            #{da.eventJinJianApp},
+            #{da.eventJinJianAppCost},
+            #{da.eventCreditGrantApp},
+            #{da.eventCreditGrantAppCost},
+            #{da.eventOrderPaid},
+            #{da.eventOrderPaidPurchaseAmount},
+            #{da.eventNextDayStayCost},
+            #{da.eventNextDayStayRatio},
+            #{da.eventOrderPaidCost},
+            #{da.eventNextDayStay},
+            #{da.eventAppInvoked},
+            #{da.eventCreditGrantAppRatio}
+            )
+        </foreach>
+    </insert>
 </mapper>

+ 27 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml

@@ -1,10 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper">
+    <resultMap id="BaseResultMap" type="cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo">
+        <id  column="id"  property="user_id" />
+        <result column="realname" property="user_name"/>
+        <result column="leader_id" property="parent_id"/>
+        <collection property="children" ofType="cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo"
+                    select="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper.getOperator" column="id">
+        </collection>
+    </resultMap>
+
+    <select id="getOperator" resultMap="BaseResultMap"  parameterType="String">
+        SELECT id,realname,leader_id
+        FROM sys_user
+        WHERE leader_id=#{userId};
+    </select>
 
+    <select id="getAllAccountId" resultType="Long">
+        SELECT DISTINCT t.account_id  as 'accountId' from ctop_user_allocation t
+    </select>
     <select id="getKuaiShouGroup" resultType="Map">
     SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.unit_id as 'unitId',t.group_create_time as 'groupCreatTime',DATE_FORMAT(DATE_ADD(t.group_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
-     from ctop_user_allocation t1 LEFT JOIN  ctop_kuaishou_group t on t1.account_id=t.account_id
+     from ctop_user_allocation t1 LEFT JOIN  ctop_kuaishou_group t on t1.account_id=t.account_id and t.account_id=#{accountId}
      <where>
          <choose>
              <when test="date!= null and date!=''">
@@ -19,7 +36,7 @@
 
     <select id="getKuaiShouCampaign" resultType="Map">
         SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.campaign_id as 'campaignId',t.put_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.put_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
-        from ctop_user_allocation t1 LEFT JOIN  ctop_kuaishou_campaign t on t1.account_id=t.account_id
+        from ctop_user_allocation t1 LEFT JOIN  ctop_kuaishou_campaign t on t1.account_id=t.account_id and t.account_id=#{accountId}
         <where>
             <choose>
                 <when test="date != null and date !=''">
@@ -34,7 +51,7 @@
 
     <select id="getTouTiaoCampaign" resultType="Map">
         SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.id as 'campaignId',t.ad_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.ad_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
-        from ctop_user_allocation t1 LEFT JOIN  ctop_bytedance_advertise_plan t on t1.account_id=t.account_id
+        from ctop_user_allocation t1 LEFT JOIN  ctop_bytedance_advertise_plan t on t1.account_id=t.account_id and t.account_id=#{accountId}
         <where>
             <choose>
                 <when test="date != null and date !=''">
@@ -47,17 +64,17 @@
         </where>
     </select>
 
-    <select id="getGroupCharge" resultType="String">
+    <select id="getGroupCharge" resultType="BigDecimal">
 
         select sum(charge) from ctop_kuaishou_report_daily_group t where t.stat_date &lt; #{afterDate} and t.unit_id=#{unitId}
     </select>
 
-    <select id="getCampaignCharge" resultType="String">
+    <select id="getCampaignCharge" resultType="BigDecimal">
 
         select sum(charge) from ctop_kuaishou_report_daily_campaign t where t.stat_date &lt; #{afterDate} and t.campaign_id=#{campaignId}
     </select>
 
-    <select id="getCampaignChargeTouTiao" resultType="String">
+    <select id="getCampaignChargeTouTiao" resultType="BigDecimal">
 
         select sum(cost) from ctop_bytedance_report_plan_daily t where t.stat_datetime &lt; #{afterDate} and t.ad_id=#{campaignId}
     </select>
@@ -72,11 +89,11 @@
         (#{accountId},#{accountName},#{operatingName},#{campaignId},#{createTime},#{projectType},#{effective})
     </insert>
 
-    <select id="getMonitorGroupByUnitId" resultType="int" >
+    <select id="getMonitorGroupByUnitId" resultType="String" >
         select  t.effective from ctop_new_monitor_group t where t.unit_id=#{unitId}
     </select>
 
-    <select id="getMonitorPlanByCampaignId" resultType="int" >
+    <select id="getMonitorPlanByCampaignId" resultType="String" >
         select  t.effective from ctop_new_monitor_campaign t where t.campaign_id=#{campaignId}
     </select>
 
@@ -161,4 +178,6 @@
         </choose>
     </select>
 
+
+
 </mapper>

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyGenderService.java

@@ -11,4 +11,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaishouAudienceReportDailyGenderService extends IService<KuaishouAudienceReportDailyGender> {
 
+    void mergeAudienceReportDailyDate(String statDate);
+
 }

+ 6 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java

@@ -9,15 +9,17 @@ import java.util.List;
 public interface NewMonitorService {
     public Result synchronousMonitor(String type);
 
-    List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate,String target);
+    List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate, String target);
 
     JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate);
 
     List<JSONObject> getKuaiShouGroupMessageGroup(JSONArray array, String startDate, String endDate);
 
-    List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate,String target,String project);
+    List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate, String target, String project);
 
-    JSONObject getPlanSum(JSONArray array, String startDate, String endDate,String project);
+    JSONObject getPlanSum(JSONArray array, String startDate, String endDate, String project);
 
-    List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate,String project);
+    List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project);
+
+    List<JSONObject> getOperator(String userId, String userName);
 }

+ 113 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyGenderServiceImpl.java

@@ -1,5 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyGenderMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
@@ -7,6 +9,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+
 /**
  * 人群分析报表
  *
@@ -17,5 +23,112 @@ import org.springframework.stereotype.Service;
 @Slf4j
 @Service
 public class KuaishouAudienceReportDailyGenderServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyGenderMapper, KuaishouAudienceReportDailyGender> implements IKuaishouAudienceReportDailyGenderService {
+    @Resource
+    KuaishouAudienceReportDailyGenderMapper genderMapper;
+
+    @Override
+    public void mergeAudienceReportDailyDate(String statDate){
+        List<KuaishouAudienceReportDailyGender> genderList = genderMapper.selectByStatDate(statDate);
+        Map<String,KuaishouAudienceReportDailyGender> genderResultMap = new HashMap<>();
+        List<KuaishouAudienceReportDailyGender> result = new ArrayList<>();
+        if(!Check.isNull(genderList)){
+            genderList.forEach(gender ->{
+                String key = gender.getProjectId()+gender.getGender()+gender.getSignature()+gender.getStatDate();
+                if(genderResultMap.containsKey(key)){
+                    KuaishouAudienceReportDailyGender mergeGender = genderResultMap.get(key);
+                    merge(mergeGender, gender);
+                }else {
+                    genderResultMap.put(key,gender);
+                }
+            });
+        }
+
+        if(!Check.isNull(genderResultMap)){
+            Set<String> keys = genderResultMap.keySet();
+            keys.forEach(key -> result.add(genderResultMap.get(key)));
+        }
+
+        if(!Check.isNull(result)){
+            result.forEach(a -> {
+                System.out.println(a.toString());
+            });
+            saveAudienceReportDailyGenderToDb(result);
+        }
+    }
+
+    public void merge(KuaishouAudienceReportDaily o1, KuaishouAudienceReportDaily o2){
+        o1.setAclick(o1.getAclick()+o2.getAclick());
+        o1.setBclick(o1.getBclick()+o2.getBclick());
+        o1.setPhotoClickCost(o1.getPhotoClickCost()+o2.getPhotoClickCost());
+        o1.setDownloadStarted(o1.getDownloadStarted()+o2.getDownloadStarted());
+        o1.setDownloadCompleted(o1.getDownloadCompleted()+o2.getDownloadCompleted());
+        o1.setActivation(o1.getActivation()+o2.getActivation());
+        o1.setSubmit(o1.getSubmit()+o2.getSubmit());
+        o1.setPhotoShow(o1.getPhotoShow()+o2.getPhotoShow());
+        o1.setPhotoClickRatio(o1.getPhotoClickRatio()+o2.getPhotoClickRatio());
+        o1.setPhotoClick(o1.getPhotoClick()+o2.getPhotoClick());
+        o1.setCharge(o1.getCharge()+o2.getCharge());
+        o1.setActionRatio(o1.getActionRatio()+o2.getActionRatio());
+//        if(!Check.isNull(o1.getImpression_1kCost()) && !Check.isNull(o2.getImpression_1kCost())){
+//        }else{
+//            o1.setImpression_1kCost(!Check.isNull(o1.getImpression_1kCost()) ? o1.getImpression_1kCost() : !Check.isNull(o2.getImpression_1kCost()) ? o2.getImpression_1kCost() : null);
+//        }
+
+        o1.setImpression_1kCost(add(o1.getImpression_1kCost(),o2.getImpression_1kCost()));
+        o1.setActionCost(add(o1.getActionCost(),o2.getActionCost()));
+        o1.setEventPayFirstDay(o1.getEventPayFirstDay()+o2.getEventPayFirstDay());
+        o1.setEventPayPurchaseAmountFirstDay(add(o1.getEventPayPurchaseAmountFirstDay(),o2.getEventPayPurchaseAmountFirstDay()));
+
+        o1.setEventPayFirstDayRoi(o1.getEventPayFirstDayRoi()+o2.getEventPayFirstDayRoi());
+        o1.setEventPay(o1.getEventPay()+o2.getEventPay());
+        o1.setEventPayPurchaseAmount(add(o1.getEventPayPurchaseAmount(),o2.getEventPayPurchaseAmount()));
+
+        o1.setEventPayRoi(o1.getEventPayRoi()+o2.getEventPayRoi());
+        o1.setEventRegister(o1.getEventRegister()+o2.getEventRegister());
+        o1.setEventRegisterCost(add(o1.getEventRegisterCost(),o2.getEventRegisterCost()));
+
+        o1.setEventRegisterRatio(o1.getEventRegisterRatio()+o2.getEventRegisterRatio());
+        o1.setEventJinJianApp(o1.getEventJinJianApp()+o2.getEventJinJianApp());
+        o1.setEventJinJianAppCost(add(o1.getEventJinJianAppCost(),o2.getEventJinJianAppCost()));
+        o1.setEventCreditGrantApp(o1.getEventCreditGrantApp()+o2.getEventCreditGrantApp());
+        o1.setEventCreditGrantAppCost(add(o1.getEventCreditGrantAppCost(),o2.getEventCreditGrantAppCost()));
+        o1.setEventOrderPaid(o1.getEventOrderPaid()+o2.getEventOrderPaid());
+        o1.setEventOrderPaidPurchaseAmount(add(o1.getEventOrderPaidPurchaseAmount(),o2.getEventOrderPaidPurchaseAmount()));
+        o1.setEventNextDayStayCost(add(o1.getEventNextDayStayCost(),o2.getEventNextDayStayCost()));
+        o1.setEventNextDayStayRatio(add(o1.getEventNextDayStayRatio(),o2.getEventNextDayStayRatio()));
+        o1.setEventOrderPaidCost(add(o1.getEventOrderPaidCost(),o2.getEventOrderPaidCost()));
+
+        o1.setEventNextDayStay(o1.getEventNextDayStay()+o2.getEventNextDayStay());
+        o1.setEventAppInvoked(o1.getEventAppInvoked()+o2.getEventAppInvoked());
+        o1.setEventCreditGrantAppRatio(add(o1.getEventCreditGrantAppRatio(),o2.getEventCreditGrantAppRatio()));
+    }
+
+    public BigDecimal add(BigDecimal b1, BigDecimal b2){
+        if(!Check.isNull(b1) && !Check.isNull(b2)){
+            return b1.add(b2);
+        }else{
+            return !Check.isNull(b1) ? b1 : !Check.isNull(b2) ? b2 : new BigDecimal(0);
+        }
+    }
+
+    private void saveAudienceReportDailyGenderToDb(List<KuaishouAudienceReportDailyGender> mergeGenderList) {
+        if(mergeGenderList == null || mergeGenderList.isEmpty()){
+            return;
+        }
+
+        List<KuaishouAudienceReportDailyGender> batchList = new ArrayList<>();
+        for(KuaishouAudienceReportDailyGender mergeGender : mergeGenderList){
+            batchList.add(mergeGender);
+
+            if(batchList.size() >= 1000){
+                genderMapper.replaceBatchNewMerge(batchList);
+                batchList.clear();
+            }
+        }
 
+        if(batchList.isEmpty() == false){
+            genderMapper.replaceBatchNewMerge(batchList);
+            batchList.clear();
+        }
+    }
 }

+ 181 - 134
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.service.impl;
 
+import cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo;
 import cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper;
 import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import com.alibaba.fastjson.JSONArray;
@@ -10,6 +11,7 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -35,134 +37,142 @@ public class NewMonitorServiceImpl implements NewMonitorService {
         List<Map> kuaiShouCampaign = new ArrayList<>();
         List<Map> TouTiaoCampaign = new ArrayList<>();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        /*--------------------快手广告组-----------------------*/
-        if (type.equals("0")) {
-            //查询创建不满7天的快手组信息
-            kuaiShouGroup = newMonitorMapper.getKuaiShouGroup(sdf.format(new Date()));
-        } else {
-            //查询全量快手组信息
-            kuaiShouGroup = newMonitorMapper.getKuaiShouGroup(null);
-        }
-        //处理快手组数据
-        if (!kuaiShouGroup.isEmpty()) {
-            kuaiShouGroup.stream().forEach(obj -> {
-                if (obj != null) {
-                    String unitId = obj.get("unitId") == null ? null : String.valueOf(obj.get("unitId"));
-                    String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
-                    String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
-                    String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
-                    String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
-                    String groupCreatTime = obj.get("groupCreatTime") == null ? null : (String) obj.get("groupCreatTime");
-                    if (unitId != null && afterTime != null) {
-                        String groupCharge = newMonitorMapper.getGroupCharge(unitId, afterTime);
-                        //大于500为有效广告组
-                        String effective = "0";
-                        if (groupCharge != null && Long.parseLong(groupCharge) > 500) {
-                            //有效
-                            effective = "1";
-                        }
-                        String effectiveResult = newMonitorMapper.getMonitorGroupByUnitId(unitId);
-                        //判断是否存在
-                        if (effectiveResult != null) {
-                            if (!effectiveResult.equals(effective)) {
-                                //存在更新
-                                newMonitorMapper.updateMonitorGroupByUnitId(unitId, effective);
-                            }
+        List<Long> allAccountId = newMonitorMapper.getAllAccountId();
+        if (!allAccountId.isEmpty()) {
+            for (Long accId : allAccountId) {
+                if (accId != null) {
+                    /*--------------------快手广告组-----------------------*/
+                    if (type.equals("0")) {
+                        //查询创建不满7天的快手组信息
+                        kuaiShouGroup = newMonitorMapper.getKuaiShouGroup(sdf.format(new Date()), String.valueOf(accId));
+                    } else {
+                        //查询全量快手组信息
+                        kuaiShouGroup = newMonitorMapper.getKuaiShouGroup(null, String.valueOf(accId));
+                    }
+                    //处理快手组数据
+                    if (!kuaiShouGroup.isEmpty()) {
+                        kuaiShouGroup.stream().forEach(obj -> {
+                            if (obj != null) {
+                                String unitId = obj.get("unitId") == null ? null : String.valueOf(obj.get("unitId"));
+                                String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                                String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                                String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                                String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                                String groupCreatTime = obj.get("groupCreatTime") == null ? null : (String) obj.get("groupCreatTime");
+                                if (unitId != null && afterTime != null) {
+                                    BigDecimal groupCharge = newMonitorMapper.getGroupCharge(unitId, afterTime);
+                                    //大于500为有效广告组
+                                    String effective = "0";
+                                    if (groupCharge != null && groupCharge.compareTo(new BigDecimal(500)) == 1) {
+                                        //有效
+                                        effective = "1";
+                                    }
+                                    String effectiveResult = newMonitorMapper.getMonitorGroupByUnitId(unitId);
+                                    //判断是否存在
+                                    if (effectiveResult != null) {
+                                        if (!effectiveResult.equals(effective)) {
+                                            //存在更新
+                                            newMonitorMapper.updateMonitorGroupByUnitId(unitId, effective);
+                                        }
 
-                        } else {
-                            //不存在插入
-                            newMonitorMapper.saveMonitorGroup(accountId, accountName, userName, unitId, groupCreatTime, "1", effective);
-                        }
+                                    } else {
+                                        //不存在插入
+                                        newMonitorMapper.saveMonitorGroup(accountId, accountName, userName, unitId, groupCreatTime, "1", effective);
+                                    }
+                                }
+                            }
+                        });
                     }
-                }
-            });
-        }
 
 
-        /*---------------快手广告计划------------------*/
-        if (type.equals("0")) {
-            //查询创建不满7天的快手广告计划
-            kuaiShouCampaign = newMonitorMapper.getKuaiShouCampaign(sdf.format(new Date()));
-        } else {
-            //查询全量快手广告计划
-            kuaiShouCampaign = newMonitorMapper.getKuaiShouCampaign(null);
-        }
-        //处理快手广告计划数据
-        if (!kuaiShouCampaign.isEmpty()) {
-            kuaiShouCampaign.stream().forEach(obj -> {
-                if (obj != null) {
-                    String campaignId = obj.get("campaignId") == null ? null : String.valueOf(obj.get("campaignId"));
-                    String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
-                    String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
-                    String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
-                    String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
-                    String campaignCreatTime = obj.get("campaignCreatTime") == null ? null : (String) obj.get("campaignCreatTime");
-                    if (campaignId != null && afterTime != null) {
-                        String campaignCharge = newMonitorMapper.getCampaignCharge(campaignId, afterTime);
-                        //大于500为有效广告计划
-                        String effective = "0";
-                        if (campaignCharge != null && Long.parseLong(campaignCharge) > 500) {
-                            //有效
-                            effective = "1";
-                        }
-                        String effectiveResult = newMonitorMapper.getMonitorPlanByCampaignId(campaignId);
-                        //判断是否存在
-                        if (effectiveResult != null) {
-                            if (!effectiveResult.equals(effective)) {
-                                //存在更新
-                                newMonitorMapper.updateMonitorPlanByCampaignId(campaignId, effective);
+                    /*---------------快手广告计划------------------*/
+                    if (type.equals("0")) {
+                        //查询创建不满7天的快手广告计划
+                        kuaiShouCampaign = newMonitorMapper.getKuaiShouCampaign(sdf.format(new Date()), String.valueOf(accId));
+                    } else {
+                        //查询全量快手广告计划
+                        kuaiShouCampaign = newMonitorMapper.getKuaiShouCampaign(null, String.valueOf(accId));
+                    }
+                    //处理快手广告计划数据
+                    if (!kuaiShouCampaign.isEmpty()) {
+                        kuaiShouCampaign.stream().forEach(obj -> {
+                            if (obj != null) {
+                                String campaignId = obj.get("campaignId") == null ? null : String.valueOf(obj.get("campaignId"));
+                                String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                                String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                                String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                                String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                                String campaignCreatTime = obj.get("campaignCreatTime") == null ? null : (String) obj.get("campaignCreatTime");
+                                if (campaignId != null && afterTime != null) {
+                                    BigDecimal campaignCharge = newMonitorMapper.getCampaignCharge(campaignId, afterTime);
+                                    //大于500为有效广告计划
+                                    String effective = "0";
+                                    if (campaignCharge != null && campaignCharge.compareTo(new BigDecimal(500)) == 1) {
+                                        //有效
+                                        effective = "1";
+                                    }
+                                    String effectiveResult = newMonitorMapper.getMonitorPlanByCampaignId(campaignId);
+                                    //判断是否存在
+                                    if (effectiveResult != null) {
+                                        if (!effectiveResult.equals(effective)) {
+                                            //存在更新
+                                            newMonitorMapper.updateMonitorPlanByCampaignId(campaignId, effective);
+                                        }
+                                    } else {
+                                        //不存在插入
+                                        newMonitorMapper.saveMonitorCampaign(accountId, accountName, userName, campaignId, campaignCreatTime, "1", effective);
+                                    }
+                                }
                             }
-                        } else {
-                            //不存在插入
-                            newMonitorMapper.saveMonitorCampaign(accountId, accountName, userName, campaignId, campaignCreatTime, "1", effective);
-                        }
+                        });
                     }
-                }
-            });
-        }
 
-        /*---------------头条广告计划------------------*/
-        if (type.equals("0")) {
-            //查询创建不满7天的头条广告计划
-            TouTiaoCampaign = newMonitorMapper.getTouTiaoCampaign(sdf.format(new Date()));
-        } else {
-            //查询全量头条广告计划
-            TouTiaoCampaign = newMonitorMapper.getTouTiaoCampaign(null);
-        }
-        //处理快手广告计划数据
-        if (!TouTiaoCampaign.isEmpty()) {
-            TouTiaoCampaign.stream().forEach(obj -> {
-                if (obj != null) {
-                    String campaignId = obj.get("campaignId") == null ? null : String.valueOf(obj.get("campaignId"));
-                    String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
-                    String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
-                    String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
-                    String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
-                    String campaignCreatTime = obj.get("campaignCreatTime") == null ? null : (String) obj.get("campaignCreatTime");
-                    if (campaignId != null && afterTime != null) {
-                        String campaignCharge = newMonitorMapper.getCampaignChargeTouTiao(campaignId, afterTime);
-                        //大于500为有效广告计划
-                        String effective = "0";
-                        if (campaignCharge != null && Long.parseLong(campaignCharge) > 500) {
-                            //有效
-                            effective = "1";
-                        }
-                        String effectiveResult = newMonitorMapper.getMonitorPlanByCampaignId(campaignId);
-                        //判断是否存在
-                        if (effectiveResult != null) {
-                            if (!effectiveResult.equals(effective)) {
-                                //存在更新
-                                newMonitorMapper.updateMonitorPlanByCampaignId(campaignId, effective);
+                    /*---------------头条广告计划------------------*/
+                    if (type.equals("0")) {
+                        //查询创建不满7天的头条广告计划
+                        TouTiaoCampaign = newMonitorMapper.getTouTiaoCampaign(sdf.format(new Date()), String.valueOf(accId));
+                    } else {
+                        //查询全量头条广告计划
+                        TouTiaoCampaign = newMonitorMapper.getTouTiaoCampaign(null, String.valueOf(accId));
+                    }
+                    //处理快手广告计划数据
+                    if (!TouTiaoCampaign.isEmpty()) {
+                        TouTiaoCampaign.stream().forEach(obj -> {
+                            if (obj != null) {
+                                String campaignId = obj.get("campaignId") == null ? null : String.valueOf(obj.get("campaignId"));
+                                String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                                String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                                String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                                String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                                String campaignCreatTime = obj.get("campaignCreatTime") == null ? null : (String) obj.get("campaignCreatTime");
+                                if (campaignId != null && afterTime != null) {
+                                    BigDecimal campaignCharge = newMonitorMapper.getCampaignChargeTouTiao(campaignId, afterTime);
+                                    //大于500为有效广告计划
+                                    String effective = "0";
+                                    if (campaignCharge != null && campaignCharge.compareTo(new BigDecimal(500)) == 1) {
+                                        //有效
+                                        effective = "1";
+                                    }
+                                    String effectiveResult = newMonitorMapper.getMonitorPlanByCampaignId(campaignId);
+                                    //判断是否存在
+                                    if (effectiveResult != null) {
+                                        if (!effectiveResult.equals(effective)) {
+                                            //存在更新
+                                            newMonitorMapper.updateMonitorPlanByCampaignId(campaignId, effective);
+                                        }
+                                    } else {
+                                        //不存在插入
+                                        newMonitorMapper.saveMonitorCampaign(accountId, accountName, userName, campaignId, campaignCreatTime, "0", effective);
+                                    }
+                                }
                             }
-                        } else {
-                            //不存在插入
-                            newMonitorMapper.saveMonitorCampaign(accountId, accountName, userName, campaignId, campaignCreatTime, "0", effective);
-                        }
+                        });
                     }
                 }
-            });
+            }
         }
 
+
         return result;
     }
 
@@ -175,8 +185,9 @@ public class NewMonitorServiceImpl implements NewMonitorService {
      */
     @Override
     public List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate, String target) {
-        return  newMonitorMapper.getKuaiShouGroupMessage(array,startDate,endDate);
+        return newMonitorMapper.getKuaiShouGroupMessage(array, startDate, endDate);
     }
+
     /**
      * 查询快手组新上和有效数量
      *
@@ -185,8 +196,9 @@ public class NewMonitorServiceImpl implements NewMonitorService {
      */
     @Override
     public JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate) {
-        return newMonitorMapper.getKuaiShouGroupSum(array,startDate,endDate);
+        return newMonitorMapper.getKuaiShouGroupSum(array, startDate, endDate);
     }
+
     /**
      * 查询快手组时间轴数据
      *
@@ -195,15 +207,15 @@ public class NewMonitorServiceImpl implements NewMonitorService {
      */
     @Override
     public List<JSONObject> getKuaiShouGroupMessageGroup(JSONArray array, String startDate, String endDate) {
-        String group="0";
-        List<JSONObject> kuaiShouGroupMessageGroup=new ArrayList<>();
+        String group = "0";
+        List<JSONObject> kuaiShouGroupMessageGroup = new ArrayList<>();
         try {
-            if(DateUtils.isMoreSixMonth(startDate,endDate)){
-                group="1";
+            if (DateUtils.isMoreSixMonth(startDate, endDate)) {
+                group = "1";
             }
-            kuaiShouGroupMessageGroup= newMonitorMapper.getKuaiShouGroupMessageGroup(array, startDate, endDate, group);
-        }catch (Exception e){
-            log.info("查询数据错误:{}",e.toString());
+            kuaiShouGroupMessageGroup = newMonitorMapper.getKuaiShouGroupMessageGroup(array, startDate, endDate, group);
+        } catch (Exception e) {
+            log.info("查询数据错误:{}", e.toString());
         }
 
         return kuaiShouGroupMessageGroup;
@@ -211,8 +223,9 @@ public class NewMonitorServiceImpl implements NewMonitorService {
 
     @Override
     public List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate, String target, String project) {
-        return newMonitorMapper.getPlanMessage(array,startDate,endDate,project);
+        return newMonitorMapper.getPlanMessage(array, startDate, endDate, project);
     }
+
     /**
      * 查询快手广告计划 新上和有效数量
      *
@@ -221,22 +234,56 @@ public class NewMonitorServiceImpl implements NewMonitorService {
      */
     @Override
     public JSONObject getPlanSum(JSONArray array, String startDate, String endDate, String project) {
-        return newMonitorMapper.getPlanSum(array,startDate,endDate,project);
+        return newMonitorMapper.getPlanSum(array, startDate, endDate, project);
     }
 
     @Override
     public List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project) {
-        String group="0";
-        List<JSONObject> planGroupMessageGroup=new ArrayList<>();
+        String group = "0";
+        List<JSONObject> planGroupMessageGroup = new ArrayList<>();
         try {
-            if(DateUtils.isMoreSixMonth(startDate,endDate)){
-                group="1";
+            if (DateUtils.isMoreSixMonth(startDate, endDate)) {
+                group = "1";
             }
-            planGroupMessageGroup= newMonitorMapper.getPlanMessageGroup(array, startDate, endDate, group,project);
-        }catch (Exception e){
-            log.info("查询数据错误:{}",e.toString());
+            planGroupMessageGroup = newMonitorMapper.getPlanMessageGroup(array, startDate, endDate, group, project);
+        } catch (Exception e) {
+            log.info("查询数据错误:{}", e.toString());
         }
 
         return planGroupMessageGroup;
     }
+
+    @Override
+    public List<JSONObject> getOperator(String userId, String userName) {
+        List<JSONObject> list = new ArrayList<>();
+        JSONObject ob = new JSONObject();
+        ob.put("user_id", userId);
+        ob.put("user_name", userName);
+        list.add(ob);
+        try {
+            if (userId != null) {
+                List<NewMonitorInfo> operator = newMonitorMapper.getOperator(userId);
+                list.addAll(getAllNode(operator));
+            }
+        } catch (Exception e) {
+            log.info("查询失败:{}", e.toString());
+        }
+        return list;
+    }
+
+    List<JSONObject> getAllNode(List<NewMonitorInfo> operator) {
+        List<JSONObject> objects = new ArrayList<>();
+        if (!operator.isEmpty()) {
+            for (NewMonitorInfo newMonitorInfo : operator) {
+                JSONObject js = new JSONObject();
+                js.put("user_id", newMonitorInfo.getUser_id());
+                js.put("user_name", newMonitorInfo.getUser_name());
+                objects.add(js);
+                if (newMonitorInfo.getChildren() != null && newMonitorInfo.getChildren().size() > 0) {
+                    objects.addAll(getAllNode(newMonitorInfo.getChildren()));
+                }
+            }
+        }
+        return objects;
+    }
 }

+ 21 - 35
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml

@@ -27,33 +27,22 @@
                sum(show_num)       showNum,
                sum(click)          click,
                CASE
-                   WHEN (click / show_num) IS NULL THEN
-                       0
-                   ELSE
-                       CONCAT(
-                               cast(
-                                       ROUND(
-                                               (click / show_num) * 100,
-                                               2
-                                           ) as char),
-                               '%'
-                           )
-                   END AS          'clickRate',
+                   WHEN sum(click)>=0 and sum(show_num)>0 THEN
+                       round(sum(click)/sum(show_num)*100,2)
+                   ELSE 0
+                   END AS  'clickRate',
                CASE
-                   WHEN (cost / show_num) IS NULL THEN
-                       0
+                   WHEN sum(cost)>=0 and sum(show_num)>0 THEN
+                       round(sum(cost)/sum(show_num)*1000,2)
                    ELSE
-                       ROUND(
-                               (cost / show_num) * 1000,
-                               2
-                           )
-                   END AS          'cpm',
-               CASE
-                   WHEN (click / cost) IS NULL THEN
                        0
+                   END AS  'cpm',
+               CASE
+                   WHEN sum(click)>=0 and sum(cost)>0 THEN
+                       round(sum(cost)/sum(click),2)
                    ELSE
-                       ROUND((cost / click), 2)
-                   END AS          'cp'
+                       0
+                   END AS  'cp'
         FROM ctop_bytedance_report_advertiser_hourly
         WHERE stat_datetime = #{statDate}
         GROUP BY stat_hour
@@ -75,8 +64,8 @@
                sum(show_num)                          showNum,
                sum(click)                             click,
                CASE
-                   WHEN sum(click)>=0 and sum(show_num)>0 THEN CONCAT(ROUND(sum(click) / sum(show_num) * 100,2) ,'%')
-                   else '0%' end AS   'clickRate',
+                   WHEN sum(click)>=0 and sum(show_num)>0 THEN ROUND(sum(click) / sum(show_num) * 100,2)
+                   else '0' end AS   'clickRate',
                CASE
                    WHEN (sum(cost) / sum(show_num)) IS NULL THEN
                        0
@@ -108,14 +97,12 @@
                    WHEN (sum(click) / sum(show_num)) IS NULL THEN
                        0
                    ELSE
-                       CONCAT(
-                               cast(
+
+
                                        ROUND(
                                                (sum(click) / sum(show_num)) * 100,
                                                2
-                                           ) as char),
-                               '%'
-                           )
+                                           )
                    END AS                          'clickRate',
                CASE
                    WHEN (sum(cost) / sum(show_num)) IS NULL THEN
@@ -148,14 +135,13 @@
                    WHEN (sum(click) / sum(show_num)) IS NULL THEN
                        0
                    ELSE
-                       CONCAT(
-                               cast(
+
+
                                        ROUND(
                                                (sum(click) / sum(show_num)) * 100,
                                                2
-                                           ) as char),
-                               '%'
-                           )
+                                           )
+
                    END AS                                                  'clickRate',
                CASE
                    WHEN (sum(cost) / sum(show_num)) IS NULL THEN

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceNewPlanReportMapper.xml

@@ -264,7 +264,8 @@
                 role_code IN (
                               'operator',
                               'touTiaoOperationManager',
-                              'operationAssistant'
+                              'operationAssistant',
+                              'admin'
                 )
     </select>
 

+ 24 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 项目成员
@@ -281,6 +282,29 @@ public class ProjectMemberController {
     }
 
 
+    @GetMapping(value = "/participateListV3")
+    public Result participateListV3(ProjectMember projectMember,
+                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                          HttpServletRequest req) {
+
+        Result<IPage<ProjectMember>> result = this.participateListV2(projectMember,pageNo,pageSize,req);
+        List<ProjectMember> resultList = new ArrayList<>();
+        if (result.isSuccess()){
+            List<ProjectMember> listProject = result.getResult().getRecords();
+            if (!Check.isNull(listProject)){
+                Map<String, List<ProjectMember>> groupByMedia = listProject.stream().filter(p-> (!Check.isNull(p.getMediaId()))).collect(Collectors.groupingBy(ProjectMember::getMediaId));
+                resultList = groupByMedia.get(projectMember.getMediaId());
+                if (!Check.isNull(resultList)){
+                    resultList.stream().filter(p -> (!Check.isNull(p.getAdvertiserName()))).collect(Collectors.toList());
+                    resultList = resultList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ProjectMember :: getAdvertiserId))), ArrayList::new));
+                    }
+                }
+            }
+        return Result.successMsg("成功。",resultList);
+    }
+
+
     /**
      * 分页列表查询
      *

+ 31 - 202
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -94,22 +94,11 @@ public class TestController {
     private IKuaishouInterfaceService2 kuaishouInterfaceService2;
     @Autowired
     private IUserAllocationService userAllocationService;
-    @Autowired
-    private DouyinMusicService douyinMusicService;
-    @Autowired
-    private CrawlerDouyinMusicTaskService crawlerDouyinMusicTaskService;
-    @Autowired
-    private MusicInfoService musicInfoService;
-    @Autowired
-    private IKuaiShouHistoryReportTaskService kuaiShouHistoryReportTaskService;
-
     static ExecutorService executorService = Executors.newFixedThreadPool(10);
     static ExecutorService suzhaoService = Executors.newFixedThreadPool(5);
     @Autowired
     private IKuaiShouDailyAgentService dailyAgentService;
     @Autowired
-    private IKuaishouTemplateService templateService;
-    @Autowired
     private ICtopOauthTokenService ctopOauthTokenService;
     @Autowired
     private IBindAccountAuthService bindAccountAuthService;
@@ -125,7 +114,6 @@ public class TestController {
     private IKuaiShouProjectDataService kuaiShouProjectDataService;
     @Autowired
     private IKuaiShouReportDailyMaterialService kuaiShouReportDailyMaterialService;
-
     @Autowired
     private IKuaiShouCreativeService creativeService;
     @Autowired
@@ -134,7 +122,6 @@ public class TestController {
     private MailLogMapper mailLogMapper;
     @Autowired
     private CorpWexinUtils corpWexinUtils;
-
     @Autowired
     private IBatchService batchService;
     static ExecutorService videoService = Executors.newFixedThreadPool(8);
@@ -144,30 +131,29 @@ public class TestController {
     private IKuaishouProgramCreativeService kuaishouProgramCreativeService;
     @Autowired
     private IEtlKuaishouVideoInfoService etlKuaishouVideoInfoService;
-
+    @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
+    @Autowired
+    private IReportService reportService;
+    @Autowired
+    private IBytedanceEffectVideoInfoService effectVideoInfoService;
+    @Autowired
+    public IBytedanceInterfaceService bytedanceInterfaceService;
+    @Autowired
+    private IKuaiShouCommentService kuaiShouCommentService;
+    @Autowired
+    IBytedanceVideoReportService bytedanceVideoReportService;
+    @Autowired
+    IETLReportBytedanceVideoService etlReportBytedanceVideoService;
+    @Autowired
+    private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
+    static ExecutorService executorServic1e = Executors.newFixedThreadPool(5);
+    @Autowired
+    private IKuaiShouDailyReportTaskService dailyReportTaskService;
 
     @Value("${xxl-job.requestUrl}")
     private String jobUrl;
 
-//
-//    @PostConstruct
-//    public void haha(){
-//        System.out.println("开始拉取数据~~~~~");
-//        CtopOauthToken token = tokenService.getTokenByAccountId(9556431l);
-//        JSONArray types = new JSONArray();
-//        // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布, clientId: 系统分布 businessInterestTags: 商业兴趣分布
-//
-//        types.add("province");
-//        types.add("city");
-//        types.add("gender");
-//        types.add("ageSegment");
-//        types.add("businessInterestTags");
-//        types.add("clientId");
-//        kuaishouAudienceReportDailyService.crowdAnalysisReport3(token, "2021-05-01", types, 50293820l, 216264247l, 1, 2000);
-//        System.out.println("开始拉取完毕~~~~~");
-//    }
-
-
     @GetMapping(value = "/cleanData")
     public void cleanData() {
         List<String> dateList = videoGetService.getDateList();
@@ -175,14 +161,11 @@ public class TestController {
             String s = dateList.get(i);
             etlKuaishouVideoInfoService.etlKuaishouVideoInfo(s);
         }
-
     }
 
-
     @GetMapping(value = "/getProgramCreative")
     public void getProgramCreative() {
         List<Long> list = new ArrayList();
-
         list.add(10344460L);
         list.add(10344415L);
         list.add(10344390L);
@@ -251,7 +234,6 @@ public class TestController {
         list.add(9549313L);
         list.add(9549277L);
 
-
         for (int i = 0; i < list.size(); i++) {
             Long accountId = list.get(i);
             CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
@@ -278,8 +260,6 @@ public class TestController {
         list.add(10299210L);
         list.add(10299221L);
         list.add(10299241L);
-
-
         for (int i = 0; i < list.size(); i++) {
             Long accountId = list.get(i);
             CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
@@ -328,8 +308,6 @@ public class TestController {
                     }
                 });
             }
-
-
         }
     }
 
@@ -343,7 +321,6 @@ public class TestController {
         list.add(9767717L);
         list.add(9549313L);
 
-
         for (int i = 0; i < list.size(); i++) {
             Long accountId = list.get(i);
             CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
@@ -434,9 +411,6 @@ public class TestController {
 
     }
 
-    @Autowired
-    private IKuaiShouUpdateService kuaiShouUpdateService;
-
     @GetMapping(value = "/updateCreative")
     public void updateCreative() {
         List<Long> list = new ArrayList();
@@ -737,103 +711,10 @@ public class TestController {
         }
     }
 
-
-    @GetMapping(value = "/getMd5")
-    public void getMd5() {
-        kuaiShouHistoryReportTaskService.getMd5(null, null);
-
-    }
-
-
-    @GetMapping(value = "/syncDouyinMusicAsc")
-    public String syncDouyinMusicAsc() {
-        QueryWrapper<CrawlerDouyinMusicTask> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("status", "init").orderByAsc("id").last(" limit 20");
-
-        List<CrawlerDouyinMusicTask> list = crawlerDouyinMusicTaskService.list(queryWrapper);
-
-        while (list != null && list.size() > 0) {
-            for (CrawlerDouyinMusicTask crawlerDouyinMusicTask : list) {
-                MusicInfo musicInfo = new MusicInfo();
-                musicInfo.setExtId(crawlerDouyinMusicTask.getId());
-                musicInfo = douyinMusicService.getMusicInfo(musicInfo);
-                musicInfoService.save(musicInfo);
-                crawlerDouyinMusicTask.setStatus("done");
-                crawlerDouyinMusicTaskService.updateById(crawlerDouyinMusicTask);
-            }
-            list = crawlerDouyinMusicTaskService.list(queryWrapper);
-        }
-        return "success";
-    }
-
-    @GetMapping(value = "/syncDouyinMusic")
-    public String syncDouyinMusic() {
-        for (int i = 0; i < 10; i++) {
-            final int j = i;
-            Thread thread = new Thread() {
-                @Override
-                public void run() {
-                    QueryWrapper<CrawlerDouyinMusicTask> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("status", "init").likeLeft("id", j).orderByDesc("id").last(" limit 20");
-                    List<CrawlerDouyinMusicTask> list = crawlerDouyinMusicTaskService.list(queryWrapper);
-                    while (list != null && list.size() > 0) {
-                        log.info("【同步歌曲】第" + j + "线程正在处理:" + list.size() + "条数据");
-                        for (CrawlerDouyinMusicTask crawlerDouyinMusicTask : list) {
-                            MusicInfo musicInfo = new MusicInfo();
-                            musicInfo.setExtId(crawlerDouyinMusicTask.getId());
-                            douyinMusicService.getMusicInfo(musicInfo);
-                        }
-                        list = crawlerDouyinMusicTaskService.list(queryWrapper);
-                    }
-                }
-            };
-            thread.start();
-        }
-
-        return "success";
-    }
-
-    @GetMapping(value = "/parseDouyinMusic")
-    public String parseDouyinMusic() {
-        for (int i = 0; i < 10; i++) {
-            final int j = i;
-            Thread thread = new Thread() {
-                @Override
-                public void run() {
-                    QueryWrapper<CrawlerDouyinMusicTask> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("status", "done").likeLeft("id", j).orderByDesc("id").last(" limit 20");
-                    List<CrawlerDouyinMusicTask> list = crawlerDouyinMusicTaskService.list(queryWrapper);
-                    while (list != null && list.size() > 0) {
-                        log.info("【解析分类】第" + j + "线程正在处理:" + list.size() + "条数据");
-                        for (CrawlerDouyinMusicTask crawlerDouyinMusicTask : list) {
-                            QueryWrapper<MusicInfo> queryWrapper1 = new QueryWrapper<>();
-                            queryWrapper1.eq("ext_id", crawlerDouyinMusicTask.getId()).last(" limit 1");
-                            MusicInfo musicInfo = musicInfoService.getOne(queryWrapper1);
-                            if (musicInfo != null) {
-                                douyinMusicService.parseTag(musicInfo);
-                            }
-                        }
-                        list = crawlerDouyinMusicTaskService.list(queryWrapper);
-                    }
-                }
-            };
-            thread.start();
-        }
-
-        return "success";
-    }
-
-    @GetMapping(value = "/testdouyinmusic")
-    public String testDouyinMusic() {
-        douyinMusicService.getHotMusicList();
-        return "success";
-    }
-
     @GetMapping(value = "/getDailyDataByProjectId")
     public String getDailyDataByProjectId(Long projectId, String startDate, String endDate) {
         Result<String> result = new Result<>();
         try {
-
             QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
             userAllocationQueryWrapper.eq("project_id", projectId);
             List<UserAllocation> list = userAllocationService.list(userAllocationQueryWrapper);
@@ -849,10 +730,7 @@ public class TestController {
 
                     }
                 }
-
             }
-
-
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
@@ -865,7 +743,6 @@ public class TestController {
     public String getHistoryDataByProjectId(Long projectId, String startDate, String endDate) {
         Result<String> result = new Result<>();
         try {
-
             QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
             userAllocationQueryWrapper.eq("project_id", projectId);
             // userAllocationQueryWrapper.eq("account_status", 0);
@@ -879,13 +756,9 @@ public class TestController {
                     CtopOauthToken ctopOauthTokens = tokenMapper.selectOne(tokenQueryWrapper);
                     if (!Check.isNull(ctopOauthTokens)) {
                         historyReportTaskService.createTask(ctopOauthTokens.getAccountId(), ctopOauthTokens.getAccessToken(), startDate, endDate, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
-
                     }
                 }
-
             }
-
-
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
@@ -893,7 +766,6 @@ public class TestController {
         return "success";
     }
 
-
     @GetMapping(value = "/getDailyDataByAccountId")
     public String getDailyDataByAccountId(Long accountId) {
         Result<String> result = new Result<>();
@@ -906,7 +778,6 @@ public class TestController {
             CtopOauthToken ctopOauthTokens = tokenMapper.selectOne(tokenQueryWrapper);
             if (!Check.isNull(ctopOauthTokens)) {
                 historyReportTaskService.createTask(ctopOauthTokens.getAccountId(), ctopOauthTokens.getAccessToken(), statDate, statDate, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_DAILY);
-
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -947,9 +818,6 @@ public class TestController {
                 });
             }
         }
-        // InputStream in, String fileName, String fileType, long fileSize, String fileSavePath
-
-
     }
 
 
@@ -994,22 +862,6 @@ public class TestController {
         return "Success";
     }
 
-
-    @GetMapping(value = "/getAccountReport")
-    public String getAccountReport(Long accountId, String startDate, String endDate) throws ParseException {
-        QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-        oauthTokenQueryWrapper.eq("media_id", 2);
-        oauthTokenQueryWrapper.eq("account_id", accountId);
-        oauthTokenQueryWrapper.last("limit 1");
-        CtopOauthToken token = tokenMapper.selectOne(oauthTokenQueryWrapper);
-        SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
-        Date date1 = sim.parse(startDate);
-        Date date2 = sim.parse(endDate);
-        //    kuaishouInterfaceService.getAdvertiserReportDaily(token, date1, date2);
-        return "Success";
-    }
-
-
     @GetMapping(value = "/updateCode")
     public String updateCode() {
         List<MaterialInfo> list = materialInfoService.list();
@@ -1070,7 +922,6 @@ public class TestController {
     public String getHistoryData(String startDate, String endDate) {
         Result<String> result = new Result<>();
         try {
-
             QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
             tokenQueryWrapper.eq("media_id", 2);
             List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
@@ -1092,14 +943,12 @@ public class TestController {
     public String getHistoryDataByAccountId(Long accountId, String startDte, String endDate) {
         Result<String> result = new Result<>();
         try {
-
             QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
             tokenQueryWrapper.eq("media_id", 2);
             tokenQueryWrapper.eq("account_id", accountId);
             CtopOauthToken ctopOauthTokens = tokenMapper.selectOne(tokenQueryWrapper);
             if (!Check.isNull(ctopOauthTokens)) {
                 historyReportTaskService.createTask(ctopOauthTokens.getAccountId(), ctopOauthTokens.getAccessToken(), startDte, endDate, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
-
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -1123,7 +972,6 @@ public class TestController {
         return "success";
     }
 
-
     @GetMapping(value = "/gerCreative")
     public void gerCreative() {
         QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
@@ -1166,8 +1014,6 @@ public class TestController {
         return result;
     }
 
-    @Autowired
-    private IKuaiShouDailyReportTaskService dailyReportTaskService;
 
     @GetMapping("loadBytedanceHistoryData")
     public Map<String, Object> loadBytedanceHistoryData() {
@@ -1208,8 +1054,6 @@ public class TestController {
         }
     }
 
-    @Autowired
-    private IByteDanceAdvertiserDataService advertiserDataService;
 
     @GetMapping("getBytedanceData")
     public Map<String, Object> getBytedanceData() {
@@ -1228,8 +1072,6 @@ public class TestController {
         return result;
     }
 
-    @Autowired
-    private IReportService reportService;
 
     @GetMapping(value = "/getAllCreativeList")
     public void getAllCreativeList() {
@@ -1290,8 +1132,6 @@ public class TestController {
     }
 
 
-    @Autowired
-    private IBytedanceEffectVideoInfoService effectVideoInfoService;
 
     @GetMapping("/bytedance/effectVideo/get")
     public Map<String, Object> effectVideoGet(String date) {
@@ -1398,8 +1238,6 @@ public class TestController {
         return result;
     }
 
-    @Autowired
-    public IBytedanceInterfaceService bytedanceInterfaceService;
 
     @GetMapping(value = "/searchLog")
     public Result searchLog(@Param("accountId") Long accountId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("operationTarget") Integer operationTarget) {
@@ -1447,8 +1285,6 @@ public class TestController {
         return result;
     }
 
-    @Autowired
-    private IKuaiShouCommentService kuaiShouCommentService;
 
     @GetMapping("deleteComment")
     public Map<String, Object> deleteComment(Long accountId) {
@@ -1481,16 +1317,6 @@ public class TestController {
         return result;
     }
 
-    @Autowired
-    IBytedanceVideoReportService bytedanceVideoReportService;
-    @Autowired
-    IETLReportBytedanceVideoService etlReportBytedanceVideoService;
-
-
-    @Autowired
-    private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
-    static ExecutorService executorServic1e = Executors.newFixedThreadPool(5);
-
     /**
      * 勿动勿删,煜一人群报表数据拉取接口。
      *
@@ -1534,11 +1360,13 @@ public class TestController {
     @Resource
     AiKuaishouUnitLevelOperationRecordMapper kuaishouUnitLevelOperationRecordMapper;
     @GetMapping(value = "/getAudienceDataNew")
-    public void getAudienceData() throws Exception {
+    public void getAudienceData(@RequestParam(required = false,defaultValue = "2019-01-01") String date) throws Exception {
         int page = 1;
         int pageSize = 2000;
-        String mulDate = DateUtils.formatDate(DateUtils.addDay(DateUtils.getNowDate(), -1), "yyyy-MM-dd");
-        List<CtopOauthToken> tokens = tokenService.getByProjectId(458l);    //淘特项目
+        if(date.equals("2019-01-01")){
+            date = DateUtils.formatDate(DateUtils.addDay(DateUtils.getNowDate(), -1), "yyyy-MM-dd");
+        }
+        List<CtopOauthToken> tokens = tokenService.getByProjectId(458L);    //淘特项目
         for (CtopOauthToken token : tokens) {
             Date startDate = DateUtils.getNowDate();
             if(startDate.after(token.getAccessTokenExpiresIn())){   //过期跳过
@@ -1550,15 +1378,16 @@ public class TestController {
                 continue;
             }
             countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
+            String finalDate = date;
             planIdsAndUnitIds.forEach(planIdAndUnitId -> executorService.submit(() -> {
                 try {
                     // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
-                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, mulDate, "province", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
-                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, mulDate, "city", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
-                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, mulDate, "gender", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
-                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, mulDate, "clientId", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
-                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, mulDate, "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
-                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, mulDate, "businessInterestTags", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "province", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "city", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "gender", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "clientId", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                    kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, finalDate, "businessInterestTags", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
 
                 } catch (Exception e) {
                 } finally {

+ 1 - 40
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -535,46 +535,7 @@ public class UserAllocationController {
     @ApiOperation(value = "用户分配-编辑", notes = "用户分配-编辑")
     @PutMapping(value = "/edit")
     public Result<UserAllocation> edit(@RequestBody UserAllocation userAllocation) {
-        Result<UserAllocation> result = new Result<>();
-        UserAllocation userAllocationEntity = userAllocationService.getById(userAllocation.getId());
-        if (userAllocationEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            boolean ok = userAllocationService.updateById(userAllocation);
-            Integer accountStatus = userAllocation.getAccountStatus();
-            if (!Check.isNull(accountStatus)) {
-                if (accountStatus == 1) {
-                    QueryWrapper<RuleAccountTemplate> ruleAccountTemplateQueryWrapper = new QueryWrapper<>();
-                    ruleAccountTemplateQueryWrapper.eq("account_id", userAllocationEntity.getAccountId());
-                    RuleAccountTemplate updateRuleAccountTemplate = new RuleAccountTemplate();
-                    updateRuleAccountTemplate.setTemplateStatus(1);
-                    ruleAccountTemplateService.update(updateRuleAccountTemplate, ruleAccountTemplateQueryWrapper);
-                }
-            }
-
-            UserAllocation update = userAllocationService.getById(userAllocation.getId());
-            QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
-            memberQueryWrapper.eq("user_id", update.getUserId());
-            memberQueryWrapper.eq("project_id", update.getProjectId());
-            memberQueryWrapper.last("limit 1");
-            ProjectMember member = memberMapper.selectOne(memberQueryWrapper);
-            if (Check.isNull(member)) {
-                ProjectMember addMember = new ProjectMember();
-                addMember.setProjectId(userAllocationEntity.getProjectId());
-                addMember.setUserId(userAllocationEntity.getUserId());
-                addMember.setUserName(userAllocationEntity.getUserName());
-                String roleCode = sysRoleService.getRoleCodeByUserId(userAllocationEntity.getUserId());
-                if (!Check.isNull(roleCode)) {
-                    addMember.setRoleCode(roleCode);
-                }
-                projectMemberService.save(addMember);
-            }
-
-            if (ok) {
-                result.success("修改成功!");
-            }
-        }
-        return result;
+        return userAllocationService.editUserAlloCation(userAllocation);
     }
 
     /**

+ 203 - 11
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,30 +1,222 @@
 package org.jeecg;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouUnitLevelOperationRecordMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
 import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Scanner;
+import java.util.concurrent.CountDownLatch;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
 public class SampleTest {
-    @Resource
-    CorpWexinUtils corpWexinUtils;
-    @Resource
-    MailLogMapper mailLogMapper;
+
+    @Autowired
+    IKuaishouAudienceReportDailyGenderService audienceReportDailyGenderService;
     @Test
-    public void weixin(){
-        JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("26bbe90edc5b475ca41ec3f76aa65067");
-        StringBuilder text = new StringBuilder();
-        text.append("您有一条销售政策需要审核,该客户为:");
-        text.append("测试");
-        text.append(",请及时登录助手平台-销售政策页面进行审核,谢谢!");
-        corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
+    public void IKuaishouAudienceReportDailyGenderServiceTest(){
+        audienceReportDailyGenderService.mergeAudienceReportDailyDate("2021-07-20");
     }
 
+
+
+//    @Resource
+//    CorpWexinUtils corpWexinUtils;
+//    @Resource
+//    MailLogMapper mailLogMapper;
+//    @Test
+//    public void weixin(){
+//        JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("26bbe90edc5b475ca41ec3f76aa65067");
+//        StringBuilder text = new StringBuilder();
+//        text.append("您有一条销售政策需要审核,该客户为:");
+//        text.append("测试");
+//        text.append(",请及时登录助手平台-销售政策页面进行审核,谢谢!");
+//        corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
+//    }
+//
+//    @Autowired
+//    IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
+//    @Resource
+//    AiKuaishouUnitLevelOperationRecordMapper kuaishouUnitLevelOperationRecordMapper;
+//    @Test
+//    public void getAudienceReport() throws InterruptedException {
+//        int page = 1;
+//        int pageSize = 2000;
+//        Date beginDate = DateUtils.parseDate("2021-05-01", "yyyy-MM-dd");
+//        Date endDate = DateUtils.parseDate("2021-06-01", "yyyy-MM-dd");
+//
+//        while (beginDate.before(endDate)){
+//            Date mulDate = beginDate;
+//            List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountId(mulDate, DateUtils.addDay(mulDate,1));
+//            countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
+//            planIdsAndUnitIds.forEach(planIdAndUnitId -> executorService.submit(() -> {
+//                try{
+//                    CtopOauthToken token = tokenService.getTokenByAccountId(planIdAndUnitId.getAccountId());
+//                    if(!Check.isNull(token)){
+//                        Date startDate = mulDate;
+//                        Date enDate = DateUtils.addDay(startDate, 30);
+//                        // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
+//                        while (startDate.before(enDate)){
+//                            kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate,"yyyy-MM-dd"), "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+//                            System.out.println("获取完毕 -> unit:" + planIdAndUnitId.getUnitId() +",日期:" + DateUtils.formatDate(startDate,"yyyy-MM-dd"));
+//                            startDate = DateUtils.addDay(startDate, 1);
+//                        }
+//
+//                    }else {
+//                        System.out.println("token异常 -》 accountId:"+planIdAndUnitId.getAccountId());
+//                    }
+//                }catch (Exception e){
+//                }finally {
+//                    countDownLatch.countDown();
+//                }
+//            }));
+//            beginDate = DateUtils.addDay(beginDate, 1);
+//            countDownLatch.await();
+//        }
+//
+//        System.out.println("走完了~");
+//
+//    }
+//    @Autowired
+//    cn.com.ctop.kuaishou.modules.report.service.IKuaishouPullTaskInfoService kuaishouPullTaskInfoService;
+//    /**
+//     * 发布任务到表里,大家消耗任务。  458  淘特项目所有账户从6月1日开始到现在所有的最新的数据
+//     */
+//    @Test
+//    public void initKusishouTaskInfo() {
+//        Date beginDate = DateUtils.parseDate("2021-06-01", "yyyy-MM-dd");
+//        Date endDate = DateUtils.parseDate("2021-08-04", "yyyy-MM-dd");
+//        while (beginDate.before(endDate)) {
+//            Date mulDate = beginDate;
+//            List<KuaishouPullTaskInfo> result = new ArrayList<>();
+//            List<Long> accountIds = kuaishouUnitLevelOperationRecordMapper.selectAllAccountIds(mulDate, DateUtils.addDay(mulDate, 1));
+//            accountIds.forEach(accountId -> {
+//                KuaishouPullTaskInfo taskInfo = new KuaishouPullTaskInfo();
+//                taskInfo.setAccountId(accountId);
+//                taskInfo.setTargetDate(DateUtils.formatDate(mulDate,"yyyy-MM-dd"));
+//                result.add(taskInfo);
+//            });
+//            kuaishouPullTaskInfoService.saveBatch(result);
+//            beginDate = DateUtils.addDay(beginDate, 1);
+//        }
+//
+//    }
+
+//    public void getAudienceReport() throws InterruptedException{
+//        int page = 1;
+//        int pageSize = 2000;
+//
+//        System.out.println("");
+//        System.out.println("");
+//        System.out.println("");
+//        System.out.println("");
+//        System.out.println("拉取人群报表数据服务已开始执行!");
+//        Scanner scan = new Scanner(System.in);
+//        System.out.println("请输入要运行几个任务:");
+//        int num = scan.nextInt();
+//        System.out.println("即将执行"+num+"个任务,执行完毕会自动退出此程序。");
+//        System.out.println("");
+//        System.out.println("");
+//        System.out.println("");
+//        System.out.println("");
+//        List<KuaishouPullTaskInfo> taskInfos = kuaishouPullTaskInfoMapper.getTaskInfos(num);
+//        System.exit(0);
+//        if(!Check.isNull(taskInfos)){
+//            taskInfos.forEach(taskInfo -> taskInfo.setStatus(1));
+//            kuaishouPullTaskInfoService.updateBatchById(taskInfos);
+//
+//            for (KuaishouPullTaskInfo taskInfo : taskInfos) {
+//                Date mulDate = DateUtils.parseDate(taskInfo.getTargetDate(), "yyyy-MM-dd");
+//                List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountIdAndDate(taskInfo.getAccountId(), mulDate, DateUtils.addDay(mulDate, 1));
+//                countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
+//                planIdsAndUnitIds.forEach(planIdAndUnitId -> executorService.submit(() -> {
+//                    try {
+//                        CtopOauthToken token = tokenService.getTokenByAccountId(planIdAndUnitId.getAccountId());
+//                        if (!Check.isNull(token)) {
+//                            Date startDate = mulDate;
+//                            Date enDate = DateUtils.addDay(startDate, 30);
+//                            // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
+//                            while (startDate.before(enDate)) {
+//                                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "province", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+//                                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "city", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+//                                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "gender", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+//                                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "clientId", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+//                                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+//                                kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "businessInterestTags", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+//                                System.out.println("获取完毕 -> unit:" + planIdAndUnitId.getUnitId() + ",日期:" + DateUtils.formatDate(startDate, "yyyy-MM-dd"));
+//                                startDate = DateUtils.addDay(startDate, 1);
+//                            }
+//
+//                        } else {
+//                            System.out.println("token异常 -》 accountId:" + planIdAndUnitId.getAccountId());
+//                        }
+//                    } catch (Exception e) {
+//                    } finally {
+//                        countDownLatch.countDown();
+//                    }
+//                }));
+//                countDownLatch.await();
+//            }
+//            System.out.println("11111111111111111111111111111111111111111111111111111111");
+//            System.out.println("11111111111111111111111111执行完毕111111111111111111111111");
+//            System.out.println("11111111111111111111111111111111111111111111111111111111");
+//            System.exit(0);
+//        }else{
+//            List<KuaishouPullTaskLog> taskLogs = kuaishouPullTaskLogMapper.getTaskInfos(num * 1000);
+//            if(Check.isNull(taskLogs)){
+//                System.out.println("所有的表里的任务走完啦,请联系发布任务!!!");
+//                return;
+//            }
+//
+//            taskLogs.forEach(taskLog -> taskLog.setStatus(1));
+//            kuaishouPullTaskLogService.updateBatchById(taskLogs);
+//
+//            countDownLatch = new CountDownLatch(taskLogs.size());
+//            taskLogs.forEach(taskLog -> executorService.submit(() -> {
+//                try {
+//                    CtopOauthToken token = tokenService.getTokenByAccountId(taskLog.getAccountId());
+//                    if (!Check.isNull(token)) {
+//                        Date startDate = DateUtils.parseDate(taskLog.getTargetDate(),"yyyy-MM-dd");
+//                        // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
+//                        kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "province", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
+//                        kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "city", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
+//                        kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "gender", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
+//                        kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "clientId", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
+//                        kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "ageSegment", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
+//                        kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, taskLog.getTargetDate(), "businessInterestTags", taskLog.getPlanId(), taskLog.getUnitId(), page, pageSize);
+//                        System.out.println("获取完毕 -> unit:" + taskLog.getUnitId() + ",日期:" + taskLog.getTargetDate());
+//                    } else {
+//                        System.out.println("token异常 -》 accountId:" + taskLog.getAccountId());
+//                    }
+//                } catch (Exception e) {
+//                } finally {
+//                    countDownLatch.countDown();
+//                }
+//            }));
+//            countDownLatch.await();
+//
+//            System.out.println("11111111111111111111111111111111111111111111111111111111");
+//            System.out.println("11111111111111111111111111执行完毕111111111111111111111111");
+//            System.out.println("11111111111111111111111111111111111111111111111111111111");
+//            System.exit(0);
+//        }
+//
+//
+//    }
 }

+ 0 - 2
jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java

@@ -8,11 +8,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.builder.SpringApplicationBuilder;
 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.core.env.Environment;
-import org.springframework.scheduling.annotation.EnableScheduling;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;

+ 2 - 2
jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-test.yml

@@ -261,8 +261,8 @@ bytedance:
     advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
 ai:
   callback:
-    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
-    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative
+    callback-unit-url: http://139.186.165.84:31012/ai_callback_add_group
+    callback-creative-url: http://139.186.165.84:31012/ai_callback_add_creative
 xxl-job:
   requestUrl: http://jiaoyangapi.shyouteng.com.cn