Forráskód Böngészése

添加投放模块

zhaoxian 3 éve
szülő
commit
3f06864285

+ 22 - 0
pom.xml

@@ -32,6 +32,8 @@
         <commons.collections.version>3.2.2</commons.collections.version>
         <hutool-all.version>5.3.8</hutool-all.version>
         <lombok.version>1.16.20</lombok.version>
+        <gson.version>2.8.6</gson.version>
+        <pdfbox.version>2.0.15</pdfbox.version>
         <cos_api.version>5.6.25</cos_api.version>
         <poi.version>4.1.2</poi.version>
         <velocity.version>2.3</velocity.version>
@@ -160,6 +162,18 @@
                 <version>${lombok.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>com.google.code.gson</groupId>
+                <artifactId>gson</artifactId>
+                <version>${gson.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.pdfbox</groupId>
+                <artifactId>fontbox</artifactId>
+                <version>${pdfbox.version}</version>
+            </dependency>
+
             <!--cos_api-->
             <dependency>
                 <groupId>com.qcloud</groupId>
@@ -238,6 +252,13 @@
                 <version>${ruixuan.version}</version>
             </dependency>
 
+            <!-- 广告投放模块-->
+            <dependency>
+                <groupId>com.ruixuan</groupId>
+                <artifactId>ruixuan-launch</artifactId>
+                <version>${ruixuan.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 
@@ -250,6 +271,7 @@
         <module>ruixuan-common</module>
         <module>ruixuan-salesLeads</module>
         <module>ruixuan-live</module>
+        <module>ruixuan-launch</module>
     </modules>
     <packaging>pom</packaging>
 

+ 15 - 9
ruixuan-admin/pom.xml

@@ -37,7 +37,7 @@
             <version>1.6.2</version>
         </dependency>
 
-         <!-- Mysql驱动包 -->
+        <!-- Mysql驱动包 -->
         <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
@@ -62,19 +62,25 @@
         </dependency>
 
 
-         <!-- 销售线索模块-->
+        <!-- 销售线索模块-->
         <dependency>
             <groupId>com.ruixuan</groupId>
             <artifactId>ruixuan-salesLeads</artifactId>
         </dependency>
 
 
-         <!-- 直播业务模块-->
+        <!-- 直播业务模块-->
         <dependency>
             <groupId>com.ruixuan</groupId>
             <artifactId>ruixuan-live</artifactId>
         </dependency>
 
+        <!-- 直播业务模块-->
+        <dependency>
+            <groupId>com.ruixuan</groupId>
+            <artifactId>ruixuan-launch</artifactId>
+        </dependency>
+
 
     </dependencies>
 
@@ -121,15 +127,15 @@
                     </execution>
                 </executions>
             </plugin>
-            <plugin>   
-                <groupId>org.apache.maven.plugins</groupId>   
-                <artifactId>maven-war-plugin</artifactId>   
-                <version>3.1.0</version>   
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>3.1.0</version>
                 <configuration>
                     <failOnMissingWebXml>false</failOnMissingWebXml>
                     <warName>${project.artifactId}</warName>
-                </configuration>   
-           </plugin>   
+                </configuration>
+            </plugin>
         </plugins>
         <finalName>${project.artifactId}</finalName>
     </build>

+ 10 - 0
ruixuan-common/pom.xml

@@ -71,6 +71,16 @@
             <artifactId>lombok</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.pdfbox</groupId>
+            <artifactId>fontbox</artifactId>
+        </dependency>
+
         <!--cos_api-->
         <dependency>
             <groupId>com.qcloud</groupId>

+ 64 - 77
ruixuan-common/src/main/java/com/ruixuan/common/utils/DateUtils.java

@@ -18,11 +18,10 @@ import org.springframework.security.config.web.servlet.headers.HttpPublicKeyPinn
 
 /**
  * 时间工具类
- * 
+ *
  * @author ruoyi
  */
-public class DateUtils extends org.apache.commons.lang3.time.DateUtils
-{
+public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     public static String YYYY = "yyyy";
 
     public static String YYYY_MM = "yyyy-MM";
@@ -36,63 +35,52 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
 
     private static String[] parsePatterns = {
-            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", 
+            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
             "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
             "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
 
     /**
      * 获取当前Date型日期
-     * 
+     *
      * @return Date() 当前日期
      */
-    public static Date getNowDate()
-    {
+    public static Date getNowDate() {
         return new Date();
     }
 
     /**
      * 获取当前日期, 默认格式为yyyy-MM-dd
-     * 
+     *
      * @return String
      */
-    public static String getDate()
-    {
+    public static String getDate() {
         return dateTimeNow(YYYY_MM_DD);
     }
 
-    public static final String getTime()
-    {
+    public static final String getTime() {
         return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
     }
 
-    public static final String dateTimeNow()
-    {
+    public static final String dateTimeNow() {
         return dateTimeNow(YYYYMMDDHHMMSS);
     }
 
-    public static final String dateTimeNow(final String format)
-    {
+    public static final String dateTimeNow(final String format) {
         return parseDateToStr(format, new Date());
     }
 
-    public static final String dateTime(final Date date)
-    {
+    public static final String dateTime(final Date date) {
         return parseDateToStr(YYYY_MM_DD, date);
     }
 
-    public static final String parseDateToStr(final String format, final Date date)
-    {
+    public static final String parseDateToStr(final String format, final Date date) {
         return new SimpleDateFormat(format).format(date);
     }
 
-    public static final Date dateTime(final String format, final String ts)
-    {
-        try
-        {
+    public static final Date dateTime(final String format, final String ts) {
+        try {
             return new SimpleDateFormat(format).parse(ts);
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             throw new RuntimeException(e);
         }
     }
@@ -100,8 +88,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期路径 即年/月/日 如2018/08/08
      */
-    public static final String datePath()
-    {
+    public static final String datePath() {
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyy/MM/dd");
     }
@@ -109,8 +96,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期路径 即年/月/日 如20180808
      */
-    public static final String dateTime()
-    {
+    public static final String dateTime() {
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyyMMdd");
     }
@@ -118,18 +104,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期型字符串转化为日期 格式
      */
-    public static Date parseDate(Object str)
-    {
-        if (str == null)
-        {
+    public static Date parseDate(Object str) {
+        if (str == null) {
             return null;
         }
-        try
-        {
+        try {
             return parseDate(str.toString(), parsePatterns);
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             return null;
         }
     }
@@ -137,8 +118,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 获取服务器启动时间
      */
-    public static Date getServerStartDate()
-    {
+    public static Date getServerStartDate() {
         long time = ManagementFactory.getRuntimeMXBean().getStartTime();
         return new Date(time);
     }
@@ -146,16 +126,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 计算相差天数
      */
-    public static int differentDaysByMillisecond(Date date1, Date date2)
-    {
+    public static int differentDaysByMillisecond(Date date1, Date date2) {
         return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
     }
 
     /**
      * 计算两个时间差
      */
-    public static String getDatePoor(Date endDate, Date nowDate)
-    {
+    public static String getDatePoor(Date endDate, Date nowDate) {
         long nd = 1000 * 24 * 60 * 60;
         long nh = 1000 * 60 * 60;
         long nm = 1000 * 60;
@@ -176,8 +154,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 增加 LocalDateTime ==> Date
      */
-    public static Date toDate(LocalDateTime temporalAccessor)
-    {
+    public static Date toDate(LocalDateTime temporalAccessor) {
         ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
         return Date.from(zdt.toInstant());
     }
@@ -185,8 +162,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 增加 LocalDate ==> Date
      */
-    public static Date toDate(LocalDate temporalAccessor)
-    {
+    public static Date toDate(LocalDate temporalAccessor) {
         LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
         ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
         return Date.from(zdt.toInstant());
@@ -195,78 +171,71 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
 
     /**
      * 时间字符串转long类型
-     *  2022-05-01 ===>>>> 20220501
+     * 2022-05-01 ===>>>> 20220501
+     *
      * @param date
      * @return
      */
-    public static Long strDateToInt(String date){
+    public static Long strDateToInt(String date) {
 
-        return Long.valueOf(date.replaceAll("-",""));
+        return Long.valueOf(date.replaceAll("-", ""));
     }
 
 
-
-
     /**
-     *
-     * @description: 获取当前周的开始和截至时间
      * @param
+     * @description: 获取当前周的开始和截至时间
      * @return: java.util.Map
      * @author: zianY
      * @time: 2022/6/1
      */
-    public static Map getWeekBeginAndEnd(){
-        Map<String,String> timeMap = new HashMap<>();
-        String begin = parseDateToStr(YYYY_MM_DD,getBeginDayOfWeek());
-        String end = parseDateToStr(YYYY_MM_DD,getEendDayOfWeek());
-        timeMap.put("begin",begin+" 00:00:00");
-        timeMap.put("end",end+" 23:59:59");
+    public static Map getWeekBeginAndEnd() {
+        Map<String, String> timeMap = new HashMap<>();
+        String begin = parseDateToStr(YYYY_MM_DD, getBeginDayOfWeek());
+        String end = parseDateToStr(YYYY_MM_DD, getEendDayOfWeek());
+        timeMap.put("begin", begin + " 00:00:00");
+        timeMap.put("end", end + " 23:59:59");
         return timeMap;
     }
 
 
-
     /**
-     *
-     * @description: 获取本周开始时间
-     *
      * @param
+     * @description: 获取本周开始时间
      * @return: java.util.Date
      * @author: zianY
      * @time: 2022/6/1
      */
-    public static Date getBeginDayOfWeek(){
+    public static Date getBeginDayOfWeek() {
         Date date = new Date();
         Calendar cal = Calendar.getInstance();
         cal.setTime(date);
         int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
-        if (dayOfWeek ==  1){
-            dayOfWeek +=7;
+        if (dayOfWeek == 1) {
+            dayOfWeek += 7;
         }
-        cal.add(Calendar.DATE,2-dayOfWeek);
+        cal.add(Calendar.DATE, 2 - dayOfWeek);
         return cal.getTime();
     }
 
     /**
-     *
-     * @description: 获取本周结束时间
-     *
      * @param
+     * @description: 获取本周结束时间
      * @return: java.util.Date
      * @author: zianY
      * @time: 2022/6/1
      */
-    public static Date getEendDayOfWeek(){
+    public static Date getEendDayOfWeek() {
 
         Calendar cal = Calendar.getInstance();
         cal.setTime(getBeginDayOfWeek());
-        cal.add(Calendar.DAY_OF_WEEK,6);
+        cal.add(Calendar.DAY_OF_WEEK, 6);
         return cal.getTime();
     }
 
     public static void main(String[] args) {
         //System.out.println(parseDateToStr(YYYY_MM_DD,getBeginDayOfWeek()));
-       // System.out.println(parseDateToStr(YYYY_MM_DD,getEendDayOfWeek()));
+        // System.out.println(parseDateToStr(YYYY_MM_DD,getEendDayOfWeek()));
 
         System.out.println(strDateToInt("2022-05"));
     }
@@ -285,4 +254,22 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return getSDFormat(pattern).format(date);
     }
 
+
+    /**
+     * 日期转换为时间戳
+     */
+    public static long timeToStamp(String timers) {
+        Date d = new Date();
+        long timeStemp = 0;
+        try {
+            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            // 日期转换为时间戳
+            d = sf.parse(timers);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        timeStemp = d.getTime();
+        return timeStemp;
+    }
+
 }

+ 28 - 0
ruixuan-common/src/main/java/com/ruixuan/common/utils/http/HttpGetWithBodyEntity.java

@@ -0,0 +1,28 @@
+package com.ruixuan.common.utils.http;
+
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+
+import java.net.URI;
+
+public class HttpGetWithBodyEntity extends HttpEntityEnclosingRequestBase {
+    private final static String METHOD_NAME = "GET";
+
+    @Override
+    public String getMethod() {
+        return METHOD_NAME;
+    }
+
+    public HttpGetWithBodyEntity() {
+        super();
+    }
+
+    public HttpGetWithBodyEntity(final URI uri) {
+        super();
+        setURI(uri);
+    }
+
+    HttpGetWithBodyEntity(final String uri) {
+        super();
+        setURI(URI.create(uri));
+    }
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 998 - 0
ruixuan-common/src/main/java/com/ruixuan/common/utils/http/HttpUtil.java


+ 4 - 0
ruixuan-common/src/main/java/com/ruixuan/common/utils/http/HttpUtils.java

@@ -272,4 +272,8 @@ public class HttpUtils
             return true;
         }
     }
+
+
+
+
 }

+ 49 - 0
ruixuan-launch/pom.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>ruixuan</artifactId>
+        <groupId>com.ruixuan</groupId>
+        <version>3.8.2</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>ruixuan-launch</artifactId>
+
+    <description>
+        广告投放模块
+    </description>
+
+    <dependencies>
+        <!-- 通用工具-->
+        <dependency>
+            <groupId>com.ruixuan</groupId>
+            <artifactId>ruixuan-common</artifactId>
+        </dependency>
+        <!-- system-->
+        <dependency>
+            <groupId>com.ruixuan</groupId>
+            <artifactId>ruixuan-system</artifactId>
+        </dependency>
+        <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
+        <dependency>
+            <groupId>io.swagger</groupId>
+            <artifactId>swagger-models</artifactId>
+            <version>1.6.2</version>
+        </dependency>
+        <!-- excel-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.0.5</version>
+        </dependency>
+        <!-- csv -->
+        <dependency>
+            <groupId>de.siegmar</groupId>
+            <artifactId>fastcsv</artifactId>
+            <version>1.0.3</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 26 - 0
ruixuan-salesLeads/src/main/java/com.ruixuan.salesLeads/controller/DemoController.java

@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.common.core.controller.BaseController;
 import com.ruixuan.common.core.domain.AjaxResult;
 import com.ruixuan.common.core.domain.ResultResponse;
+import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.common.utils.StringUtils;
+import com.ruixuan.common.utils.http.HttpUtil;
 import com.ruixuan.common.utils.poi.ExcelUtil;
 import com.ruixuan.salesLeads.listener.ImportExcelListener;
 import com.ruixuan.salesLeads.mapper.TestMapper;
@@ -161,6 +163,30 @@ public class DemoController extends BaseController {
 
 
 
+    @ApiOperation(value = "查询报表测试")
+    @GetMapping("getLiveReportData")
+    public void getLiveReportData(Long accountId,String start_time,String end_time,Integer group_type) throws Exception {
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/gw/esp/v1/report/list";
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", "d3731e2e43ab3c45f15a1800478cae02");
+            Map<String, Object> param = new HashMap<String, Object>();
+            param.put("advertiser_id", accountId);
+            JSONObject params = new JSONObject();
+            params.put("start_time", DateUtils.timeToStamp(start_time));
+            params.put("end_time",DateUtils.timeToStamp(end_time));
+            params.put("group_type",group_type);//汇总方式	1-分日 2-分时仅时间跨度为一天的时候支持分时。仅最近 7 天支持分时查询
+            params.put("view_type",1);//查询类型	1-账户 2-计划 3-组 4-创意
+            param.put("param",params);
+            System.out.println(param);
+            String result = HttpUtil.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            System.out.println(resultJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
+    }
 
 }