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

Merge remote-tracking branch 'origin/V2.0.1' into V2.0.1

zhaoxian 3 лет назад
Родитель
Сommit
d3cefddfab
100 измененных файлов с 2261 добавлено и 1087 удалено
  1. 0 4
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/ProvinceCityArea.java
  2. 0 1
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/es/JeecgElasticsearchTemplate.java
  3. 0 5
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java
  4. 2 8
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/dynamic/db/FreemarkerParseFactory.java
  5. 0 5
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/filter/StrAttackFilter.java
  6. 0 3
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/oConvertUtils.java
  7. 10 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  8. 5 7
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java
  9. 0 5
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/advertise/controller/BytedanceRejectReasonController.java
  10. 0 1
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java
  11. 0 1
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/advertise/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  12. 0 6
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/advertise/service/impl/BytedanceRejectReasonServiceImpl.java
  13. 0 1
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/service/impl/CtopOauthTokenServiceImpl.java
  14. 0 19
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/utils/ApkUtils.java
  15. 0 12
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/utils/Check.java
  16. 0 6
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/utils/GetCampaignNum.java
  17. 0 9
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/utils/StringUtils.java
  18. 0 10
      jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/report/utils/TimeStartAndEndUtil.java
  19. 21 24
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/agent/controller/AgentManagementController.java
  20. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/agent/mapper/CtopAccountTransactionDayMapper.java
  21. 4 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/agent/service/AgentManagementService.java
  22. 35 35
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/agent/service/impl/AgentManagementServiceImpl.java
  23. 15 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java
  24. 95 95
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/DemoController.java
  25. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml
  26. 0 12
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/utils/Check.java
  27. 0 18
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/DemoReportController.java
  28. 29 14
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java
  29. 8 20
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementController.java
  30. 11 24
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java
  31. 2 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementFileInfo.java
  32. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementInfo.java
  33. 27 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/CtopCwjsSlettementReport.java
  34. 7 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/ProfitReportBytedanceVo.java
  35. 3 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/ProfitReportKuaiShouVo.java
  36. 1 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SettlementFileParamsVo.java
  37. 28 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/CwjsProfitMapper.java
  38. 26 13
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java
  39. 3 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java
  40. 10 3
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementInfoMapper.java
  41. 27 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/CwjsProfitMapper.xml
  42. 367 108
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml
  43. 18 11
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml
  44. 9 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementInfoMapper.xml
  45. 9 10
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/IReportSettlementService.java
  46. 6 9
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementFileInfoService.java
  47. 4 5
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementInfoService.java
  48. 439 129
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java
  49. 24 28
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java
  50. 127 22
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java
  51. 152 20
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java
  52. 42 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/createExcelByTemplate.java
  53. 1 1
      jeecg-boot-finance/src/main/resources/application-prod.yml
  54. 27 17
      jeecg-boot-finance/src/test/java/org/jeecg/modules/finance/FinanceTest.java
  55. 1 21
      jeecg-boot-module-demo/src/main/java/org/jeecg/modules/demo/mock/vxe/controller/VxeMockController.java
  56. 0 2
      jeecg-boot-module-demo/src/main/java/org/jeecg/modules/demo/test/service/impl/JeecgDemoServiceImpl.java
  57. 10 11
      jeecg-boot-module-demo/src/main/java/org/jeecg/modules/dlglong/controller/DlMockController.java
  58. 0 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/alarm/modules/controller/RuleTemplateController.java
  59. 19 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java
  60. 3 18
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/RuleDateUnitKuaishou.java
  61. 9 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  62. 38 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  63. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  64. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  65. 21 20
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java
  66. 90 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  67. 3 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserCompanyServiceImpl.java
  68. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java
  69. 0 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ParseInstallPackageUtil.java
  70. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java
  71. 5 6
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java
  72. 0 8
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CrossAccountBatchController.java
  73. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouGroupTemplateController.java
  74. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActionBarTextServiceImpl.java
  75. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  76. 0 55
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java
  77. 0 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouOverRunSendMessageServiceImpl.java
  78. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  79. 0 98
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  80. 2 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl2.java
  81. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouRealTimeDataServiceImpl.java
  82. 127 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/clean/controller/EstimatePepoleNumberController.java
  83. 5 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/dimension/controller/KuaiShouDimensionStrategyController.java
  84. 0 9
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/dimension/controller/KuaiShouDimensionUnitController.java
  85. 26 12
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java
  86. 11 6
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewPlanReportCtrl.java
  87. 3 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyGender.java
  88. 16 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/NewMonitorInfo.java
  89. 4 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyGenderMapper.java
  90. 24 18
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java
  91. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KsNewPlanReportMapper.xml
  92. 92 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyGenderMapper.xml
  93. 31 10
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml
  94. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyGenderService.java
  95. 6 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java
  96. 1 7
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/AccountReportServiceImpl.java
  97. 108 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyGenderServiceImpl.java
  98. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java
  99. 0 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java
  100. 0 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java

+ 0 - 4
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/ProvinceCityArea.java

@@ -40,7 +40,6 @@ public class ProvinceCityArea {
     }
 
     private void initAreaList(){
-        //System.out.println("=====================");
         if(this.areaList==null || this.areaList.size()==0){
             this.areaList = new ArrayList<Area>();
             try {
@@ -49,20 +48,17 @@ public class ProvinceCityArea {
                 //第一层 省
                 JSONObject provinceJson = baseJson.getJSONObject("86");
                 for(String provinceKey: provinceJson.keySet()){
-                    //System.out.println("===="+provinceKey);
                     Area province = new Area(provinceKey,provinceJson.getString(provinceKey),"86");
                     this.areaList.add(province);
                     //第二层 市
                     JSONObject cityJson = baseJson.getJSONObject(provinceKey);
                     for(String cityKey:cityJson.keySet()){
-                        //System.out.println("-----"+cityKey);
                         Area city = new Area(cityKey,cityJson.getString(cityKey),provinceKey);
                         this.areaList.add(city);
                         //第三层 区
                         JSONObject areaJson =  baseJson.getJSONObject(cityKey);
                         if(areaJson!=null){
                             for(String areaKey:areaJson.keySet()){
-                                //System.out.println("········"+areaKey);
                                 Area area = new Area(areaKey,areaJson.getString(areaKey),cityKey);
                                 this.areaList.add(area);
                             }

+ 0 - 1
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/es/JeecgElasticsearchTemplate.java

@@ -125,7 +125,6 @@ public class JeecgElasticsearchTemplate {
             data.remove("id");
             bodySB.append(data.toJSONString()).append("\n");
         }
-        System.out.println("+-+-+-: bodySB.toString(): " + bodySB.toString());
         HttpHeaders headers = RestUtil.getHeaderApplicationJson();
         RestUtil.request(url, HttpMethod.PUT, headers, null, bodySB, JSONObject.class);
         return true;

+ 0 - 5
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/util/JwtUtil.java

@@ -209,9 +209,4 @@ public class JwtUtil {
 		if(returnValue!=null){returnValue = returnValue + moshi;}
 		return returnValue;
 	}
-	
-//	public static void main(String[] args) {
-//		 String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NjUzMzY1MTMsInVzZXJuYW1lIjoiYWRtaW4ifQ.xjhud_tWCNYBOg_aRlMgOdlZoWFFKB_givNElHNw3X0";
-//		 System.out.println(JwtUtil.getUsername(token));
-//	}
 }

+ 2 - 8
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/dynamic/db/FreemarkerParseFactory.java

@@ -98,10 +98,7 @@ public class FreemarkerParseFactory {
             paras.remove(MINI_DAO_FORMAT);
             return sql;
         } catch (Exception e) {
-            log.error(e.getMessage(), e.fillInStackTrace());
-            log.error("发送一次的模板key:{ " + tplName + " }");
-            //System.err.println(e.getMessage());
-            //System.err.println("模板名:{ "+ tplName +" }");
+            e.printStackTrace();
             throw new RuntimeException("解析SQL模板异常");
         }
     }
@@ -130,10 +127,7 @@ public class FreemarkerParseFactory {
             paras.remove(MINI_DAO_FORMAT);
             return sql;
         } catch (Exception e) {
-            log.error(e.getMessage(), e.fillInStackTrace());
-            log.error("发送一次的模板key:{ " + tplContent + " }");
-            //System.err.println(e.getMessage());
-            //System.err.println("模板内容:{ "+ tplContent +" }");
+            e.printStackTrace();
             throw new RuntimeException("解析SQL模板异常");
         }
     }

+ 0 - 5
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/filter/StrAttackFilter.java

@@ -16,9 +16,4 @@ public class StrAttackFilter {
         Matcher m = p.matcher(str);
         return m.replaceAll("").trim();
     }
-
-//    public static void main(String[] args) {
-//        String filter = filter("@#jeecg/《》【bo】¥%……&*(o))))!@t<>,.,/?'\'~~`");
-//        System.out.println(filter);
-//    }
 }

+ 0 - 3
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/oConvertUtils.java

@@ -71,9 +71,6 @@ public class oConvertUtils {
 		}
 		try {
 			byte[] b = strIn.getBytes(sourceCode);
-			for (int i = 0; i < b.length; i++) {
-				System.out.print(b[i] + "  ");
-			}
 			strOut = new String(b, targetCode);
 		} catch (Exception e) {
 			e.printStackTrace();

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

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

+ 5 - 7
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java

@@ -68,13 +68,11 @@ public class ShiroRealm extends AuthorizingRealm {
 
         // 设置用户拥有的角色集合,比如“admin,test”
         Set<String> roleSet = commonAPI.queryUserRoles(username);
-        System.out.println(roleSet.toString());
         info.setRoles(roleSet);
 
         // 设置用户拥有的权限集合,比如“sys:role:add,sys:user:add”
         Set<String> permissionSet = commonAPI.queryUserAuths(username);
         info.addStringPermissions(permissionSet);
-        System.out.println(permissionSet);
         log.info("===============Shiro权限认证成功==============");
         return info;
     }
@@ -88,7 +86,7 @@ public class ShiroRealm extends AuthorizingRealm {
      * @throws AuthenticationException
      */
     @Override
-    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
+    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) {
         log.debug("===============Shiro身份认证开始============doGetAuthenticationInfo==========");
         String token = (String) auth.getCredentials();
         if (token == null) {
@@ -105,7 +103,7 @@ public class ShiroRealm extends AuthorizingRealm {
      *
      * @param token
      */
-    public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException {
+    public LoginUser checkUserTokenIsEffect(String token){
         // 解密获得username,用于和数据库进行对比
         String username = JwtUtil.getUsername(token);
         if (username == null) {
@@ -116,15 +114,15 @@ public class ShiroRealm extends AuthorizingRealm {
         log.debug("———校验token是否有效————checkUserTokenIsEffect——————— "+ token);
         LoginUser loginUser = commonAPI.getUserByName(username);
         if (loginUser == null) {
-            throw new AuthenticationException("用户不存在!");
+            log.info("用户不存在!");
         }
         // 判断用户状态
         if (loginUser.getStatus() != 1) {
-            throw new AuthenticationException("账号已被锁定,请联系管理员!");
+            log.info("账号已被锁定,请联系管理员!");
         }
         // 校验token是否超时失效 & 或者账号密码是否错误
         if (!jwtTokenRefresh(token, username, loginUser.getPassword())) {
-            throw new AuthenticationException("Token失效,请重新登录!");
+            log.info("Token失效,请重新登录!");
         }
 
         return loginUser;

+ 0 - 5
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/advertise/controller/BytedanceRejectReasonController.java

@@ -60,14 +60,10 @@ public class BytedanceRejectReasonController {
         Result result = new Result();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         if (null == tokens || tokens.isEmpty()) {
-            System.out.println("未获取到token");
             result.setCode(500);
             result.setMessage("未获取到token");
             return result;
         }
-
-        System.out.println("---------------------------------->>"+tokens.size()+"个token<<----------------------------------");
-
         tokens.forEach(token -> executorService.submit(()->getRejectReasonByToken(token, hour)));
 
 
@@ -93,7 +89,6 @@ public class BytedanceRejectReasonController {
 
             while(adids.size() > 10){
                 List<String> mulAdids = adids.subList(0,10);
-//                System.out.println("查询的计划是"+Arrays.toString(mulAdids.toArray()));
                 Result dataListResult = marketingService.getRejectReason(token, token.getAccountId().toString(), mulAdids);
                 if(dataListResult.getMessage().toString().contains("No permission to operate account")){
                     return;

+ 0 - 1
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java

@@ -599,7 +599,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
 
     private Long createAdInfo(CtopOauthToken token, AiBytedanceAdvertiserStrategy strategy, JSONObject adParams) {
         Result result = marketingService.createAdvertiserPlan(token,adParams,strategy);
-        System.out.println(result);
         if(result.getCode()!=0){
             AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
                     strategy.getAccountId(),

+ 0 - 1
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/advertise/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -56,7 +56,6 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
             params.put("advertiser_id", accountId);
             String result = HttpUtils.httpGetRequest(url, headers, params);
             JSONObject jsonObject = JSONObject.parseObject(result);
-            System.err.println(jsonObject);
             if (Check.isNull(jsonObject)) {
                 throw new Exception("返回结果为空");
             }

+ 0 - 6
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/advertise/service/impl/BytedanceRejectReasonServiceImpl.java

@@ -72,9 +72,6 @@ public class BytedanceRejectReasonServiceImpl implements BytedanceRejectReasonSe
                     }
 
                     int res = bytedancePlanRejectReasonMapper.replaceIntoDb(bytedancePlanRejectReason);
-                    if(res == 0){
-                        System.out.println(bytedancePlanRejectReason.toString());
-                    }
                 }
             }
 
@@ -119,9 +116,6 @@ public class BytedanceRejectReasonServiceImpl implements BytedanceRejectReasonSe
                         bytedanceMaterialRejectReason.setAdId(ad_reject.getLong("ad_id"));
                     }
                     int res =  BytedanceMaterialRejectReasonMapper.replaceIntoDb(bytedanceMaterialRejectReason);
-                    if(res == 0){
-                        System.out.println(bytedanceMaterialRejectReason.toString());
-                    }
 //                    BytedanceMaterialRejectReasonMapper.insert(bytedanceMaterialRejectReason);
                 }
             }

+ 0 - 1
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/service/impl/CtopOauthTokenServiceImpl.java

@@ -73,7 +73,6 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         param.put("grant_type", "refresh_token");
         param.put("refresh_token", token.getRefreshToken());
         String result = HttpUtils.httpPostRequest(url, param, new HashMap<>());
-        System.err.println(JSONObject.parseObject(result));
         log.info("头条刷新token;accountId:{},返回信息:{}", token.getAccountId(), result);
         if (null == result || "".equals(result.trim()) || "null".equalsIgnoreCase(result)) {
             log.info("头条刷新token失败;accountId:{},返回信息:{}", token.getAccountId(), result);

+ 0 - 19
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/utils/ApkUtils.java

@@ -229,23 +229,4 @@ public class ApkUtils {
         }
         return map;
     }
-
-
-    public static void main(String[] args) {
-       // Map map = ApkUtils.readAPK("https://apps.bytesfield.com/download/basic/cur/1c728178004c8d4d6c83444a05c414c1a1cfae48");
-
-        String filePath = LoadFileUtil.downLoadFromUrl("https://apps.bytesfield.com/download/basic/cur/1c728178004c8d4d6c83444a05c414c1a1cfae48-","E:\\appFiles");
-        //String filePath = LoadFileUtil.downLoadFromUrl("https://apps.bytesfield.com/download/basic/cur/96e5f2491826db22962149059da9e4eee7589764","E:\\appFiles");
-
-        System.out.println(filePath);
-
-        Map map = ApkUtils.readAPK(filePath);
-        Map map2 = ApkUtils.readIPA(filePath);
-
-        System.out.println(map);
-        System.out.println(map2);
-
-
-    }
-
 }

+ 0 - 12
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/utils/Check.java

@@ -138,16 +138,4 @@ public class Check {
         }
         return beanList;
     }
-
-
-    public static void main(String[] args) {
-        JSONObject params = new JSONObject();
-        params.put("advertiser_id", "123");
-        params.put("campaign_id", "123");
-        params.put("modify_time", null);
-        System.out.println(jsonRemoveEmpty(params));
-    }
-
-
-
 }

+ 0 - 6
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/utils/GetCampaignNum.java

@@ -22,16 +22,10 @@ public class GetCampaignNum {
 
         Long zu = countNum / campaignAdCnt;
         Long yu = countNum % campaignAdCnt;
-        //System.out.println("余---"+yu);
         // 不能整除 有余数 则 组 = 商 + 1
         // 整除 组 = 商
         Long count = yu != 0 ? zu.intValue()+1 : zu;
        // 账户配置中的组数量 < 当前 组序号
-        if (count.intValue() <= campaignCnt){
-            System.out.println("组序号----------"+count);
-        }else {
-            System.out.println("组序号-超过了规定的最大值-----"+count);
-        }
         return count;
     }
 

+ 0 - 9
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/common/utils/StringUtils.java

@@ -191,15 +191,6 @@ public class StringUtils {
         return list;
     }
 
-    public static void main(String[] args) {
-        String msg = "PerformanceManager{第1个中括号}Product{第2个中括号}<{第3个中括号}79~";
-        List<String> list = extractMessageByRegular(msg);
-        for (int i = 0; i < list.size(); i++) {
-            System.out.println(i+"-->"+list.get(i));
-        }
-    }
-
-
     /**
      *
      * 获取目标转化出价

+ 0 - 10
jeecg-boot-bytedance-ad/src/main/java/ctop/bytedance/ad/report/utils/TimeStartAndEndUtil.java

@@ -79,14 +79,4 @@ public class TimeStartAndEndUtil {
         }
         return dateList;
     }
-
-
-
-    public static void main(String[] args) throws Exception {
-//        Map<String,String> map = TimeStartAndEndUtil.getStartEndTime("2020-05-15","2020-05-18");
-        List<String> list = TimeStartAndEndUtil.getAllDatesOfTwoTimes("2021-05-19","2021-05-27");
-        System.out.println(list);
-    }
-
-
 }

+ 21 - 24
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/agent/controller/AgentManagementController.java

@@ -10,9 +10,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
 
 @RestController
 @RequestMapping("/agent")
@@ -22,9 +19,10 @@ public class AgentManagementController {
     @Autowired
     AgentManagementService agentManagementService;
 
+
     @RequestMapping("/queryAccountTransactionDetails")
-    public void getList(@Param("starDate")String startDate,@Param("endDate")String endDate) {
-        Result recharge = agentManagementService.synchronousAccountTransactionDetails(startDate,endDate);
+    public void getList(@Param("starDate") String startDate, @Param("endDate") String endDate) {
+        Result recharge = agentManagementService.synchronousAccountTransactionDetails(startDate, endDate);
 
     }
 
@@ -35,36 +33,35 @@ public class AgentManagementController {
 
 
     @RequestMapping("/synchronousAccountTransactionDay")
-    public void synchronousAccountTransactionDay(@Param("starDate")String startDate,@Param("endDate")String endDate) {
-        Result recharge = agentManagementService.synchronousAccountTransactionDay(startDate,endDate);
+    public void synchronousAccountTransactionDay(@Param("starDate") String startDate, @Param("endDate") String endDate) {
+        Result recharge = agentManagementService.synchronousAccountTransactionDay(startDate, endDate);
     }
 
 
     @RequestMapping("/synchronous")
     public void synchronous() throws ParseException {
-        String date1="2021-05-01";
-        String date2="2021-05-31";
-        String date3="2021-06-01";
-        String date4="2021-06-30";
-        String date5="2021-07-01";
-        String date6="2021-07-31";
-        String date7="2021-08-01";
-        String date8="2021-08-31";
+        String date1 = "2021-05-01";
+        String date2 = "2021-05-31";
+        String date3 = "2021-06-01";
+        String date4 = "2021-06-30";
+        String date5 = "2021-07-01";
+        String date6 = "2021-07-31";
+        String date7 = "2021-08-01";
+        String date8 = "2021-08-31";
         agentManagementService.synchronousAccount();
         //5月份
-         agentManagementService.synchronousAccountTransactionDetails(date1,date2);
-         agentManagementService.synchronousAccountTransactionDay(date1,date2);
+        agentManagementService.synchronousAccountTransactionDetails(date1, date2);
+        agentManagementService.synchronousAccountTransactionDay(date1, date2);
         //6月份
-         agentManagementService.synchronousAccountTransactionDetails(date3,date4);
-         agentManagementService.synchronousAccountTransactionDay(date3,date4);
+        agentManagementService.synchronousAccountTransactionDetails(date3, date4);
+        agentManagementService.synchronousAccountTransactionDay(date3, date4);
         //7月份
-         agentManagementService.synchronousAccountTransactionDetails(date5,date6);
-         agentManagementService.synchronousAccountTransactionDay(date5,date6);
+        agentManagementService.synchronousAccountTransactionDetails(date5, date6);
+        agentManagementService.synchronousAccountTransactionDay(date5, date6);
         //8月份
-          agentManagementService.synchronousAccountTransactionDetails(date7,date8);
-          agentManagementService.synchronousAccountTransactionDay(date7,date8);
+        agentManagementService.synchronousAccountTransactionDetails(date7, date8);
+        agentManagementService.synchronousAccountTransactionDay(date7, date8);
     }
 
 
-
 }

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/agent/mapper/CtopAccountTransactionDayMapper.java

@@ -9,7 +9,7 @@ import java.util.List;
 @Mapper
 public interface CtopAccountTransactionDayMapper {
 
-    List<String> getAdvertiserIdByDate(@Param("date") String date,@Param("advertiserId") String advertiserId);
+    List<String> getAdvertiserIdByDate(@Param("date") String date, @Param("advertiserId") String advertiserId);
 
     void saveAccountTransactionDay(@Param("list") List<TransactionDay> list, @Param("date") String date);
 

+ 4 - 4
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/agent/service/AgentManagementService.java

@@ -12,17 +12,17 @@ public interface AgentManagementService {
 
 
     //查询账号流水
-    public JSONObject queryAccountTransactionDetails(String AccountId, String transaction_type, int pageNum, int pageSize,String startDate,String endDate);
+    public JSONObject queryAccountTransactionDetails(String AccountId, String transaction_type, int pageNum, int pageSize, String startDate, String endDate);
 
     //查询账号流水
-    public JSONObject queryAccountTransactionDay(String AccountId, int pageNum, int pageSize,String startDate,String endDate);
+    public JSONObject queryAccountTransactionDay(String AccountId, int pageNum, int pageSize, String startDate, String endDate);
 
     //同步代理商账户入库
     public Result synchronousAccount();
 
     //同步账户交易流水
-    public Result synchronousAccountTransactionDetails(String startDate,String endDate);
+    public Result synchronousAccountTransactionDetails(String startDate, String endDate);
 
     //同步账户日流水
-    public Result synchronousAccountTransactionDay(String startDate,String endDate);
+    public Result synchronousAccountTransactionDay(String startDate, String endDate);
 }

+ 35 - 35
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/agent/service/impl/AgentManagementServiceImpl.java

@@ -124,7 +124,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @create: 2021-07-15
      */
     @Override
-    public Result synchronousAccountTransactionDetails(String startDate,String endDate) {
+    public Result synchronousAccountTransactionDetails(String startDate, String endDate) {
         log.info("开始同步账号交易流水");
         Result result = new Result();
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
@@ -136,9 +136,9 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                 accountIdList.stream().forEach(str -> {
                     if (!str.isEmpty()) {
                         //查询账号下充值的交易流水
-                        JSONObject jsonObject = queryAccountTransactionDetails(str, RECHARGE, 1, 1000, startDate,endDate);
+                        JSONObject jsonObject = queryAccountTransactionDetails(str, RECHARGE, 1, 1000, startDate, endDate);
                         int code = (int) jsonObject.get("code");
-                        if(code!=0){
+                        if (code != 0) {
                             result.setMessage((String) jsonObject.get("message"));
                             log.info((String) jsonObject.get("message"));
                             return;
@@ -162,7 +162,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                                 //查询其他页数据
                                 if (total_page > 1) {
                                     for (int i = 2; i <= total_page; i++) {
-                                        JSONObject jo = queryAccountTransactionDetails(str, RECHARGE, i, 1000, startDate,endDate);
+                                        JSONObject jo = queryAccountTransactionDetails(str, RECHARGE, i, 1000, startDate, endDate);
                                         JSONObject accountData = (JSONObject) jo.get("data");
                                         List<Object> rechargeList = (List<Object>) accountData.get("list");
                                         rechargeList.stream().forEach(transactionDetails -> {
@@ -178,10 +178,10 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                         }
 
                         //查询账号下转账的交易流水
-                        JSONObject transferJsonObject = queryAccountTransactionDetails(str, TRANSFER, 1, 1000, startDate,endDate);
+                        JSONObject transferJsonObject = queryAccountTransactionDetails(str, TRANSFER, 1, 1000, startDate, endDate);
                         JSONObject transferData = (JSONObject) transferJsonObject.get("data");
                         int code1 = (int) jsonObject.get("code");
-                        if(code1!=0){
+                        if (code1 != 0) {
                             result.setMessage((String) jsonObject.get("message"));
                             log.info((String) jsonObject.get("message"));
                             return;
@@ -203,7 +203,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                                 //查询其他页数据
                                 if (transferTotalPage > 1) {
                                     for (int i = 2; i <= transferTotalPage; i++) {
-                                        JSONObject jo = queryAccountTransactionDetails(str, TRANSFER, i, 1000, startDate,endDate);
+                                        JSONObject jo = queryAccountTransactionDetails(str, TRANSFER, i, 1000, startDate, endDate);
                                         JSONObject accountData = (JSONObject) jo.get("data");
                                         List<Object> rechargeList = (List<Object>) accountData.get("list");
                                         rechargeList.stream().forEach(transactionDetails -> {
@@ -246,7 +246,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @create: 2021-07-15
      */
     @Override
-    public Result synchronousAccountTransactionDay(String startDate,String endDate) {
+    public Result synchronousAccountTransactionDay(String startDate, String endDate) {
         log.info("开始同步账号日流水");
         Result result = new Result();
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
@@ -260,18 +260,18 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                 accountIdList.stream().forEach(str -> {
                     if (!str.isEmpty()) {
                         //查询账号下充值的交易流水
-                        JSONObject jsonObject = queryAccountTransactionDay(str, 1, 1000, startDate,endDate);
-                        JSONObject data=null;
-                        int code=1;
-                        if(jsonObject!=null){
-                             data = (JSONObject) jsonObject.get("data");
-                             code = (int) jsonObject.get("code");
-                        }else {
+                        JSONObject jsonObject = queryAccountTransactionDay(str, 1, 1000, startDate, endDate);
+                        JSONObject data = null;
+                        int code = 1;
+                        if (jsonObject != null) {
+                            data = (JSONObject) jsonObject.get("data");
+                            code = (int) jsonObject.get("code");
+                        } else {
                             log.info("返回数据jsonObject为null:");
                         }
-                        if(code!=0){
+                        if (code != 0) {
                             result.setMessage((String) jsonObject.get("message"));
-                            log.info("返回数据:"+jsonObject.toJSONString()+":"+str);
+                            log.info("返回数据:" + jsonObject.toJSONString() + ":" + str);
                         }
                         if (data != null) {
                             List<Object> dataList = (List<Object>) data.get("list");
@@ -280,9 +280,9 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                                 //保存第一页数据
                                 dataList.stream().forEach(ob -> {
                                     TransactionDay transactionDay = JSONObject.toJavaObject((JSON) ob, TransactionDay.class);
-                                    List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(),transactionDay.getAdvertiserId());
+                                    List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
                                     //订单号不存在
-                                    if (advertiserIdList.isEmpty() || advertiserIdList.size()<=0) {
+                                    if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
                                         transactionDetailsList.add(transactionDay);
                                     }
 
@@ -292,15 +292,15 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                                 //查询其他页数据
                                 if (total_page > 1) {
                                     for (int i = 2; i <= total_page; i++) {
-                                        JSONObject jo = queryAccountTransactionDay(str, i, 1000, startDate,endDate);
+                                        JSONObject jo = queryAccountTransactionDay(str, i, 1000, startDate, endDate);
                                         JSONObject accountData = (JSONObject) jo.get("data");
                                         List<Object> rechargeList = (List<Object>) accountData.get("list");
                                         rechargeList.stream().forEach(obj -> {
                                             TransactionDay transactionDay = JSONObject.toJavaObject((JSON) obj, TransactionDay.class);
-                                            List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(),transactionDay.getAdvertiserId());
+                                            List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
 
                                             //订单号不存在
-                                            if (advertiserIdList.isEmpty() || advertiserIdList.size()<=0) {
+                                            if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
                                                 transactionDetailsList.add(transactionDay);
                                             }
                                         });
@@ -338,7 +338,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @create: 2021-07-14
      */
     @Override
-    public JSONObject queryAccountTransactionDetails(String AccountId, String transaction_type, int pageNum, int pageSize, String startDate,String endDate) {
+    public JSONObject queryAccountTransactionDetails(String AccountId, String transaction_type, int pageNum, int pageSize, String startDate, String endDate) {
         // 请求参数
         Map data = new HashMap() {
             {
@@ -362,22 +362,22 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @create: 2021-07-14
      */
     @Override
-    public JSONObject queryAccountTransactionDay(String AccountId, int pageNum, int pageSize,String startDate,String endDate) {
+    public JSONObject queryAccountTransactionDay(String AccountId, int pageNum, int pageSize, String startDate, String endDate) {
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
         Calendar ca = Calendar.getInstance();
         ca.setTime(new Date());
         ca.add(Calendar.DATE, -1);
-            // 请求参数
-            Map data = new HashMap() {
-                {
-                    put("advertiser_id", AccountId);
-                    put("start_date", startDate);
-                    put("end_date", endDate);
-                    put("page", pageNum);
-                    put("page_size", pageSize);
-                }
-            };
-            return sendHttpRequest(data, ACCOUNT_TRANSACTION_DAY_URL);
+        // 请求参数
+        Map data = new HashMap() {
+            {
+                put("advertiser_id", AccountId);
+                put("start_date", startDate);
+                put("end_date", endDate);
+                put("page", pageNum);
+                put("page_size", pageSize);
+            }
+        };
+        return sendHttpRequest(data, ACCOUNT_TRANSACTION_DAY_URL);
 
 
     }

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

@@ -36,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
 
 import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.policy.utils.ListPageUtil;
+import org.jeecg.ctop.finance.settlement.service.serviceImpl.ReportSettlementServiceImpl;
 import org.jeecg.modules.ctop.service.IMaterialReportOverViewService;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -89,6 +90,11 @@ public class CwjsPolicyInfoController {
      @Autowired
      private ISysUserService sysUserService;
 
+
+     @Resource
+     private ReportSettlementServiceImpl reportSettlementService;
+
+
 	 @GetMapping(value = "/queryApprovalRejectReason")
 	 public Result<CwjsPolicyApprovalLog> queryApprovalRejectReason(@RequestParam(name="id",required=true) Integer id){
 		 CwjsPolicyApprovalLog policyApprovalLog = policyApprovalLogService.getOneByPolicyId(id);
@@ -149,6 +155,14 @@ public class CwjsPolicyInfoController {
 			 CwjsCompanyApprovalUser nextApprovalUser = companyApprovalUserMapper.queryByCompanySubjectIdAndLevel(companySubjectId, cwjsCompanyApprovalUser.getLevel() + 1);
 			 if(!Check.isNull(cwjsCompanyApprovalUser) && Check.isNull(nextApprovalUser)){//没有下一个审核人员,是终审
 				cwjsPolicyInfoEntity.setApprovedStatus(3);
+
+				 /**
+				  * 终审通过后 添加 起始时间
+				  */
+
+				 reportSettlementService.cwjsPRofit(cwjsPolicyInfoEntity);
+
+
 			}else{	//不是终审
 				cwjsPolicyInfoEntity.setApprovedStatus(2);
 				cwjsPolicyInfoEntity.setApprovedProgress(nextApprovalUser.getApprovalUserId());	//设置一下个人为审核人员
@@ -269,7 +283,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>
 

+ 0 - 12
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/utils/Check.java

@@ -134,16 +134,4 @@ public class Check {
         }
         return beanList;
     }
-
-
-    public static void main(String[] args) {
-        JSONObject params = new JSONObject();
-        params.put("advertiser_id", "123");
-        params.put("campaign_id", "123");
-        params.put("modify_time", null);
-        System.out.println(jsonRemoveEmpty(params));
-    }
-
-
-
 }

+ 0 - 18
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/DemoReportController.java

@@ -221,22 +221,4 @@ public class DemoReportController {
         output.close();
        return "123";
     }
-
-
-    public static void main(String[] args) throws Exception {
-        File file1 = new File("C:\\Users\\Administrator\\Desktop\\汇创\\20210507161223.jpg");
-        File file2 = new File("https://media-1301855440.cos.ap-chongqing.myqcloud.com/image/2021-08-05/2-1628129040416.jpg");
-        System.out.println(file1.exists());
-        System.out.println(file2.exists());
-
-        //BufferedImage bufferImg = ImageIO.read(new File("media-1301855440\\u002Ecos\\u002Eap-chongqing\\u002Emyqcloud\\u002Ecom/image/2021-08-05/2-1628129040416.jpg"));
-       //String imagePath = "https:\\/\\/media-1301855440.cos.ap-chongqing.myqcloud.com"+File.separator+"image"+File.separator+"2021-08-05"+File.separator+"2-1628129040416.jpg";
-        String imagePath = "https://media-1301855440.cos.ap-chongqing.myqcloud.com/image/2021-08-05/2-1628129040416.jpg";
-        System.out.println(imagePath);
-        //InputStream is = new FileInputStream(imagePath);
-        InputStream is = createExcelByTemplate.getInputStreamByUrl(imagePath);
-        System.out.println(is);
-
-    }
-
 }

+ 29 - 14
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java

@@ -1,14 +1,20 @@
 package org.jeecg.ctop.finance.settlement.controller;
 
+import cn.com.ctop.common.module.service.ISysUserService;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.entity.SysUser;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.Date;
 
 
 /**
@@ -24,23 +30,30 @@ public class ExportReportController {
 
     @Autowired
     private IReportSettlementService reportSettlementService;
-
+    @Autowired
+    private ISysUserService userService;
 
     @ApiOperation(value = "财务结算-结算单导出-头条", notes = "财务结算-结算单导出-头条")
     @GetMapping(value = "/settlementReportBytedance")
-    public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-
-        return reportSettlementService.settlementReportBytedance(paramsVo,response);
-
+    public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) throws Exception{
+        SysUser user = userService.getById(paramsVo.getUserId());
+        String date = paramsVo.getUploadYears();
+        if(null == date||date.equals("")){
+            paramsVo.setUploadYears(DateUtils.formatDate(new Date(),"yyyy-MM"));
+        }
+        return reportSettlementService.settlementReportBytedance(paramsVo,response,user);
     }
 
 
     @ApiOperation(value = "财务结算-结算单导出-快手", notes = "财务结算-结算单导出-快手")
     @GetMapping(value = "/settlementReportKuaiShou")
     public Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-
-        return reportSettlementService.settlementReportKuaiShou(paramsVo,response);
-
+        SysUser user = userService.getById(paramsVo.getUserId());
+        String date = paramsVo.getUploadYears();
+        if(null == date||date.equals("")){
+            paramsVo.setUploadYears(DateUtils.formatDate(new Date(),"yyyy-MM"));
+        }
+        return reportSettlementService.settlementReportKuaiShou(paramsVo,response,user);
     }
 
 
@@ -48,25 +61,27 @@ public class ExportReportController {
     @ApiOperation(value = "财务结算-利润表导出-头条", notes = "财务结算-利润表导出-头条")
     @GetMapping(value = "/porfitReportBytedance")
     public Result porfitReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-
         return reportSettlementService.porfitReportBytedance(paramsVo,response);
-
     }
 
 
     @ApiOperation(value = "财务结算-利润表导出-快手", notes = "财务结算-利润表导出-快手")
     @GetMapping(value = "/porfitReportKuaiShou")
     public Result porfitReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-
         return reportSettlementService.porfitReportKuaiShou(paramsVo,response);
-
     }
 
 
     @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 - 20
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,21 +117,13 @@ public class SettlementController {
             ids = materialReportOverViewService.recursiveQuerySubordinate(userId);
         }
         List<Map<String,Object>> list = settlementInfoService.getUserByIds(ids);
-        return Result.successMsg("查询用户",list);
+        return Result.successMsg("查询用户",list);
     }
 
-
-
     @ApiOperation(value="财务结算-获取所有运营人员", notes="财务结算-获取所有运营人员")
     @GetMapping("/getAllOperationUser")
     public Result getAllOperationUser() {
         List<Map<String,Object>> list = cwjsPolicyInfoService.getAllOperationUser();
-        return Result.successMsg("查询运营用户列表",list);
+        return Result.successMsg("查询运营用户列表",list);
     }
-
-
-
-
-
-
 }

+ 11 - 24
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java

@@ -1,23 +1,23 @@
 package org.jeecg.ctop.finance.settlement.controller;
 
+import cn.com.ctop.common.module.service.ISysUserService;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.entity.SysUser;
+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.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;
 
@@ -31,20 +31,13 @@ import java.util.Set;
 @RestController
 @RequestMapping("/settLementFileController")
 public class SettlementFileController {
-
     @Autowired
     private ISettlementFileInfoService settlementFileInfoService;
-
-
     @Autowired
     private ISysRoleService sysRoleService;
-
-
     @Autowired
     private IMaterialReportOverViewService materialReportOverViewService;
 
-
-
     @ApiOperation(value="结算单-结算单列表查询", notes="结算单-结算单列表查询")
     @GetMapping(value = "/getSettlementSheetList")
     public Result<PageInfo<Map<String,String>>> getSettlementSheetList(SettlementFileParamsVo paramsVo,
@@ -93,29 +86,23 @@ public class SettlementFileController {
         return settlementFileInfoService.deleteSettlementFile(paramsVo);
     }
 
-
-
     @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("账户截图不能为空!");
         }
         return settlementFileInfoService.insertAccountImages(settlementFileInfo);
     }
 
-
     @ApiOperation(value="结算单-查询账户数量以及图片数量", notes="结算单-查询账户数量以及图片数量")
     @PostMapping(value = "/getAccountNumAndImgNum")
     public Result getAccountNumAndImgNum(@RequestBody SettlementFileParamsVo paramsVo) {
-        return settlementFileInfoService.getAccountNumAndImgNum(paramsVo);
+        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        SysUser user = userService.getById(loginUser.getId());
+        return settlementFileInfoService.getAccountNumAndImgNum(paramsVo,user);
     }
-
-
-
-
-
-
-
+    @Autowired
+    private ISysUserService userService;
 
 }

+ 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;
+}

+ 7 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/ProfitReportBytedanceVo.java

@@ -20,6 +20,9 @@ public class ProfitReportBytedanceVo implements Serializable {
     @Excel(name = "产品名称",width = 25)
     private String productName;
 
+    @Excel(name = "账户ID",width = 25)
+    private String accountId;
+
     @Excel(name = "总消耗",width = 10)
     private String cost;
 
@@ -44,6 +47,10 @@ public class ProfitReportBytedanceVo implements Serializable {
     @Excel(name = "运营所属区域",width = 12)
     private String operateArea;
 
+    @Excel(name = "政策起止时间",width = 30)
+    private String time;
+
+
 
 
 }

+ 3 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/ProfitReportKuaiShouVo.java

@@ -49,6 +49,9 @@ public class ProfitReportKuaiShouVo implements Serializable {
     @Excel(name = "运营所属区域",width = 12)
     private String operateArea;
 
+    @Excel(name = "政策起止时间",width = 30)
+    private String time;
+
 
 
 }

+ 1 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SettlementFileParamsVo.java

@@ -26,6 +26,7 @@ public class SettlementFileParamsVo implements Serializable {
     //@Dict(dicCode = "id", dictTable = "ctop_advertiser", dicText = "name")
     private String advertiserId;
     private String advertiserName;
+    private String userId;
 
     /**
      * 产品id

+ 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);
+
+
+
+
+}

+ 26 - 13
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -1,14 +1,13 @@
 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;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 
 /**
@@ -34,45 +33,59 @@ public interface ReportSettlementMapper {
      * @return
      */
     List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShou(SettlementFileParamsVo paramsVo);
+    //获取快手 账户 日流水信息  代理商维度
+    List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShouAgent(SettlementFileParamsVo paramsVo);
+    // 获取快手 结算单 账户 和 代理商 维度
+    List<SettlementReportKuaiShouVo> getTransactionDayKuaiShouAgentAndAccount(SettlementFileParamsVo paramsVo);
 
 
     /**
-     * 查询 头条 账户id
+     * 查询 账户id
      * @return
      */
-   List<String> getAccountIdBytedance(SettlementFileParamsVo paramsVo);
+   List<String> getAccountIdBytedance(@Param("sales") Set<String> sales, @Param("mediaId")String mediaId, @Param("advertiserId")String advertiserId, @Param("productId")String productId);
 
     /**
      * 查询 头条 账户 图片
      * @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>> getProfitBytedanceAccount(@Param("startTime") String startTime,@Param("endTime") String endTime);
+    Map<String,Object> getProfitBytedanceAccountCost(@Param("accountId") String accountId,@Param("startTime") String startTime,@Param("endTime") String endTime);
+
+    List<Map<String,Object>> getProfitBytedanceCost(@Param("accountId") String accountId,@Param("startTime") String startTime,@Param("endTime") String endTime);
 
     /**
-     * 查询 快手 利润表 总花费
-     * @param uploadYears
+     * 查询 快手 利润表 所有账户
+     * @param
      * @return
      */
-    List<Map<String,Object>> getProfitKuaiShou(String uploadYears);
+    List<Map<String,Object>> getProfitKuaiShouAgentAccount(@Param("startTime")String startTime ,@Param("endTime")String endTime);
+    Map<String,Object> getProfitKuaiShouAccountCost(@Param("accountId")String accountId,@Param("startTime")String startTime ,@Param("endTime")String endTime);
+    //快手 利润表 账户 时间段内的数据信息
+    List<Map<String,Object>> 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> getProfitReportSale(String accountId);
 
     Map<String,Object> getProfitBytedanceOperate(String accountId);
 
-    Map<String,Object> getProfitKuaiShouOperate(String accountId);
+    Map<String,Object> getProfitReportOperateAndArea(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>

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

@@ -10,7 +10,8 @@
         balance,cash_cost,cost,frozen,income,reward_cost,shared_wallet_cost,transfer_in,transfer_out,create_time
          from
         ctop_account_transaction_day
-        where advertiser_id = #{accountId}
+        where cost >0
+        and advertiser_id = #{accountId}
             )t
       LEFT JOIN ctop_user_allocation c on t.advertiser_id = c.account_id
         where uploadYears = #{uploadYears}
@@ -32,10 +33,16 @@
         <if test="mediaId !=null and mediaId != ''">
             AND media_id = #{mediaId}
         </if>
+        <if test="sales !=null and sales != ''">
+            AND create_user_id in
+            <foreach collection="sales" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
 
     </select>
 
-
     <!-- 查询 头条 账户 图片-->
     <select id="getAccountImagesBytedance" resultType="java.lang.String">
         SELECT
@@ -44,14 +51,10 @@
         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,
@@ -70,137 +73,400 @@
         where uploadYears = #{uploadYears}
     </select>
 
+    <!-- 获取快手 账户 日流水信息  代理商维度-->
+    <select id="getAccountTransactionDayKuaiShouAgent" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
+
+        SELECT
+            t.*
+        FROM
+            (
+                SELECT
+                    account_id,
+                    date_time AS date,
+		DATE_FORMAT( date_time, '%Y-%m' ) AS uploadYears,
+		user_id AS ksId,
+		total_charged_in_yuan AS dailyCharge,
+		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
+            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
+                           total_charged_in_yuan >0
+                          and account_id = #{accountId}
+                    ) t
+                WHERE
+                    DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
+                ORDER BY
+                    t.date
+                    LIMIT 31
+            ) a
+                LEFT JOIN (
+                SELECT
+                    t.*,
+                    c.auth_name AS accountNameF,
+                    base.user_id AS ksIdF
+                FROM
+                    (
+                        SELECT
+                            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="getProfitBytedanceAccount" resultType="java.util.LinkedHashMap">
+        SELECT
+        d.advertiser_id as accountId
+        FROM
+        ctop_account_transaction_day d
+        WHERE d.cost >0
+    <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="getProfitBytedanceAccountCost" resultType="java.util.LinkedHashMap">
+        SELECT
+        d.advertiser_id as accountId,
+        ROUND(SUM( d.cost ),2) AS cost,
+        ROUND(SUM( d.cash_cost ),2) AS cashCost,
+        ROUND(SUM( d.reward_cost ),2) as rewardCost,
+        IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.advertiser_id = u.account_id and u.advertiser_id = a.id),(SELECT a.name
+        from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.advertiser_id and c.advertiser_id = a.id)) as advertiserName,
+        IFNULL((SELECT
+        p.product_name
+        FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.advertiser_id = u.account_id and u.project_id = pj.id and pj.product_id = p.id
+        ),(SELECT p.product_name
+        FROM ctop_cwjs_settlement_info c,ctop_product p where d.advertiser_id = c.account_id and c.product_id = p.id)) productName
+        FROM
+        ctop_account_transaction_day d
+<where>
+    <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>
+</where>
+        GROUP BY d.advertiser_id
+        limit 1
+
+</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,
-            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
-        WHERE
-            cwjs.del_flag = 0
-        <if test="uploadYears !=null and uploadYears != ''">
-            AND DATE_FORMAT(d.date,'%Y-%m') = #{uploadYears}
-        </if>
-        GROUP BY
-            d.advertiser_id;
+        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
+        <where>
+            <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>
+        </where>
 
     </select>
 
 
 
-    <!-- 查询 头条利润表  销售人员姓名 以及 返点类型和比列-->
-    <select id="getProfitBytedanceSale" resultType="java.util.LinkedHashMap">
+    <!-- 查询 头条利润表  返点类型和比列-->
+    <select id="getProfitBytedance" resultType="java.util.LinkedHashMap">
+        SELECT t.* from (
         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
-        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
+        min(r.policy_date )as policyStartDate,
+        max(r.policy_date ) as policyEndDate,
+        cp.create_time as createTime
+        FROM
+        ctop_cwjs_policy_info cp
+        RIGHT JOIN ctop_cwjs_slettement_report r on r.policy_id = cp.id and r.advertiser_name = cp.advertiser_name
         WHERE
-        pp.del_flag = 0
-        AND cp.del_flag = 0
-        <if test="productId !=null and productId != ''">
-            AND pp.id = #{productId}
+        cp.del_flag = 0
+        and cp.approved_status = 3
+        <if test="mediaType !=null and mediaType != ''">
+            AND cp.media_type = #{mediaType}
         </if>
-
-
-    </select>
-
-
-
-    <!-- 查询 头条利润表  广告主和运营和运营所属区域-->
-    <select id="getProfitBytedanceOperate" resultType="java.util.LinkedHashMap">
-        select
-        u.advertiser_id,
-        u.advertiser_name as advertiserName,
-        u.user_id,
-        u.user_name as operateName,
-        u.auth_name,
-        IFNULL(p.nick_name,'') as operateArea
-        from
-        ctop_user_allocation u
-        LEFT JOIN user_company p on p.user_id = u.user_id
-          <where>
-              <if test="accountId !=null and accountId != ''">
-                  AND u.account_id = #{accountId}
-              </if>
-          </where>
+            AND r.product_name = #{productName}
+        <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 r.policy_id
+        ) t
     </select>
 
 
-<!-- 查询 快手 利润表 总花费-->
-    <select id="getProfitKuaiShou" resultType="java.util.LinkedHashMap">
+    <!-- 查询 利润表  返点类型和比列-->
+    <select id="getProfitRebate" 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
-        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
+        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
-            cwjs.del_flag = 0
-        <if test="uploadYears !=null and uploadYears != ''">
-          and DATE_FORMAT(d.date,'%Y-%m') = #{uploadYears}
+        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
-            d.account_id;
+        p.id
+        limit 1
     </select>
 
-
-
-
-    <!-- 查询 快手 利润表  广告主和运营和运营所属区域-->
-    <select id="getProfitKuaiShouOperate" resultType="java.util.LinkedHashMap">
-        select
-        u.advertiser_id,
-        u.account_id,
-        b.user_id as ksId,
-        u.advertiser_name as advertiserName,
-        u.user_id,
-        u.user_name as operateName,
-        u.auth_name,
-        IFNULL(p.nick_name,'') as operateArea
-        from
+    <!-- 查询 利润表  销售人员姓名 -->
+    <select id="getProfitReportSale" 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
+        p.sale_id,
+        y.realname AS saleName
+        FROM
         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
-    <where>
+        LEFT JOIN ctop_project p ON u.project_id = p.id
+        LEFT JOIN sys_user y ON y.id = p.sale_id
+        WHERE
+        u.account_id = #{accountId}
+        LIMIT 1
+        )
+        UNION ALL
+        (
+        SELECT
+        f.create_user_id,
+        u.realname AS saleName
+        FROM
+        ctop_cwjs_settlement_info f
+        LEFT JOIN sys_user u ON u.id = f.create_user_id
+        WHERE
+        f.del_flag = 0
+        AND f.account_id = #{accountId}
+        LIMIT 1
+        )
+        LIMIT 1
+    </select>
+
+    <!-- 查询 头条利润表  广告主和运营和运营所属区域-->
+    <select id="getProfitBytedanceOperate" resultType="java.util.LinkedHashMap">
+        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 u.account_id = #{accountId}
+            AND c.account_id = #{accountId}
         </if>
-    </where>
+        limit 1
     </select>
 
+    <!-- 查询 快手 代理商 所有账户-->
+    <select id="getProfitKuaiShouAgentAccount" resultType="java.util.LinkedHashMap">
+        SELECT k.* from
+        ctop_kuaishou_daily_agent k
+        where k.total_charged_in_yuan !=0
+            <if test="startTime !=null and startTime != ''">
+                AND k.date_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND k.date_time &lt;= #{endTime}
+            </if>
+        GROUP BY k.account_id
+    </select>
 
+    <!-- 查询 快手 利润表 总花费-->
+    <select id="getProfitKuaiShouAccountCost" resultType="java.util.LinkedHashMap">
+        SELECT
+        d.account_id as accountId,
+        d.user_id AS ksId,
+        round(SUM(d.total_charged_in_yuan),3) AS cost,
+        round(SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)),3) as cashCost,
+        IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.account_id = u.account_id and u.advertiser_id = a.id),(SELECT a.name
+        from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.account_id and c.advertiser_id = a.id)) as advertiserName,
+        IFNULL((SELECT
+        p.product_name
+        FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.account_id = u.account_id and u.project_id = pj.id and pj.product_id = p.id
+        ),(SELECT p.product_name
+        FROM ctop_cwjs_settlement_info c,ctop_product p where d.account_id = c.account_id and c.product_id = p.id)) productName
+        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>
+        GROUP BY d.account_id
+        limit 1
 
 
+    </select>
 
-    <!--  给运营人员发送微信通知 -->
+    <!-- 查询 快手 利润表 总花费-->
+    <select id="getProfitKuaiShouCost" resultType="java.util.LinkedHashMap">
+        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>
 
 
-<!--  查询 所有已绑定用户的运营人员id -->
+    <!-- 查询 利润表  运营和运营所属区域-->
+    <select id="getProfitReportOperateAndArea" resultType="java.util.LinkedHashMap">
+        <!--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
+        u.user_id AS operateUserId,
+        u.user_name AS operateName,
+        IFNULL( p.nick_name, '' ) AS operateArea
+        FROM
+        ctop_user_allocation u
+        LEFT JOIN user_company p ON u.user_id = p.user_id
+        WHERE
+        u.account_id = #{accountId}
+        LIMIT 1
+        ) UNION ALL
+        (
+        SELECT
+        c.create_user_id AS operateUserId,
+        p.user_name AS operateName,
+        IFNULL( p.nick_name, '' ) AS operateArea
+        FROM
+        ctop_cwjs_settlement_file_info c
+        LEFT JOIN user_company p ON c.create_user_id = p.user_id
+        WHERE
+        c.del_flag = 0
+        AND c.account_id = #{accountId}
+        LIMIT 1
+        )
+        LIMIT 1
+    </select>
+
+    <!--  查询 所有已绑定用户的运营人员id -->
     <select id="getAccountOperateUserId" resultType="java.util.LinkedHashMap">
         SELECT user_id userId,user_name userName
         from ctop_user_allocation
@@ -226,11 +492,4 @@
 	AND c.user_id = #{userId}
     </select>
 
-
-
-
-
-    <!--  给运营人员发送微信通知 -->
-
-
 </mapper>

+ 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

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

@@ -1,11 +1,11 @@
 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.common.system.entity.SysUser;
+import org.jeecg.common.system.vo.LoginUser;
+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;
@@ -14,20 +14,19 @@ public interface IReportSettlementService {
 
     List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance();
 
-    Result settlementReportBytedance(SettlementFileParamsVo paramsVo,HttpServletResponse response);
-
-    Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo,HttpServletResponse response);
-
-
+    Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response, SysUser user);
 
+    Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response, SysUser user);
 
     Result porfitReportBytedance(SettlementFileParamsVo paramsVo,HttpServletResponse response);
 
     Result porfitReportKuaiShou(SettlementFileParamsVo paramsVo,HttpServletResponse response);
 
+    Result sendMessageToOperate();
 
+    Result sendMessageToOperateDemo(String userId);
 
+    void cwjsPRofit(CwjsPolicyInfo cwjsPolicyInfo);
 
-    Result sendMessageToOperate(String userId);
-
+    List<String> getAccountId(SettlementFileParamsVo paramsVo,SysUser user);
 }

+ 6 - 9
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementFileInfoService.java

@@ -3,23 +3,20 @@ 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.common.system.entity.SysUser;
+import org.jeecg.common.system.vo.LoginUser;
+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 getAccountNumAndImgNum(SettlementFileParamsVo paramsVo);
-
+    Result insertAccountImages(CtopCwjsSettlementFileInfo settlementFileInfo);
 
+    Result getAccountNumAndImgNum(SettlementFileParamsVo paramsVo, SysUser user);
 }

+ 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);

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

@@ -2,9 +2,16 @@ package org.jeecg.ctop.finance.settlement.service.serviceImpl;
 
 import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.com.ctop.common.module.entity.SysLog;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.mapper.SysLogMapper;
+import cn.com.ctop.common.module.mapper.SysRoleMapper;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.common.module.utils.ImageUtils;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -14,51 +21,71 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.entity.SysUser;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.ctop.finance.policy.entity.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.jeecg.modules.ctop.service.IMaterialReportOverViewService;
+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.text.SimpleDateFormat;
+import java.util.*;
 import java.util.List;
-import java.util.Map;
 import java.util.stream.Collectors;
 
 
 @Slf4j
 @Service
 public class ReportSettlementServiceImpl implements IReportSettlementService {
-
     @Resource
     private ReportSettlementMapper reportSettlementMapper;
-
     @Resource
     private CorpWexinUtils corpWexinUtils;
     @Resource
     private MailLogMapper mailLogMapper;
+    @Resource
+    private CwjsProfitMapper cwjsProfitMapper;
+    @Resource
+    private UserAllocationMapper userAllocationMapper;
+    @Resource
+    private SysRoleMapper roleMapper;
+    @Autowired
+    private IMaterialReportOverViewService materialReportOverViewService;
+    @Resource
+    private SysLogMapper sysLogMapper;
 
 
     @Override
     public List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance() {
         return reportSettlementMapper.getAccountTransactionDayBytedance(null);
     }
-
     @Override
-    public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-
+    public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response, SysUser user) {
         try {
-
             //第一步创建workbook
             HSSFWorkbook wb = new HSSFWorkbook();
 
@@ -73,16 +100,15 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             style.setFont(font);
 
             //查询 账户id
-            List<String> accountIdList = reportSettlementMapper.getAccountIdBytedance(paramsVo);
+            List<String> accountIdList = this.getAccountId(paramsVo,user);
 
             if (Check.isNull(accountIdList)){
-                return Result.errorMsg("该广告主和产品下无法查询到绑定的账户信息");
+                return Result.errorMsg("该广告主和产品下无法查询到绑定的账户信息");
             }
 
             int num = 0;
 
             for (int k = 0; k < accountIdList.size(); k++) {
-
                 String accountId = accountIdList.get(k);
                 paramsVo.setAccountId(accountId);
 
@@ -113,23 +139,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("      账户名称      ");
+                cell.setCellValue("账户名称");
                 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("      所属代理商ID      ");
+                cell.setCellValue("所属代理商ID");
                 cell.setCellStyle(style);
 
                 cell = row.createCell(5);
@@ -164,9 +190,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 cell.setCellValue("冻结(¥)");
                 cell.setCellStyle(style);
 
-
-
-
                 for (int i = 0; i < settlementList.size(); i++) {
                     SettlementReportBytedanceVo vo = settlementList.get(i);
                     //创建行 (表头占0-1行 所以 从 2开始)
@@ -189,21 +212,25 @@ 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 +241,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             }
 
             if(accountIdList.size() == num){
-                return Result.errorMsg("暂无数据");
+                return Result.errorMsg("暂无账户流水数据");
             }
 
             response.setCharacterEncoding("UTF-8");
@@ -222,7 +249,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);
@@ -231,19 +258,65 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             output.close();
         } catch (Exception e) {
             e.printStackTrace();
-            log.error("====>>>>", e.getMessage());
             return Result.errorMsg(e.getMessage());
         }
         return null;
     }
+    /**
+     * @param paramsVo
+     * @param user
+     * @return
+     */
+    @Override
+    public List<String> getAccountId(SettlementFileParamsVo paramsVo,SysUser user) {
+        String uploadYears = paramsVo.getUploadYears();
+        //1:区分媒体(头条:1 快手:2)
+        Integer mediaId = paramsVo.getMediaId();
+
+        String roleCode = roleMapper.getRoleCodeByUserId(user.getId());
+        Set<String>sales = new HashSet<>();
+        List<UserAllocation>allocations ;
+        if("admin".equals(roleCode)|| "finance".equals(roleCode)){
+            //查询所有可用的账户
+        }else if("saleDirector".equals(roleCode)){
+            //查询自己下辖的所有销售绑定的账户
+            sales = materialReportOverViewService.recursiveQuerySubordinate(paramsVo.getCreateUserId());
+        }else if("saleAssistant".equals(roleCode)|| "sale".equals(roleCode)|| "saleAm".equals(roleCode)){
+            //查询自己名绑定下的账户
+            sales.add(user.getId());
+        }
+        if(sales.isEmpty()){
+            sales = null;
+        }
+        List<String> settlementAccountList = reportSettlementMapper.getAccountIdBytedance(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId());
+        allocations = userAllocationMapper.getAccountInfoBySalesId(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId());
+        return mergeAccountId(settlementAccountList,allocations,uploadYears);
+    }
 
-
+    private List<String> mergeAccountId(List<String> settlementAccountList, List<UserAllocation> allocations,String uploadYears) {
+        List<String>salesAccount = new ArrayList<>();
+        for(UserAllocation allocation:allocations){
+            if(allocation.getAccountStatus() == 0){
+                salesAccount.add(allocation.getAccountId()+"");
+            }
+            if(allocation.getAccountStatus() == 1){
+                //被关停的账户
+                Long updateDateNum = Long.parseLong(DateUtils.formatDate(allocation.getUpdateTime(),"yyyymm"));
+                uploadYears = uploadYears.replace("-","");
+                Long uploadYearNum = Long.parseLong(uploadYears);
+                if(updateDateNum>=uploadYearNum){
+                    salesAccount.add(allocation.getAccountId()+"");
+                }
+            }
+        }
+        settlementAccountList.removeAll(salesAccount);
+        settlementAccountList.addAll(salesAccount);
+        return settlementAccountList;
+    }
 
     @Override
-    public Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-
+    public Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response, SysUser user) {
         try {
-
             //第一步创建workbook
             HSSFWorkbook wb = new HSSFWorkbook();
 
@@ -257,22 +330,28 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             font.setFontHeightInPoints((short) 12);//设置字体大小
             style.setFont(font);
 
-            //查询 账户id
-            List<String> accountIdList = reportSettlementMapper.getAccountIdBytedance(paramsVo);
+            //查询 需要导出的数据的账户id
+            List<String> accountIdList = this.getAccountId(paramsVo,user);
 
             if (Check.isNull(accountIdList)){
-                return Result.errorMsg("该广告主和产品下无法查询到绑定的快手账户信息");
+                return Result.errorMsg("该广告主和产品下无法查询到绑定的快手账户信息");
             }
 
             int num = 0;
-
             for (int k = 0; k < accountIdList.size(); k++) {
-
                 String accountId = accountIdList.get(k);
                 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 +377,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 +429,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 +451,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 +482,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             }
 
             if(accountIdList.size() == num){
-                return Result.errorMsg("暂无数据");
+                return Result.errorMsg("暂无数据");
             }
 
             response.setCharacterEncoding("UTF-8");
@@ -409,7 +490,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);
@@ -418,15 +499,11 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             output.close();
         } catch (Exception e) {
             e.printStackTrace();
-            log.error("====>>>>", e.getMessage());
             return Result.errorMsg(e.getMessage());
         }
         return null;
     }
 
-
-
-
     /**
      *
      * @description: 财务结算 利润表导出 头条
@@ -437,49 +514,141 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
      */
     @Override
     public Result porfitReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
-
         try {
-            //查询 头条利润表 总花费
-            List<Map<String,Object>> list = reportSettlementMapper.getProfitBytedanceCost(paramsVo.getUploadYears());
+            //查询 头条利润表 时间段内 所有 账户
+            List<Map<String,Object>> list = reportSettlementMapper.getProfitBytedanceAccount(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","")+"");//返点比列
+            for (Map<String, Object> mapList : list) {
+              //查看该账户 状态信息
+                /*QueryWrapper<SysLog> sysLogQw = new QueryWrapper<>();
+                sysLogQw.eq("log_type", 2);
+                //操作类型
+                sysLogQw.eq("operate_type", 10001);
+                sysLogQw.eq("log_content", "0");//0开 1关
+                sysLogQw.eq("request_param", mapList.get("accountId").toString());
+                sysLogQw.orderByDesc("create_time");
+                sysLogQw.last("limit 1");
+                SysLog sysLog = sysLogMapper.selectOne(sysLogQw);
+                if (!Check.isNull(sysLog)) {
+                    SimpleDateFormat m = new SimpleDateFormat("MM");
+                    String createMonth = m.format(sysLog.getCreateTime());
+                    int crate = Integer.valueOf(createMonth);
+                    Calendar cal = Calendar.getInstance();
+                    int month = cal.get(Calendar.MONTH) + 1;
+                }*/
+                //查看账户数据
+                Map<String,Object> map = reportSettlementMapper.getProfitBytedanceAccountCost(mapList.get("accountId").toString(),paramsVo.getStartTime(),paramsVo.getEndTime());
+
+                ProfitReportBytedanceVo voSource = new ProfitReportBytedanceVo();
+                voSource.setAccountId(map.get("accountId")+"");
+
+                voSource.setAdvertiserName(!Check.isNull(map.get("advertiserName")) ? map.getOrDefault("advertiserName","")+"" : "" );//广告主名称
+                //产品名称
+                voSource.setProductName(!Check.isNull(map.get("productName")) ? map.getOrDefault("productName","")+"" : "" );
+
+
+                //查询销售
+                Map<String,Object> slaeMap = reportSettlementMapper.getProfitReportSale(map.get("accountId")+"");
+                voSource.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName","")+"");//销售
+                //查询运营
+                Map<String,Object> operateMap = reportSettlementMapper.getProfitReportOperateAndArea(map.get("accountId")+"");
+                if (!Check.isNull(operateMap)){
+                    voSource.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
+                    voSource.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
+                }
+                //政策所有时间点
+                List<String> policyDaysList = new ArrayList<>();
+                if (!Check.isNull(map.get("productName"))){
+                    //查询 头条利润表  返点类型和比列
+                    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.size() < 2 ? times.get(i).toString() : times.get(i + 1).toString());
+                        i += 1;
+                        arrayList.add(mapTime);
+                    }
+
+
+                    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.setCost(String.format("%.3f",new Double(vo.getCost())));
+                        vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost","")+"");//现金消耗
+                        vo.setCashCost(String.format("%.3f",new Double(vo.getCashCost())));
+                        vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost","")+"");//赠款消耗
+                        vo.setRewardCost(String.format("%.3f",new Double(vo.getRewardCost())));
+                        BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
+                        vo.setTime(stringMap.get("startDate")+"----"+stringMap.get("endDate"));
+                        resultList.add(vo);
+                        policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"),stringMap.get("endDate")));
                     }
+
                 }
 
-                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.setCost(String.format("%.3f",new Double(vo.getCost())));
+                    vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost","")+"");//现金消耗
+                    vo.setCashCost(String.format("%.3f",new Double(vo.getCashCost())));
+                    vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost","")+"");//赠款消耗
+                    vo.setRewardCost(String.format("%.3f",new Double(vo.getRewardCost())));
+                    BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
+                    vo.setTime((!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate")+"----"+stringMap.get("endDate") : ""));
+                    resultList.add(vo);
                 }
-                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);
@@ -487,14 +656,11 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
         } catch (Exception e) {
             e.printStackTrace();
-            log.error("====>>>>", e.getMessage());
             return Result.errorMsg(e.getMessage());
         }
         return null;
     }
 
-
-
     /**
      *
      * @description: 财务结算 利润表导出 快手
@@ -507,40 +673,130 @@ 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.getProfitKuaiShouAgentAccount(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","")+"");//返点比列
+            for (Map<String, Object> mapList : list) {
+                //查看该账户 状态信息
+               /* QueryWrapper<SysLog> sysLogQw = new QueryWrapper<>();
+                sysLogQw.eq("log_type", 2);
+                //操作类型
+                sysLogQw.eq("operate_type", 10001);
+                sysLogQw.eq("log_content", "0");//0开 1关
+                sysLogQw.eq("request_param", mapList.get("account_id").toString());
+                sysLogQw.orderByDesc("create_time");
+                sysLogQw.last("limit 1");
+                SysLog sysLog = sysLogMapper.selectOne(sysLogQw);
+                if (!Check.isNull(sysLog)) {
+                    SimpleDateFormat m = new SimpleDateFormat("MM");
+                    String createMonth = m.format(sysLog.getCreateTime());
+                    int crate = Integer.parseInt(createMonth);
+                    Calendar cal = Calendar.getInstance();
+                    int month = cal.get(Calendar.MONTH) + 1;
+
+                }*/
+
+                //查询账户数据信息
+               Map<String,Object> map = reportSettlementMapper.getProfitKuaiShouAccountCost(mapList.get("account_id").toString(),paramsVo.getStartTime(),paramsVo.getEndTime());
+                ProfitReportKuaiShouVo voSource = new ProfitReportKuaiShouVo();
+                voSource.setAccountId(map.getOrDefault("accountId", "") + "");//账户id
+                voSource.setProductName( !Check.isNull(map.get("productName")) ? map.getOrDefault("productName", "") + "" : "");//产品名称
+                voSource.setKsId(map.getOrDefault("ksId", "") + "");//快手id
+                voSource.setAdvertiserName(!Check.isNull(map.get("advertiserName")) ? map.getOrDefault("advertiserName", "") + "" : "");//广告主名称
+
+                //销售
+                Map<String, Object> slaeMap = reportSettlementMapper.getProfitReportSale(map.get("accountId") + "");
+                voSource.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName", "") + "");//销售
+                //运营
+                Map<String, Object> operateMap = reportSettlementMapper.getProfitReportOperateAndArea(map.get("accountId") + "");
+                if (!Check.isNull(operateMap)) {
+                    voSource.setOperateName(operateMap.getOrDefault("operateName", "") + "");//运营
+                    voSource.setOperateArea(operateMap.getOrDefault("operateArea", "") + "");//运营所属区域
+                }
+
+                //政策所有时间点
+                List<String> policyDaysList = new ArrayList<>();
+                if (!Check.isNull(map.get("productName"))) {
+                    //查询 快手利润表  返点类型和比列
+                    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<>();
+                    if (!Check.isNull(times)){
+                        for (int i = 0; i < times.size(); i++) {
+                            HashMap<String, String> mapTime = new HashMap<>();
+                            mapTime.put("startDate", times.get(i).toString());
+                            mapTime.put("endDate", times.size() < 2 ? times.get(i).toString() : times.get(i + 1).toString());
+                            i += 1;
+                            arrayList.add(mapTime);
+                        }
+                    }
+
+                    for (Map<String, String> stringMap : arrayList) {
+                        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));
+                        vo.setTime(stringMap.get("startDate") + "----" + stringMap.get("endDate"));
+                        resultList.add(vo);
+                        policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"), stringMap.get("endDate")));
                     }
                 }
 
-                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","")+"");//运营所属区域
+
+                //不使用政策 的时间段
+                // 获取两个日期之间 所有的 时间 年-月-日
+                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));
+                    vo.setTime(!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate") + "----" + stringMap.get("endDate") : "");
+                    resultList.add(vo);
                 }
-                resultList.add(vo);
+
             }
 
             Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("快手利润单", "快手利润单"), ProfitReportKuaiShouVo.class, resultList);
@@ -556,7 +812,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
         } catch (Exception e) {
             e.printStackTrace();
-            log.error("====>>>>", e.getMessage());
             return Result.errorMsg(e.getMessage());
         }
         return null;
@@ -567,22 +822,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 +851,73 @@ 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);
+        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}。请及时上传,多谢配合!";
 
-    public static void main(String[] args) {
-        String a =  "woshiwoshi{1}woshi{2}111{3}===";
-        String b = MessageFormat.format(a,"测试","我","你","结束");
-        System.out.println(a);
-        System.out.println(b);
+        //查询所有 运营绑定的账户
+        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("发送微信通知成功-test",null);
     }
 
+    @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);
+            }
+        }
+    }
 }

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

@@ -1,45 +1,34 @@
 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.entity.SysUser;
 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.IReportSettlementService;
 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 +119,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 +132,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 +154,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,23 +166,25 @@ 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);
     }
 
+    @Autowired
+    private IReportSettlementService reportSettlementService;
 
     /**
      * @description: 查询账户数量以及图片数量
@@ -202,10 +193,15 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
      * @author: zianY
      */
     @Override
-    public Result getAccountNumAndImgNum(SettlementFileParamsVo paramsVo) {
+    public Result getAccountNumAndImgNum(SettlementFileParamsVo paramsVo, SysUser user) {
         Map<String,String> map =  settlementFileInfoMapper.getAccountNumAndImgNum(paramsVo);
-        return Result.successMsg("查询账户数量以及图片数量成功。",map);
-
+        List<String>accountIds = reportSettlementService.getAccountId(paramsVo,user);
+        if(null == accountIds||accountIds.isEmpty()){
+            map.put("accountNum","0");
+        }else{
+            map.put("accountNum",accountIds.size()+"");
+        }
+        return Result.successMsg("查询账户数量以及图片数量成功",map);
     }
 
 

+ 127 - 22
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(String.valueOf(status));
+            sysLog.setRequestParam(userAllocation.getAccountId().toString());
+            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,35 @@ 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;
+                    }
+                    //查询 账户 状态
+                    UserAllocation userAllocation = userAllocationService.getByAccountId(new Long(importVo.getAccountId()));
+                    if (Check.isNull(userAllocation)){
+                        settlementInfo.setStatus(0);
+                    }else {
+                        settlementInfo.setStatus(userAllocation.getAccountStatus());
+                    }
                     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);
         }
 
 

+ 152 - 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,8 +164,134 @@ 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);
+        }
+
+        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;
+    }
 
 }

+ 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;
+    }
+
+
+
 
 
 }

+ 1 - 1
jeecg-boot-finance/src/main/resources/application-prod.yml

@@ -125,7 +125,7 @@ spring:
     port: 6379
 #mybatis plus 设置
 mybatis-plus:
-  mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
+  mapper-locations: classpath*:org/jeecg/**/xml/*Mapper.xml,classpath*:cn/com/ctop/**/xml/*Mapper.xml
   global-config:
     # 关闭MP3.0自带的banner
     banner: false

+ 27 - 17
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;
 
@@ -34,28 +38,34 @@ public class FinanceTest {
         corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
     }
 
-
+    @Resource
+    ICwjsPolicyInfoService policyInfoService;
     @Test
-    public void getAccountId(){
-        String str1 = "123123123-1";
-        String str2 = "123123123-1";
-        String str = str1.substring(0, str1.indexOf("-"));
-        String str3 = str2.substring(0, str2.indexOf("-"));
-
-        System.out.println(str);
-        System.out.println(str3);
+    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);
 
-    }
+        cwjsPolicyInfo.setPolicyStartDate("2021-08-08");
+        cwjsPolicyInfo.setPolicyEndDate("2021-08-09");
 
+        cwjsPolicyInfo.setPolicyStartDate("2021-08-08");
+        cwjsPolicyInfo.setPolicyEndDate("2021-08-10");
 
-    public static void main(String[] args) {
-        String str1 = "123123123-1";
-        String str2 = "123123123-1";
-        String str = str1.substring(0, str1.indexOf("-"));
-        String str3 = str2.substring(0, str2.indexOf("-"));
+        cwjsPolicyInfo.setPolicyStartDate("2021-08-11");
+        cwjsPolicyInfo.setPolicyEndDate("2021-08-12");
 
-        System.out.println(str);
-        System.out.println(str3);
     }
 
+    @Autowired
+    IKuaishouAudienceReportDailyGenderService audienceReportDailyGenderService;
+    @Test
+    public void IKuaishouAudienceReportDailyGenderServiceTest(){
+        audienceReportDailyGenderService.mergeAudienceReportDailyDate("2021-07-20");
+    }
 }

+ 1 - 21
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/demo/mock/vxe/controller/VxeMockController.java

@@ -143,7 +143,6 @@ public class VxeMockController {
      */
     @PutMapping("/immediateSaveRow")
     public Result mockImmediateSaveRow(@RequestBody JSONObject rowData) throws Exception {
-        System.out.println("即时保存.rowData:" + rowData.toJSONString());
         // 延时1.5秒,模拟网慢堵塞真实感
         Thread.sleep(500);
         return Result.ok();
@@ -163,7 +162,7 @@ public class VxeMockController {
         //    只传新增的数据给后台insert即可,否者将会造成性能上的浪费。
         // 3、新增的行是没有id的,通过这一点,就可以判断是否是新增的数据
 
-        System.out.println("即时保存.tableData:" + tableData.toJSONString());
+        log.info("即时保存.tableData:" + tableData.toJSONString());
         // 延时1.5秒,模拟网慢堵塞真实感
         Thread.sleep(1000);
         return Result.ok();
@@ -221,30 +220,12 @@ public class VxeMockController {
         // 获取查询条件(前台传递的查询参数)
         Map<String, String[]> parameterMap = request.getParameterMap();
         // 遍历输出到控制台
-        System.out.println("\ngetDdjhData - 普通查询条件:");
-        for (String key : parameterMap.keySet()) {
-            System.out.println("-- " + key + ": " + JSON.toJSONString(parameterMap.get(key)));
-        }
         // 输出高级查询
         try {
-            System.out.println("\ngetDdjhData - 高级查询条件:");
             // 高级查询模式
             MatchTypeEnum matchType = MatchTypeEnum.getByValue(superQueryMatchType);
-            if (matchType == null) {
-                System.out.println("-- 高级查询模式:不识别(" + superQueryMatchType + ")");
-            } else {
-                System.out.println("-- 高级查询模式:" + matchType.getValue());
-            }
             superQueryParams = URLDecoder.decode(superQueryParams, "UTF-8");
             List<QueryCondition> conditions = JSON.parseArray(superQueryParams, QueryCondition.class);
-            if (conditions != null) {
-                for (QueryCondition condition : conditions) {
-                    System.out.println("-- " + JSON.toJSONString(condition));
-                }
-            } else {
-                System.out.println("-- 没有传递任何高级查询条件");
-            }
-            System.out.println();
         } catch (Exception e) {
             log.error("-- 高级查询操作失败:" + superQueryParams, e);
             e.printStackTrace();
@@ -256,7 +237,6 @@ public class VxeMockController {
         // 封装成 MyBatisPlus 能识别的 QueryWrapper,可以直接使用这个对象进行SQL筛选条件拼接
         // 这个方法也会自动封装高级查询条件,但是高级查询参数名必须是superQueryParams和superQueryMatchType
         QueryWrapper<MockEntity> queryWrapper = QueryGenerator.initQueryWrapper(mockEntity, parameterMap);
-        System.out.println("queryWrapper: " + queryWrapper.getCustomSqlSegment());
 
         // 模拟JSON数据路径
         String path = "classpath:org/jeecg/modules/demo/mock/vxe/json/ddjh.json";

+ 0 - 2
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/demo/test/service/impl/JeecgDemoServiceImpl.java

@@ -65,8 +65,6 @@ public class JeecgDemoServiceImpl extends ServiceImpl<JeecgDemoMapper, JeecgDemo
 	@Cacheable(cacheNames = CacheConstant.TEST_DEMO_CACHE, key = "#id")
 	public JeecgDemo getByIdCacheable(String id) {
 		JeecgDemo t = jeecgDemoMapper.selectById(id);
-		System.err.println("---未读缓存,读取数据库---");
-		System.err.println(t);
 		return t;
 	}
 

+ 10 - 11
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/dlglong/controller/DlMockController.java

@@ -142,7 +142,7 @@ public class DlMockController {
      */
     @PutMapping("/immediateSaveRow")
     public Result mockImmediateSaveRow(@RequestBody JSONObject rowData) throws Exception {
-        System.out.println("即时保存.rowData:" + rowData.toJSONString());
+        log.info("即时保存.rowData:" + rowData.toJSONString());
         // 延时1.5秒,模拟网慢堵塞真实感
         Thread.sleep(500);
         return Result.ok();
@@ -162,7 +162,7 @@ public class DlMockController {
         //    只传新增的数据给后台insert即可,否者将会造成性能上的浪费。
         // 3、新增的行是没有id的,通过这一点,就可以判断是否是新增的数据
 
-        System.out.println("即时保存.tableData:" + tableData.toJSONString());
+        log.info("即时保存.tableData:" + tableData.toJSONString());
         // 延时1.5秒,模拟网慢堵塞真实感
         Thread.sleep(1000);
         return Result.ok();
@@ -220,30 +220,29 @@ public class DlMockController {
         // 获取查询条件(前台传递的查询参数)
         Map<String, String[]> parameterMap = request.getParameterMap();
         // 遍历输出到控制台
-        System.out.println("\ngetDdjhData - 普通查询条件:");
+        log.info("\ngetDdjhData - 普通查询条件:");
         for (String key : parameterMap.keySet()) {
-            System.out.println("-- " + key + ": " + JSON.toJSONString(parameterMap.get(key)));
+            log.info("-- " + key + ": " + JSON.toJSONString(parameterMap.get(key)));
         }
         // 输出高级查询
         try {
-            System.out.println("\ngetDdjhData - 高级查询条件:");
+            log.info("\ngetDdjhData - 高级查询条件:");
             // 高级查询模式
             MatchTypeEnum matchType = MatchTypeEnum.getByValue(superQueryMatchType);
             if (matchType == null) {
-                System.out.println("-- 高级查询模式:不识别(" + superQueryMatchType + ")");
+                log.info("-- 高级查询模式:不识别(" + superQueryMatchType + ")");
             } else {
-                System.out.println("-- 高级查询模式:" + matchType.getValue());
+                log.info("-- 高级查询模式:" + matchType.getValue());
             }
             superQueryParams = URLDecoder.decode(superQueryParams, "UTF-8");
             List<QueryCondition> conditions = JSON.parseArray(superQueryParams, QueryCondition.class);
             if (conditions != null) {
                 for (QueryCondition condition : conditions) {
-                    System.out.println("-- " + JSON.toJSONString(condition));
+                    log.info("-- " + JSON.toJSONString(condition));
                 }
             } else {
-                System.out.println("-- 没有传递任何高级查询条件");
+                log.info("-- 没有传递任何高级查询条件");
             }
-            System.out.println();
         } catch (Exception e) {
             log.error("-- 高级查询操作失败:" + superQueryParams, e);
             e.printStackTrace();
@@ -255,7 +254,7 @@ public class DlMockController {
         // 封装成 MyBatisPlus 能识别的 QueryWrapper,可以直接使用这个对象进行SQL筛选条件拼接
         // 这个方法也会自动封装高级查询条件,但是高级查询参数名必须是superQueryParams和superQueryMatchType
         QueryWrapper<MockEntity> queryWrapper = QueryGenerator.initQueryWrapper(mockEntity, parameterMap);
-        System.out.println("queryWrapper: " + queryWrapper.getCustomSqlSegment());
+        log.info("queryWrapper: " + queryWrapper.getCustomSqlSegment());
 
         // 模拟JSON数据路径
         String path = "classpath:org/jeecg/modules/dlglong/json/ddjh.json";

+ 0 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/alarm/modules/controller/RuleTemplateController.java

@@ -97,11 +97,6 @@ public class RuleTemplateController {
         return result;
     }
 
-    public static void main(String[] args) {
-        System.err.println(new JSONObject());
-    }
-
-
     /**
      * 通过id查询
      *

+ 19 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
 
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 /**
  * 快手预警指标数据
  */
@@ -59,5 +61,21 @@ public class RuleDataTargetKuaishou {
 	private Integer network;
 
 	private java.util.Date createTime;
-
+	/**
+	 * 出价
+	 */
+	private BigDecimal cpaBid;
+	/**
+	 * 深度转化目标出价
+	 */
+	private BigDecimal deepConversionBid;
+	/**
+	 * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
+	 */
+	private Integer deepConversionType;
+	/**
+	 * 优化目标
+	 * 2:行为数;180:激活数;53:表单数;190: 付费;191:首日ROI;324:唤起应用;348:有效线索;383: 授信;384: 完件;394:订单提交;;396:注册
+	 */
+	private Integer ocpxActionType;
 }

+ 3 - 18
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/RuleDateUnitKuaishou.java

@@ -69,32 +69,17 @@ public class RuleDateUnitKuaishou {
      * 付费
      */
     private Long eventPay;
-    /**
-     * 深度转化目标出价
-     */
-    private BigDecimal deepConversionBid;
-    /**
-     * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
-     */
-    private Integer deepConversionType;
+
     /**
      * 安卓版本  3:不限, 4: 4.x+, 5: 5.x+, 6: 6.x+, 7: 7.x+;
      */
     private Integer androidOsv;
-    /**
-     * 优化目标
-     * 2:行为数;180:激活数;53:表单数;190: 付费;191:首日ROI;324:唤起应用;348:有效线索;383: 授信;384: 完件;394:订单提交;;396:注册
-     */
-    private Integer ocpxActionType;
+
     /**
      * 付费单价
      */
     private BigDecimal payCost;
-    /**
-     * 出价
-     */
-    private BigDecimal cpaBid;
-
+    
     private Integer status;
 
     private java.util.Date createTime;

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

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * @Description: 用户分配
@@ -60,4 +62,11 @@ 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);
+
+    List<UserAllocation> getAccountInfoBySalesId(@Param("sales")Set<String> sales,@Param("mediaId")String mediaId,@Param("advertiserId")String advertiserId,@Param("productId")String productId);
 }

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

@@ -25,7 +25,7 @@
         <if test="userId != null and userId != ''">
             and cua.user_id = #{userId}
         </if>
-
+        and account_status = 0
     </select>
 
     <select id="queryAdvertiserId" resultType="String">
@@ -239,4 +239,41 @@
         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>
+    <select id="getAccountInfoBySalesId" resultType="cn.com.ctop.common.module.entity.UserAllocation">
+        select cua.*
+            from ctop_user_allocation cua
+            left join ctop_project cp on cp.id = cua.project_id
+        where 1=1
+          and cua.media_id = #{mediaId}
+          <if test="advertiserId!=null and advertiserId!= '' ">
+              and cp.advertiser_id = #{advertiserId}
+          </if>
+        <if test="productId!=null and productId!= '' ">
+            and cp.product_id = #{productId}
+        </if>
+        <if test="sales !=null and sales != ''">
+            AND cp.sale_id in
+            <foreach collection="sales" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+    <!-- 修改状态 -->
+    <update id="updCwjsSettlementStatus">
+        UPDATE ctop_cwjs_settlement_info
+        SET STATUS = #{status}
+        WHERE
+            id = #{id}
+    </update>
+
+
+
+
 </mapper>

+ 3 - 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,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     List<Long> queryAutomaticAccounts(Long projectId);
 
+    Result<UserAllocation> editUserAlloCation(UserAllocation userAllocation);
+
 }

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -77,7 +77,6 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         param.put("grant_type", "refresh_token");
         param.put("refresh_token", token.getRefreshToken());
         String result = HttpUtils.httpPostRequest(url, param, new HashMap<>());
-        System.err.println(JSONObject.parseObject(result));
         XxlJobHelper.log("头条刷新token;accountId:{},返回信息:{}", token.getAccountId(), result);
         if (null == result || "".equals(result.trim()) || "null".equalsIgnoreCase(result)) {
             XxlJobHelper.log("头条刷新token失败;accountId:{},返回信息:{}", token.getAccountId(), result);

+ 21 - 20
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java

@@ -51,8 +51,6 @@ import java.util.Map;
 public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements IFileInfoService {
     @Value("${jeecg.path.image-upload}")
     private String imageUploadPath;
-    @Value("${jeecg.path.video-upload}")
-    private String videoUploadPath;
     @Resource
     FileInfoMapper fileInfoMapper;
     @Resource
@@ -68,29 +66,32 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
 
     @Override
     public void uploadVideoToBytedance(String accountId, String videoUrl, String userId, String materialName) {
+        UserAllocation userAllocation = userAllocationService.getByAccountId(Long.parseLong(accountId));
+        Project project = projectService.getById(userAllocation.getProjectId());
         try {
             CtopOauthToken token = ctopOauthTokenService.getOauthTokenByAccountId(accountId);
             JSONObject jsonObject = videoUpload(token, videoUrl,materialName);
-            if (!Check.isNull(jsonObject)) {
-                Integer code = jsonObject.getInteger("code");
-                if (code == 0) {
-                    log.info("头条上传素材成功,返回信息:{},accountId:{}", jsonObject, accountId);
-                    //TODO 信息返回之后同步入库
-                } else {
-                    log.error("头条上传素材失败,返回信息:{},accountId:{}", jsonObject, accountId);
-                    UserAllocation allocation = userAllocationService.getByAccountId(Long.valueOf(accountId));
-                    Project project = projectService.getById(allocation.getProjectId());
-                    String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, allocation.getAuthName(), materialName, jsonObject.getString("message"));
-                    sendMessageService.sendMessage(userId, message);
-                }
-
-            } else {
-                log.info("头条上传素材返回结果为空,返回信息:{},accountId:{}", jsonObject, accountId);
+            if (Check.isNull(jsonObject)) {
+                log.info("头条视频素材推送信息==>返回结果为空,返回信息:{},accountId:{}", jsonObject, accountId);
+                String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, "头条上传素材返回结果为空");
+                sendMessageService.sendMessage(userId, message);
+                return ;
             }
-
+            Integer code = jsonObject.getInteger("code");
+            if (code == 0) {
+                log.info("头条视频素材推送信息==>上传素材成功,返回信息:{},accountId:{}", jsonObject, accountId);
+                String message = messageTemplate.getMaterialSyncSucessTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, jsonObject.getString("message"));
+                sendMessageService.sendMessage(userId, message);
+                return ;
+            }
+            log.error("头条视频素材推送信息==>上传素材失败,返回信息:{},accountId:{}", jsonObject, accountId);
+            String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, jsonObject.getString("message"));
+            sendMessageService.sendMessage(userId, message);
         } catch (Exception e) {
-            log.error("头条上传视频文件失败,accountId:{}", accountId);
-            log.error(e.getMessage(), e);
+            log.error("头条视频素材推送信息==>上传视频文件异常,accountId:{}", accountId);
+            e.printStackTrace();
+            String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, "头条api上传素材返回结果异常:系统异常,联系研发人员");
+            sendMessageService.sendMessage(userId, message);
         }
     }
 

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

@@ -1,6 +1,11 @@
 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;
@@ -11,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: 用户分配
@@ -222,4 +229,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(String.valueOf(accountStatus));
+            sysLog.setRequestParam(userAllocationEntity.getAccountId().toString());
+            sysLog.setOperateType(10001);
+            sysLog.setUserid(user.getId());
+            sysLog.setCreateBy(user.getRealname());
+            sysLog.setCreateTime(new Date());
+            sysLogMapper.insert(sysLog);
+
+        }
+
+        return result;
+    }
+
+
 }

+ 3 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserCompanyServiceImpl.java

@@ -52,7 +52,6 @@ public class UserCompanyServiceImpl extends ServiceImpl<UserCompanyMapper, UserC
                 }
                 if (!"1".equals(depart.getOrgType())) {
                     depId = depart.getParentId();
-                    continue;
                 } else {
                     UserCompany userCompany = new UserCompany();
                     userCompany.setUserId(user.getId());
@@ -62,7 +61,7 @@ public class UserCompanyServiceImpl extends ServiceImpl<UserCompanyMapper, UserC
                     String departName = depart.getDepartName();
                     if(!Check.isNull(departName)){
                         if(departName.trim().contains("北京汇创思拓数字科技有限公司")){
-                            userCompany.setNickName("华北,石家庄");
+                            userCompany.setNickName("华北");
                         }
                         if(departName.trim().contains("上海汇创思拓数字科技有限公司")){
                             userCompany.setNickName("华东");
@@ -74,7 +73,7 @@ public class UserCompanyServiceImpl extends ServiceImpl<UserCompanyMapper, UserC
                             userCompany.setNickName("华南");
                         }
                         if(departName.trim().contains("北京次元像素")){
-                            userCompany.setNickName("华北,石家庄");
+                            userCompany.setNickName("石家庄");
                         }
                         if(departName.trim().contains("杭州妙构思数字科技有限公司")){
                             userCompany.setNickName("杭州");
@@ -109,14 +108,13 @@ public class UserCompanyServiceImpl extends ServiceImpl<UserCompanyMapper, UserC
     /**
      * 删除公司信息
      *
-     * @param
+     * @param userId 用户id
      */
     @Override
     public void removeByUserId(String userId) {
         Map<String, Object> deleteMap = new HashMap<>();
         deleteMap.put("user_id", userId);
         userCompanyMapper.deleteByMap(deleteMap);
-
     }
 
     @Override

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java

@@ -669,7 +669,6 @@ public class HttpUtils {
         String strReturn = "";
         try {
             String uri = url + "?" + mapParamsSortToStringBySeperator(params, "&");
-            System.err.println(uri);
             HttpGet httpGet = new HttpGet(uri);
             if (headers != null) {
                 Iterator<String> keyIter = headers.keySet().iterator();

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

@@ -123,11 +123,6 @@ public class ParseInstallPackageUtil {
 
             NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(infoIs);
 
-            // 如果想要查看有哪些key ,可以把下面注释放开
-//            for (String keyName : rootDict.allKeys()) {
-//                System.out.println(keyName + ":" + rootDict.get(keyName).toString());
-//            }
-
             // 应用包名
             NSString parameters = (NSString) rootDict.get("CFBundleIdentifier");
             map.put("package", parameters.toString());

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java

@@ -387,6 +387,8 @@ public class AiKuaishouAdvertiserStrategy {
     private String materialKeyword;
     private Integer historyTop;
     private Integer multipleBids;
+    private Integer systemOptimization;
+
 
     @TableField(exist = false)
     private String authName;

+ 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;
     }
 }

+ 0 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CrossAccountBatchController.java

@@ -140,7 +140,6 @@ public class CrossAccountBatchController {
                 returnArr.add(returnJson);
             }
             result.setSuccess(true);
-            System.err.println(returnArr);
             result.setResult(returnArr);
         } catch (Exception e) {
             e.printStackTrace();
@@ -199,7 +198,6 @@ public class CrossAccountBatchController {
      */
     @PostMapping(value = "/crossAccountUnitCreate")
     public Result<JSONArray> batchUnitCreate(@RequestBody JSONObject requestJson) {
-        System.err.println(requestJson);
         Result<JSONArray> result = new Result<>();
         try {
 
@@ -243,9 +241,7 @@ public class CrossAccountBatchController {
                     createUnitArr = crossAccountBatchService.assembleUnitArray(oauthToken, createUnitArr, campaignList);
                 }
             }
-            System.err.println("组装数据:" + createUnitArr);
             JSONArray returnArray = crossAccountBatchService.createUnit(createUnitArr);
-            System.err.println(returnArray);
             result.setSuccess(true);
             result.setResult(returnArray);
         } catch (Exception e) {
@@ -262,8 +258,6 @@ public class CrossAccountBatchController {
     public Result<JSONArray> crossAccountCreativeCreate(@RequestBody JSONObject requestJson) {
         Result<JSONArray> result = new Result<>();
         try {
-            System.err.println(requestJson);
-
             if (Check.isNull(requestJson)) {
                 throw new Exception("参数不能为空");
             }
@@ -276,9 +270,7 @@ public class CrossAccountBatchController {
                 JSONObject accountJson = accountArr.getJSONObject(i);
                 creativeArray = crossAccountBatchService.assembleCreativeJson(creativeArray, accountJson);
             }
-            System.err.println("组装数据:" + creativeArray);
             JSONArray returnArray = crossAccountBatchService.createCreative(creativeArray);
-            System.err.println(returnArray);
             result.setSuccess(true);
             result.setResult(returnArray);
 

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouGroupTemplateController.java

@@ -62,7 +62,6 @@ public class KuaiShouGroupTemplateController {
      */
     @PostMapping(value = "/submitUnitTask")
     public Result<JSONObject> submitUnitTask(@RequestBody JSONObject requestJson) {
-        System.err.println(requestJson);
         Result<JSONObject> result = new Result<>();
         try {
             if (Check.isNull(requestJson)) {

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActionBarTextServiceImpl.java

@@ -61,7 +61,6 @@ public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouAction
             requestJson.put("campaign_type", list.get(i));
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
-            System.err.println(resultJson);
             Integer code = resultJson.getInteger("code");
             if (code == 0) {
                 JSONObject data = resultJson.getJSONObject("data");

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -193,7 +193,6 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
             return;
         }
         addGroupV2(accountId, details);
-        log.info("组数据入库成功=》id:{}",unitId);
     }
 
 

+ 0 - 55
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java

@@ -368,60 +368,6 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
                 }
 
             }
-
-
-            //   System.err.println(reportList);
-          /*  if (!Check.isNull(localPath)) {
-                Map<String, Object> deleteMap = new HashMap<>();
-                deleteMap.put("account_id", task.getAccountId());
-
-                if (task.getViewType() == 1) {
-                    reportDailyAccountMapper.deleteByMap(deleteMap);
-                    reportDailyAccountMapper.loadAccountDailyReport(task.getAccountId(), localPath);
-                } else if (task.getViewType() == 2) {
-                    reportDailyCampaignMapper.deleteByMap(deleteMap);
-                    reportDailyCampaignMapper.loadCampaignDailyReport(task.getAccountId(), localPath);
-
-                } else if (task.getViewType() == 3) {
-                    reportDailyGroupMapper.deleteByMap(deleteMap);
-                    reportDailyGroupMapper.loadGroupDailyReport(task.getAccountId(), localPath);
-
-                } else if (task.getViewType() == 4) {
-                    reportDailyCreativeMapper.deleteByMap(deleteMap);
-                    reportDailyCreativeMapper.loadCreativeDailyReport(task.getAccountId(), localPath);
-
-                } else if (task.getViewType() == 10) {
-                    reportDailyCreativeMapper.deleteByAccountId(task.getAccountId());
-                    reportDailyCreativeMapper.loadProgramCreativeDailyReport(task.getAccountId(), localPath);
-
-                } else if (task.getViewType() == 5) {
-                    kuaishouReportDailyMaterialMapper.deleteByMap(deleteMap);
-                    kuaishouReportDailyMaterialMapper.loadMaterialDailyReport(task.getAccountId(), localPath);
-                    Thread thread = new Thread() {
-                        @Override
-                        public void run() {
-                            try {
-                                Thread.sleep(1 * 500L);
-                                getMd5(null, task.getAccountId());
-                            } catch (InterruptedException e) {
-                                e.printStackTrace();
-                            }
-                        }
-
-                    };
-                    thread.start();
-                } else if (task.getViewType() == 7) {
-                    kuaishouReportDailyImageMapper.deleteByMap(deleteMap);
-                    //封面报表
-                    kuaishouReportDailyImageMapper.loadImageDailyReport(task.getAccountId(), localPath);
-                    //清洗数据
-                    kuaishouReportDailyImageMapper.updateImageReportCode();
-                    kuaishouReportDailyImageMapper.updateImageReportUserId();
-                    kuaishouReportDailyImageMapper.updateImageReportRealname();
-                }
-
-
-            }*/
             task.setTaskStatus(4);
 
         } catch (Exception e) {
@@ -442,7 +388,6 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
         reader.readHeaders();
         // 逐行读入除表头的数据
         while (reader.readRecord()) {
-            //  System.out.println(reader.getRawRecord());
             csvFileList.add(reader.getValues());
         }
         reader.close();

+ 0 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouOverRunSendMessageServiceImpl.java

@@ -86,9 +86,4 @@ public class KuaiShouOverRunSendMessageServiceImpl extends ServiceImpl<KuaishouO
         }
 
     }
-
-    public static void main(String[] args) {
-        String startTime = DateUtils.getStartTime(new Date());
-        System.err.println(startTime);
-    }
 }

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -610,7 +610,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             headers.put("Content-Type", "application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, unitJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
-            log.info("修改广告组返回信息:{}", resultJson);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {

+ 0 - 98
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -2856,97 +2856,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaiShouVideoGetService videoGetService;
     static ExecutorService suZhaoService = Executors.newFixedThreadPool(15);
 
-   /* @Override
-    public void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate) {
-        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
-        Map<String, String> headers = new HashMap<String, String>();
-        headers.put("Content-Type", "application/json");
-        headers.put("Access-Token", token);
-        Map<String, Object> param = new HashMap<String, Object>();
-        param.put("advertiser_id", accountId);
-        param.put("page", page);
-        param.put("page_size", 200);
-        if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
-            param.put("start_date", startDate);
-            param.put("end_date", endDate);
-        }
-        String result = HttpUtils.httpPostRequest(url, param, headers);
-        JSONObject resultJson = JSONObject.parseObject(result);
-        System.err.println(resultJson);
-        if (Check.isNull(resultJson)) {
-            return;
-        }
-        Integer code = resultJson.getInteger("code");
-        String message = resultJson.getString("message");
-        if (null == code || code != 0) {
-            log.error("获取快手素造列表数据异常:{},accountId:{}", message, accountId);
-            return;
-        }
-        JSONObject dataJson = resultJson.getJSONObject("data");
-        if (Check.isNull(dataJson)) {
-            return;
-        }
-
-
-        JSONArray details = dataJson.getJSONArray("details");
-        if (Check.isNull(details)) {
-            return;
-        }
-
-        List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
-        for (int i = 0; i < details.size(); i++) {
-            JSONObject detailJson = details.getJSONObject(i);
-            if (Check.isNull(detailJson)) {
-                continue;
-            }
-            KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
-            String photo_id = detailJson.getString("photo_id");
-            videoGet.setId(accountId + photo_id);
-            videoGet.setAccountId(accountId);
-            videoGet.setCoverUrl(detailJson.getString("cover_url"));
-            videoGet.setPhotoId(photo_id);
-            videoGet.setPhotoName(detailJson.getString("photo_name"));
-            videoGet.setStatDate(detailJson.getDate("upload_time"));
-            String signature = detailJson.getString("signature");
-            videoGet.setSignature(signature);
-            Integer source = detailJson.getInteger("source");
-            if (source == 2) {
-                videoGet.setChannelType(1);
-            } else {
-                videoGet.setChannelType(0);
-            }
-            Integer new_status = detailJson.getInteger("new_status");
-            if (new_status == 1) {
-                videoGet.setStatus(0);
-            } else {
-                videoGet.setStatus(1);
-            }
-            videoGet.setUrl(detailJson.getString("url"));
-            Integer width = detailJson.getInteger("width");
-            videoGet.setWidth(width);
-            Integer height = detailJson.getInteger("height");
-            videoGet.setHeight(height);
-            Integer type = MaterialEnum.getTypeBySize(width, height);
-            if (!Check.isNull(type)) {
-                videoGet.setMaterialType(type);
-            }
-            videoGetList.add(videoGet);
-            Thread thread = new Thread() {
-                @Override
-                public void run() {
-                    videoGetService.getKeyFrame(token, accountId, signature, photo_id);
-                }
-            };
-            thread.start();
-        }
-        if (!Check.isNull(videoGetList)) {
-            videoGetService.replaceBatch(videoGetList);
-        }
-
-        getSuZaoList(token, accountId, page + 1, startDate, endDate);
-
-    }*/
-
     @Autowired
     private IMaterialCutFrameService cutFrameService;
     private static ExecutorService executorService = Executors.newFixedThreadPool(10);
@@ -2963,11 +2872,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             JSONObject param = new JSONObject();
             param.put("advertiser_id", accountId);
             param.put("page_size", 200);
-
-           /* Map<String, Object> deleteMap = new HashMap<>();
-            deleteMap.put("account_id", accountId);
-            deleteMap.put("campaign_id", campaignId);
-            creativeService.removeByMap(deleteMap);*/
             QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
             groupQueryWrapper.eq("account_id", accountId);
             groupQueryWrapper.eq("campaign_id", campaignId);
@@ -3082,8 +2986,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             e.printStackTrace();
 
         }
-
-
     }
 
     /**

+ 2 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl2.java

@@ -124,7 +124,6 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
                 }
             }else{
                 if(code == 500000){
-                    System.out.println("5秒后重试,accountId:"+advertiserId+",日期:"+startDate);
                     try{Thread.sleep(5000);} catch (InterruptedException e){};
                     getOperationRecordByPage(advertiserId, accessToken,page, pageSize, operationTarget, startDate, endDate);
                 }else {
@@ -216,7 +215,6 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
                 }
             }else{
                 if(code == 500000){
-                    System.out.print("》》5秒后重试,accountId:"+advertiserId+",日期:"+startDate+"《《 ");
                     try{Thread.sleep(5000);} catch (InterruptedException e){};
                     getOperationRecordByPage2(advertiserId, accessToken,page, pageSize, operationTarget, startDate, endDate);
                 }else {
@@ -295,7 +293,7 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
                 } else if (operationTarget == 7) {
                     kuaishouOperationRecordMapper.insertOperationRecordInfoPackageNew(batchList);
                 } else {
-                    System.out.println("未知的目标类型!");
+                    log.info("未知的目标类型!");
                 }
                 batchList.clear();
             }
@@ -317,7 +315,7 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
             } else if (operationTarget == 7) {
                 kuaishouOperationRecordMapper.insertOperationRecordInfoPackageNew(batchList);
             } else {
-                System.out.println("未知的目标类型!");
+                log.info("未知的目标类型!");
             }
             batchList.clear();
         }

+ 0 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouRealTimeDataServiceImpl.java

@@ -43,7 +43,6 @@ public class KuaishouRealTimeDataServiceImpl implements IKuaishouRealTimeDataSer
         param.put("campaign_ids", array);
         try {
             String result = HttpUtils.httpPostRequest(url, param, headers);
-            System.err.println(result);
             JSONObject jsonObject = JSONObject.parseObject(result);
             if (!Check.isNull(jsonObject)) {
                 Integer code = jsonObject.getInteger("code");

+ 127 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/clean/controller/EstimatePepoleNumberController.java

@@ -0,0 +1,127 @@
+package cn.com.ctop.kuaishou.modules.clean.controller;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+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 javax.annotation.Resource;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Description: 快手-账户清理
+ * @Author: zzy
+ * @Date: 2021-07-20
+ * @Version: V1.0
+ */
+@RestController
+@RequestMapping("/estimatePeopleNumber")
+@Slf4j
+public class EstimatePepoleNumberController {
+
+    private final String OPEN_API_URL_PREFIX = "https://ad.e.kuaishou.com/rest/openapi/v1/";
+    private final String ACCOUNT_LIST_URL = "tool/audience/prediction";
+
+    @Resource
+    CtopOauthTokenMapper ctopOauthTokenMapper;
+
+
+    /**
+     * 获取人群预估数量
+     *
+     * @param map
+     * @return
+     */
+    @PostMapping("/getCount")
+    public JSONObject getCount(@RequestBody HashMap map) {
+        return sendHttpRequest(map, ACCOUNT_LIST_URL, String.valueOf(map.get("advertiser_id")));
+    }
+
+    /**
+     * 根据地址请求巨量殷勤,返回响应结果
+     *
+     * @author zzy
+     * @Param data 请求参数    apiUrl请求路径
+     * @create: 2021-07-14
+     */
+    public JSONObject sendHttpRequest(Map data, String apiUrl, String accountId) {
+        String access_token = getToken(accountId);
+        // 构造请求
+        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+            @Override
+            public String getMethod() {
+                return "POST";
+            }
+        };
+
+        httpEntity.setHeader("Access-Token", access_token);
+
+        CloseableHttpResponse response = null;
+        CloseableHttpClient client = null;
+
+        try {
+            client = HttpClientBuilder.create().build();
+            httpEntity.setURI(URI.create(OPEN_API_URL_PREFIX + apiUrl));
+            httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
+
+            response = client.execute(httpEntity);
+            if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuffer result = new StringBuffer();
+                String line = "";
+                while ((line = bufferedReader.readLine()) != null) {
+                    result.append(line);
+                }
+                bufferedReader.close();
+                return JSONObject.parseObject(result.toString());
+            }
+
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                client.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 获取token
+     *
+     * @author zzy
+     * @create: 2021-07-14
+     */
+    public String getToken(String accountId) {
+        CtopOauthToken ctopOauthToken = ctopOauthTokenMapper.selectByAccountId(Long.parseLong(accountId));
+        if (ctopOauthToken != null) {
+            return ctopOauthToken.getAccessToken();
+        } else {
+            log.info("未查询到Token");
+            return null;
+        }
+    }
+}

+ 5 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/dimension/controller/KuaiShouDimensionStrategyController.java

@@ -235,11 +235,11 @@ public class KuaiShouDimensionStrategyController {
             if (Check.isNull(appInfoArray)) {
                 throw new Exception("策略配置应用不能为空");
             }
-
-            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-
-
-            kuaiShouDimensionStrategyService.insertStrategy(sysUser.getId(), strategyJson);
+            String userId = strategyJson.getString("userId");
+            if (Check.isNull(userId)) {
+                throw new Exception("userId不能为空");
+            }
+            kuaiShouDimensionStrategyService.insertStrategy(userId, strategyJson);
             result.success("添加成功!");
         } catch (Exception e) {
             log.error(e.getMessage(), e);

+ 0 - 9
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/dimension/controller/KuaiShouDimensionUnitController.java

@@ -257,15 +257,6 @@ public class KuaiShouDimensionUnitController {
         return result;
     }
 
-
-    public static void main(String[] args) {
-        String a = "1";
-        List<String> strings = Arrays.asList(a.split(","));
-        System.err.println(strings);
-        JSONArray array = JSONArray.parseArray(strings.toString());
-        System.err.println(array);
-    }
-
     /**
      * 通过id查询
      *

+ 26 - 12
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数据
      */
@@ -65,15 +68,17 @@ public class KsNewGroupReportCtrl {
 
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
+        startDate=startDate+" 00:00:00";
+        endDate=endDate+" 59:59:59";
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
-            JSONObject sumData = newGroupReportService.getSumNewGroupBy(accountIds, startDate, endDate);
+            /*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);
+            List<JSONObject> listData = newGroupReportService.getKsNewGroupGroupByAccount(accountIds, startDate, endDate, target, order);*/
+            List<JSONObject> chartData = newMonitorService.getKuaiShouGroupMessageGroup(accountIds, startDate, endDate);
             JSONObject sumData = newMonitorService.getKuaiShouGroupSum(accountIds, startDate, endDate);
-            List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);*/
+            List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -130,6 +135,8 @@ public class KsNewGroupReportCtrl {
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
         String target = requestBody.getString("target");
+        startDate=startDate+" 00:00:00";
+        endDate=endDate+" 59:59:59";
         String order = requestBody.getString("order");
         List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);
 
@@ -145,7 +152,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 +169,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) {

+ 11 - 6
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewPlanReportCtrl.java

@@ -60,15 +60,17 @@ public class KsNewPlanReportCtrl {
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
+        startDate=startDate+" 00:00:00";
+        endDate=endDate+" 59:59:59";
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
-            //JSONObject sumData = newPlanReportService.getSumNewPlanBy(accountIds, startDate, endDate);
-            JSONObject sumData = newMonitorService.getPlanSum(accountIds, startDate, endDate, "1");
-            //List<JSONObject> chartData = newPlanReportService.getKsNewPlanGroupByStatDate(accountIds, startDate, endDate);
+            /*JSONObject sumData = newPlanReportService.getSumNewPlanBy(accountIds, startDate, endDate);
+            List<JSONObject> chartData = newPlanReportService.getKsNewPlanGroupByStatDate(accountIds, startDate, endDate);
+            List<JSONObject> listData = newPlanReportService.getKsNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);*/
+           List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "1");
             List<JSONObject> chartData = newMonitorService.getPlanMessageGroup(accountIds, startDate, endDate, "1");
-            //List<JSONObject> listData = newPlanReportService.getKsNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
-            List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "1");
+            JSONObject sumData = newMonitorService.getPlanSum(accountIds, startDate, endDate, "1");
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -127,6 +129,8 @@ public class KsNewPlanReportCtrl {
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
+        startDate=startDate+" 00:00:00";
+        endDate=endDate+" 59:59:59";
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "1");
@@ -143,7 +147,7 @@ public class KsNewPlanReportCtrl {
             excelList.add(temp);
         });
         try {
-            String[] headers = {"账户名称","账户ID","账户所属人","新上计划数","有效计划数","最近上新时间"};
+            String[] headers = {"账户名称", "账户ID", "账户所属人", "新上计划数", "有效计划数", "最近上新时间"};
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
             XSSFWorkbook workbook = new XSSFWorkbook();
@@ -156,6 +160,7 @@ public class KsNewPlanReportCtrl {
             log.error(e.getMessage());
         }
     }
+
     /**
      * 查询所有的快手运营
      */

+ 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>

+ 31 - 10
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 where  account_status=0
+    </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>
 
@@ -96,7 +113,7 @@
                #{item}
         </foreach>
         GROUP BY account_id
-
+        order by account_id desc
     </select>
 
 
@@ -108,7 +125,7 @@
             #{item}
         </foreach>
         GROUP BY account_id
-
+        order by account_id desc
     </select>
 
     <select id="getKuaiShouGroupSum" resultType="com.alibaba.fastjson.JSONObject">
@@ -143,6 +160,7 @@
                 GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m-%d')
             </otherwise>
         </choose>
+        order by t.create_time asc
     </select>
 
     <select id="getPlanMessageGroup" resultType="com.alibaba.fastjson.JSONObject" >
@@ -159,6 +177,9 @@
                 GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m-%d')
             </otherwise>
         </choose>
+        order by t.create_time asc
     </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);
 }

+ 1 - 7
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/AccountReportServiceImpl.java

@@ -673,7 +673,7 @@ public class AccountReportServiceImpl implements IAccountReportService {
                 queryMap.put("accountIds", accountIds);
             }
 
-            if ((type != 1 && type != 2) && type != null) {
+            if (type != 1 && type != 2) {
                 JSONObject ratioJson = accountReportMapper.selectSummaryByMap(queryMap);
                 returnJson.put("ratioJson", ratioJson);
             }
@@ -685,10 +685,4 @@ public class AccountReportServiceImpl implements IAccountReportService {
         }
         return returnJson;
     }
-
-    public static void main(String[] args) {
-        Calendar calendar = Calendar.getInstance();
-        int maxHour = calendar.get(Calendar.HOUR_OF_DAY);
-        System.out.println(maxHour);
-    }
 }

+ 108 - 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,107 @@ 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);
+                }
+            });
+        }
+
+        Set<String> keys = genderResultMap.keySet();
+        keys.forEach(key -> result.add(genderResultMap.get(key)));
+
+        if(!Check.isNull(result)){
+            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();
+        }
+    }
 }

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

@@ -335,7 +335,6 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                     }
                 } else {
                     if(code == 500000 || code == 400001){
-                        System.out.print("》》5秒后重试,accountId:"+unit+",日期:"+date+"《《 "+resultJson);
                         try{Thread.sleep(5000);} catch (InterruptedException e){}
                         crowdAnalysisReport2(token,date, type, plan, unit, page, pageSize);
                     }else{

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

@@ -204,7 +204,6 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
             String postData = "{\"pageInfo\":{\"currentPage\":" + currentPage + ",\"pageSize\":200,\"total\":1000},\"reviewStatus\":\"-1\",\"selectType\":1,\"selectValue\":\"\",\"createBeginTime\":0,\"createEndTime\":0}";
             String listUrl = "https://agent.e.kuaishou.com/rest/dsp/agent/account/list";
             String result = HttpUtils2.httpPostRequestTest(listUrl, postData, headerMap);
-            System.out.println(result);
             ObjectMapper mapper = new ObjectMapper();
             mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
             JsonNode resultNode = mapper.readTree(result);

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


Некоторые файлы не были показаны из-за большого количества измененных файлов