Ver código fonte

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-boot

 Conflicts:
	module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/ByteDanceVideoReportDaily.java
	module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java
xuzuoyun 5 anos atrás
pai
commit
0faee0f0b5
100 arquivos alterados com 3404 adições e 836 exclusões
  1. 47 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/AccountReportConstants.java
  2. 21 6
      jeecg-boot-base-common/src/main/java/org/jeecg/common/system/vo/LoginUser.java
  3. 35 4
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  4. 101 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/JsonResourceUtil.java
  5. 10 9
      jeecg-boot-module-system/pom.xml
  6. 6 0
      jeecg-boot-module-system/src/main/java/org/jeecg/JeecgApplication.java
  7. 0 67
      jeecg-boot-module-system/src/main/java/org/jeecg/config/RabbitConfig.java
  8. 115 114
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  9. 4 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  10. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AgentInfoController.java
  11. 72 53
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  12. 8 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialCutFrameController.java
  13. 26 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  14. 5 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialUploadController.java
  15. 30 46
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/PangolinController.java
  16. 3 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  17. 22 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  18. 157 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ReleaseRecordController.java
  19. 171 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ReleaseViewRecordController.java
  20. 139 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  21. 28 13
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  22. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ProjectMember.java
  23. 46 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ReleaseRecord.java
  24. 46 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ReleaseViewRecord.java
  25. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/RefreshTokenJob.java
  26. 51 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyAsyncJob.java
  27. 6 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyMaterialReportJob.java
  28. 25 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyMaterialReportRetryJob.java
  29. 67 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyVideoMaterialReportAddJob.java
  30. 64 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyVideoMaterialReportJob.java
  31. 40 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedancePlanDailyReportYeterdayLoadJob.java
  32. 59 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/CutFrameJob.java
  33. 30 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaiShouRefreshTokenJob.java
  34. 27 30
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java
  35. 47 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoLoginJob.java
  36. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCrawlerJob.java
  37. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java
  38. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportNextDayStayJob.java
  39. 10 342
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/OceanengineJob.java
  40. 1 14
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/PangolinDataJob.java
  41. 2 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/PangolinLoginJob.java
  42. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java
  43. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ReleaseRecordMapper.java
  44. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ReleaseViewRecordMapper.java
  45. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/TransferAccountMapper.java
  46. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/AdvertiserMapper.xml
  47. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialTopMapper.xml
  48. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml
  49. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ReleaseRecordMapper.xml
  50. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ReleaseViewRecordMapper.xml
  51. 16 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/TransferAccountMapper.xml
  52. 4 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java
  53. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IReleaseRecordService.java
  54. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IReleaseViewRecordService.java
  55. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ITransferAccountService.java
  56. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/AdvertiserServiceImpl.java
  57. 2 10
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CrawlerServiceImpl.java
  58. 22 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java
  59. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MaterialTopServiceImpl.java
  60. 55 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  61. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ReleaseRecordServiceImpl.java
  62. 80 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ReleaseViewRecordServiceImpl.java
  63. 21 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java
  64. 0 20
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Receiver.java
  65. 0 27
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Sender.java
  66. 144 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/opencv/utils/ExtractionVideoKeyFrames.java
  67. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/PeriodConstant.java
  68. 36 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/RateConstant.java
  69. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/StandardValue.java
  70. 111 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/controller/PerformanceShowCtrl.java
  71. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/DesignDetail.java
  72. 75 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/OperateDetail.java
  73. 146 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/PerformanceQuarter.java
  74. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/CalculatePerformanceMapper.java
  75. 11 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/DesignDetailMapper.java
  76. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/OperateDetailMapper.java
  77. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/PerformanceQuarterMapper.java
  78. 27 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/CalculatePerformanceMapper.xml
  79. 52 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/DesignDetailMapper.xml
  80. 78 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/OperateDetailMapper.xml
  81. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/PerformanceQuarterMapper.xml
  82. 28 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/DesignDetailServiceImpl.java
  83. 12 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ICalculatePerformanceService.java
  84. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IDesignDetailService.java
  85. 27 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IOperateDetailService.java
  86. 8 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceInfoService.java
  87. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceQuarterService.java
  88. 75 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/CalculatePerformanceServiceImpl.java
  89. 189 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/OperateDetailServiceImpl.java
  90. 81 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceInfoInfoServiceImpl.java
  91. 109 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceQuarterServiceImpl.java
  92. 35 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/testCtrl.java
  93. 32 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/vo/TransferDetailVO.java
  94. 0 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/performanceappraisal/aa.java
  95. 52 21
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  96. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java
  97. 26 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserRoleMapper.java
  98. 28 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
  99. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserRoleService.java
  100. 0 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java

+ 47 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/AccountReportConstants.java

@@ -0,0 +1,47 @@
+package org.jeecg.common.constant;
+
+import org.jeecg.common.util.JsonResourceUtil;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *  Created by JQ.bi on 2020.5.30
+ */
+public class AccountReportConstants {
+
+    /**
+     * 私有构造器
+     */
+    private AccountReportConstants(){
+
+    }
+
+    /** 单体实例 */
+    private static AccountReportConstants instance;
+
+
+    /**
+     * @return 返回 instance
+     */
+    public static AccountReportConstants getInstance() {
+        if (instance == null) {
+            instance = new AccountReportConstants();
+        }
+        return instance;
+    }
+
+    /** 字典数据 */
+    public static Map<String, Map<String,Object>> dicMap = new HashMap<>();
+
+    /**
+     * 初始化字典
+     */
+    public void init(){
+        //加载json文件
+        Object json=JsonResourceUtil.getJsonObjFromResource("/json_template/bytedance_filed_mapping.json");
+        //json 转为map存为静态常量
+        dicMap=JsonResourceUtil.jsonToMap(json);
+    }
+
+}

+ 21 - 6
jeecg-boot-base-common/src/main/java/org/jeecg/common/system/vo/LoginUser.java

@@ -1,14 +1,12 @@
 package org.jeecg.common.system.vo;
 
-import java.util.Date;
-
-import org.springframework.format.annotation.DateTimeFormat;
-
 import com.fasterxml.jackson.annotation.JsonFormat;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 /**
  * <p>
@@ -73,11 +71,28 @@ public class LoginUser {
 	 * 状态(1:正常 2:冻结 )
 	 */
 	private Integer status;
-	
+
 	private String delFlag;
 	/**
      * 同步工作流引擎1同步0不同步
      */
     private String activitiSync;
 
+	@Override
+	public String toString() {
+		return "LoginUser{" +
+				"id='" + id + '\'' +
+				", username='" + username + '\'' +
+				", realname='" + realname + '\'' +
+				", orgCode='" + orgCode + '\'' +
+				", avatar='" + avatar + '\'' +
+				", birthday=" + birthday +
+				", sex=" + sex +
+				", email='" + email + '\'' +
+				", phone='" + phone + '\'' +
+				", status=" + status +
+				", delFlag='" + delFlag + '\'' +
+				", activitiSync='" + activitiSync + '\'' +
+				'}';
+	}
 }

+ 35 - 4
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -1,5 +1,6 @@
 package org.jeecg.common.util;
 
+import org.jeecg.common.constant.SystemDateConstant;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.StringUtils;
@@ -20,7 +21,7 @@ import java.util.*;
  */
 public class DateUtils extends PropertyEditorSupport {
 
-    private static Logger logger= LoggerFactory.getLogger(DateUtils.class);
+    private static Logger logger = LoggerFactory.getLogger(DateUtils.class);
 
     /**
      * 以毫秒表示的时间
@@ -1227,7 +1228,7 @@ public class DateUtils extends PropertyEditorSupport {
             e.printStackTrace();
         }
         //得到相差的天数 betweenDate
-        return  (endDate.getTime() - startDate.getTime())/(60*60*24*1000);
+        return (endDate.getTime() - startDate.getTime()) / (60 * 60 * 24 * 1000);
     }
 
     /***
@@ -1313,8 +1314,38 @@ public class DateUtils extends PropertyEditorSupport {
         return calendar.getTime();
     }
 
-    public static void main(String[] args) throws ParseException {
-        System.out.println(calDiffMonth(DateUtils.parseDate("2019-04-01", "yyyy-MM-dd"), new Date()));
+    /**
+     * 判断两个日期间隔是否大于半年
+     *
+     * @return
+     */
+    public static boolean isMoreSixMonth(String startDate, String endDate) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(Objects.requireNonNull(parseDate(startDate, SystemDateConstant.yyyy_MM_dd)));
+        long time1 = c.getTimeInMillis();
+        c.setTime(Objects.requireNonNull(parseDate(endDate, SystemDateConstant.yyyy_MM_dd)));
+        long time2 = c.getTimeInMillis();
+        long between_days = (time2 - time1) / (1000 * 3600 * 24);
+        int day = Integer.parseInt(String.valueOf(between_days));
+        return day > 180;
+    }
+
+    public static List<Date> findDates(Date dBegin, Date dEnd) {
+        List<Date> lDate = new ArrayList<Date>();
+        lDate.add(dBegin);
+        Calendar calBegin = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calBegin.setTime(dBegin);
+        Calendar calEnd = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calEnd.setTime(dEnd);
+        // 测试此日期是否在指定日期之后
+        while (dEnd.after(calBegin.getTime())) {
+            // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
+            calBegin.add(Calendar.DAY_OF_MONTH, 1);
+            lDate.add(calBegin.getTime());
+        }
+        return lDate;
     }
 
 }

+ 101 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/JsonResourceUtil.java

@@ -0,0 +1,101 @@
+package org.jeecg.common.util;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.jeecg.common.constant.AccountReportConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import java.io.File;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+/**
+ * Created by JQ.bi on 2020.06.03
+ */
+public class JsonResourceUtil {
+
+    private static Logger logger = LoggerFactory.getLogger(JsonResourceUtil.class);
+
+    private JsonResourceUtil() {
+
+    }
+
+    //filename 为文件名字 如 “/json/app_version_info.json”
+    public static JSONObject getJsonObjFromResource(String filename) {
+        JSONObject json = null;
+        if (!filename.contains(".json")) {
+            filename += ".json";
+        }
+        try {
+            ClassPathResource classPathResource = new ClassPathResource(filename);
+            if (classPathResource.exists()) {
+                InputStream inputStream = classPathResource.getInputStream();
+                String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+                json = JSON.parseObject(content);
+            } else {
+                logger.info("file not exist!");
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.info("readFileToString" + e.getMessage());
+        }
+        return json;
+    }
+
+    public static Map<String, Map<String, Object>> jsonToMap(Object jsonObj) {
+        JSONObject jsonObject = JSONObject.parseObject(jsonObj.toString());
+        Map<String, Map<String, Object>> mapMap = new HashMap<>();
+        jsonObject.forEach((key, value) -> {
+            mapMap.put(key, JSONObject.parseObject(value.toString()));
+        });
+        return mapMap;
+    }
+
+    /**
+     * 拼接字段
+     */
+    public static String joinFiled(JSONArray array) {
+        StringBuilder sb = new StringBuilder();
+        array.forEach(it -> {
+            if (AccountReportConstants.dicMap.get(it.toString()).isEmpty()) {
+                sb.append(it).append(",");
+            } else {
+                sb.append(AccountReportConstants.dicMap.get(it.toString()).get("filed")).append(",");
+            }
+        });
+        return sb.deleteCharAt(sb.length() - 1).toString();
+    }
+
+    /**
+     * 拼接title
+     */
+    public static List<String> joinTitle(JSONArray array) {
+        List<String> titles = new ArrayList<>(20);
+        array.forEach(it -> {
+            if (AccountReportConstants.dicMap.get(it.toString()).isEmpty()) {
+                titles.add(it.toString());
+            } else {
+                titles.add(AccountReportConstants.dicMap.get(it.toString()).get("comment").toString());
+            }
+        });
+        return titles;
+    }
+
+    /**
+     * 拼接字段
+     */
+    public static String joinAllFiled() {
+        StringBuilder sb = new StringBuilder();
+        AccountReportConstants.dicMap.forEach((k, v) -> {
+            sb.append(v.get("filed")).append(",");
+        });
+        return sb.deleteCharAt(sb.length() - 1).toString();
+    }
+}

+ 10 - 9
jeecg-boot-module-system/pom.xml

@@ -41,12 +41,6 @@
     </repositories>
 
     <dependencies>
-        <!-- rabbitmq 依赖jar包-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-amqp</artifactId>
-            <version>1.5.2.RELEASE</version>
-        </dependency>
         <dependency>
             <groupId>org.jeecgframework.boot</groupId>
             <artifactId>jeecg-boot-base-common</artifactId>
@@ -112,6 +106,7 @@
             <version>2.0.2</version>
             <scope>compile</scope>
         </dependency>
+
         <dependency>
             <groupId>com.bstek.ureport</groupId>
             <artifactId>ureport2-console</artifactId>
@@ -130,9 +125,9 @@
             <version>3.17</version>
         </dependency>
         <dependency>
-        <groupId>org.apache.poi</groupId>
-        <artifactId>poi-ooxml-schemas</artifactId>
-        <version>3.17</version>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>3.17</version>
         </dependency>
 
         <dependency>
@@ -236,5 +231,11 @@
                 <activatedProperties>prod</activatedProperties>
             </properties>
         </profile>
+        <profile>
+            <id>wps</id>
+            <properties>
+                <activatedProperties>wps</activatedProperties>
+            </properties>
+        </profile>
     </profiles>
 </project>

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/JeecgApplication.java

@@ -3,6 +3,7 @@ package org.jeecg;
 import cn.com.ctop.common.module.utils.SpringUtils;
 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.constant.AccountReportConstants;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.ConfigurableApplicationContext;
@@ -48,5 +49,10 @@ public class JeecgApplication {
     public PaginationInterceptor paginationInterceptor() {
         return new PaginationInterceptor();
     }
+    //加载数据字典
+    @Bean
+    public void instanceFiledDic(){
+        AccountReportConstants.getInstance().init();
+    }
 
 }

+ 0 - 67
jeecg-boot-module-system/src/main/java/org/jeecg/config/RabbitConfig.java

@@ -1,67 +0,0 @@
-package org.jeecg.config;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
-import org.springframework.amqp.rabbit.connection.ConnectionFactory;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Scope;
-
-@Configuration
-@Slf4j
-public class RabbitConfig {
-    @Value("${spring.rabbitmq.host}")
-    private String host;
-
-    @Value("${spring.rabbitmq.port}")
-    private int port;
-
-    @Value("${spring.rabbitmq.username}")
-    private String username;
-
-    @Value("${spring.rabbitmq.password}")
-    private String password;
-
-
-    public static final String EXCHANGE_A = "my-mq-exchange_A";
-    public static final String EXCHANGE_B = "my-mq-exchange_B";
-    public static final String EXCHANGE_C = "my-mq-exchange_C";
-
-
-    public static final String QUEUE_A = "QUEUE_A";
-    public static final String QUEUE_B = "QUEUE_B";
-    public static final String QUEUE_C = "QUEUE_C";
-
-    public static final String ROUTINGKEY_A = "spring-boot-routingKey_A";
-    public static final String ROUTINGKEY_B = "spring-boot-routingKey_B";
-    public static final String ROUTINGKEY_C = "spring-boot-routingKey_C";
-
-    @Bean
-    public ConnectionFactory connectionFactory() {
-        CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host, port);
-        connectionFactory.setUsername(username);
-        connectionFactory.setPassword(password);
-        connectionFactory.setVirtualHost("/");
-        connectionFactory.setPublisherConfirms(true);
-        return connectionFactory;
-    }
-
-    /**
-     * 必须是prototype类型
-     */
-    @Bean
-    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-    public RabbitTemplate rabbitTemplate() {
-        RabbitTemplate template = new RabbitTemplate(connectionFactory());
-        return template;
-    }
-
-    @Bean
-    public Queue helloQueue() {
-        return new Queue("hello");
-    }
-}

+ 115 - 114
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -28,20 +28,20 @@ import java.util.Map;
 @Configuration
 public class ShiroConfig {
 
-	/**
-	 * Filter Chain定义说明
-	 *
-	 * 1、一个URL可以配置多个Filter,使用逗号分隔
-	 * 2、当设置多个过滤器时,全部验证通过,才视为通过
-	 * 3、部分过滤器可指定参数,如perms,roles
-	 */
-	@Bean("shiroFilter")
-	public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
-		ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
-		shiroFilterFactoryBean.setSecurityManager(securityManager);
-		// 拦截器
-		Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
-		// 配置不会被拦截的链接 顺序判断
+    /**
+     * Filter Chain定义说明
+     * <p>
+     * 1、一个URL可以配置多个Filter,使用逗号分隔
+     * 2、当设置多个过滤器时,全部验证通过,才视为通过
+     * 3、部分过滤器可指定参数,如perms,roles
+     */
+    @Bean("shiroFilter")
+    public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
+        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
+        shiroFilterFactoryBean.setSecurityManager(securityManager);
+        // 拦截器
+        Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
+        // 配置不会被拦截的链接 顺序判断
         //登录接口排除
         filterChainDefinitionMap.put("/sys/login", "anon");
         filterChainDefinitionMap.put("/sys/wxlogin", "anon");
@@ -70,64 +70,63 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/sys/common/download/**", "anon");
         //pdf预览
         filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");
-		filterChainDefinitionMap.put("/ctop/bytedanceAreaInfo/**", "anon");
-		filterChainDefinitionMap.put("/ctop/bytedanceInterestCategory/**", "anon");
-		filterChainDefinitionMap.put("/template/creative/words/get", "anon");
-		filterChainDefinitionMap.put("/appium/crawler/*", "anon");
+        filterChainDefinitionMap.put("/ctop/bytedanceAreaInfo/**", "anon");
+        filterChainDefinitionMap.put("/ctop/bytedanceInterestCategory/**", "anon");
+        filterChainDefinitionMap.put("/template/creative/words/get", "anon");
+        filterChainDefinitionMap.put("/appium/crawler/*", "anon");
 
         filterChainDefinitionMap.put("/ctop/kuaishouChannelRegInfo/*", "anon");
 
 
-		filterChainDefinitionMap.put("/ctop/byteDance/homePage/report/*", "anon");
-		filterChainDefinitionMap.put("/ctop/material/top/cost", "anon");
+        filterChainDefinitionMap.put("/ctop/byteDance/homePage/report/*", "anon");
+        filterChainDefinitionMap.put("/ctop/material/top/cost", "anon");
 
-		filterChainDefinitionMap.put("/pangolin/**", "anon");
+        filterChainDefinitionMap.put("/v1/**", "anon");
 
         filterChainDefinitionMap.put("/generic/**", "anon");
-		filterChainDefinitionMap.put("/", "anon");
-		filterChainDefinitionMap.put("/doc.html", "anon");
-		filterChainDefinitionMap.put("/**/*.js", "anon");
-		filterChainDefinitionMap.put("/**/*.css", "anon");
-		filterChainDefinitionMap.put("/**/*.html", "anon");
-		filterChainDefinitionMap.put("/**/*.svg", "anon");
-		filterChainDefinitionMap.put("/**/*.jpg", "anon");
-		filterChainDefinitionMap.put("/**/*.png", "anon");
-		filterChainDefinitionMap.put("/**/*.ico", "anon");
-		filterChainDefinitionMap.put("/druid/**", "anon");
-		filterChainDefinitionMap.put("/swagger-ui.html", "anon");
-		filterChainDefinitionMap.put("/swagger**/**", "anon");
-		filterChainDefinitionMap.put("/webjars/**", "anon");
-		filterChainDefinitionMap.put("/v2/**", "anon");
+        filterChainDefinitionMap.put("/", "anon");
+        filterChainDefinitionMap.put("/doc.html", "anon");
+        filterChainDefinitionMap.put("/**/*.js", "anon");
+        filterChainDefinitionMap.put("/**/*.css", "anon");
+        filterChainDefinitionMap.put("/**/*.html", "anon");
+        filterChainDefinitionMap.put("/**/*.svg", "anon");
+        filterChainDefinitionMap.put("/**/*.jpg", "anon");
+        filterChainDefinitionMap.put("/**/*.png", "anon");
+        filterChainDefinitionMap.put("/**/*.ico", "anon");
+        filterChainDefinitionMap.put("/druid/**", "anon");
+        filterChainDefinitionMap.put("/swagger-ui.html", "anon");
+        filterChainDefinitionMap.put("/swagger**/**", "anon");
+        filterChainDefinitionMap.put("/webjars/**", "anon");
+        filterChainDefinitionMap.put("/v2/**", "anon");
         filterChainDefinitionMap.put("/kuaishou", "anon");
         filterChainDefinitionMap.put("/kuaishou/report", "anon");
-		filterChainDefinitionMap.put("/ctop/bindAccount/**", "anon");
-		filterChainDefinitionMap.put("/**/*.mp4", "anon");
+        filterChainDefinitionMap.put("/ctop/bindAccount/**", "anon");
+        filterChainDefinitionMap.put("/**/*.mp4", "anon");
 
-
-		//性能监控
-		filterChainDefinitionMap.put("/actuator/metrics/**", "anon");
-		filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
-		filterChainDefinitionMap.put("/actuator/redis/**", "anon");
+        //性能监控
+        filterChainDefinitionMap.put("/actuator/metrics/**", "anon");
+        filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
+        filterChainDefinitionMap.put("/actuator/redis/**", "anon");
         //消息队列
         filterChainDefinitionMap.put("/mq/**", "anon");
         //模板测试
         filterChainDefinitionMap.put("/test/**", "anon");
-		//oauth接口
+        //oauth接口
         filterChainDefinitionMap.put("/auth/**", "anon");
-		filterChainDefinitionMap.put("/ctop/syncdata/**", "anon");
-		//头条接口
+        filterChainDefinitionMap.put("/ctop/syncdata/**", "anon");
+        //头条接口
         filterChainDefinitionMap.put("/bytedance", "anon");
-		filterChainDefinitionMap.put("/toutiao/dictitem/list", "anon");
+        filterChainDefinitionMap.put("/toutiao/dictitem/list", "anon");
         filterChainDefinitionMap.put("/toutiao/loadAllData", "anon");
         filterChainDefinitionMap.put("/toutiao/loadSingleData", "anon");
-		filterChainDefinitionMap.put("/kuaishou/getReport/historyData", "anon");
-		filterChainDefinitionMap.put("/toutiao/advertiser/**", "anon");
+        filterChainDefinitionMap.put("/kuaishou/getReport/historyData", "anon");
+        filterChainDefinitionMap.put("/toutiao/advertiser/**", "anon");
         filterChainDefinitionMap.put("/toutiao/industry/list", "anon");
         filterChainDefinitionMap.put("/template/bytedance/industry/list", "anon");
         filterChainDefinitionMap.put("/template/convert/list", "anon");
-		filterChainDefinitionMap.put("/template/convert/list/url", "anon");
+        filterChainDefinitionMap.put("/template/convert/list/url", "anon");
         //文件上传接口
-		filterChainDefinitionMap.put("/upload/**", "anon");
+        filterChainDefinitionMap.put("/upload/**", "anon");
         filterChainDefinitionMap.put("/appium/appiumTask/run", "anon");
 
         filterChainDefinitionMap.put("/system/userCompany/**", "anon");
@@ -136,71 +135,73 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/test/getVideoAndImage/**", "anon");
         filterChainDefinitionMap.put("/test/gerCreative/**", "anon");
 
-		filterChainDefinitionMap.put("/report/kuaishouReportDailyAgent/get","anon");
+        filterChainDefinitionMap.put("/report/kuaishouReportDailyAgent/get", "anon");
 
-		filterChainDefinitionMap.put("/appium/appiumTask/run/login", "anon");
-		filterChainDefinitionMap.put("/zip/download", "anon");
-		//爬虫接口
-		filterChainDefinitionMap.put("/graphql/video", "anon");
-		filterChainDefinitionMap.put("/ks/web/test", "anon");
+        filterChainDefinitionMap.put("/appium/appiumTask/run/login", "anon");
+        filterChainDefinitionMap.put("/zip/download", "anon");
+        //爬虫接口
+        filterChainDefinitionMap.put("/graphql/video", "anon");
+        filterChainDefinitionMap.put("/ks/web/test", "anon");
         filterChainDefinitionMap.put("/ureport/**", "anon");
-        filterChainDefinitionMap.put("/ctop/advertiser/**", "anon");
-
-		// 添加自己的过滤器并且取名为jwt
-		Map<String, Filter> filterMap = new HashMap<>(1);
-		filterMap.put("jwt", new JwtFilter());
-		shiroFilterFactoryBean.setFilters(filterMap);
-		// <!-- 过滤链定义,从上向下顺序执行,一般将/**放在最为下边
-		filterChainDefinitionMap.put("/**", "jwt");
-
-		// 未授权界面返回JSON
-		shiroFilterFactoryBean.setUnauthorizedUrl("/sys/common/403");
-		shiroFilterFactoryBean.setLoginUrl("/sys/common/403");
-		shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
-		return shiroFilterFactoryBean;
-	}
-
-	@Bean("securityManager")
-	public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
-		DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
-		securityManager.setRealm(myRealm);
-
-		/*
-		 * 关闭shiro自带的session,详情见文档
-		 * http://shiro.apache.org/session-management.html#SessionManagement-
-		 * StatelessApplications%28Sessionless%29
-		 */
-		DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
-		DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
-		defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
-		subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
-		securityManager.setSubjectDAO(subjectDAO);
-
-		return securityManager;
-	}
-
-	/**
-	 * 下面的代码是添加注解支持
-	 * @return
-	 */
-	@Bean
-	@DependsOn("lifecycleBeanPostProcessor")
-	public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
-		DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
-		defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
-		return defaultAdvisorAutoProxyCreator;
-	}
-
-	@Bean
-	public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
-		return new LifecycleBeanPostProcessor();
-	}
-
-	@Bean
-	public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
-		AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
-		advisor.setSecurityManager(securityManager);
-		return advisor;
-	}
+        //filterChainDefinitionMap.put("/ctop/performance/show/**", "anon");
+        filterChainDefinitionMap.put("/job/test/*", "anon");
+
+        // 添加自己的过滤器并且取名为jwt
+        Map<String, Filter> filterMap = new HashMap<>(1);
+        filterMap.put("jwt", new JwtFilter());
+        shiroFilterFactoryBean.setFilters(filterMap);
+        // <!-- 过滤链定义,从上向下顺序执行,一般将/**放在最为下边
+        filterChainDefinitionMap.put("/**", "jwt");
+
+        // 未授权界面返回JSON
+        shiroFilterFactoryBean.setUnauthorizedUrl("/sys/common/403");
+        shiroFilterFactoryBean.setLoginUrl("/sys/common/403");
+        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
+        return shiroFilterFactoryBean;
+    }
+
+    @Bean("securityManager")
+    public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
+        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
+        securityManager.setRealm(myRealm);
+
+        /*
+         * 关闭shiro自带的session,详情见文档
+         * http://shiro.apache.org/session-management.html#SessionManagement-
+         * StatelessApplications%28Sessionless%29
+         */
+        DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
+        DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
+        defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
+        subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
+        securityManager.setSubjectDAO(subjectDAO);
+
+        return securityManager;
+    }
+
+    /**
+     * 下面的代码是添加注解支持
+     *
+     * @return
+     */
+    @Bean
+    @DependsOn("lifecycleBeanPostProcessor")
+    public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
+        DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
+        defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
+        return defaultAdvisorAutoProxyCreator;
+    }
+
+    @Bean
+    public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
+        return new LifecycleBeanPostProcessor();
+    }
+
+    @Bean
+    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
+        AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
+        advisor.setSecurityManager(securityManager);
+        return advisor;
+    }
 
 }

+ 4 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
@@ -78,7 +79,7 @@ public class AdvertiserController {
         try {
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
             QueryWrapper<Advertiser> queryWrapper = new QueryWrapper<>();
-            if (!"admin".equals(roleCode)) {
+            if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
                 QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
                 userCompanyQueryWrapper.eq("user_id", userId);
                 userCompanyQueryWrapper.orderByDesc("create_time");
@@ -115,7 +116,7 @@ public class AdvertiserController {
         Result<IPage<Advertiser>> result = new Result<>();
         String roleCode = sysRoleService.getRoleCodeByUserId(advertiser.getUserId());
         String userId = advertiser.getUserId();
-        if ("admin".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
+        if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
             advertiser.setUserId(null);
         }
         String industryId = advertiser.getIndustryId();
@@ -426,10 +427,9 @@ public class AdvertiserController {
                 sheets.add(vo);
             }
         }
-
         OutputStream outputStream = response.getOutputStream();
         String date = DateUtils.formatDate(new Date());
-        HttpUtils.setResponseHeader(response, "爱上消消消日报" + date + ".xls");
+        HttpUtils.setResponseHeader(response, "爱上消消消日报" + date + ".xlsx");
         ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
         for (int i = 0; i < sheets.size(); i++) {
             Sheet sheet = new Sheet(i + 1, 0, KuaishouXxlEntity.class);

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

@@ -202,7 +202,6 @@ public class AgentInfoController {
         } catch (UnsupportedEncodingException e) {
             e.printStackTrace();
         }
-
         //Step.2 AutoPoi 导出Excel
         ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
         List<AgentInfo> pageList = agentInfoService.list(queryWrapper);

+ 72 - 53
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -11,6 +11,7 @@ import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
@@ -24,7 +25,10 @@ import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysDepartService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+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 javax.servlet.http.HttpServletResponse;
@@ -55,6 +59,8 @@ public class CallbackController {
     private ICtopOauthTokenService ctopOauthTokenService;
     @Autowired
     private IByteDanceAdvertiserDataService advertiserDataService;
+    @Autowired
+    private IReportService reportService;
 
     @GetMapping("/feishu/auth")
     public void feishuAuth(HttpServletRequest request,
@@ -107,7 +113,6 @@ public class CallbackController {
     }
 
     /**
-     *
      * @param request
      * @param response
      * @param authCode
@@ -238,10 +243,6 @@ public class CallbackController {
 
         if (StringUtils.isNotBlank(authCode)) {
             Map<String, Object> map = this.getByteDanceAccessToken(authCode, state);
-            Integer code = (Integer) map.get("code");
-            if (code == 0) {
-                return "授权绑定成功";
-            }
             log.info("返回信息:{}", map.toString());
             return (String) map.get("desc");
         }
@@ -288,59 +289,79 @@ public class CallbackController {
             BigDecimal warningAmount = json.getBigDecimal("WarningAmount");
 
             JSONObject data = resultObject.getJSONObject("data");
-            CtopOauthToken token = new CtopOauthToken(advertiserId, data);
-            ctopOauthTokenService.saveOrUpdate(token);
-            //获取广告主信息
-            Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(token.getAccountId() + "");
-            Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
-            if (null == getSuccess || !getSuccess) {
-                log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
-                throw new Exception("获取广告主信息失败");
+
+            if (Check.isNull(data)) {
+                returnMap.put("code", -1);
+                returnMap.put("desc", "返回信息为空");
+                return returnMap;
+
             }
 
-            Long accountId = token.getAccountId();
-            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
-            userAllocationQueryWrapper.eq("account_id", accountId);
-            userAllocationQueryWrapper.eq("media_id", 1);
-            userAllocationQueryWrapper.orderByDesc("create_time");
-            userAllocationQueryWrapper.last("limit 1");
-            UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
-            if (!Check.isNull(checkUserAllocation)) {
+            data.remove("advertiser_id");
+            JSONArray advertiser_ids = data.getJSONArray("advertiser_ids");
+            if (Check.isNull(advertiser_ids)) {
                 returnMap.put("code", -1);
-                returnMap.put("desc", "授权失败,账号已被:" + checkUserAllocation.getUserName() + "绑定");
+                returnMap.put("desc", "请选择需要授权的账号");
                 return returnMap;
+
             }
 
-            String systemType = json.getString("systemType");
-            UserAllocation userAllocation = new UserAllocation();
-            userAllocation.setUserId(userId);
-            userAllocation.setUserName(userName);
-            userAllocation.setAccountId(token.getAccountId());
-            userAllocation.setAdvertiserName(advertiserName);
-            userAllocation.setMediaId(mediaId);
-            userAllocation.setProjectId(projectId);
-            userAllocation.setProjectName(projectName);
-            userAllocation.setSystemType(systemType);
-            userAllocation.setAuthName((String) advertiserDataMap.get("name"));
-            userAllocation.setAdvertiserId(advertiserId);
-            userAllocation.setWarningProportion(warningProportion);
-            userAllocation.setWarningAmount(warningAmount);
-            userAllocation.setCreateTime(new Date());
-            userAllocation.setUpdateTime(new Date());
-            allocationMapper.deleteById(userAllocation.getId());
-            Map<String, Object> deleteUserMap = new HashMap<>();
-            deleteUserMap.put("advertiser_id", advertiserId);
-            deleteUserMap.put("account_id", token.getAccountId());
-            allocationMapper.deleteByMap(deleteUserMap);
-            int i = allocationMapper.insert(userAllocation);
-            if (i > 0) {
-                log.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
+            data.remove("advertiser_ids");
+            StringBuilder text = new StringBuilder();
+            for (int i = 0; i < advertiser_ids.size(); i++) {
+                Long advertiser_id = advertiser_ids.getLong(i);
+                data.put("advertiser_id", advertiser_id);
+                CtopOauthToken token = new CtopOauthToken(advertiserId, data);
+                ctopOauthTokenService.saveOrUpdate(token);
+                //获取广告主信息
+                Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(token.getAccountId() + "");
+                Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
+                if (null == getSuccess || !getSuccess) {
+                    log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
+                    continue;
+                }
+
+                Long accountId = token.getAccountId();
+                QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+                userAllocationQueryWrapper.eq("account_id", accountId);
+                userAllocationQueryWrapper.eq("media_id", 1);
+                userAllocationQueryWrapper.orderByDesc("create_time");
+                userAllocationQueryWrapper.last("limit 1");
+                UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
+                if (!Check.isNull(checkUserAllocation)) {
+                    text.append("accountId:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定失败,失败原因:已被" + checkUserAllocation.getUserName() + "绑定。")
+                            .append("<br/>");
+                    continue;
+                }
+                text.append("accountId:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
+                String systemType = json.getString("systemType");
+                UserAllocation userAllocation = new UserAllocation();
+                userAllocation.setUserId(userId);
+                userAllocation.setUserName(userName);
+                userAllocation.setAccountId(token.getAccountId());
+                userAllocation.setAdvertiserName(advertiserName);
+                userAllocation.setMediaId(mediaId);
+                userAllocation.setProjectId(projectId);
+                userAllocation.setProjectName(projectName);
+                userAllocation.setSystemType(systemType);
+                userAllocation.setAuthName((String) advertiserDataMap.get("name"));
+                userAllocation.setAdvertiserId(advertiserId);
+                userAllocation.setWarningProportion(warningProportion);
+                userAllocation.setWarningAmount(warningAmount);
+                userAllocation.setCreateTime(new Date());
+                userAllocation.setUpdateTime(new Date());
+                int j = allocationMapper.insert(userAllocation);
+                if (j > 0) {
+                    log.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
+                }
+                //账号绑定
+                bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
+                new Thread(() -> reportService.loadBytedanceHistoryData(token)).start();
             }
-            //账号绑定
-            bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
-            new Thread(() -> reportService.loadBytedanceHistoryData(token)).start();
+
             returnMap.put("code", 0);
-            returnMap.put("desc", "success");
+            returnMap.put("desc", text.toString());
+
         } catch (Exception e) {
             e.printStackTrace();
             returnMap.put("code", -1);
@@ -349,7 +370,5 @@ public class CallbackController {
         return returnMap;
     }
 
-    @Autowired
-    private IReportService reportService;
 
 }

+ 8 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialCutFrameController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
+import java.util.List;
 
 
 /**
@@ -49,15 +50,20 @@ public class MaterialCutFrameController {
                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                          HttpServletRequest req) {
-        Result<IPage<MaterialCutFrame>> result = new Result<IPage<MaterialCutFrame>>();
+        Result<IPage<MaterialCutFrame>> result = new Result<>();
         QueryWrapper<MaterialCutFrame> queryWrapper = QueryGenerator.initQueryWrapper(materialCutFrame, req.getParameterMap());
-        Page<MaterialCutFrame> page = new Page<MaterialCutFrame>(pageNo, pageSize);
+        queryWrapper.orderByAsc("image_index");
+        Page<MaterialCutFrame> page = new Page<>(pageNo, pageSize);
+        //TODO 这边代码有bug,先临时紧急处理,后续优化截帧任务
         IPage<MaterialCutFrame> pageList = materialCutFrameService.page(page, queryWrapper);
+        List<MaterialCutFrame> list = materialCutFrameService.getListByVideoSignature(materialCutFrame.getVideoSignature());
+        pageList.setRecords(list);
         result.setSuccess(true);
         result.setResult(pageList);
         return result;
     }
 
+
     /**
      * 添加
      *

+ 26 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.ctop.controller;
 
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.Check;
@@ -24,6 +25,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.service.IKuaiShouUploadService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.ctop.service.IProjectService;
@@ -168,7 +170,7 @@ public class MaterialInfoController {
         materialInfo.setCreateTime(null);
         if (!Check.isNull(materialInfo.getUserId())) {
             String roleCode = materialInfoService.getRoleCodeByUserId(materialInfo.getUserId());
-            if ("admin".equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
+            if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
                 materialInfo.setUserId(null);
                 queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
             } else if ("designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode) || "plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode)) {
@@ -232,12 +234,17 @@ public class MaterialInfoController {
                     material.setKuaiShou(JSONObject.parseObject(kuaiShouString));
                 }
 
+
+                Project project = projectService.getById(material.getProjectId());
+                if (!Check.isNull(project)) {
+                    material.setMediaId(project.getMediaId());
+                    material.setProjectName(project.getProjectName());
+                }
                 /*JSONObject generalizationJson = materialInfoService.getGeneralizationInfo(material.getCode());
                 if (!Check.isNull(generalizationJson)) {
-                    material.setGeneralization(generalizationJson);
+                    material.setGeneralization(generaliz  ationJson);
                 }*/
 
-
                 QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
                 imageInfoQueryWrapper.eq("video_id", material.getCode());
                 imageInfoQueryWrapper.eq("status", 0);
@@ -317,6 +324,10 @@ public class MaterialInfoController {
      */
     @Autowired
     private IProjectService projectService;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+    @Autowired
+    private ISendMessageService sendMessageService;
 
     @AutoLog(value = "素材信息-编辑")
     @ApiOperation(value = "素材信息-编辑", notes = "素材信息-编辑")
@@ -383,6 +394,14 @@ public class MaterialInfoController {
             if (ok) {
                 result.success("修改成功!");
             }
+
+            Integer status = materialInfo.getStatus();
+            // 如果状态为2 审核拒绝 给上传人发送消息
+            if (status == 2) {
+                Project project = projectService.getById(materialInfoEntity.getProjectId());
+                String text = messageTemplate.getMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
+                sendMessageService.sendMessage(materialInfoEntity.getUserId(), text);
+            }
         }
 
         return result;
@@ -474,6 +493,10 @@ public class MaterialInfoController {
         List<String> effiList = materialInfoService.getEffiCode();
         Object createTime = materialInfo.getCreateTime();
         materialInfo.setCreateTime(null);
+        Long projectId = materialInfo.getProjectId();
+        if(projectId != null){
+            queryWrapper.eq("project_id", projectId);
+        }
         queryWrapper.in("code", effiList);
         queryWrapper.groupBy("code");
         //queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());

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

@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -44,8 +46,10 @@ public class MaterialUploadController {
             if (Check.isNull(materialArray) || Check.isNull(accountArray)) {
                 throw new Exception("请选择账号或素材");
             }
+            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 
-            new Thread(() -> materialUploadService.uploadAccount(mediaId, materialArray, accountArray)).start();
+
+            new Thread(() -> materialUploadService.uploadAccount(mediaId, materialArray, accountArray, sysUser.getId())).start();
             returnMap.put("success", true);
             returnMap.put("message", "开始上传文件");
             returnMap.put("code", 0);

+ 30 - 46
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/PangolinController.java

@@ -1,12 +1,11 @@
 package org.jeecg.modules.ctop.controller;
 
-import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.service.ISysRoleService;
-import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.common.module.vo.PangolinReportAppMonthVO;
 import cn.com.ctop.crawler.modules.pangolin.service.*;
-import cn.com.ctop.crawler.modules.pangolin.vo.PangolinReportAppMonthVO;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 import org.apache.shiro.SecurityUtils;
@@ -35,61 +34,49 @@ public class PangolinController {
     private PangolinChannelService pangolinChannelService;
     @Autowired
     private ISysRoleService sysRoleService;
-    @Autowired
-    private IBindAccountLoginService bindAccountLoginService;
-    @Autowired
-    private IUserAllocationService userAllocationService;
-    @PostMapping("api/user/list")
-    public Map<String, Object> userList(@RequestBody JSONObject data) {
-//        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        String userId = user.getId();
-        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
-        String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
-            userId = null;
-        }
-
-        return userAllocationService.getPangolinAccountListByParams(userId,data);
-    }
-
-    @PostMapping("api/project/list")
-    public Map<String, Object> projectList(@RequestBody JSONObject data) {
-//        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        String userId = user.getId();
-        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
-        String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
-            userId = null;
-        }
-        return userAllocationService.getPangolinProjectListByParams(userId);
-    }
 
     @PostMapping("api/channel/list")
     public Map<String, Object> channelList(@RequestBody JSONObject data) {
-//        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        String userId = user.getId();
-        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = user.getId();
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         return pangolinChannelService.getListByUserId(userId);
     }
 
-
     @PostMapping("api/app/list")
     public Map<String, Object> appList(@RequestBody JSONObject data) {
-//        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        String userId = user.getId();
-        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = user.getId();
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         return pangolinAppService.getListByUserId(userId,data);
     }
 
 
+    @PostMapping("api/memberList")
+    public Map<String,Object> memberList(){
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            String userId = user.getId();
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (null!=roleCode&&CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
+                userId = null;
+            }
+            resultMap = pangolinAppService.getMemberList(userId);
+            return resultMap;
+        } catch (Exception e) {
+            ResultMapUtils.setResultMap(resultMap,StatusCode.COMMON_SERVER_ERROR);
+            return resultMap;
+        }
+    }
+
+
     /**
      * 实时数据
      */
@@ -97,9 +84,8 @@ public class PangolinController {
     public Map<String, Object> realTime(@RequestBody JSONObject data) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = user.getId();
-//        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         return pangolinReportAppHourService.getRealTimeData(userId,data);
@@ -112,9 +98,8 @@ public class PangolinController {
     public Map<String, Object> activationList(@RequestBody JSONObject data) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = user.getId();
-//        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         return pangolinReportChannelDailyService.getActivationList(userId, data);
@@ -128,9 +113,8 @@ public class PangolinController {
         Map<String,Object> result = new HashMap<>();
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = user.getId();
-//        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         PageInfo<PangolinReportAppMonthVO> pageInfo = pangolinReportBillMonthService.checkAppList(userId, data);

+ 3 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
@@ -100,7 +101,7 @@ public class ProjectController {
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
         QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
         List<Project> projects = new ArrayList<>();
-        if (!"admin".equals(roleCode) && !"sale".equals(roleCode) && !"saleDirector".equals(roleCode)) {
+        if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) && !"sale".equals(roleCode) && !"saleDirector".equals(roleCode)) {
             if ("designTeamLeader".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "planeLeader".equals(roleCode)) {
                 QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
                 memberQueryWrapper.eq("user_id", userId);
@@ -178,7 +179,7 @@ public class ProjectController {
         Page<Project> page = new Page<>(pageNo, pageSize);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String roleCode = sysRoleService.getRoleCodeByUserId(sysUser.getId());
-        if (!("admin".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode))) {
+        if (!(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode))) {
             queryWrapper.eq("user_id", sysUser.getId());
             queryWrapper.orderByDesc("create_time");
         }

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -23,6 +24,7 @@ import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -329,7 +331,7 @@ public class ProjectMemberController {
     @AutoLog(value = "头条视频报表-参与项目列表")
     @ApiOperation(value = "头条视频报表-参与项目列表", notes = "头条视频报表-参与项目列表")
     @GetMapping(value = "/bytedanceProjectParticipateInList")
-    public  Result<List<ProjectMember>> bytedanceProjectParticipateInList() {
+    public Result<List<ProjectMember>> bytedanceProjectParticipateInList() {
         Result<List<ProjectMember>> result = new Result<>();
         List<Integer> mediaIds = new ArrayList<>();
         mediaIds.add(1);
@@ -345,7 +347,25 @@ public class ProjectMemberController {
 
     }
 
-
+    /**
+     * 查询当前账户下的
+     *
+     * @return
+     */
+    @GetMapping(value = "/getProjectAccountByUserId")
+    public Result<List<Map<String, Object>>> getProjectAccountBy() {
+        Result<List<Map<String, Object>>> resultBody = new Result<>();
+        try {
+            String userId=((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
+            List<Map<String, Object>> result = projectMemberService.getProjectAccountByUserId(userId);
+            resultBody.setSuccess(true);
+            resultBody.setResult(result);
+        } catch (Exception e) {
+            resultBody.setSuccess(false);
+            resultBody.success("查询失败");
+        }
+        return resultBody;
+    }
 
 
 }

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

@@ -0,0 +1,157 @@
+package org.jeecg.modules.ctop.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 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.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.ctop.entity.ReleaseRecord;
+import org.jeecg.modules.ctop.service.IReleaseRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+ /**
+ * 发版记录信息
+ * @author jeecg-boot
+ * @date   2020-06-10
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="发版记录信息")
+@RestController
+@RequestMapping("/ctop/releaseRecord")
+public class ReleaseRecordController {
+	@Autowired
+	private IReleaseRecordService releaseRecordService;
+
+	/**
+	  * 分页列表查询
+	 * @param releaseRecord
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-分页列表查询")
+	@ApiOperation(value="发版记录信息-分页列表查询", notes="发版记录信息-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<ReleaseRecord>> queryPageList(ReleaseRecord releaseRecord,
+													  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+													  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+													  HttpServletRequest req) {
+		Result<IPage<ReleaseRecord>> result = new Result<>();
+		QueryWrapper<ReleaseRecord> queryWrapper = QueryGenerator.initQueryWrapper(releaseRecord, req.getParameterMap());
+		Page<ReleaseRecord> page = new Page<ReleaseRecord>(pageNo, pageSize);
+		IPage<ReleaseRecord> pageList = releaseRecordService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param releaseRecord
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-添加")
+	@ApiOperation(value="发版记录信息-添加", notes="发版记录信息-添加")
+	@PostMapping(value = "/add")
+	public Result<ReleaseRecord> add(@RequestBody ReleaseRecord releaseRecord) {
+		Result<ReleaseRecord> result = new Result<>();
+		try {
+			releaseRecordService.save(releaseRecord);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param releaseRecord
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-编辑")
+	@ApiOperation(value="发版记录信息-编辑", notes="发版记录信息-编辑")
+	@PutMapping(value = "/edit")
+	public Result<ReleaseRecord> edit(@RequestBody ReleaseRecord releaseRecord) {
+		Result<ReleaseRecord> result = new Result<ReleaseRecord>();
+		ReleaseRecord releaseRecordEntity = releaseRecordService.getById(releaseRecord.getId());
+		if(releaseRecordEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = releaseRecordService.updateById(releaseRecord);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-通过id删除")
+	@ApiOperation(value="发版记录信息-通过id删除", notes="发版记录信息-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			releaseRecordService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-批量删除")
+	@ApiOperation(value="发版记录信息-批量删除", notes="发版记录信息-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<ReleaseRecord> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<ReleaseRecord> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.releaseRecordService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-通过id查询")
+	@ApiOperation(value="发版记录信息-通过id查询", notes="发版记录信息-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<ReleaseRecord> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<ReleaseRecord> result = new Result<>();
+		ReleaseRecord releaseRecord = releaseRecordService.getById(id);
+		if(releaseRecord==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(releaseRecord);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

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

@@ -0,0 +1,171 @@
+package org.jeecg.modules.ctop.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+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.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.ctop.entity.ReleaseViewRecord;
+import org.jeecg.modules.ctop.service.IReleaseViewRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+import java.util.Map;
+
+/**
+ * 发版记录信息
+ * @author jeecg-boot
+ * @date   2020-06-10
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="发版记录信息")
+@RestController
+@RequestMapping("/ctop/releaseViewRecord")
+public class ReleaseViewRecordController {
+	@Autowired
+	private IReleaseViewRecordService releaseViewRecordService;
+
+	@PostMapping("check")
+	public Map<String,Object>check(){
+		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+		return releaseViewRecordService.check(user.getId());
+	}
+	@PostMapping("view")
+	public Map<String,Object>view(@RequestBody JSONObject data){
+		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+		return releaseViewRecordService.view(user.getId(),data);
+	}
+	/**
+	  * 分页列表查询
+	 * @param releaseViewRecord
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-分页列表查询")
+	@ApiOperation(value="发版记录信息-分页列表查询", notes="发版记录信息-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<ReleaseViewRecord>> queryPageList(ReleaseViewRecord releaseViewRecord,
+														  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+														  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+														  HttpServletRequest req) {
+		Result<IPage<ReleaseViewRecord>> result = new Result<>();
+		QueryWrapper<ReleaseViewRecord> queryWrapper = QueryGenerator.initQueryWrapper(releaseViewRecord, req.getParameterMap());
+		Page<ReleaseViewRecord> page = new Page<>(pageNo, pageSize);
+		IPage<ReleaseViewRecord> pageList = releaseViewRecordService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param releaseViewRecord
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-添加")
+	@ApiOperation(value="发版记录信息-添加", notes="发版记录信息-添加")
+	@PostMapping(value = "/add")
+	public Result<ReleaseViewRecord> add(@RequestBody ReleaseViewRecord releaseViewRecord) {
+		Result<ReleaseViewRecord> result = new Result<>();
+		try {
+			releaseViewRecordService.save(releaseViewRecord);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param releaseViewRecord
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-编辑")
+	@ApiOperation(value="发版记录信息-编辑", notes="发版记录信息-编辑")
+	@PutMapping(value = "/edit")
+	public Result<ReleaseViewRecord> edit(@RequestBody ReleaseViewRecord releaseViewRecord) {
+		Result<ReleaseViewRecord> result = new Result<>();
+		ReleaseViewRecord releaseViewRecordEntity = releaseViewRecordService.getById(releaseViewRecord.getId());
+		if(releaseViewRecordEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = releaseViewRecordService.updateById(releaseViewRecord);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-通过id删除")
+	@ApiOperation(value="发版记录信息-通过id删除", notes="发版记录信息-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			releaseViewRecordService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-批量删除")
+	@ApiOperation(value="发版记录信息-批量删除", notes="发版记录信息-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<ReleaseViewRecord> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<ReleaseViewRecord> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.releaseViewRecordService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "发版记录信息-通过id查询")
+	@ApiOperation(value="发版记录信息-通过id查询", notes="发版记录信息-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<ReleaseViewRecord> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<ReleaseViewRecord> result = new Result<>();
+		ReleaseViewRecord releaseViewRecord = releaseViewRecordService.getById(id);
+		if(releaseViewRecord==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(releaseViewRecord);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

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

@@ -15,16 +15,19 @@ import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanDailyReportService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanHourlyReportService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
+import org.quartz.JobExecutionException;
 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.RestController;
 
+import java.io.IOException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -57,6 +60,8 @@ public class TestController {
     private IMaterialTagService tagService;
     @Autowired
     private IMaterialImageInfoService iMaterialImageInfoService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
 
     @GetMapping(value = "/t")
     public String test() {
@@ -87,10 +92,119 @@ public class TestController {
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
+    @Autowired
+    private IMaterialCutFrameService cutFrameService;
+
+
+    @GetMapping(value = "/getAccountList")
+    public void getAccountList(String startDate, String endDate) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
+                try {
+                    Date start = sim.parse(startDate);
+                    Date end = sim.parse(endDate);
+                    //1:查询当日数据
+                    List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                    if (null == tokens || tokens.size() <= 0) {
+                        log.info("定时获取快手数据异常:未获取到可用的token");
+                        return;
+                    }
+
+                    executorService = Executors.newFixedThreadPool(3);
+                    tokens.forEach(token -> {
+                        executorService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                //1: 获取广告主信息数据
+                                kuaishouInterfaceService.getAdvertiserReportDaily(token, start, end);
+                            }
+                        });
+                    });
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+
+
+            }
+        };
+        thread.start();
+
+    }
+
+
+    @GetMapping(value = "/getVideo")
+    public String getVideo(String startDate, String endDate) throws IOException {
+
+        try {
+
+
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+
+
+                    QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+                    tokenQueryWrapper.eq("media_id", 2);
+                    List<CtopOauthToken> list = tokenService.list(tokenQueryWrapper);
+
+                    executorService = Executors.newFixedThreadPool(8);
+                    list.forEach(token -> {
+                        executorService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                try {
+                                    //获取全量视频素材数据
+                                    kuaishouInterfaceService.getVideoList(token, null, null);
+                                    // 获取图片信息数据
+                                    //   kuaishouInterfaceService.getImageList(token, startDate, endDate);
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                } finally {
+                                }
+                            }
+                        });
+                    });
+                    log.info("快手物料数据同步完成");
+                }
+            };
+            thread.start();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "Success";
+    }
+
+    @GetMapping(value = "/createCutTask")
+    public String createCutTask(String startDate, String endDate) throws IOException {
+
+        List<MaterialInfo> materialInfos = materialInfoService.getListByDate(startDate, endDate);
+        if (!Check.isNull(materialInfos)) {
+            for (MaterialInfo materialInfo : materialInfos) {
+                if (!Check.isNull(materialInfo)) {
+                    String code = materialInfo.getCode();
+                    QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
+                    parameterQueryWrapper.eq("material_id", code);
+                    parameterQueryWrapper.last("limit 1");
+                    MaterialParameter materialParameter = parameterService.getOne(parameterQueryWrapper);
+                    if (!Check.isNull(materialParameter)) {
+                        cutFrameService.getCutFrame(materialInfo.getUrl(), code, materialParameter.getSecond(), materialParameter.getHeight(), materialParameter.getWidth());
+
+                    }
+
+                }
+
+            }
+
+        }
+        return "Success";
+    }
+
 
     @GetMapping(value = "/getToken")
-    public String getToken(Long accountId, String refreshToken, Integer agentType) {
-        oauthTokenService.getKuaiShouRefreshToken(accountId, refreshToken, agentType);
+    public String getToken(Long accountId, String token, String refreshToken, Integer agentType) {
+        oauthTokenService.getKuaiShouRefreshToken(accountId, token, refreshToken, agentType);
         return "Success";
     }
 
@@ -543,4 +657,27 @@ public class TestController {
     }
 
 
+    @GetMapping(value = "/BytedanceDailyAsyncJob")
+    public void BytedanceDailyAsyncJob() {
+        String startDate = "2020-06-01";
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String endDate = DateUtils.formatDate(getDate);
+        endDate = "2020-06-02";
+        log.info("头条广告计划异步任务开始执行,跑的是" + startDate + "~" + endDate + "的数据");
+
+        List<CtopOauthToken> tokens = tokenService.getToutiaoTokenByCreateTime(endDate);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
+            return;
+        }
+
+        //1.创意 2.广告主 3.广告组 4.广告计划
+        for (CtopOauthToken token : tokens) {
+            bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 1);
+            bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 2);
+            bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 3);
+            bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 4);
+        }
+    }
+
 }

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ISysRoleService;
@@ -54,7 +55,6 @@ public class UserAllocationController {
     @Autowired
     private IProjectMemberService projectMemberService;
 
-
     @GetMapping(value = "/accountTurnProject")
     public Result<Object> getAccountList(Long accountId, Long projectId) {
         Result<Object> result = new Result<>();
@@ -124,10 +124,10 @@ public class UserAllocationController {
             QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("user_id", userId);
             queryWrapper.eq("project_id", projectId);
-            Project project = projectService.getById(projectId);
-            if (!Check.isNull(project)) {
+           /*  Project project = projectService.getById(projectId);
+                if (!Check.isNull(project)) {
                 queryWrapper.eq("media_id", project.getMediaId());
-            }
+            }*/
 
             List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
             result.setSuccess(true);
@@ -149,13 +149,8 @@ public class UserAllocationController {
             QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("project_id", projectId);
 
-           /* if (!Check.isNull(project)) {
-            Project project = projectService.getById(projectId);
-                queryWrapper.eq("media_id", project.getMediaId());
-            }*/
-
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-            if (!"admin".equals(roleCode) && !"kuaishouOperationManager".equals(roleCode) && !"designTeamLeader".equals(roleCode) && !"touTiaoOperationManager".equals(roleCode)) {
+            if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) && !"kuaishouOperationManager".equals(roleCode) && !"designTeamLeader".equals(roleCode) && !"touTiaoOperationManager".equals(roleCode)) {
                 queryWrapper.eq("user_id", userId);
             }
             queryWrapper.orderByDesc("create_time");
@@ -182,10 +177,9 @@ public class UserAllocationController {
     public Result<List<UserAllocation>> getAccountListByProjectId(Long projectId) {
         Result<List<UserAllocation>> result = new Result<>();
         try {
-
             QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("project_id", projectId);
-
+            queryWrapper.eq("account_status", 0);
            /* if (!Check.isNull(project)) {
                  Project project = projectService.getById(projectId);
                  queryWrapper.eq("media_id", project.getMediaId());
@@ -224,7 +218,7 @@ public class UserAllocationController {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         QueryWrapper<UserAllocation> queryWrapper = QueryGenerator.initQueryWrapper(userAllocation, req.getParameterMap());
         String roleCode = sysRoleService.getRoleCodeByUserId(user.getId());
-        if (!"admin".equals(roleCode)) {
+        if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
             queryWrapper.eq("user_id", user.getId());
             queryWrapper.orderByDesc("id");
         }
@@ -357,4 +351,25 @@ public class UserAllocationController {
         }
         return result;
     }
+
+    /**
+     * 统计报表 查看所有账号
+     *
+     * @param projectId
+     * @return
+     */
+    @GetMapping(value = "/selectAccountListByProjectId")
+    public Result<List<UserAllocation>> selectAccountListByProjectId(Long projectId) {
+        Result<List<UserAllocation>> result = new Result<>();
+        try {
+            List<UserAllocation> userAllocations = userAllocationService.selectAccountListByProjectId(projectId);
+            result.setSuccess(true);
+            result.setResult(userAllocations);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success("查询失败");
+        }
+        return result;
+    }
+
 }

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ProjectMember.java

@@ -13,6 +13,7 @@ import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -27,7 +28,7 @@ import java.util.Date;
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 @ApiModel(value = "ctop_project_member对象", description = "项目成员")
-public class ProjectMember {
+public class ProjectMember implements  Serializable{
 
     /**
      * id

+ 46 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ReleaseRecord.java

@@ -0,0 +1,46 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 发版记录信息
+ * @author jeecg-boot
+ * @date   2020-06-10
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_release_record")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_release_record对象", description="发版记录信息")
+public class ReleaseRecord {
+
+	/**id*/
+	@TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**版本号*/
+	@Excel(name = "版本号", width = 15)
+    @ApiModelProperty(value = "版本号")
+	private String version;
+	/**更新详情*/
+	@Excel(name = "更新详情", width = 15)
+    @ApiModelProperty(value = "更新详情")
+	private String detail;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 46 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ReleaseViewRecord.java

@@ -0,0 +1,46 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 发版记录信息
+ * @author jeecg-boot
+ * @date   2020-06-10
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_release_view_record")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_release_view_record对象", description="发版记录信息")
+public class ReleaseViewRecord {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**userId*/
+	@Excel(name = "userId", width = 15)
+    @ApiModelProperty(value = "userId")
+	private String userId;
+	/**版本id*/
+	@Excel(name = "版本id", width = 15)
+    @ApiModelProperty(value = "版本id")
+	private Long releaseId;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/RefreshTokenJob.java

@@ -6,7 +6,7 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
-public class RefreshTokenJob implements Job {
+public class ByteDanceRefreshTokenJob implements Job {
     @Autowired
     private IRefreshTokenService refreshTokenService;
 
@@ -21,7 +21,7 @@ public class RefreshTokenJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                refreshTokenService.getRefresh();
+                refreshTokenService.byteDanceRefresh();
             }
         };
         thread.start();

+ 51 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyAsyncJob.java

@@ -0,0 +1,51 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 头条数据异步报表  获取前一天绑定的账户,跑从2020-01-01到前一天的数据;目的是防止新绑定账户数据缺失;
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyAsyncJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        String startDate = "2020-01-01";
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String endDate = DateUtils.formatDate(getDate);
+
+        log.info("头条数据异步报表  获取前一天绑定的账户,跑从2020-01-01到前一天的数据,时间为:" + startDate + "~" + endDate + "的数据");
+
+        List<CtopOauthToken> tokens = tokenService.getToutiaoTokenByCreateTime(endDate);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
+            return;
+        }
+
+        //1.创意 2.广告主 3.广告组 4.广告计划
+        for (CtopOauthToken token : tokens) {
+            bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 1);
+            bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 2);
+            bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 3);
+            bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 4);
+        }
+
+    }
+}

+ 6 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyMaterialReportJob.java

@@ -29,9 +29,12 @@ public class BytedanceDailyMaterialReportJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate2 = DateUtils.addDay(new Date(), -2);
+        String date2 = DateUtils.formatDate(getDate2);
+
         Date getDate = DateUtils.addDay(new Date(), -1);
         String date = DateUtils.formatDate(getDate);
-        log.info("头条获取素材报表数据任务开始,任务时间:" + date);
+        log.info("头条获取素材报表数据任务开始,任务时间:" + date2 + "~" + date);
 
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         if (null == tokens || tokens.size() <= 0) {
@@ -45,6 +48,8 @@ public class BytedanceDailyMaterialReportJob implements Job {
                 @Override
                 public void run() {
                     try {
+                        //获取头条素材报表两天前的数据
+                        bytedanceReportService.bytedanceMaterialReport(token, date2, date2);
                         //获取头条素材报表数据
                         bytedanceReportService.bytedanceMaterialReport(token, date, date);
                     } catch (Exception e) {

+ 25 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyMaterialReportRetryJob.java

@@ -3,8 +3,10 @@ package org.jeecg.modules.ctop.job;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -25,6 +27,8 @@ public class BytedanceDailyMaterialReportRetryJob implements Job {
     private ICtopOauthTokenService tokenService;
     @Autowired
     private IBytedanceReportService bytedanceReportService;
+    @Autowired
+    private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
@@ -38,9 +42,28 @@ public class BytedanceDailyMaterialReportRetryJob implements Job {
                 @Override
                 public void run() {
                     try {
-                        CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(retry.getAccountId()));
+                        String startDate = retry.getStartDate();
+                        String endDate = retry.getEndDate();
+                        Long accountId = retry.getAccountId();
+                        Integer type = retry.getType();
+                        CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
                         log.info("头条素材报表重试定时任务,当前accountId为:" + token.getAccountId());
-                        bytedanceReportService.bytedanceMaterialReportRetry(token, retry.getStartDate(), retry.getEndDate());
+
+                        Long days = DateUtils.getDiscrepantDays(startDate, endDate); //间隔天数
+                        String start = null;
+                        String end = null;
+                        for (int i = 0; i <= days; i++) {
+                            start = DateUtils.addDay(startDate, i);
+                            end = start;
+                            //获取头条素材报表数据
+                            int code = bytedanceReportService.bytedanceMaterialReportRetry(type, token, start, end);
+                            if(code ==200 || code == 1){
+                                if(type == 1){
+                                    //重试成功清洗数据
+                                    byteDanceVideoReportDailyService.videoInfoListByAccountId(start,end,accountId);
+                                }
+                            }
+                        }
                     } catch (Exception e) {
                         e.printStackTrace();
                     } finally {

+ 67 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyVideoMaterialReportAddJob.java

@@ -0,0 +1,67 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 头条视频素材报表每天将前一天新绑定的账户数据从20200101开始跑到前一天
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyVideoMaterialReportAddJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String endDate = DateUtils.formatDate(getDate);
+        String startDate = "2020-01-01";
+        log.info("头条获取视频素材报表数据补充任务开始,任务时间:{}~{}",startDate,endDate);
+
+        List<CtopOauthToken> tokens = tokenService.getToutiaoTokenByCreateTime(endDate);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取素材报表数据任务执行失败:未获取到可用的token");
+            return;
+        }
+
+        final ExecutorService executorService = Executors.newFixedThreadPool(3);
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+
+                        Long days = DateUtils.getDiscrepantDays(startDate, endDate); //间隔天数
+                        String start = null;
+                        String end = null;
+                        for (int i = 0; i <= days; i++) {
+                            start = DateUtils.addDay(startDate, i);
+                            end = start;
+                            bytedanceReportService.bytedanceVideoMaterialReport(token, start, end);
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    } finally {
+                    }
+                }
+            });
+        });
+
+    }
+}

+ 64 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyVideoMaterialReportJob.java

@@ -0,0 +1,64 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 头条视频素材报表按天跑前两天的数据任务
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyVideoMaterialReportJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate2 = DateUtils.addDay(new Date(), -2);
+        String date2 = DateUtils.formatDate(getDate2);
+
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String date = DateUtils.formatDate(getDate);
+        log.info("头条获取素材报表数据任务开始,任务时间:" + date2 + "~" + date);
+
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取素材报表数据任务执行失败:未获取到可用的token");
+            return;
+        }
+
+        final ExecutorService executorService = Executors.newFixedThreadPool(3);
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        //获取头条视频素材报表两天前的数据
+                        bytedanceReportService.bytedanceVideoMaterialReport(token, date2, date2);
+                        //获取头条视频素材报表数据
+                        bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    } finally {
+                    }
+                }
+            });
+        });
+
+    }
+}

+ 40 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedancePlanDailyReportYeterdayLoadJob.java

@@ -0,0 +1,40 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.toutiao.modules.report.service.IReportService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+
+@Slf4j
+public class BytedancePlanDailyReportYeterdayLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IReportService reportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+        tokens.forEach(token -> {
+            //获取广告计划信息数据
+            reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        });
+    }
+
+}

+ 59 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/CutFrameJob.java

@@ -0,0 +1,59 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.IMaterialCutFrameTaskService;
+import cn.com.ctop.common.module.utils.Check;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.Executors;
+
+import static org.jeecg.modules.ctop.job.KuaishouDailyGroupReportLoadJob.executorService;
+
+/**
+ * 获取抽帧视频
+ */
+@Slf4j
+public class CutFrameJob implements Job {
+    @Autowired
+    private IMaterialCutFrameService materialCutFrameService;
+    @Autowired
+    private IMaterialCutFrameTaskService taskService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+
+                log.info("开始抽帧定时任务");
+                QueryWrapper<MaterialCutFrameTask> taskQueryWrapper = new QueryWrapper<>();
+                taskQueryWrapper.eq("job_status", 0);
+                List<MaterialCutFrameTask> list = taskService.list(taskQueryWrapper);
+
+                if (Check.isNull(list)) {
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(5);
+                list.forEach(cutFrameTask -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            //获取广告计划信息数据
+                            materialCutFrameService.loadCutFrame(cutFrameTask.getJobId(), cutFrameTask.getVideoSignature());
+                        }
+                    });
+                });
+            }
+        };
+        thread.start();
+
+
+    }
+}

+ 30 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaiShouRefreshTokenJob.java

@@ -0,0 +1,30 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.service.IRefreshTokenService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class KuaiShouRefreshTokenJob implements Job {
+    @Autowired
+    private IRefreshTokenService refreshTokenService;
+
+    /**
+     * 刷新token
+     *
+     * @param jobExecutionContext
+     * @throws JobExecutionException
+     */
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                refreshTokenService.getKuaiShouRefresh();
+            }
+        };
+        thread.start();
+
+    }
+}

+ 27 - 30
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java

@@ -2,8 +2,8 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
@@ -13,6 +13,9 @@ import org.springframework.beans.factory.annotation.Value;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @Slf4j
 public class KuaishouCommentAutoDelete implements Job {
@@ -22,39 +25,33 @@ public class KuaishouCommentAutoDelete implements Job {
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
+    static ExecutorService executorService = null;
+    //线程计数器
+    static CountDownLatch countDownLatch = null;
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("login_type", "kuaishou");
-                queryWrapper.eq("status", 1);
-                List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
-                if (list != null && list.size() > 0) {
-                    for (BindAccountLogin account : list) {
-                        try {
-                            log.info("正在删除评论:{}", account.getAccountName());
-                            kuaishouWebInterfaceService.adkuaishouWebLogin(account.getAccountName(), account.getPassword());
-                            kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
-                            Runtime runtime = Runtime.getRuntime();
-                            Process pro = runtime.exec(cleanUrl);
-                            int status = pro.waitFor();
-                            if (status == 0) {
-                                log.info("success,删除评论调用shell脚本执行成功");
-                            } else {
-                                log.info("error,删除评论调用shell脚本执行失败");
-                            }
-                            Thread.sleep(5 * 1000L);
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
+        Long start = System.currentTimeMillis();
+        List<BindAccountLogin>loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
+        if (loginList != null && !loginList.isEmpty()) {
+            executorService = Executors.newFixedThreadPool(5);
+            countDownLatch = new CountDownLatch(loginList.size());
+            loginList.forEach(login -> executorService.submit(()->{
+                try {
+                    kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login);
+                }catch (Exception e){
+                    log.error(e.getMessage(),e);
+                }finally {
+                    countDownLatch.countDown();
                 }
+            }));
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
             }
-        };
-        thread.start();
-
+            Long end = System.currentTimeMillis();
+            log.info("快手删评论所用时长:{}毫秒",end-start);
+        }
     }
 }

+ 47 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoLoginJob.java

@@ -0,0 +1,47 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.BindAccountLogin;
+import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import java.util.List;
+
+@Slf4j
+public class KuaishouCommentAutoLoginJob implements Job {
+    @Value("${chrome.script.clean}")
+    private String cleanUrl;
+    @Autowired
+    private IBindAccountLoginService bindAccountLoginService;
+    @Autowired
+    private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
+        if(list!=null&&!list.isEmpty()){
+            for (BindAccountLogin login:list) {
+                if(null==login.getCookie()||"".equals(login.getCookie().trim())){
+                    kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
+                    Runtime runtime = Runtime.getRuntime();
+                    try {
+                        Process pro = runtime.exec(cleanUrl);
+                        int status = pro.waitFor();
+                        if (status == 0) {
+                            log.info("success,删除评论调用shell脚本执行成功");
+                        } else {
+                            log.info("error,删除评论调用shell脚本执行失败");
+                        }
+                    } catch (Exception e) {
+                        log.error(e.getMessage(),e);
+                    }
+                }
+            }
+        }
+    }
+}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCrawlerJob.java

@@ -24,7 +24,7 @@ public class KuaishouCrawlerJob implements Job {
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         try {
             Integer page = 1;
-            QueryWrapper<KuaishouAppAccount> queryWrapper = new QueryWrapper<KuaishouAppAccount>();
+            QueryWrapper<KuaishouAppAccount> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("path","/rest/n/feed/hot");
             List<KuaishouAppAccount> list = kuaishouAppAccountService.list(queryWrapper);
             if (list != null) {
@@ -37,7 +37,7 @@ public class KuaishouCrawlerJob implements Job {
                 }
             }
 
-            QueryWrapper<KuaishouIosAccount> queryWrapper2 = new QueryWrapper<KuaishouIosAccount>();
+            QueryWrapper<KuaishouIosAccount> queryWrapper2 = new QueryWrapper<>();
             queryWrapper2.eq("path","/rest/n/feed/hot");
             List<KuaishouIosAccount> list2 = kuaishouIosAccountService.list(queryWrapper2);
             if (list2 != null) {

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java

@@ -33,6 +33,7 @@ public class KuaishouDailyAccountReportLoadJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
+                Date getDate2 = DateUtils.addDay(new Date(), -2);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
                 List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
@@ -46,6 +47,8 @@ public class KuaishouDailyAccountReportLoadJob implements Job {
                     executorService.submit(new Runnable() {
                         @Override
                         public void run() {
+                            //跑两天前的账户报表---次留统计用
+                            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate2);
                             //1: 获取广告主信息数据
                             kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
                         }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportNextDayStayJob.java

@@ -34,7 +34,7 @@ public class KuaishouDailyAccountReportNextDayStayJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                Date getDate = DateUtils.addDay(new Date(), -2);
+                Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
                 List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
                 if (null == tokens || tokens.size() <= 0) {

+ 10 - 342
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/OceanengineJob.java

@@ -1,361 +1,29 @@
 package org.jeecg.modules.ctop.job;
 
-import cn.com.ctop.common.module.utils.Base64Utils;
-import cn.com.ctop.common.module.utils.HttpUtils2;
-import cn.com.ctop.crawler.modules.core.util.FateadmHttpUtil;
-import cn.com.ctop.crawler.modules.core.util.FateadmUtil;
-import cn.com.ctop.crawler.modules.oceanengine.entity.DouyinHot;
-import cn.com.ctop.crawler.modules.oceanengine.entity.EffectCase;
-import cn.com.ctop.crawler.modules.oceanengine.entity.HotMaterial;
-import cn.com.ctop.crawler.modules.oceanengine.service.IDouyinHotService;
-import cn.com.ctop.crawler.modules.oceanengine.service.IEffectCaseService;
-import cn.com.ctop.crawler.modules.oceanengine.service.IHotMaterialService;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.http.impl.cookie.BasicClientCookie;
-import org.bytedeco.javacv.FFmpegFrameGrabber;
-import org.bytedeco.javacv.Frame;
-import org.bytedeco.javacv.Java2DFrameConverter;
-import org.openqa.selenium.Cookie;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.chrome.ChromeDriver;
-import org.openqa.selenium.chrome.ChromeOptions;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-import java.util.*;
 
 @Slf4j
 public class OceanengineJob implements Job {
-    @Value("${jeecg.path.chrome-driver}")
-    private String chromeDriver;
-    @Autowired
-    private IDouyinHotService douyinHotService;
-    @Autowired
-    private IEffectCaseService effectCaseService;
     @Autowired
-    private IHotMaterialService hotMaterialService;
-
-    public static String getVideoUrlByVid(String vid) {
-        String url = "https://aweme.snssdk.com/aweme/v1/playwm/?video_id=" + vid + "&line=0";
-        return getRealVideoUrl(url);
-    }
+    private IOceanEngineService oceanEngineService;
 
-    public static String getRealVideoUrl(String url) {
-        try {
-            URL serverUrl = new URL(url);
-            HttpURLConnection conn = (HttpURLConnection) serverUrl
-                    .openConnection();
-            conn.setRequestMethod("GET");
-            // 必须设置false,否则会自动redirect到Location的地址
-            conn.setInstanceFollowRedirects(false);
-            conn.addRequestProperty("User-Agent",
-                    "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Firefox/3.6.8");
-            conn.connect();
-            String location = conn.getHeaderField("Location");
-            return location;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-    private void hotMaterialHandler(int page,int appCode,String appName){
-        String result = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/hot_material/list?material_type=3&order_by=convert_show_rate&period_type=3&aggr_app_code="+appCode+"&page="+page+"&limit=20");
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-        try {
-            JsonNode node = mapper.readTree(result);
-            int code = node.get("code").asInt();
-            if (code == 0) {
-                if (node.get("data") != null&&node.get("data").get("materials")!=null) {
-                    String dataJson = node.get("data").get("materials").toString();
-                    List<HotMaterial> list = mapper.readValue(dataJson,new TypeReference<List<HotMaterial>>() {});
-                    if(list != null && list.size() > 0){
-                        for (HotMaterial material : list){
-                            material.setAppCode(appCode);
-                            material.setAppName(appName);
-                            material.setVideoUrl(getRealVideoUrl("https://aweme.snssdk.com/aweme/v1/playwm/?video_id="+material.getVid()+"&line=0"));
-                            if(material.getVideoUrl() == null){
-                                material.setVideoUrl(getVideoUrl(material.getVid()));
-                            }
-//                            material.setVideoUrl(getVideoUrl(material.getVid()));
-                            material.setCoverImage(getVideoFirstImage(material.getVideoUrl()));
-                            if(material.getCoverImage() == null){
-                                Thread.sleep(1000);
-                                material.setCoverImage(getVideoFirstImage(material.getVideoUrl()));
-                            }
-                            hotMaterialService.saveOrUpdate(material);
-                        }
-                        hotMaterialHandler(page+1,appCode,appName);
-                    }
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-    public static String getVideoUrl(String vid) throws Exception {
-        String url = "http://i.snssdk.com/video/urls/1/toutiao/mp4/"+vid;
-        String result = HttpUtils2.httpGetRequest(url);
-        ObjectMapper mapper = new ObjectMapper();
-        if(result != null){
-            JsonNode node = mapper.readTree(result);
-            String mainUrl = node.get("data").get("video_list").get("video_1").get("main_url").asText();
-            return Base64Utils.decode(mainUrl);
-        }
-        return null;
-    }
-    private void effectCaseHandler(int page){
-        String result = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/case/effect_case_list?industry=0&style=0&mode=0&page="+page+"&limit=20");
-        ObjectMapper mapper = new ObjectMapper();
-        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-        try {
-            JsonNode node = mapper.readTree(result);
-            int code = node.get("code").asInt();
-            if(code == 0) {
-                if (node.get("data") != null) {
-                    String dataJson = node.get("data").get("effect_cases").toString();
-                    List<EffectCase> list = mapper.readValue(dataJson,new TypeReference<List<EffectCase>>() {});
-                    if (list != null && list.size() > 0) {
-                        for (EffectCase effectCase:list){
-                            String resultDetail = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/case/effect_case/"+effectCase.getId());
-                            JsonNode detailNode = mapper.readTree(resultDetail);
-                            int detailCode = detailNode.get("code").asInt();
-                            if(detailCode == 0){
-                                if(detailNode.get("data") != null){
-//                                    String detailJson = node.get("data").get("effect_cases").toString();
-//                                    EffectCase effectCase1 = mapper.readValue(detailJson,EffectCase.class);
-                                    effectCase.setAuthor(detailNode.get("data").get("effect_case").get("author").asText());
-                                    effectCase.setCreateDate(detailNode.get("data").get("effect_case").get("create_date").asText());
-                                    effectCase.setCreativeId(detailNode.get("data").get("effect_case").get("creative_id").asLong());
-                                    effectCase.setCreativeScore(detailNode.get("data").get("effect_case").get("creative_score").asText());
-                                    effectCase.setEffect(detailNode.get("data").get("effect_case").get("effect").toString());
-                                    effectCase.setMethods(detailNode.get("data").get("effect_case").get("methods").toString());
-                                    effectCase.setVideoUrl(getRealVideoUrl("https://aweme.snssdk.com/aweme/v1/playwm/?video_id="+effectCase.getVid()+"&line=0"));
-                                    if (effectCase.getVideoUrl() == null){
-                                        effectCase.setVideoUrl(getVideoUrl(effectCase.getVid()));
-                                    }
-//                                    effectCase.setVideoUrl(getVideoUrl(effectCase.getVid()));
-                                    effectCase.setCoverImage(getVideoFirstImage(effectCase.getVideoUrl()));
-                                    if (effectCase.getCoverImage() == null){
-                                        Thread.sleep(1000);
-                                        effectCase.setCoverImage(getVideoFirstImage(effectCase.getVideoUrl()));
-                                    }
-                                    effectCase.setCreativeLabel(detailNode.get("data").get("effect_case").get("creative_label").toString());
-                                }
-                            }
-                            effectCaseService.saveOrUpdate(effectCase);
-                        }
-                        effectCaseHandler(page+1);
-                    }
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-    private String getVideoFirstImage(String url){
-        try {
-            FFmpegFrameGrabber ff = new FFmpegFrameGrabber(url);
-            ff.start();
-            int lenght = ff.getLengthInFrames();
-            int i = 0;
-            Frame f = null;
-            while (i < lenght) {
-// 过滤前5帧,避免出现全黑的图片,依自己情况而定
-                f = ff.grabFrame();
-                if ((i > 5) && (f.image != null)) {
-                    break;
-                }
-                i++;
-            }
-//            opencv_core.IplImage img = f.image;
-            int owidth = f.imageWidth;
-            int oheight = f.imageHeight;
-            Java2DFrameConverter converter =new Java2DFrameConverter();
-            BufferedImage fecthedImage =converter.getBufferedImage(f);
-// 对截取的帧进行等比例缩放
-            int width = 800;
-            int height = (int) (((double) width / owidth) * oheight);
-            BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
-            bi.getGraphics().drawImage(fecthedImage.getScaledInstance(width, height, Image.SCALE_SMOOTH),
-                    0, 0, null);
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();//io流
-            ImageIO.write(bi, "jpg", baos);
-            byte[] bytes = baos.toByteArray();//转换成字节
-            String png_base64 = Base64.getEncoder().encodeToString(bytes).trim();//转换成base64串
-            png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n
-            //        ImageIO.write(bufferedImage, "png", new File("D:/qrcode1.png"));
-            baos.close();
-            ff.close();
-            return "data:image/jpg;base64,"+png_base64;
-        }catch (Exception e){
-            e.printStackTrace();
-            return null;
-        }
-
-    }
-    private void douyinHotHandler(int page,int listType){
-        String result = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/hot_video/user_side/list?page="+page+"&limit=20&list_type="+listType+"&aggr_duration_type=-1");
-        ObjectMapper mapper = new ObjectMapper();
-        try {
-            JsonNode node = mapper.readTree(result);
-            int code = node.get("code").asInt();
-            if(code == 0){
-                if(node.get("data")!= null){
-                    String dataJson = node.get("data").get("items").toString();
-                    List<DouyinHot> list = mapper.readValue(dataJson,new TypeReference<List<DouyinHot>>() {});
-                    if (list != null && list.size() > 0){
-                        for (DouyinHot douyinHot : list){
-                            douyinHot.setUrl(getRealVideoUrl("https://aweme.snssdk.com/aweme/v1/playwm/?video_id="+douyinHot.getVideoId()+"&line=0"));
-                            if(douyinHot.getUrl() == null){
-                                douyinHot.setUrl(getVideoUrl(douyinHot.getVideoId()));
-                            }
-//                            douyinHot.setUrl(getVideoUrl(douyinHot.getVideoId()));
-                            douyinHot.setCoverImage(getVideoFirstImage(douyinHot.getUrl()));
-                            if(douyinHot.getCoverImage() == null){
-                                Thread.sleep(1000);
-                                douyinHot.setCoverImage(getVideoFirstImage(douyinHot.getUrl()));
-                            }
-                            douyinHotService.saveOrUpdate(douyinHot);
-                        }
-                        douyinHotHandler(page+1,listType);
-                    }else {
-                        if(listType < 4){
-                            douyinHotHandler(1,listType+1);
-                        }
-                    }
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-
-    }
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         String account="3248395570@qq.com";
         String password = "Ydxq-704127411";
-        login(account,password);
-        douyinHotHandler(1,1);
-        effectCaseHandler(1);
-        hotMaterialHandler(1,1,"西瓜");
-        hotMaterialHandler(1,3,"火山");
-        hotMaterialHandler(1,4,"抖音");
-        hotMaterialHandler(1,8,"头条");
-        hotMaterialHandler(1,9,"穿山甲");
+        oceanEngineService.login(account,password);
+        oceanEngineService.douyinHotHandler(1,1);
+        oceanEngineService.effectCaseHandler(1);
+        oceanEngineService.hotMaterialHandler(1,1,"西瓜");
+        oceanEngineService.hotMaterialHandler(1,3,"火山");
+        oceanEngineService.hotMaterialHandler(1,4,"抖音");
+        oceanEngineService.hotMaterialHandler(1,8,"头条");
+        oceanEngineService.hotMaterialHandler(1,9,"穿山甲");
         log.info("巨量创意抓取完成");
     }
-
-    private void login(String account,String password){
-        String url = "https://cc.oceanengine.com/login";
-        System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
-        ChromeOptions chromeOptions = new ChromeOptions();
-        chromeOptions.addArguments("--headless");
-        chromeOptions.addArguments("--no-sandbox");
-        chromeOptions.addArguments("--window-size=1920,1080");
-        chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
-        chromeOptions.setAcceptInsecureCerts(true);
-        WebDriver webDriver = new ChromeDriver(chromeOptions);
-        //清除所有的缓存
-        webDriver.manage().deleteAllCookies();
-        try {
-            //获取登录页面
-            webDriver.get(url);
-            for (Cookie cookie : webDriver.manage().getCookies()) {
-                BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
-                ck.setDomain("oceanengine.com");
-                ck.setExpiryDate(cookie.getExpiry());
-                ck.setPath(cookie.getPath());
-                HttpUtils2.cookieStore.addCookie(ck);
-            }
-            Map<String, String> header = new HashMap<>();
-            header.put("Accept", "*/*");
-            header.put("Connection", "keep-alive");
-            header.put("Host", "sso.toutiao.com");
-            header.put("Content-Type", "application/x-www-form-urlencoded");
-            header.put("Origin", "https://cc.oceanengine.com");
-            header.put("Referer", "https://cc.oceanengine.com/login");
-            Map<String, Object> param = new HashMap<>();
-            param.put("mobile", "");
-            param.put("code", "");
-            param.put("account", account);
-            param.put("password", password);
-            param.put("captcha", "hqde");
-            param.put("is_30_days_no_login", "true");
-            param.put("service", "https://cc.oceanengine.com");
-            String res = HttpUtils2.httpPostParamRequest("https://sso.toutiao.com/account_login/", param, header);
-            ObjectMapper mapper = new ObjectMapper();
-            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-            JsonNode jsonNode = mapper.readTree(res);
-            //errorcode == 1102 验证码错误,请重新输入验证码
-            //errorcode == 1101 验证码为空
-
-            Integer errorCode = jsonNode.get("error_code").asInt();
-            String orderId = null;
-            while (errorCode != 0) {
-                //用户名或者密码错误
-                if (null != errorCode && errorCode == 1009) {
-                    return;
-                }
-                FateadmUtil fateadmUtil = new FateadmUtil();
-                fateadmUtil.init();
-                if (orderId != null) {
-                    fateadmUtil.justice(orderId);
-                }
-                String captcha = jsonNode.get("captcha").asText();
-                Base64.Decoder decoder = Base64.getDecoder();
-                FateadmHttpUtil.HttpResp resp = fateadmUtil.Predict("30400", decoder.decode(captcha));
-                param.put("captcha", resp.predResl);
-                orderId = resp.reqId;
-                res = HttpUtils2.httpPostParamRequest("https://sso.toutiao.com/account_login/", param, header);
-                jsonNode = mapper.readTree(res);
-                errorCode = jsonNode.get("error_code").asInt();
-            }
-            if (errorCode == 0) {
-                //表示登录成功
-                List<org.apache.http.cookie.Cookie> cookies = HttpUtils2.cookieStore.getCookies();
-                for (org.apache.http.cookie.Cookie ck : cookies) {
-                    Cookie cookie = new Cookie(ck.getName(), ck.getValue(), "." + ck.getDomain(), ck.getPath(), ck.getExpiryDate());
-                    webDriver.manage().addCookie(cookie);
-                }
-                String redirectUrl = jsonNode.get("redirect_url").asText();
-                webDriver.get(redirectUrl);
-                //登录成功 进入推广页面
-                webDriver.get("https://cc.oceanengine.com/inspiration/douyin-rank-list");
-                Thread.sleep(3000);
-                for (Cookie cookie : webDriver.manage().getCookies()) {
-                    BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
-                    ck.setDomain("cc.oceanengine.com");
-                    ck.setExpiryDate(cookie.getExpiry());
-                    ck.setPath(cookie.getPath());
-                    HttpUtils2.cookieStore.addCookie(ck);
-                }
-
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            //获得cookie
-            Set<Cookie> coo = webDriver.manage().getCookies();
-            //清除所有的缓存
-            webDriver.manage().deleteAllCookies();
-            webDriver.quit();
-        }
-    }
 }

+ 1 - 14
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/PangolinDataJob.java

@@ -2,11 +2,8 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
-import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
-import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -18,8 +15,6 @@ public class PangolinDataJob implements Job {
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
-    private PangolinAppService pangolinAppService;
-    @Autowired
     private PangolinCrawlerService pangolinCrawlerService;
 
     @Override
@@ -31,15 +26,7 @@ public class PangolinDataJob implements Job {
         List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
         if (list != null && !list.isEmpty()) {
             for (BindAccountLogin bindAccountLogin : list) {
-                pangolinCrawlerService.getChannelList(bindAccountLogin);
-                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
-                pangolinCrawlerService.getCheckList(bindAccountLogin);
-                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
-                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
-                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
-                if (appList != null && !appList.isEmpty()) {
-                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId()));
-                }
+                pangolinCrawlerService.getNowData(bindAccountLogin);
             }
         }
     }

+ 2 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/PangolinLoginJob.java

@@ -2,8 +2,8 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -18,10 +18,7 @@ public class PangolinLoginJob implements Job {
     private PangolinLoginService pangolinLoginService;
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("login_type","pangolin");
-        queryWrapper.eq("status",1);
-        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_PANGOLIN_PY,1);
         if(list!=null&&!list.isEmpty()){
             for (BindAccountLogin login:list) {
                 if(null==login.getCookie()||"".equals(login.getCookie().trim())){

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java

@@ -29,4 +29,6 @@ public interface ProjectMemberMapper extends BaseMapper<ProjectMember> {
 
     String getCompanyIdByUserId(@Param("userId")String userId);
 
+    List<ProjectMember> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
+
 }

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ReleaseRecordMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.ReleaseRecord;
+
+/**
+ * 发版记录信息
+ * @author: jeecg-boot
+ * @date:   2020-06-10
+ * @cersion: V1.0
+ */
+public interface ReleaseRecordMapper extends BaseMapper<ReleaseRecord> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ReleaseViewRecordMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.ReleaseViewRecord;
+
+/**
+ * 发版记录信息
+ * @author: jeecg-boot
+ * @date:   2020-06-10
+ * @cersion: V1.0
+ */
+public interface ReleaseViewRecordMapper extends BaseMapper<ReleaseViewRecord> {
+
+}

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/TransferAccountMapper.java

@@ -1,8 +1,11 @@
 package org.jeecg.modules.ctop.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.lettuce.core.dynamic.annotation.Param;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -12,4 +15,6 @@ import org.jeecg.modules.ctop.entity.TransferAccount;
  */
 public interface TransferAccountMapper extends BaseMapper<TransferAccount> {
 
+    List<TransferAccount> getAccountQuarterDetail(@Param(value = "accountId") Long accountId, @Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate);
+
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/AdvertiserMapper.xml

@@ -62,7 +62,7 @@
             and allocation.account_id = #{accountId}
         </if>
         <if test="groupBy != null">
-            group by report.stat_date;
+            group by report.stat_date desc
         </if>
 
     </select>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialTopMapper.xml

@@ -108,7 +108,7 @@
               sum(t1.next_day_open) AS residue,
               sum(t1.play_duration_3s) AS play3s,
               sum(t1.play_duration_10s) AS play3s,
-              0 AS mediaType
+              1 AS mediaType
         FROM
             ctop_bytedance_report_material_daily t1
                 LEFT JOIN ctop_bytedance_video_info t2 ON t1.material_id = t2.material_id
@@ -189,7 +189,7 @@
               sum(t1.activation) AS 'active',
               sum(t1.event_register) AS 'register',
               sum(t1.form_count) AS 'form_convert',
-              '2' AS 'media_type'
+              2 AS 'media_type'
         FROM
             ctop_kuaishou_report_daily_creative t1
         WHERE

+ 17 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml

@@ -105,4 +105,21 @@
         where user_id = #{userId}
     </select>
 
+    <select id="queryProjectMemberByUserId" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
+        select
+        distinct b.id as projectId,
+        b.project_name as projectName,
+        a.advertiser_id as advertiserId,
+        a.advertiser_name as advertiserName,
+        a.media_id as mediaId
+        from
+        ctop_user_allocation a
+        left join ctop_project_member b on a.project_id = b.project_id
+        where b.user_id = #{userId}
+        and a.media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
 </mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ReleaseRecordMapper.xml

@@ -0,0 +1,5 @@
+<?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.modules.ctop.mapper.ReleaseRecordMapper">
+
+</mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ReleaseViewRecordMapper.xml

@@ -0,0 +1,5 @@
+<?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.modules.ctop.mapper.ReleaseViewRecordMapper">
+
+</mapper>

+ 16 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/TransferAccountMapper.xml

@@ -2,4 +2,20 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.ctop.mapper.TransferAccountMapper">
 
+    <select id="getAccountQuarterDetail" resultType="org.jeecg.modules.ctop.entity.TransferAccount">
+        select
+            *
+        from
+            ctop_transfer_account
+        where
+            status = 1
+          and
+            account_id =#{accountId}
+          and
+            transferor_date &gt;= #{startDate}
+          and
+            transferor_date &lt; #{endDate}
+        order by transferor_date asc
+    </select>
+
 </mapper>

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java

@@ -6,6 +6,7 @@ import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.system.entity.SysUser;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 项目成员
@@ -17,8 +18,10 @@ import java.util.List;
 public interface IProjectMemberService extends IService<ProjectMember> {
     void addMember(SysUser sysUser, Project project);
 
-
     List<Long> selectProjectsByUserId(String userId);
 
     List<ProjectMember> getProjects(List<Integer> mediaIds);
+
+    List<Map<String, Object>> getProjectAccountByUserId(String userId);
+
 }

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IReleaseRecordService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.ReleaseRecord;
+
+/**
+ * 发版记录信息
+ * @author jeecg-boot
+ * @date   2020-06-10
+ * @version V1.0
+ */
+public interface IReleaseRecordService extends IService<ReleaseRecord> {
+    ReleaseRecord getLastRecord();
+}

+ 20 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IReleaseViewRecordService.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.ctop.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.ReleaseViewRecord;
+
+import java.util.Map;
+
+/**
+ * 发版记录信息
+ * @author jeecg-boot
+ * @date   2020-06-10
+ * @version V1.0
+ */
+public interface IReleaseViewRecordService extends IService<ReleaseViewRecord> {
+
+    Map<String, Object> check(String userId);
+
+    Map<String, Object> view(String userId, JSONObject data);
+}

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ITransferAccountService.java

@@ -1,8 +1,11 @@
 package org.jeecg.modules.ctop.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -12,4 +15,8 @@ import org.jeecg.modules.ctop.entity.TransferAccount;
  */
 public interface ITransferAccountService extends IService<TransferAccount> {
 
+    List<JSONObject> selectCost(Long accountId, String startDate, String endDate);
+
+    List<TransferAccount> getAccountQuarterDetail(Long accountId, String startDate, String endDate);
+
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/AdvertiserServiceImpl.java

@@ -115,7 +115,7 @@ public class AdvertiserServiceImpl extends ServiceImpl<AdvertiserMapper, Adverti
     private List<YdPlanAggregateEntity> getYdPlanStatisticInfo(Long projectId, String startDate, String endDate) {
         List<YdPlanAggregateEntity> result = new ArrayList<>();
         List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, null);
-        if (null != allocations && allocations.size() > 0) {
+        if (null != allocations && !allocations.isEmpty()) {
             allocations.forEach(allocation -> {
                 List<YdPlanAggregateEntity> plans = statisticWeekInfoByAccount(allocation, startDate, endDate);
                 result.addAll(plans);

+ 2 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CrawlerServiceImpl.java

@@ -32,13 +32,10 @@ public class CrawlerServiceImpl implements ICrawlerService {
     public Map<String, Object> loadInspiration() {
         //(1):效果广告解析
         loadeffectAdByPage(100, 1);
-
         //(2):广告创意视频
         loadInspiredAdByPage(100, 1);
-
         //(3):快手热门作品
         loadHotPhotoByPage(100, 1);
-
         return null;
     }
 
@@ -55,7 +52,7 @@ public class CrawlerServiceImpl implements ICrawlerService {
             return;
         }
         JSONArray hotPhotoInfos = resultObject.getJSONObject("data").getJSONArray("hotPhotoInfos");
-        if (null == hotPhotoInfos || hotPhotoInfos.size() <= 0) {
+        if (null == hotPhotoInfos || hotPhotoInfos.isEmpty()) {
             log.info("热门作品数据获取完成");
             return;
         }
@@ -120,11 +117,10 @@ public class CrawlerServiceImpl implements ICrawlerService {
             return;
         }
         JSONArray effectAds = resultObject.getJSONObject("data").getJSONArray("effectAds");
-        if (null == effectAds || effectAds.size() <= 0) {
+        if (null == effectAds || effectAds.isEmpty()) {
             log.info("效果广告数据获取完成");
             return;
         }
-//        List<KuaishouEffectAdInfo> adInfos = new ArrayList<>();
         for (int i = 0; i < effectAds.size(); i++) {
             JSONObject ad = effectAds.getJSONObject(i);
             Long contentId = ad.getLong("contentId");
@@ -132,12 +128,8 @@ public class CrawlerServiceImpl implements ICrawlerService {
                 JSONObject content = getEffectAdDetail(contentId).getJSONObject("data").getJSONObject("effectAdDetail");
                 KuaishouEffectAdInfo adInfo = new KuaishouEffectAdInfo(content);
                 effectAdInfoService.saveOrUpdate(adInfo);
-                //                adInfos.add(adInfo);
             }
         }
-        /*if (adInfos.size() > 0) {
-            effectAdInfoService.replaceBatch(adInfos);
-        }*/
         loadeffectAdByPage(pageSize, pageNum + 1);
     }
 

+ 22 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java

@@ -5,6 +5,8 @@ import cn.com.ctop.common.module.mapper.BindAccountLoginMapper;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.crawler.modules.core.util.FateadmHttpUtil;
 import cn.com.ctop.crawler.modules.core.util.FateadmUtil;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -33,6 +35,10 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
     private String chromeDriver;
     @Autowired
     private BindAccountLoginMapper bindAccountLoginMapper;
+    @Autowired
+    private PangolinLoginService pangolinLoginService;
+    @Autowired
+    private PangolinCrawlerService pangolinCrawlerService;
 
     @Override
     public Map<String, Object> bindLogin(Long projectId,String advertiserId, String accountName, String password, String loginType, String userId, String advertiserName) {
@@ -49,7 +55,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         if (null != loginType && loginType.equals(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_PY)) {
             Map<String, Object> result = this.checkAccountPassword(accountName, password);
             Boolean checkSuccess = (Boolean) result.get("success");
-            if (!checkSuccess) {
+            if (Boolean.FALSE.equals(checkSuccess)) {
                 returnMap.put("success", false);
                 returnMap.put("message", "账号验证失败");
                 return returnMap;
@@ -67,6 +73,20 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         int i = bindAccountLoginMapper.insert(bindAccountLogin);
         if (i > 0) {
             log.info("登录账号绑定成功,广告主id:{}", bindAccountLogin.getAdvertiserId());
+            if(null!=loginType&&loginType.equals(CtopAdConstant.PLATFORM_TYPE_PANGOLIN_PY)){
+                //穿山甲账户绑定
+                Thread thread = new Thread(){
+                    @Override
+                    public void run() {
+                        //1:登录
+                        pangolinLoginService.pangolinLogin(bindAccountLogin.getAccountName(), bindAccountLogin.getPassword());
+                        //2:拉取数据
+                        pangolinCrawlerService.getNowData(bindAccountLogin);
+                    }
+                };
+                thread.start();
+            }
+
             returnMap.put("success", true);
             returnMap.put("accountUd", password);
         }
@@ -164,7 +184,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(),e);
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SERVER_ERROR.getCode());
         } finally {
             //清除所有的缓存

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MaterialTopServiceImpl.java

@@ -20,7 +20,7 @@ import org.springframework.stereotype.Service;
 public class MaterialTopServiceImpl  implements IMaterialTopService {
 
     @Autowired
-    MaterialTopMapper materialTopMapper;
+    private MaterialTopMapper materialTopMapper;
 
     @Override
     public IPage<MaterialTopVO> selectByPage(String endDate, String startDate, String target, String order, int pageNo, int pageSize) {

+ 55 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java

@@ -1,7 +1,12 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.utils.SpringUtils;
+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.system.vo.LoginUser;
@@ -11,6 +16,7 @@ import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -27,10 +33,13 @@ import java.util.Map;
  */
 @Service
 public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, ProjectMember> implements IProjectMemberService {
+
     @Autowired
     private ProjectMemberMapper memberMapper;
     @Autowired
     private ISysRoleService sysRoleService;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
 
     @Override
     public void addMember(SysUser sysUser, Project project) {
@@ -63,30 +72,68 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
     }
 
     //视频报表
-    public List<ProjectMember> getProjects(List<Integer> mediaIds){
+    public List<ProjectMember> getProjects(List<Integer> mediaIds) {
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = memberMapper.getRoleCodeByUserId(userId);
         String companyId = memberMapper.getCompanyIdByUserId(userId);
 
-        //List<Integer> mediaIds = new ArrayList<>();
-        //mediaIds.add(1);
-        //mediaIds.add(3);
         //角色权限判断
         List<ProjectMember> projectMemberList = null;
-        if(roleCode.equals("plan") || roleCode.equals("clip") || roleCode.equals("shot") || roleCode.equals("plane")|| roleCode.equals("planeLeader")){
+        if (roleCode.equals("plan") || roleCode.equals("clip") || roleCode.equals("shot") || roleCode.equals("plane") || roleCode.equals("planeLeader")) {
             projectMemberList = memberMapper.designProjects(userId, mediaIds);
-        }else if( roleCode.equals("designTeamLeader")){
+        } else if (roleCode.equals("designTeamLeader")) {
             projectMemberList = memberMapper.designLeaderProjects(companyId, mediaIds);
-        }else if(roleCode.equals("admin")){
+        } else if (roleCode.equals("admin")) {
             projectMemberList = memberMapper.adminProjects(mediaIds);
-        }else if(roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")){
+        } else if (roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")) {
             projectMemberList = memberMapper.operationProjects(userId, mediaIds);
         }
 
         return projectMemberList;
     }
 
+    @Override
+    public List<Map<String, Object>> getProjectAccountByUserId(String userId) {
+        List<Map<String, Object>> result = new ArrayList<>();
+        List<Integer> mediaList = new ArrayList<>();
+        mediaList.add(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INT);
+        mediaList.add(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INSIDE_INT);
+        //查询登录账号下的项目
+        List<ProjectMember> projectMemberList = this.queryProjectMemberBy(userId,mediaList);
+        if (projectMemberList.isEmpty()) {
+            return result;
+        }
+        projectMemberList.forEach(ProjectMember -> {
+            Map<String, Object> temp=this.queryAccountByProjectId(ProjectMember);
+            if(temp!=null){
+                result.add(temp);
+            }
+        });
+        return result;
+    }
 
 
+    private Map<String, Object> queryAccountByProjectId(ProjectMember projectMember) {
+        Map<String, Object> temp = new HashMap<>();
+        temp.put("project", projectMember);
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", projectMember.getProjectId());
+        queryWrapper.isNotNull("account_id");
+        List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
+        if(userAllocations.isEmpty()){
+            temp=null;
+        }else {
+            temp.put("account", userAllocations);
+        }
+        return temp;
+    }
+
+    private List<ProjectMember> queryProjectMemberBy(String userId, List<Integer> mediaIds) {
+        String roleCode = memberMapper.getRoleCodeByUserId(userId);
+        if(roleCode.equals("admin")){
+            return memberMapper.adminProjects(mediaIds);
+        }
+        return memberMapper.queryProjectMemberByUserId(userId,mediaIds);
+    }
 }

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ReleaseRecordServiceImpl.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.ReleaseRecord;
+import org.jeecg.modules.ctop.mapper.ReleaseRecordMapper;
+import org.jeecg.modules.ctop.service.IReleaseRecordService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 发版记录信息
+ * @author jeecg-boot
+ * @date   2020-06-10
+ * @version V1.0
+ */
+@Service
+public class ReleaseRecordServiceImpl extends ServiceImpl<ReleaseRecordMapper, ReleaseRecord> implements IReleaseRecordService {
+
+    @Override
+    public ReleaseRecord getLastRecord() {
+        QueryWrapper<ReleaseRecord>queryWrapper = new QueryWrapper<>();
+        queryWrapper.orderByDesc("id").last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}

+ 80 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ReleaseViewRecordServiceImpl.java

@@ -0,0 +1,80 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.ReleaseRecord;
+import org.jeecg.modules.ctop.entity.ReleaseViewRecord;
+import org.jeecg.modules.ctop.mapper.ReleaseViewRecordMapper;
+import org.jeecg.modules.ctop.service.IReleaseRecordService;
+import org.jeecg.modules.ctop.service.IReleaseViewRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 发版记录信息
+ * @author jeecg-boot
+ * @date   2020-06-10
+ * @version V1.0
+ */
+@Service
+public class ReleaseViewRecordServiceImpl extends ServiceImpl<ReleaseViewRecordMapper, ReleaseViewRecord> implements IReleaseViewRecordService {
+    @Autowired
+    private IReleaseRecordService releaseRecordService;
+    @Override
+    public Map<String, Object> check(String userId) {
+        Map<String,Object>result = new HashMap<>();
+        ReleaseRecord releaseRecord = releaseRecordService.getLastRecord();
+        if(null==releaseRecord){
+            result.put("showPopup",false);
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+            return result;
+        }
+        ReleaseViewRecord releaseViewRecord = getRecordByParams(userId,releaseRecord.getId());
+        if(null!=releaseViewRecord){
+            result.put("showPopup",false);
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+            return result;
+        }
+        result.put("showPopup",true);
+        result.put("data",releaseRecord);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> view(String userId, JSONObject data) {
+        Map<String,Object>result = new HashMap<>();
+        Long versionId = data.getLong("versionId");
+        if(null == versionId||versionId == 0){
+            ResultMapUtils.setResultMap(result,StatusCode.COMMON_VERSION_NOT_EXIST);
+            return result;
+        }
+        ReleaseViewRecord releaseViewRecord = new ReleaseViewRecord();
+        releaseViewRecord.setUserId(userId);
+        releaseViewRecord.setReleaseId(versionId);
+        releaseViewRecord.setCreateTime(new Date());
+        releaseViewRecord.setUpdateTime(new Date());
+        this.save(releaseViewRecord);
+        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    public ReleaseViewRecord getRecordByParams(String userId,Long releaseId){
+        QueryWrapper<ReleaseViewRecord> queryWrapper = new QueryWrapper<>();
+        if(null!=userId&&!userId.trim().equals("")){
+            queryWrapper.eq("user_id",userId);
+        }
+        if(null!=releaseId&&releaseId!=0){
+            queryWrapper.eq("release_id",releaseId);
+        }
+        queryWrapper.orderByDesc("id").last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}

+ 21 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java

@@ -1,11 +1,16 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 import org.jeecg.modules.ctop.mapper.TransferAccountMapper;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 转户记录表
  *
@@ -16,4 +21,20 @@ import org.springframework.stereotype.Service;
 @Service
 public class TransferAccountServiceImpl extends ServiceImpl<TransferAccountMapper, TransferAccount> implements ITransferAccountService {
 
+    @Autowired
+    private KuaishouReportDailyAccountMapper dailyAccountMapper;
+    @Autowired
+    private TransferAccountMapper transferAccountMapper;
+
+    @Override
+    public List<JSONObject> selectCost(Long accountId, String startDate, String endDate) {
+        return dailyAccountMapper.selectCost(accountId, startDate, endDate);
+    }
+
+
+    @Override
+    public List<TransferAccount> getAccountQuarterDetail(Long accountId, String startDate, String endDate) {
+        return transferAccountMapper.getAccountQuarterDetail(accountId, startDate, endDate);
+    }
+
 }

+ 0 - 20
jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Receiver.java

@@ -1,20 +0,0 @@
-package org.jeecg.modules.mq;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-@Slf4j
-@Component
-@RabbitListener(queuesToDeclare = @Queue("hello"))
-public class Receiver {
-    /**
-     * 通过@RabbitHandler声明的方法,对hello队列中的消息进行处理
-     */
-    @RabbitHandler
-    public void receiver(String str) {
-        log.info("Receiver says:[" + str + "]");
-    }
-}

+ 0 - 27
jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Sender.java

@@ -1,27 +0,0 @@
-package org.jeecg.modules.mq;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.AmqpTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author jeecg-boot
- * 2019年12月5日19:57:58
- */
-@Component
-@Slf4j
-public class Sender {
-
-    @Autowired
-    AmqpTemplate rabbitmqTemplate;
-
-    /**
-     * 发送消息
-     */
-    public void send() {
-        String content = "Sender says:" + "'hello, I'm sender'";
-        log.info(content);
-        rabbitmqTemplate.convertAndSend("hello", content);
-    }
-}

+ 144 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/opencv/utils/ExtractionVideoKeyFrames.java

@@ -0,0 +1,144 @@
+package org.jeecg.modules.opencv.utils;
+
+import org.opencv.core.*;
+import org.opencv.imgcodecs.Imgcodecs;
+import org.opencv.imgproc.Imgproc;
+import org.opencv.videoio.VideoCapture;
+import org.opencv.videoio.Videoio;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExtractionVideoKeyFrames {
+    Mat computeColorHist3D(Mat im, Size size)
+    {
+        Mat dst = new Mat(), hist = new Mat();
+        Imgproc.resize(im, dst, size, 0, 0, Imgproc.INTER_NEAREST);
+        Mat hsv_src = new Mat();
+        Imgproc.cvtColor(im, hsv_src, Imgproc.COLOR_BGR2HSV);
+        List<Mat> images=new ArrayList<Mat>(3);
+        images.add(hsv_src);
+
+        MatOfInt channels= new MatOfInt(0);
+        MatOfInt hSize = new MatOfInt(256);
+        MatOfFloat ranges= new MatOfFloat(0,255);
+        //获取图像直方图
+        Imgproc.calcHist(images, channels, new Mat(), hist, hSize, ranges);
+        return hist;
+    }
+
+    Mat computeColorHist(Mat im, Size size)
+    {
+        Mat dst = new Mat(), hist = new Mat();
+        Imgproc.resize(im, dst, size, 0, 0, Imgproc.INTER_NEAREST);
+        Mat gray = new Mat(im.size(),CvType.CV_8UC1);
+        Imgproc.cvtColor(im,gray,Imgproc.COLOR_RGB2GRAY);
+
+        List<Mat> images = new ArrayList<Mat>();
+        images.add(gray);
+
+        MatOfInt channels= new MatOfInt(0);
+        MatOfInt hSize = new MatOfInt(128);
+        MatOfFloat ranges= new MatOfFloat(0,128);
+        Imgproc.calcHist(images, channels, new Mat(), hist, hSize, ranges);
+        return hist;
+    }
+
+    double computeASE(Mat a, Mat b) {
+        return  1 - Imgproc.compareHist(a, b, 0);
+    }
+
+    int ExtractKeyframes(String videoPath, double rate, String outImgPath){
+        VideoCapture cap = new VideoCapture();
+        System.out.println(cap.isOpened());
+        if (!cap.open(videoPath)) {
+            System.out.println("Open video file error!");
+            return -1;
+        }
+
+        File file = new File(outImgPath);
+        if(!file.exists()){
+            file.mkdirs();
+        }
+        //  Videoio.CAP_PROP_FRAME_COUNT
+        int width = (int)cap.get(Videoio.CAP_PROP_FRAME_WIDTH);
+        int height = (int)cap.get(Videoio.CAP_PROP_FRAME_HEIGHT);
+        float fps = (float)cap.get(Videoio.CAP_PROP_FPS);
+        int nframes = (int)cap.get(Videoio.CAP_PROP_FRAME_COUNT);
+        System.out.println("W:"+width+";H:"+height+";FPS:"+fps+";N:"+nframes);
+
+        int nscale = 1;
+        if (width%4==0 && height%4==0){
+            nscale = 4;
+        }else if (width%2==0 && height%2==0){
+            nscale = 2;
+        }
+        Size size = new Size(width/nscale, height/nscale);
+
+        Mat frame = new Mat();
+        Mat lastFrame = new Mat();
+        Mat histA = new Mat();
+        Mat histB = new Mat();
+        long nCount = 0;
+        int frameID = 1;
+        int lastFrameID = 1;
+        double tic = (double)Core.getTickCount();
+        while (cap.read(frame)) {
+            if (frame.empty()){
+                break;
+            }
+
+            if (lastFrameID==1) {
+                frameID = (int)cap.get(Videoio.CAP_PROP_POS_FRAMES);
+                lastFrameID = frameID;
+                frame.copyTo(lastFrame);
+                continue;
+            }
+            if (++nCount % 15 != 0){
+                continue;	// Processing one frame in each second
+            }
+
+            frameID = (int)cap.get(Videoio.CAP_PROP_POS_FRAMES);
+            histA = computeColorHist3D(frame, size);
+
+            double aseV = rate;
+            if (histB.empty()){
+                System.out.println(aseV);
+            }
+            else{
+                aseV = computeASE(histA, histB);
+                System.out.println(aseV);
+            }
+
+            if (aseV >= rate) {
+                String imagePath = outImgPath+"/"+lastFrameID+".jpg";
+                if (!Imgcodecs.imwrite(imagePath, lastFrame)){
+                    return -2;
+                }
+                lastFrameID = frameID;
+                frame.copyTo(lastFrame);
+            }
+
+            histA.copyTo(histB);
+        }
+
+        if (!lastFrame.empty()) {
+            String imagePath=outImgPath+"/"+ lastFrameID+".jpg";
+            if (!Imgcodecs.imwrite(imagePath, lastFrame)){
+                return -2;
+            }
+        }
+        System.out.println("NFRAMES(in reality)="+nCount);
+
+        double toc = (double)Core.getTickCount();
+        System.out.println("ELAPSED TIME="+(toc-tic)/Core.getTickFrequency());
+        return 0;
+    }
+
+    public static void main(String[] args) {
+        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
+        ExtractionVideoKeyFrames evf = new ExtractionVideoKeyFrames();
+        evf.ExtractKeyframes("D:\\data\\fill.mp4",0.5,"D:\\data\\");
+    }
+}

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/PeriodConstant.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.performance.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+@Getter
+public enum PeriodConstant {
+
+    Q1("01-01","03-31"),
+    Q2("04-01","06-30"),
+    Q3("07-01","09-30"),
+    Q4("10-01","12-31");
+
+    PeriodConstant(String start, String end) {
+        this.start = start;
+        this.end = end;
+    }
+
+    private final String start;
+    private final String end;
+
+}

+ 36 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/RateConstant.java

@@ -0,0 +1,36 @@
+package org.jeecg.modules.performance.constants;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+public class RateConstant {
+
+    private RateConstant() {
+    }
+
+    // Percentage constant
+    public static final BigDecimal PERCENT_0 = BigDecimal.valueOf(0.00);
+    public static final BigDecimal PERCENT_5 = BigDecimal.valueOf(0.05);
+    public static final BigDecimal PERCENT_10 = BigDecimal.valueOf(0.1);
+    public static final BigDecimal PERCENT_15 = BigDecimal.valueOf(0.15);
+    public static final BigDecimal PERCENT_20 = BigDecimal.valueOf(0.2);
+    public static final BigDecimal PERCENT_30 = BigDecimal.valueOf(0.3);
+    public static final BigDecimal PERCENT_40 = BigDecimal.valueOf(0.4);
+    public static final BigDecimal PERCENT_50 = BigDecimal.valueOf(0.5);
+    public static final BigDecimal PERCENT_60 = BigDecimal.valueOf(0.6);
+    public static final BigDecimal PERCENT_70 = BigDecimal.valueOf(0.7);
+    public static final BigDecimal PERCENT_80 = BigDecimal.valueOf(0.8);
+    public static final BigDecimal PERCENT_90 = BigDecimal.valueOf(0.9);
+
+
+    // Thousand constant
+    public static final BigDecimal THOUSAND_0 = BigDecimal.valueOf(0.000);
+    public static final BigDecimal THOUSAND_1 = BigDecimal.valueOf(0.001);
+    public static final BigDecimal THOUSAND_2 = BigDecimal.valueOf(0.002);
+    public static final BigDecimal THOUSAND_3 = BigDecimal.valueOf(0.003);
+    public static final BigDecimal THOUSAND_4 = BigDecimal.valueOf(0.004);
+    public static final BigDecimal THOUSAND_5 = BigDecimal.valueOf(0.005);
+
+}

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/constants/StandardValue.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.performance.constants;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by JQ.bi on 2020.5.26
+ */
+public class StandardValue {
+
+    private StandardValue() {
+    }
+
+    // 季度消耗门槛值
+    public static final BigDecimal QUARTER_CONSUMPTION=new BigDecimal(2400000);
+
+    // 视频有效门槛值
+    public static final BigDecimal VIDEO_CLICK=new BigDecimal(5000);
+
+    // 零绩效
+    public static final BigDecimal PERFORMANCE_ZERO=new BigDecimal(0);
+
+
+}

+ 111 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/controller/PerformanceShowCtrl.java

@@ -0,0 +1,111 @@
+package org.jeecg.modules.performance.controller;
+
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.jeecg.modules.performance.service.IPerformanceInfoService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by JQ.bi on 2020.6.9
+ */
+@Slf4j
+@RestController
+@RequestMapping("/ctop/performance/show")
+public class PerformanceShowCtrl {
+
+    @Autowired
+    IPerformanceInfoService performanceService;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+    @Autowired
+    IOperateDetailService operateDetailService;
+
+    @GetMapping("/getPerformanceInfo")
+    public Result<Map<String, Object>> getPerformanceInfo() {
+        Result<Map<String, Object>> result = new Result<>();
+        result.setResult(performanceService.getPerformanceInfo());
+        result.setSuccess(true);
+        return result;
+    }
+
+    @PostMapping("/{pageNo}/{pageSize}/{order}")
+    public Result<PageInfo<PerformanceQuarter>> showPerformance(@PathVariable int pageNo,
+                                                               @PathVariable int pageSize,
+                                                               @PathVariable String order,
+                                                               @RequestBody JSONObject requestBody) {
+        Result<PageInfo<PerformanceQuarter>> result = new Result<>();
+        PageInfo<PerformanceQuarter> pageInfo = performanceQuarterService.getPerformanceByConditionsPage(pageNo, pageSize, order, requestBody);
+        result.setSuccess(true);
+        result.setResult(pageInfo);
+        return result;
+    }
+
+    /**
+     * 导出数据
+     *
+     * @param requestBody
+     * @param response
+     */
+    @PostMapping("/excel")
+    public void getExcelReport(@RequestBody JSONObject requestBody,
+                               HttpServletResponse response) {
+        List<PerformanceQuarter> excelData= performanceQuarterService.getPerformanceByConditions(requestBody);
+        if (excelData.isEmpty()) {
+            return;
+        }
+        String[] titles={"姓名","公司","职位","媒体类型","年份","季度","消耗","提成比例","绩效","管理岗绩效"};
+
+        List<List<Object>> excelList = new ArrayList<>();
+        excelData.forEach(data -> {
+            List<Object> temp = new ArrayList<>();
+            temp.add(data.getUserName());
+            temp.add(data.getCompanyName());
+            temp.add(data.getRoleName());
+            temp.add(data.getMediaType()==1?"头条":"快手");
+            temp.add(data.getYear());
+            temp.add(data.getQuarter());
+            temp.add(data.getCost());
+            temp.add(data.getPoint());
+            temp.add(data.getPerformance());
+            temp.add(data.getAdditionalFees());
+            excelList.add(temp);
+        });
+        try {
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            eeu.exportExcel(workbook, 0, "绩效", titles, excelList);
+            HttpUtils.setResponseHeader(response, "绩效.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    @PostMapping("/operateDetail")
+    public Result<List<JSONObject>> getOperateDetail(@RequestBody JSONObject requestBody){
+        Result<List<JSONObject>> result = new Result<>();
+        result.setResult(operateDetailService.getOperateGroupAccountByUser(requestBody));
+        result.setSuccess(true);
+        return result;
+    }
+
+}

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/DesignDetail.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.performance.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 设计消耗详细
+ */
+@Data
+@TableName("ctop_performance_design_detail")
+public class DesignDetail {
+
+}

+ 75 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/OperateDetail.java

@@ -0,0 +1,75 @@
+package org.jeecg.modules.performance.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 运营消耗详细
+ */
+@Data
+@TableName("ctop_performance_operate_detail")
+public class OperateDetail {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 媒体类型 1:头条 2:快手
+     */
+    private Integer mediaType;
+    /**
+     * 账户id
+     */
+    private Long accountId;
+    /**
+     * 统计开始时间
+     */
+    private String statDate;
+
+    /**
+     * 账户消耗
+     */
+    private BigDecimal cost;
+    /**
+     * leaderId
+     */
+    private String leaderId;
+    /**
+     * createTime
+     */
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    private Date updateTime;
+
+    /**
+     * 是否节假日
+     */
+    private Date isHoliday;
+
+    /**
+     * 预留字段
+     */
+    private BigDecimal cost1;
+    private BigDecimal cost2;
+    private BigDecimal cost3;
+    private BigDecimal cost4;
+
+}

+ 146 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/entity/PerformanceQuarter.java

@@ -0,0 +1,146 @@
+package org.jeecg.modules.performance.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Objects;
+
+@Data
+@TableName("ctop_performance_quarter")
+public class PerformanceQuarter {
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 用户姓名
+     */
+    private String userName;
+    /**
+     * 公司ID
+     */
+    private String companyId;
+    /**
+     * 公司名称
+     */
+    private String companyName;
+    /**
+     * 公司名称
+     */
+    private String department;
+    /**
+     * 职位code
+     */
+    private String roleCode;
+    /**
+     * 职位名称
+     */
+    private String roleName;
+    /**
+     * 负责人
+     */
+    private String leader;
+    /**
+     * 用户id
+     */
+    private Integer year;
+    /**
+     * 季度
+     */
+    private String quarter;
+    /**
+     * 消耗
+     */
+    private BigDecimal cost;
+    /**
+     * 绩效
+     */
+    private BigDecimal performance;
+    /**
+     * 提成点
+     */
+    private BigDecimal point;
+    /**
+     * 额外提成
+     */
+    private BigDecimal additionalFees;
+    /**
+     * 原因
+     */
+    private String reason;
+    /**
+     * 媒体类型
+     */
+    private Integer mediaType;
+    /**
+     * createTime
+     */
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    private Date updateTime;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        PerformanceQuarter that = (PerformanceQuarter) o;
+        return Objects.equals(id, that.id) &&
+                Objects.equals(userId, that.userId) &&
+                Objects.equals(userName, that.userName) &&
+                Objects.equals(companyId, that.companyId) &&
+                Objects.equals(companyName, that.companyName) &&
+                Objects.equals(roleCode, that.roleCode) &&
+                Objects.equals(roleName, that.roleName) &&
+                Objects.equals(leader, that.leader) &&
+                Objects.equals(year, that.year) &&
+                Objects.equals(quarter, that.quarter) &&
+                Objects.equals(cost, that.cost) &&
+                Objects.equals(performance, that.performance) &&
+                Objects.equals(point, that.point) &&
+                Objects.equals(additionalFees, that.additionalFees) &&
+                Objects.equals(reason, that.reason) &&
+                Objects.equals(mediaType, that.mediaType) &&
+                Objects.equals(createTime, that.createTime) &&
+                Objects.equals(updateTime, that.updateTime);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, userId, userName, companyId, companyName, roleCode, roleName, leader, year, quarter, cost, performance, point, additionalFees, reason, mediaType, createTime, updateTime);
+    }
+
+    @Override
+    public String toString() {
+        return "PerformanceQuarter{" +
+                "id=" + id +
+                ", userId='" + userId + '\'' +
+                ", userName='" + userName + '\'' +
+                ", companyId='" + companyId + '\'' +
+                ", companyName='" + companyName + '\'' +
+                ", roleCode='" + roleCode + '\'' +
+                ", roleName='" + roleName + '\'' +
+                ", leader='" + leader + '\'' +
+                ", year=" + year +
+                ", quarter='" + quarter + '\'' +
+                ", cost=" + cost +
+                ", performance=" + performance +
+                ", point=" + point +
+                ", additionalFees=" + additionalFees +
+                ", reason='" + reason + '\'' +
+                ", mediaType=" + mediaType +
+                ", createTime=" + createTime +
+                ", updateTime=" + updateTime +
+                '}';
+    }
+}

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/CalculatePerformanceMapper.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface CalculatePerformanceMapper {
+
+    List<JSONObject> queryOperateCostGroupByUser(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("mediaType")int mediaType);
+
+}

+ 11 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/DesignDetailMapper.java

@@ -0,0 +1,11 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+
+public interface DesignDetailMapper {
+
+    List<JSONObject> queryMaterialDetailByDate(String startDate,String endDate, int mediaType);
+}

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/OperateDetailMapper.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.performance.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.lettuce.core.dynamic.annotation.Param;
+import org.jeecg.modules.performance.entity.OperateDetail;
+
+import java.util.List;
+
+/**
+ * 运营消耗详细
+ *
+ * @author: jeecg-boot
+ * @date: 2020-04-23
+ * @cersion: V1.0
+ */
+public interface OperateDetailMapper extends BaseMapper<OperateDetail> {
+
+    List<OperateDetail> selectBytedanceByParams(@Param(value = "accountId") Long accountId, @Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId, @Param(value = "orgCode") String orgCode);
+
+    List<JSONObject> ByteDanceOperateDetailGroupAccountByDate(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId);
+
+    List<JSONObject> kuaiShouOperateDetailGroupAccountByDate(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId);
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/PerformanceQuarterMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.performance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+
+import java.util.List;
+
+public interface PerformanceQuarterMapper extends BaseMapper<PerformanceQuarter> {
+
+    List<JSONObject> queryYearAndQuarter();
+
+}

+ 27 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/CalculatePerformanceMapper.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.modules.performance.mapper.CalculatePerformanceMapper">
+
+    <select id="queryOperateCostGroupByUser" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT res.*,
+        (SELECT realname from sys_user user where user.id=res.userId limit 1) as userName,
+        (SELECT company_id from user_company company where company.user_id=res.userId limit 1) as 'companyId',
+        (SELECT company_name from user_company company where company.user_id=res.userId limit 1) as 'companyName',
+        (SELECT role_code from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleCode',
+        (SELECT role_name from sys_role role LEFT JOIN sys_user_role ur on role.id=ur.role_id where ur.user_id=res.userId limit 1) as 'roleName'
+        from (
+        SELECT
+        user_id as userId,
+        leader_id as leaderId,
+        sum(cost) as cost
+        FROM
+        ctop_performance_operate_detail
+        WHERE
+        media_type= #{mediaType}
+        AND	stat_date &gt;= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        GROUP BY user_id
+        ) res
+    </select>
+
+</mapper>

+ 52 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/DesignDetailMapper.xml

@@ -0,0 +1,52 @@
+<?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.modules.performance.mapper.DesignDetailMapper">
+
+    <select id="queryMaterialDetailByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        res.*,
+        (
+        SELECT
+        USER.id
+        FROM
+        sys_user USER
+        LEFT JOIN sys_user_role userRole ON USER .id = userRole.user_id
+        LEFT JOIN sys_role role ON userRole.role_id = role.id
+        WHERE
+        USER .org_code = (
+        SELECT
+        user1.org_code
+        FROM
+        sys_user user1
+        WHERE
+        user1.id = res.clipId
+        LIMIT 1
+        )
+        AND role.role_code = 'designTeamLeader'
+        ) AS 'leaderId'
+        FROM
+        (
+        SELECT
+        report.CODE,
+        sum(report.cost) AS cost,
+        ascription.clip_id as clipID,
+        ascription.plane_id as planeId,
+        ascription.plan_id as planID,
+        ascription.shot_id as shotID,
+        ascription.material_id as materialId
+        FROM
+        ctop_material_report_total_result report
+        LEFT JOIN ctop_material_info info on report.code=info.code
+        LEFT JOIN ctop_material_ascription ascription ON info. CODE = ascription.material_id
+        WHERE
+        report.media_type = #{param3}
+        AND report.stat_date &gt;= #{param1}
+        AND report.stat_date &lt;= #{param2}
+        GROUP BY
+        report.CODE
+        ) res
+        WHERE
+        res.cost > 0
+    </select>
+
+</mapper>

+ 78 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/OperateDetailMapper.xml

@@ -0,0 +1,78 @@
+<?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.modules.performance.mapper.OperateDetailMapper">
+
+    <select id="selectBytedanceByParams" resultType="org.jeecg.modules.performance.entity.OperateDetail">
+        select
+            #{userId} as user_id,
+            1 as media_type,
+            #{accountId} as account_id,
+            left(stat_datetime,10) as stat_date,
+            sum(cost) as cost,
+            (select
+                user.id
+            from
+                sys_user_role userRole
+            left join sys_user user on userRole.user_id = user.id
+            left join sys_role role on userRole.role_id = role.id
+            where
+                org_code = #{orgCode}
+            and
+                role.role_name = '头条运营经理'
+            ) as leader_id
+        from
+            ctop_bytedance_report_advertiser_daily
+        where
+            advertiser_id = #{accountId}
+        and
+            stat_datetime &gt;=#{startDate}
+        and
+            stat_datetime &lt;=#{endDate}
+        group by stat_datetime
+    </select>
+
+    <select id="ByteDanceOperateDetailGroupAccountByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.project_name AS projectName,
+        t2.auth_name AS authName,
+        ROUND(sum(t1.cost), 2) cost
+        FROM
+        ctop_bytedance_report_advertiser_daily t1
+        LEFT JOIN ctop_user_allocation t2 on t1.advertiser_id=t2.account_id
+        WHERE
+        t1.stat_datetime &gt;= #{startDate} '00:00:00'
+        AND t1.stat_datetime &lt;= #{endDate}
+        AND t1.advertiser_id IN (
+        SELECT
+        account_id
+        FROM
+        ctop_user_allocation
+        WHERE
+        user_id = #{userId}
+        AND media_id = 1
+        ) GROUP BY t2.account_id
+    </select>
+
+    <select id="kuaiShouOperateDetailGroupAccountByDate" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.project_name AS projectName,
+        t2.auth_name AS authName,
+        ROUND(sum(t1.charge), 2) cost
+        FROM
+        ctop_kuaishou_report_daily_account t1
+        LEFT JOIN ctop_user_allocation t2 on t1.account_id=t2.account_id
+        WHERE
+        t1.stat_date &gt;=#{startDate}
+        AND t1.stat_date &lt;=#{endDate}
+        AND t1.account_id IN (
+        SELECT
+        account_id
+        FROM
+        ctop_user_allocation
+        WHERE
+        user_id = #{userId}
+        AND media_id = 2
+        ) GROUP BY t2.account_id
+    </select>
+
+</mapper>

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/mapper/xml/PerformanceQuarterMapper.xml

@@ -0,0 +1,13 @@
+<?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.modules.performance.mapper.PerformanceQuarterMapper">
+
+    <select  id="queryYearAndQuarter" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT DISTINCT
+            year,
+            quarter
+        FROM
+            ctop_performance_quarter
+    </select>
+
+</mapper>

+ 28 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/DesignDetailServiceImpl.java

@@ -0,0 +1,28 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.performance.mapper.DesignDetailMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Slf4j
+public class DesignDetailServiceImpl implements IDesignDetailService {
+
+    @Autowired
+    DesignDetailMapper designDetailMapper;
+
+    @Override
+    public void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType) {
+        //查询出来素材对应的cost
+        List<JSONObject> jsonObjectList=designDetailMapper.queryMaterialDetailByDate(startDate,endDate,mediaType);
+        if(jsonObjectList.isEmpty()){
+            log.error("没有素材数据");
+        }
+
+
+    }
+}

+ 12 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/ICalculatePerformanceService.java

@@ -0,0 +1,12 @@
+package org.jeecg.modules.performance.service;
+
+public interface ICalculatePerformanceService {
+
+    //运营绩效计算
+    void CalculateOperatePerformance(int year, String quarter, int mediaType);
+    //设计绩效计算
+    void CalculateDesignPerformance();
+    //销售绩效计算
+    void CalculateSalePerformance();
+
+}

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IDesignDetailService.java

@@ -0,0 +1,7 @@
+package org.jeecg.modules.performance.service;
+
+public interface IDesignDetailService {
+
+    void UserCostCalculateByMaterial(String startDate, String endDate, int mediaType);
+
+}

+ 27 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IOperateDetailService.java

@@ -0,0 +1,27 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.performance.entity.OperateDetail;
+import org.jeecg.modules.performance.vo.TransferDetailVO;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * 运营消耗详细
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-23
+ */
+public interface IOperateDetailService extends IService<OperateDetail> {
+
+    void KsCostCalculateByAccount(String startDate, String endDate);
+
+    void BtCostCalculateByAccount(String startDate, String endDate);
+
+    List<TransferDetailVO> loadTransferDetail(Long accountId, String userId, String startDate, String endDate) throws ParseException;
+
+    List<JSONObject> getOperateGroupAccountByUser(JSONObject requestBody);
+}

+ 8 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceInfoService.java

@@ -0,0 +1,8 @@
+package org.jeecg.modules.performance.service;
+
+import java.util.Map;
+
+public interface IPerformanceInfoService {
+
+    Map<String,Object> getPerformanceInfo();
+}

+ 20 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/IPerformanceQuarterService.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.performance.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface IPerformanceQuarterService extends IService<PerformanceQuarter> {
+
+    Map<String, Set<String>> getYearQuarter();
+
+    List<PerformanceQuarter> getPerformanceByConditions(JSONObject requestBody);
+
+    PageInfo<PerformanceQuarter> getPerformanceByConditionsPage(int pageNo, int pageSize, String order,JSONObject requestBody);
+
+}

+ 75 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/CalculatePerformanceServiceImpl.java

@@ -0,0 +1,75 @@
+package org.jeecg.modules.performance.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.modules.performance.constants.PeriodConstant;
+import org.jeecg.modules.performance.constants.RateConstant;
+import org.jeecg.modules.performance.constants.StandardValue;
+import org.jeecg.modules.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.mapper.CalculatePerformanceMapper;
+import org.jeecg.modules.performance.service.ICalculatePerformanceService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *  Created by JQ.bi
+ */
+@Service
+public class CalculatePerformanceServiceImpl implements ICalculatePerformanceService {
+
+    @Autowired
+    CalculatePerformanceMapper calculatePerformanceMapper;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+
+    @Override
+    public void CalculateOperatePerformance(int year, String quarter, int mediaType) {
+        //TODO 查询配置的提成点
+        BigDecimal point =new BigDecimal(0);
+        if (mediaType == 1) point = RateConstant.THOUSAND_2;
+        if (mediaType == 2) point = RateConstant.THOUSAND_3;
+        String startDate= year+"-"+ PeriodConstant.valueOf(quarter).getStart();
+        String endDate= year+"-"+PeriodConstant.valueOf(quarter).getEnd();
+        List<JSONObject> operateCost = calculatePerformanceMapper.queryOperateCostGroupByUser(startDate, endDate, mediaType);
+        List<PerformanceQuarter> performanceQuarters = new ArrayList<>();
+        PerformanceQuarter performanceQuarter;
+        for(JSONObject op:operateCost){
+            performanceQuarter = new PerformanceQuarter();
+            performanceQuarter.setUserId(op.getString("userId"));
+            performanceQuarter.setUserName(op.getString("userName"));
+            performanceQuarter.setCompanyId(op.getString("companyId"));
+            performanceQuarter.setCompanyName(op.getString("companyName"));
+            performanceQuarter.setDepartment("运营部");
+            performanceQuarter.setRoleCode(op.getString("roleCode"));
+            performanceQuarter.setRoleName(op.getString("roleName"));
+            performanceQuarter.setLeader(op.getString("leaderId"));
+            performanceQuarter.setYear(year);
+            performanceQuarter.setQuarter(quarter);
+            BigDecimal cost=op.getBigDecimal("cost");
+            performanceQuarter.setCost(cost);
+            if(cost.compareTo(StandardValue.QUARTER_CONSUMPTION)>=0){
+                performanceQuarter.setPerformance(cost.multiply(point));
+            }else {
+                performanceQuarter.setPerformance(StandardValue.PERFORMANCE_ZERO);
+            }
+            performanceQuarter.setPoint(point);
+            performanceQuarter.setMediaType(mediaType);
+            performanceQuarters.add(performanceQuarter);
+        }
+        performanceQuarterService.saveBatch(performanceQuarters);
+    }
+
+    @Override
+    public void CalculateDesignPerformance() {
+
+    }
+
+    @Override
+    public void CalculateSalePerformance() {
+
+    }
+}

+ 189 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/OperateDetailServiceImpl.java

@@ -0,0 +1,189 @@
+package org.jeecg.modules.performance.service.impl;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAccountService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.TransferAccount;
+import org.jeecg.modules.ctop.service.ITransferAccountService;
+import org.jeecg.modules.performance.constants.PeriodConstant;
+import org.jeecg.modules.performance.entity.OperateDetail;
+import org.jeecg.modules.performance.mapper.OperateDetailMapper;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.jeecg.modules.performance.vo.TransferDetailVO;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysUserRoleService;
+import org.jeecg.modules.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 运营消耗详细
+ */
+@Service
+@Slf4j
+public class OperateDetailServiceImpl extends ServiceImpl<OperateDetailMapper, OperateDetail> implements IOperateDetailService {
+
+    @Autowired
+    private OperateDetailMapper operateDetailMapper;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private ITransferAccountService transferAccountService;
+    @Autowired
+    private IKuaishouReportDailyAccountService dailyAccountService;
+    @Autowired
+    private ISysUserRoleService roleService;
+    @Autowired
+    private ISysUserService sysUserService;
+
+
+    /**
+     * 快手账户消耗计算
+     */
+    @Override
+    public void KsCostCalculateByAccount(String startStatDate, String endStatDate) {
+
+        List<UserAllocation> list = userAllocationService.getByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        for (UserAllocation allocation : list) {
+            List<TransferDetailVO> transferDetailVOS = loadTransferDetail(allocation.getAccountId(), allocation.getUserId(), startStatDate, endStatDate);
+            if (Check.isNull(transferDetailVOS)) {
+                log.error("错误,未返回转户信息,accountId:{}", allocation.getAccountId());
+                continue;
+            }
+            for (TransferDetailVO transferDetail : transferDetailVOS) {
+                String userId = transferDetail.getUserId();
+                Long accountId = transferDetail.getAccountId();
+                String startDate = transferDetail.getStartDate();
+                String endDate = transferDetail.getEndDate();
+                String leaderId = roleService.getLeaderId(userId, "kuaishouOperationManager");
+                List<JSONObject> costJsonArr = dailyAccountService.selectCost(accountId, startDate, endDate);
+                if (!Check.isNull(costJsonArr)) {
+                    costJsonArr.stream().filter(costJson -> !Check.isNull(costJson)).forEach(costJson -> {
+                        BigDecimal cost = costJson.getBigDecimal("cost");
+                        if (Check.isNull(cost)) {
+                            return;
+                        }
+                        OperateDetail detail = new OperateDetail();
+                        detail.setCost(cost);
+                        detail.setAccountId(accountId);
+                        detail.setStatDate(costJson.getString("statDate"));
+                        detail.setLeaderId(leaderId);
+                        detail.setUserId(userId);
+                        detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
+                        //TODO 判断是否为节假日
+                        operateDetailMapper.insert(detail);
+                    });
+
+                }
+            }
+        }
+
+    }
+
+
+    /**
+     * 头条账户消耗计算
+     */
+    @Override
+    public void BtCostCalculateByAccount(String startStatDate, String endStatDate) {
+
+        //1:获取头条账户
+        List<UserAllocation> allocations = userAllocationService.getByMediaId(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (allocations.isEmpty()) {
+            log.info("获取头条用户失败");
+            return;
+        }
+        allocations.forEach(allocation->{
+            List<TransferDetailVO> transferDetailVOS = loadTransferDetail(allocation.getAccountId(), allocation.getUserId(), startStatDate, endStatDate);
+            if (null != transferDetailVOS && transferDetailVOS.size() > 0) {
+                transferDetailVOS.forEach(vo->{
+                    SysUser user = sysUserService.getById(vo.getUserId());
+                    List<OperateDetail> details = operateDetailMapper.selectBytedanceByParams(allocation.getAccountId(), vo.getStartDate() + " 00:00:00", vo.getEndDate() + "00:00:00", vo.getUserId(), user.getOrgCode());
+                    if (!details.isEmpty()) {
+                        details.forEach(detail->{
+                            if (null != detail && null != detail.getCost()) {
+                                if (detail.getUserId().equals(detail.getLeaderId())) {
+                                    detail.setLeaderId(null);
+                                }
+                                //TODO 判断是否为节假日
+                                this.save(detail);
+                            }
+                        });
+                    }
+                });
+            }
+        });
+    }
+
+    @Override
+    public List<TransferDetailVO> loadTransferDetail(Long accountId, String userId, String startDate, String endDate) {
+        List<TransferDetailVO> vos = new ArrayList<>();
+        String realEndDate = DateUtils.addDay(endDate, -1);
+        List<TransferAccount> transferAccounts = transferAccountService.getAccountQuarterDetail(accountId, startDate, endDate);
+        if (Check.isNull(transferAccounts)) {
+            vos.add(new TransferDetailVO(startDate, endDate, userId, accountId));
+            return vos;
+        } else if (transferAccounts.size() == 1) {
+            TransferAccount account = transferAccounts.get(0);
+            if (account.getTransferorDate().equals(startDate)) {
+                //极限情况 季度末最后一天转让
+                vos.add(new TransferDetailVO(startDate, endDate, userId, accountId));
+                return vos;
+            } else {
+                vos.add(new TransferDetailVO(startDate, account.getAssigneeDate(), userId, accountId));
+                vos.add(new TransferDetailVO(account.getAssigneeDate(), endDate, userId, accountId));
+                return vos;
+            }
+        } else {
+            TransferAccount firstAccount = transferAccounts.get(0);
+            TransferAccount lastAccout = transferAccounts.get(transferAccounts.size() - 1);
+            vos.add(new TransferDetailVO(startDate, firstAccount.getAssigneeDate(), firstAccount.getTransferor(), accountId));
+            String lastTwoAssigneeDate = "";
+            for (int i = 1; i <= transferAccounts.size() - 1; i++) {
+                TransferAccount account = transferAccounts.get(i);
+                TransferAccount preAccount = transferAccounts.get(i - 1);
+                vos.add(new TransferDetailVO(preAccount.getAssigneeDate(), account.getAssigneeDate(), account.getTransferor(), accountId));
+                lastTwoAssigneeDate = account.getAssigneeDate();
+            }
+            if (lastAccout.getTransferorDate().equals(realEndDate)) {
+                //最后一条数据的转让时间为季度末尾
+                vos.add(new TransferDetailVO(lastTwoAssigneeDate, endDate, lastAccout.getTransferor(), accountId));
+            } else {
+                vos.add(new TransferDetailVO(lastTwoAssigneeDate, lastAccout.getAssigneeDate(), lastAccout.getTransferor(), accountId));
+                vos.add(new TransferDetailVO(lastAccout.getAssigneeDate(), endDate, lastAccout.getAssignee(), accountId));
+            }
+            vos = vos.parallelStream().filter(
+                    vo -> !vo.getStartDate().equals(vo.getEndDate())
+            ).collect(Collectors.toList());
+        }
+        return vos;
+    }
+
+    @Override
+    public List<JSONObject> getOperateGroupAccountByUser(JSONObject requestBody) {
+        String userId=requestBody.getString("userId");
+        int year= requestBody.getInteger("year");
+        String quarter=requestBody.getString("quarter");
+        int mediaType=requestBody.getInteger("mediaType");
+        String startDate= year+"-"+ PeriodConstant.valueOf(quarter).getStart();
+        String endDate= year+"-"+PeriodConstant.valueOf(quarter).getEnd();
+        List<JSONObject> result=new ArrayList<>();
+        if(mediaType==CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INT){
+            result=operateDetailMapper.ByteDanceOperateDetailGroupAccountByDate(startDate,endDate,userId);
+        }else if(mediaType==CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT){
+            result=operateDetailMapper.kuaiShouOperateDetailGroupAccountByDate(startDate,endDate,userId);
+        }
+        return result;
+    }
+}

+ 81 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceInfoInfoServiceImpl.java

@@ -0,0 +1,81 @@
+package org.jeecg.modules.performance.service.impl;
+
+import cn.com.ctop.common.module.entity.SysCompany;
+import cn.com.ctop.common.module.service.ISysCompanyService;
+import cn.com.ctop.common.module.service.ISysRoleService;
+import cn.com.ctop.common.module.utils.CtopMediaTypeUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
+import org.jeecg.modules.performance.service.IPerformanceInfoService;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.jeecg.modules.system.service.ISysUserService;
+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;
+
+/**
+ *  Created by JQ.bi on 2020.6.10
+ */
+@Service
+public class PerformanceInfoInfoServiceImpl implements IPerformanceInfoService {
+
+    @Autowired
+    ISysCompanyService sysCompanyService;
+    @Autowired
+    ISysRoleService sysRoleService;
+    @Autowired
+    ISysUserService sysUserService;
+    @Autowired
+    ProjectMemberMapper projectMemberMapper;
+    @Autowired
+    IPerformanceQuarterService performanceQuarterService;
+
+    @Override
+    public Map<String, Object> getPerformanceInfo() {
+
+        Map<String,Object> result= new HashMap<>();
+        //获取公司名称
+        result.put("company",this.getCompany());
+        //部门
+        result.put("depart",this.getDepart());
+        //获取媒体类型
+        result.put("mediaType", CtopMediaTypeUtil.getMediaTypeAll());
+        //获取年份,季度
+        result.put("data",performanceQuarterService.getYearQuarter());
+        //获取职位
+        result.put("post",sysRoleService.list());
+
+        return result;
+    }
+
+    //根据权限查看绩效
+    private List<SysCompany> getCompany(){
+        List<SysCompany> result;
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        Map<String,Object> role=sysUserService.queryRoleCode(userId);
+        if(role.get("roleName").equals("管理员")){
+            result=sysCompanyService.list();
+        }else {
+            String companyId=projectMemberMapper.getCompanyIdByUserId(userId);
+            QueryWrapper<SysCompany> queryWrapper= new QueryWrapper<>();
+            queryWrapper.eq("company_id",companyId);
+            result= sysCompanyService.list(queryWrapper);
+        }
+        return result;
+    }
+    //TODO 部门暂时写死
+    private List<String> getDepart(){
+        List<String> depart=new ArrayList<>();
+        depart.add("运营部");
+        depart.add("设计部");
+        depart.add("销售部");
+        return depart;
+    }
+}

+ 109 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/service/impl/PerformanceQuarterServiceImpl.java

@@ -0,0 +1,109 @@
+package org.jeecg.modules.performance.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+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 org.jeecg.modules.performance.entity.PerformanceQuarter;
+import org.jeecg.modules.performance.mapper.PerformanceQuarterMapper;
+import org.jeecg.modules.performance.service.IPerformanceQuarterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+public class PerformanceQuarterServiceImpl extends ServiceImpl<PerformanceQuarterMapper, PerformanceQuarter> implements IPerformanceQuarterService {
+
+    @Autowired
+    PerformanceQuarterMapper performanceQuarterMapper;
+
+    /**
+     *  获取绩效表里有的年份季度
+     *
+     */
+    @Override
+    public Map<String, Set<String>> getYearQuarter() {
+        Map<String, Set<String>> result= new HashMap<>();
+        List<JSONObject> jsonObjectList=performanceQuarterMapper.queryYearAndQuarter();
+        if(jsonObjectList.isEmpty()){
+            return result;
+        }
+        jsonObjectList.forEach(it->{
+            if(result.get(it.getInteger("year").toString())==null){
+                Set<String> quarter= new HashSet<>();
+                quarter.add(it.getString("quarter"));
+                result.put(it.getInteger("year").toString(),quarter);
+            }else {
+                result.get(it.getInteger("year").toString()).add(it.getString("quarter"));
+            }
+        });
+        return result;
+    }
+
+    @Override
+    public List<PerformanceQuarter> getPerformanceByConditions(JSONObject requestBody) {
+        QueryWrapper<PerformanceQuarter> quarterWrapper=new QueryWrapper<>();
+        String[] columns={"user_id","user_name","company_name","role_name","media_type","year","quarter","cost","point","performance","additional_fees"};
+        quarterWrapper.select(columns);
+        Map<String,Object> map = new HashMap<>(10);
+        if(!requestBody.getString("company").equals("")) {
+            map.put("company_id",requestBody.getString("company"));
+        }
+        if(!requestBody.getString("department").equals("")) {
+            map.put("department",requestBody.getString("department"));
+        }
+        if(requestBody.getInteger("mediaType")!=0) {
+            map.put("media_type",requestBody.getInteger("mediaType"));
+        }
+        if(requestBody.getInteger("year")!=0) {
+            map.put("year",requestBody.getInteger("year"));
+        }
+        if(!requestBody.getString("quarter").equals("")) {
+            map.put("quarter",requestBody.getString("quarter"));
+        }
+        if(!requestBody.getString("roleCode").equals("")) {
+            map.put("role_code",requestBody.getString("roleCode"));
+        }
+        quarterWrapper.allEq(map);
+        quarterWrapper.like("user_name",requestBody.getString("userName"));
+        return performanceQuarterMapper.selectList(quarterWrapper);
+    }
+
+    @Override
+    public PageInfo<PerformanceQuarter> getPerformanceByConditionsPage(int pageNo, int pageSize, String order,JSONObject requestBody) {
+        QueryWrapper<PerformanceQuarter> quarterWrapper=new QueryWrapper<>();
+        String[] columns={"user_id","user_name","company_name","department","role_name","media_type","year","quarter","cost","point","performance","additional_fees"};
+        quarterWrapper.select(columns);
+        Map<String,Object> map = new HashMap<>(16);
+        if(!requestBody.getString("company").equals("")) {
+            map.put("company_id",requestBody.getString("company"));
+        }
+        if(!requestBody.getString("department").equals("")) {
+            map.put("department",requestBody.getString("department"));
+        }
+        if(requestBody.getInteger("mediaType")!=0) {
+            map.put("media_type",requestBody.getInteger("mediaType"));
+        }
+        if(requestBody.getInteger("year")!=0) {
+            map.put("year",requestBody.getInteger("year"));
+        }
+        if(!requestBody.getString("quarter").equals("")) {
+            map.put("quarter",requestBody.getString("quarter"));
+        }
+        if(!requestBody.getString("roleCode").equals("")) {
+            map.put("role_code",requestBody.getString("roleCode"));
+        }
+        quarterWrapper.allEq(map);
+        quarterWrapper.like("user_name",requestBody.getString("userName"));
+        if(order.equals("asc"))
+            quarterWrapper.orderByAsc("cost");
+        else
+            quarterWrapper.orderByDesc("cost");
+        PageHelper.startPage(pageNo,pageSize);
+        List<PerformanceQuarter> maps = performanceQuarterMapper.selectList(quarterWrapper);
+        return (PageInfo<PerformanceQuarter>) new PageInfo(maps);
+    }
+
+}

+ 35 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/testCtrl.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.performance;
+
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.performance.service.ICalculatePerformanceService;
+import org.jeecg.modules.performance.service.IOperateDetailService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+
+@RestController
+public class testCtrl {
+
+    @Autowired
+    IOperateDetailService operateDetailService;
+
+    @Autowired
+    ICalculatePerformanceService  calculatePerformanceService;
+
+    @GetMapping("/job/test/operator")
+    public String testOperator(){
+/*
+        Date nowDate= new Date();
+
+        String startStatDate = DateUtils.getQuarterStartDate(nowDate);
+        String endStatDate = DateUtils.getQuarterEndDate(nowDate);
+
+        operateDetailService.KsCostCalculateByAccount(startStatDate,endStatDate);
+        operateDetailService.BtCostCalculateByAccount(startStatDate,endStatDate);*/
+        calculatePerformanceService.CalculateOperatePerformance(2020,"Q2",2);
+        return "success";
+    }
+
+}

+ 32 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performance/vo/TransferDetailVO.java

@@ -0,0 +1,32 @@
+package org.jeecg.modules.performance.vo;
+
+import lombok.Data;
+
+@Data
+public class TransferDetailVO {
+    private String startDate;
+    private String endDate;
+    private String userId;
+    private Long accountId;
+
+    public TransferDetailVO() {
+
+    }
+
+    public TransferDetailVO(String startDate, String endDate, String userId, Long accountId) {
+        this.startDate = startDate;
+        this.endDate = endDate;
+        this.userId = userId;
+        this.accountId = accountId;
+    }
+
+    @Override
+    public String toString() {
+        return "TransferDetailVO{" +
+                "startDate='" + startDate + '\'' +
+                ", endDate='" + endDate + '\'' +
+                ", userId='" + userId + '\'' +
+                ", accountId=" + accountId +
+                '}';
+    }
+}

+ 0 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/performanceappraisal/aa.java

@@ -1,4 +0,0 @@
-package org.jeecg.modules.performanceappraisal;
-
-public class aa {
-}

+ 52 - 21
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -25,10 +25,8 @@ import org.jeecg.common.util.RedisUtil;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.system.entity.SysDepart;
-import org.jeecg.modules.system.entity.SysUser;
-import org.jeecg.modules.system.entity.SysUserDepart;
-import org.jeecg.modules.system.entity.SysUserRole;
+import org.jeecg.modules.system.entity.*;
+import org.jeecg.modules.system.mapper.UserCompanyMapper;
 import org.jeecg.modules.system.model.DepartIdModel;
 import org.jeecg.modules.system.model.SysUserDepartsVO;
 import org.jeecg.modules.system.service.*;
@@ -96,34 +94,41 @@ public class SysUserController {
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     public Result<IPage<SysUser>> queryPageList(SysUser user, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
-        Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
+        Result<IPage<SysUser>> result = new Result<>();
+        String realName = user.getRealname();
         QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
-        Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
+        if(null!=realName&&!"".equals(realName)){
+            queryWrapper.like("realname",realName);
+        }
+        Page<SysUser> page = new Page<>(pageNo, pageSize);
         IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);
         return result;
     }
 
+    @Autowired
+    private UserCompanyMapper userCompanyMapper;
 
     @RequestMapping(value = "/getAllUserListByCompany", method = RequestMethod.GET)
-    public Result<List<SysUserVo>> getAllUserListByCompany(String userId) {
+    public Result<List<SysUserVo>> getAllUserListByCompany() {
         Result<List<SysUserVo>> result = new Result<>();
         try {
-            /*List<SysUserVo> userList = new ArrayList<>();
-            String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
-            if (!"admin".equals(roleCode)) {
-                QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
-                userCompanyQueryWrapper.eq("user_id", userId);
-                userCompanyQueryWrapper.orderByDesc("create_time");
-                userCompanyQueryWrapper.last("limit 1");
-                UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
-                userList = sysUserService.getUserListByCompany(userCompany.getCompanyId());
-            } else {
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
+            userCompanyQueryWrapper.eq("user_id", user.getId());
+            userCompanyQueryWrapper.orderByDesc("create_time");
+            userCompanyQueryWrapper.last("limit 1");
+            UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
+            String companyId = userCompany.getCompanyId();
+            List<SysUserVo> userList;
+            if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
                 userList = sysUserService.getAllUser();
+            } else {
+                userList = sysUserService.getUserListByCompany(companyId);
             }
-*/
-            List<SysUserVo> userList = sysUserService.getAllUser();
+
+
             result.setSuccess(true);
             result.setResult(userList);
         } catch (Exception e) {
@@ -140,7 +145,19 @@ public class SysUserController {
     public Result<List<SysUserVo>> getAllList() {
         Result<List<SysUserVo>> result = new Result<>();
         try {
-            List<SysUserVo> userList = sysUserService.getAllUser();
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
+            userCompanyQueryWrapper.eq("user_id", user.getId());
+            userCompanyQueryWrapper.orderByDesc("create_time");
+            userCompanyQueryWrapper.last("limit 1");
+            UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
+            String companyId = userCompany.getCompanyId();
+            List<SysUserVo> userList;
+            if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
+                userList = sysUserService.getAllUser();
+            } else {
+                userList = sysUserService.getUserListByCompany(companyId);
+            }
             result.setSuccess(true);
             result.setResult(userList);
         } catch (Exception e) {
@@ -155,7 +172,21 @@ public class SysUserController {
     public Result<List<SysUserVo>> getSaleList() {
         Result<List<SysUserVo>> result = new Result<>();
         try {
-            List<SysUserVo> userList = sysUserService.getAllSales();
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            List<SysUserVo> userList;
+            QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
+            userCompanyQueryWrapper.eq("user_id", user.getId());
+            userCompanyQueryWrapper.orderByDesc("create_time");
+            userCompanyQueryWrapper.last("limit 1");
+            UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
+            String companyId = userCompany.getCompanyId();
+            if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
+                userList = sysUserService.getAllSales();
+            } else {
+                userList = sysUserService.getAllSalesByCompanyId(companyId);
+            }
+
+
             result.setSuccess(true);
             result.setResult(userList);
         } catch (Exception e) {

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java

@@ -80,4 +80,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
     List<SysUserVo> getUserListByCompany(@Param("companyId") String companyId);
 
     List<SysUserVo> getAllSale();
+
+    List<SysUserVo> getAllSalesByCompanyId(@Param("companyId") String companyId);
 }

+ 26 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserRoleMapper.java

@@ -18,4 +18,30 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
 
 	@Select("select role_code from sys_role where id in (select role_id from sys_user_role where user_id = (select id from sys_user where username=#{username}))")
 	List<String> getRoleByUserName(@Param("username") String username);
+
+	@Select("SELECT\n" +
+			"\tt3.user_id\n" +
+			"FROM\n" +
+			"\t(\n" +
+			"\t\tSELECT\n" +
+			"\t\t\tt2.user_id,\n" +
+			"\t\t\tt2.role_id\n" +
+			"\t\tFROM\n" +
+			"\t\t\tsys_user_depart t1\n" +
+			"\t\tLEFT JOIN sys_user_role t2 ON t1.user_id = t2.user_id\n" +
+			"\t\tWHERE\n" +
+			"\t\t\tt1.dep_id = (\n" +
+			"\t\t\t\tSELECT\n" +
+			"\t\t\t\t\tdep_id\n" +
+			"\t\t\t\tFROM\n" +
+			"\t\t\t\t\tsys_user_depart\n" +
+			"\t\t\t\tWHERE\n" +
+			"\t\t\t\t\tuser_id = #{userId}\n" +
+			"\t\t\t)\n" +
+			"\t) t3\n" +
+			"LEFT JOIN sys_role t4 ON t3.role_id = t4.id\n" +
+			"WHERE\n" +
+			"\tt4.role_code =  #{roleCode}\n")
+	String getLeaderIdByUser(@Param("userId") String userId, @Param("roleCode") String roleCode);
+
 }

+ 28 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml

@@ -94,15 +94,34 @@ SELECT
     WHERE t1.company_id = #{companyId}
     </select>
     <select id="getAllSale" resultType="cn.com.ctop.common.module.vo.SysUserVo">
-        SELECT
-            t1.id userId,
-            t1.username userName,
-            t1.realname realName,
-            t3.role_name as  roleName
-        FROM sys_user t1
-        LEFT JOIN sys_user_role t2 on t1.id = t2.user_id
-        left join sys_role t3 on t3.id = t2.role_id
-        where t3.role_name like '销售%';
+       SELECT
+	t2.id userId,
+	t2.username userName,
+	t2.realname realName,
+   t4.role_name AS roleName
+    FROM
+	user_company t1
+    LEFT JOIN sys_user t2 ON t1.user_id = t2.id
+    LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
+    LEFT JOIN sys_role t4 ON t3.role_id = t4.id
+    WHERE
+	t4.role_name LIKE '%销售%';
+    </select>
+
+
+    <select id="getAllSalesByCompanyId" resultType="cn.com.ctop.common.module.vo.SysUserVo">
+       SELECT
+	t2.id userId,
+	t2.username userName,
+	t2.realname realName,
+    t4.role_name AS roleName
+  FROM
+	user_company t1
+    LEFT JOIN sys_user t2 ON t1.user_id = t2.id
+    LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
+    LEFT JOIN sys_role t4 ON t3.role_id = t4.id
+    WHERE t1.company_id = #{companyId}
+	and t4.role_name LIKE '%销售%';
     </select>
 
 

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserRoleService.java

@@ -22,4 +22,7 @@ public interface ISysUserRoleService extends IService<SysUserRole> {
 	Map<String,String> queryUserRole();
 
 	SysUserRole getUserRoleByUserId(String userId);
+
+	String getLeaderId(String userId, String roleCode);
+
 }

+ 0 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff