浏览代码

添加穿山甲接口代码

syh 5 年之前
父节点
当前提交
0bc1c3ae46
共有 28 个文件被更改,包括 378 次插入101 次删除
  1. 1 1
      .gitignore
  2. 2 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/DramaInfoController.java
  3. 52 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/PangolinController.java
  4. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/DramaInfo.java
  5. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IDramaInfoService.java
  6. 18 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/DramaInfoServiceImpl.java
  7. 43 39
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/opencv/utils/CornerCheck.java
  8. 3 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/opencv/utils/Test.java
  9. 6 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/opencv/utils/VideoProcessing.java
  10. 0 1
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  11. 18 3
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportAppHour.java
  12. 27 3
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportBillMonth.java
  13. 24 3
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportChannelDaily.java
  14. 3 5
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/job/PangolinDataJob.java
  15. 2 4
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/job/PangolinLoginJob.java
  16. 5 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/PangolinReportAppHourMapper.java
  17. 4 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/PangolinReportChannelDailyMapper.java
  18. 36 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportAppHourMapper.xml
  19. 24 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportChannelDailyMapper.xml
  20. 4 5
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinCrawlerService.java
  21. 3 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinReportAppHourService.java
  22. 4 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinReportBillMonthService.java
  23. 4 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinReportChannelDailyService.java
  24. 12 17
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinCrawlerServiceImpl.java
  25. 32 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportAppHourServiceImpl.java
  26. 11 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportBillMonthServiceImpl.java
  27. 22 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportChannelDailyServiceImpl.java
  28. 14 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/vo/PangolinReportAppHourVO.java

+ 1 - 1
.gitignore

@@ -3,7 +3,7 @@
 ### Example user template
 
 # IntelliJ project files
-.idea/**
+.idea
 **/*.iml
 out
 gen

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

@@ -158,14 +158,8 @@ public class DramaInfoController {
 	@AutoLog(value = "剧本信息-通过id删除")
 	@ApiOperation(value="剧本信息-通过id删除", notes="剧本信息-通过id删除")
 	@DeleteMapping(value = "/delete")
-    public Result<Object> delete(@RequestParam(name = "id", required = true) String id) {
-		try {
-			dramaInfoService.removeById(id);
-		} catch (Exception e) {
-			log.error("删除失败",e.getMessage());
-			return Result.error("删除失败!");
-		}
-		return Result.ok("删除成功!");
+    public Map<String, Object> delete(@RequestParam(name = "id", required = true) String id) {
+        return dramaInfoService.delete(id);
 	}
 
 	/**

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

@@ -0,0 +1,52 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinReportAppHourService;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinReportBillMonthService;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinReportChannelDailyService;
+import com.alibaba.fastjson.JSONObject;
+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;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import java.util.Map;
+
+@RequestMapping("pangolin")
+public class PangolinController {
+    @Autowired
+    private PangolinReportAppHourService pangolinReportAppHourService;
+    @Autowired
+    private PangolinReportChannelDailyService pangolinReportChannelDailyService;
+    @Autowired
+    private PangolinReportBillMonthService pangolinReportBillMonthService;
+
+    /**
+     * 实时数据
+     */
+    @PostMapping("api/realtime")
+    public Map<String, Object> realTime() {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        return pangolinReportAppHourService.getRealTimeData(user.getId());
+    }
+
+    /**
+     * 激活统计
+     */
+    @PostMapping("api/activation/list")
+    public Map<String, Object> activationList(@RequestBody JSONObject data) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        return pangolinReportChannelDailyService.getActivationList(user.getId(), data);
+    }
+
+    /**
+     * 对账单
+     */
+    @PostMapping("/api/checkApps/list")
+    public Map<String, Object> checkAppList(@RequestBody JSONObject data) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        return pangolinReportBillMonthService.checkAppList(user.getId(), data);
+    }
+
+}

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

@@ -32,6 +32,7 @@ public class DramaInfo {
 	private Integer nonpublic;
 	private String introduction;
 	private Integer status;
+    private Integer enabled;
     /**
      * 场景
      */

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

@@ -3,6 +3,8 @@ package org.jeecg.modules.ctop.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.ctop.entity.DramaInfo;
 
+import java.util.Map;
+
 /**
  * 剧本信息
  * @author jeecg-boot
@@ -11,4 +13,5 @@ import org.jeecg.modules.ctop.entity.DramaInfo;
  */
 public interface IDramaInfoService extends IService<DramaInfo> {
 
+    Map<String, Object> delete(String id);
 }

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

@@ -1,11 +1,16 @@
 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.ctop.entity.DramaInfo;
 import org.jeecg.modules.ctop.mapper.DramaInfoMapper;
 import org.jeecg.modules.ctop.service.IDramaInfoService;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 剧本信息
  * @author jeecg-boot
@@ -14,5 +19,17 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class DramaInfoServiceImpl extends ServiceImpl<DramaInfoMapper, DramaInfo> implements IDramaInfoService {
-
+    @Override
+    public Map<String, Object> delete(String id) {
+        Map<String, Object> result = new HashMap<>();
+        DramaInfo info = this.getById(id);
+        if (null == info) {
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_DATA_NOT_EXIST);
+            return result;
+        }
+        info.setEnabled(0);
+        this.updateById(info);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
 }

+ 43 - 39
jeecg-boot-module-system/src/main/java/org/jeecg/modules/opencv/utils/CornerCheck.java

@@ -19,9 +19,7 @@ public class CornerCheck {
 
     private static int EXPAND_SIZE = 3;
     public static void main(String[] args) {
-//        harris();
-//        detectConers();
-        channelSplit();
+        detectConers();
     }
 
     public static Map<String, Object> detectConers() {
@@ -29,12 +27,15 @@ public class CornerCheck {
         try {
             System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
 
-            final int maxCorners = 50, blockSize = 3;
-            final double qualityLevel = 0.01, minDistance = 20.0, k = 0.04;
+            final int maxCorners = 10000;
+            int blockSize = 3;
+            final double qualityLevel = 0.01;
+            double minDistance = 5.0;
+            double k = 0.01;
             final boolean useHarrisDetector = false;
             MatOfPoint corners = new MatOfPoint();
 
-            Mat src = Imgcodecs.imread("D:\\data\\235.jpg");
+            Mat src = Imgcodecs.imread("D:\\data\\model\\src\\0.jpg");
             if (src.empty()) {
                 throw new Exception("no file");
             }
@@ -43,11 +44,30 @@ public class CornerCheck {
             //灰度
             Imgproc.cvtColor(src, gray, Imgproc.COLOR_RGB2GRAY);
             Mat binary = new Mat();
-            //二值化
-            Imgproc.threshold(gray, binary, 1, 255, Imgproc.THRESH_TOZERO);
+            Mat getSrc = gray;
+            Rect area = new Rect(324, 402, 218, 376);
+            Mat mask = new Mat(gray, area);
+//            mask.setTo(new Scalar(0));
+            for (int i = 0; i < 8; i++) {
+                for (int j = 0; j < 8; j++) {
+                    System.out.print(mask.get(i, j)[0]);
+                }
+                System.out.println();
+            }
+//            System.out.println("+++++++++++++++++++");
+//            mask = mask.setTo(new Scalar(0),getSrc);
+//            for(int i=0;i<8;i++){
+//                for(int j=0;j<8;j++){
+////                    System.out.print(getSrc.get(i,j)[0]);
+//                    System.out.print(mask.get(i,j)[0]);
+//                }
+//                System.out.println();
+//            }
+            //二值化mask
+            Imgproc.threshold(mask, binary, 1, 255, Imgproc.THRESH_TOZERO);
             Imgcodecs.imwrite("D:\\data\\binary.jpg", binary);
-            Imgproc.goodFeaturesToTrack(binary, corners, maxCorners, qualityLevel, minDistance,
-                    new Mat(), blockSize, useHarrisDetector, k);
+            Imgproc.goodFeaturesToTrack(binary, corners, maxCorners, qualityLevel, minDistance, new Mat()
+                    , blockSize, useHarrisDetector, k);
             Point[] pCorners = corners.toArray();
             List<Point> pointList = new ArrayList<>();
             double maxX = 0d;
@@ -55,24 +75,8 @@ public class CornerCheck {
             double minX = 10000d;
             double minY = 100000d;
             for (int i = 0; i < pCorners.length; i++) {
-                Imgproc.circle(dst, pCorners[i], 4, new Scalar(0, 0, 0), Imgproc.FILLED);
-                if (pCorners[i].x > 130 && pCorners[i].x < 570 && pCorners[i].y > 200 && pCorners[i].y < 850) {
-                    if (pCorners[i].x >= maxX) {
-                        maxX = pCorners[i].x;
-                    }
-                    if (pCorners[i].y >= maxY) {
-                        maxY = pCorners[i].y;
-                    }
-
-                    if (pCorners[i].x <= minX) {
-                        minX = pCorners[i].x;
-                    }
-
-                    if (pCorners[i].y <= minY) {
-                        minY = pCorners[i].y;
-                    }
-                    pointList.add(pCorners[i]);
-                }
+                Point p = new Point(pCorners[i].x + 324, pCorners[i].y + 402);
+                Imgproc.circle(dst, p, 2, new Scalar(0, 0, 0), Imgproc.FILLED);
             }
             Imgcodecs.imwrite("D:\\data\\allConers.jpg", dst);
             List<Point> cornerPoints = new ArrayList<>();
@@ -95,17 +99,17 @@ public class CornerCheck {
                 }
             });
             Imgcodecs.imwrite("D:\\data\\coners.jpg", dst);
-            for (Point p : cornerPoints) {
-            }
-            result.put("leftTop", cornerPoints.get(0));
-            result.put("rightBottom", cornerPoints.get(3));
-            if (cornerPoints.get(2).y > cornerPoints.get(1).y) {
-                result.put("rightTop", cornerPoints.get(1));
-                result.put("leftBottom", cornerPoints.get(2));
-            } else {
-                result.put("rightTop", cornerPoints.get(2));
-                result.put("leftBottom", cornerPoints.get(1));
-            }
+//            for (Point p : cornerPoints) {
+//            }
+//            result.put("leftTop", cornerPoints.get(0));
+//            result.put("rightBottom", cornerPoints.get(3));
+//            if (cornerPoints.get(2).y > cornerPoints.get(1).y) {
+//                result.put("rightTop", cornerPoints.get(1));
+//                result.put("leftBottom", cornerPoints.get(2));
+//            } else {
+//                result.put("rightTop", cornerPoints.get(2));
+//                result.put("leftBottom", cornerPoints.get(1));
+//            }
             ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
             return result;
         } catch (Exception e) {

+ 3 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/opencv/utils/Test.java

@@ -9,6 +9,9 @@ import org.opencv.imgproc.Imgproc;
 import java.io.File;
 
 public class Test {
+    public static void main(String[] args) {
+        VideoProcessing.grabberVideoFramer("D:\\data\\model\\模板视频.mp4", "D:\\Data\\model\\src\\");
+    }
     public static void initVideo() {
         System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
         String srcPath = "D:\\data\\images\\";
@@ -71,9 +74,4 @@ public class Test {
         }
     }
 
-
-    public static void main(String[] args) {
-        initVideo();
-    }
-
 }

+ 6 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/opencv/utils/VideoProcessing.java

@@ -60,12 +60,11 @@ public class VideoProcessing {
 
     public static void videoMerge(String videoFileName, String imagePackage) throws FrameRecorder.Exception {
         FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(videoFileName, 720, 1280);
-//
-        recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4); // 28
-//		recorder.setFormat("mp4");
-        //	recorder.setFormat("mov,mp4,m4a,3gp,3g2,mj2,h264,ogg,MPEG4");
+        // 28
+        recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);
         recorder.setFrameRate(25);
-        recorder.setPixelFormat(Avutils.AV_PIX_FMT_YUV422P); // yuv420p
+        // yuv420p
+        recorder.setPixelFormat(Avutils.AV_PIX_FMT_YUV422P);
         recorder.start();
         //
         OpenCVFrameConverter.ToIplImage conveter = new OpenCVFrameConverter.ToIplImage();
@@ -75,7 +74,8 @@ public class VideoProcessing {
         // 循环所有图片
         for (int i = 1; i <= flist.length; i++) {
             String fname = imagePackage + i + ".jpg";
-            opencv_core.IplImage image = cvLoadImage(fname); // 非常吃内存!!
+            // 非常吃内存!!
+            opencv_core.IplImage image = cvLoadImage(fname);
             recorder.record(conveter.convert(image));
             // 释放内存? cvLoadImage(fname); // 非常吃内存!!
             opencv_core.cvReleaseImage(image);

+ 0 - 1
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -36,7 +36,6 @@ public class SampleTest {
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
-
     @Test
     public void kuaisShouReport() {
         try {

+ 18 - 3
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportAppHour.java

@@ -1,20 +1,35 @@
 package cn.com.ctop.crawler.modules.pangolin.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
 
+/**
+ * 穿山甲实时数据
+ */
 @Data
 @TableName("ctop_pangolin_report_app_hour")
 public class PangolinReportAppHour {
+    /**
+     * 日期
+     */
     private Date date;
+    /**
+     * 时间
+     */
     private Integer hour;
+    /**
+     * appId
+     */
     private Long appId;
+    /**
+     * 类型
+     */
     private String type;
+    /**
+     * 数字
+     */
     private BigDecimal num;
 }

+ 27 - 3
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportBillMonth.java

@@ -1,22 +1,46 @@
 package cn.com.ctop.crawler.modules.pangolin.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.math.BigDecimal;
 
+/**
+ * 对账单
+ */
 @Data
 @TableName("ctop_pangolin_report_bill_month")
 public class PangolinReportBillMonth {
+    /**
+     * 年
+     */
     private Integer year;
+    /**
+     * 月
+     */
     private Integer month;
+    /**
+     * appId
+     */
     private Long appId;
+    /**
+     * 操作系统
+     */
     private String os;
+    /**
+     * 有效激活数
+     */
     private Integer sumInternalActivations;
+    /**
+     * 实际结算金额
+     */
     private BigDecimal actualTotalPrice;
+    /**
+     * 预估结算金额
+     */
     private BigDecimal estimatedTotalPrice;
+    /**
+     * 账户质量分
+     */
     private BigDecimal accountQualityScore;
 }

+ 24 - 3
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportChannelDaily.java

@@ -1,22 +1,43 @@
 package cn.com.ctop.crawler.modules.pangolin.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
 
+/**
+ * 穿山甲激活统计信息
+ */
 @Data
 @TableName("ctop_pangolin_report_channel_daily")
 public class PangolinReportChannelDaily {
+    /**
+     * 日期
+     */
     private Date date;
+    /**
+     * 渠道信息
+     */
     private String channelName;
+    /**
+     * 应用名称
+     */
     private String appName;
+    /**
+     * 操作系统
+     */
     private String os;
+    /**
+     * 激活数
+     */
     private Integer externalActivation;
+    /**
+     * 留存率
+     */
     private BigDecimal retentionRatio;
+    /**
+     * 预估结算金额
+     */
     private BigDecimal totalPrice;
 }

+ 3 - 5
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/job/PangolinDataJob.java

@@ -28,7 +28,7 @@ public class PangolinDataJob implements Job {
         queryWrapper.eq("status", 1);
         queryWrapper.isNotNull("cookie");
         List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
-        if (list != null && list.size() > 0) {
+        if (list != null && !list.isEmpty()) {
             for (BindAccountLogin bindAccountLogin : list) {
                 pangolinCrawlerService.getChannelList(bindAccountLogin);
                 pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
@@ -36,10 +36,8 @@ public class PangolinDataJob implements Job {
                 QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
                 queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
                 List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
-                if (appList != null && appList.size() > 0) {
-                    for (PangolinApp app : appList) {
-                        pangolinCrawlerService.getRealTimeList(bindAccountLogin, app.getId());
-                    }
+                if (appList != null && !appList.isEmpty()) {
+                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId()));
                 }
             }
         }

+ 2 - 4
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/job/PangolinLoginJob.java

@@ -23,10 +23,8 @@ public class PangolinLoginJob implements Job {
         queryWrapper.eq("status",1);
         queryWrapper.isNull("cookie");
         List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
-        if (list != null && list.size() > 0){
-            for (BindAccountLogin bindAccountLogin:list){
-                pangolinLoginService.pangolinLogin(bindAccountLogin.getAccountName(),bindAccountLogin.getPassword());
-            }
+        if (list != null && !list.isEmpty()) {
+            list.forEach(bindAccountLogin -> pangolinLoginService.pangolinLogin(bindAccountLogin.getAccountName(), bindAccountLogin.getPassword()));
         }
     }
 }

+ 5 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/PangolinReportAppHourMapper.java

@@ -1,7 +1,12 @@
 package cn.com.ctop.crawler.modules.pangolin.mapper;
 
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportAppHour;
+import cn.com.ctop.crawler.modules.pangolin.vo.PangolinReportAppHourVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface PangolinReportAppHourMapper extends BaseMapper<PangolinReportAppHour> {
+    List<PangolinReportAppHourVO> getRealTimeData(@Param(value = "userId") String userId, @Param(value = "date") String date);
 }

+ 4 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/PangolinReportChannelDailyMapper.java

@@ -2,6 +2,10 @@ package cn.com.ctop.crawler.modules.pangolin.mapper;
 
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportChannelDaily;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface PangolinReportChannelDailyMapper extends BaseMapper<PangolinReportChannelDaily> {
+    List<PangolinReportChannelDaily> getActivationList(@Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate, @Param(value = "userId") String userId, @Param(value = "type") String type);
 }

+ 36 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportAppHourMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.crawler.modules.pangolin.mapper.PangolinReportAppHourMapper">
+    <select id="getRealTimeData" resultType="cn.com.ctop.crawler.modules.pangolin.vo.PangolinReportAppHourVO">
+        select appHourActive.date as 'date',
+        appHourActive.hour as 'hour',
+        appHourActive.app_id as 'appId',
+        appHourActive.num as 'activeNum',
+        (select appHourRate.num
+        from ctop_pangolin_report_app_hour appHourRate
+        where appHourRate.date = appHourActive.date
+        and appHourRate.hour = appHourActive.hour
+        and appHourRate.type = 'rate') as 'rateNum',
+        (select appHourClick.num
+        from ctop_pangolin_report_app_hour appHourClick
+        where appHourClick.date = appHourActive.date
+        and appHourClick.hour = appHourActive.hour
+        and appHourClick.type = 'click') as 'clickNum'
+        from ctop_pangolin_report_app_hour appHourActive
+        left join ctop_pangolin_app app on app.id = appHourActive.app_id
+        left join ctop_bind_account_login login on login.account_name = app.account_name
+        where
+        1=1
+        <if test="userId!=null">
+            and login.user_id = #{userId}
+        </if>
+        and appHourActive.date = #{date}
+        and appHourActive.type = 'active'
+        group by
+        <if test="userId!=null">
+            login.user_id,
+        </if>
+        appHourActive.date,appHourActive.hour
+        order by appHourActive.hour
+    </select>
+</mapper>

+ 24 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportChannelDailyMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.crawler.modules.pangolin.mapper.PangolinReportChannelDailyMapper">
+
+    <select id="getActivationList"
+            resultType="cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportChannelDaily">
+        select
+            daily.date,
+            daily.app_name,
+            sum(daily.external_activation) as 'external_activation',
+            sum(daily.total_price)as 'total_price'
+        from
+        ctop_pangolin_report_channel_daily daily
+        left join ctop_pangolin_channel channel on channel.name = daily.channel_name
+        left join ctop_bind_account_login login on login.account_name = channel.account_name
+        where 1=1
+        and login.user_id = #{userId}
+        and daily.date &gt;= #{startDate}
+        and daily.date &lt;= #{endDate}
+        and daily.os = #{type}
+        group by daily.date
+    </select>
+
+</mapper>

+ 4 - 5
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinCrawlerService.java

@@ -1,14 +1,13 @@
 package cn.com.ctop.crawler.modules.pangolin.service;
 
 import cn.com.ctop.common.module.entity.BindAccountLogin;
-import com.baomidou.mybatisplus.extension.service.IService;
 
 public interface PangolinCrawlerService {
-    public void getCheckList(BindAccountLogin bindAccountLogin);
+    void getCheckList(BindAccountLogin bindAccountLogin);
 
-    public void getChannelList(BindAccountLogin bindAccountLogin);
+    void getChannelList(BindAccountLogin bindAccountLogin);
 
-    public void getActivationList(BindAccountLogin bindAccountLogin, String date, int page);
+    void getActivationList(BindAccountLogin bindAccountLogin, String date, int page);
 
-    public void getRealTimeList(BindAccountLogin bindAccountLogin, Long appId);
+    void getRealTimeList(BindAccountLogin bindAccountLogin, Long appId);
 }

+ 3 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinReportAppHourService.java

@@ -3,5 +3,8 @@ package cn.com.ctop.crawler.modules.pangolin.service;
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportAppHour;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Map;
+
 public interface PangolinReportAppHourService extends IService<PangolinReportAppHour> {
+    Map<String, Object> getRealTimeData(String userId);
 }

+ 4 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinReportBillMonthService.java

@@ -1,7 +1,11 @@
 package cn.com.ctop.crawler.modules.pangolin.service;
 
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportBillMonth;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Map;
+
 public interface PangolinReportBillMonthService extends IService<PangolinReportBillMonth> {
+    Map<String, Object> checkAppList(String userId, JSONObject data);
 }

+ 4 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinReportChannelDailyService.java

@@ -1,7 +1,11 @@
 package cn.com.ctop.crawler.modules.pangolin.service;
 
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportChannelDaily;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Map;
+
 public interface PangolinReportChannelDailyService extends IService<PangolinReportChannelDaily> {
+    Map<String, Object> getActivationList(String userId, JSONObject data);
 }

+ 12 - 17
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinCrawlerServiceImpl.java

@@ -5,13 +5,10 @@ import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.crawler.modules.pangolin.entity.*;
 import cn.com.ctop.crawler.modules.pangolin.service.*;
-import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
 import org.apache.http.impl.cookie.BasicClientCookie;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,16 +33,17 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
     @Autowired
     private PangolinReportAppHourService pangolinReportAppHourService;
 
+    @Override
     public void getCheckList(BindAccountLogin bindAccountLogin) {
         String url = "https://pangolin.bytedance.com/api/check_apps/list";
         ObjectMapper mapper = new ObjectMapper();
         try {
             List<String> cookieList = mapper.readValue(bindAccountLogin.getCookie(), new TypeReference<List<String>>() {
             });
-            if (cookieList != null && cookieList.size() > 0) {
+            if (cookieList != null && !cookieList.isEmpty()) {
                 for (String cookieStr : cookieList) {
                     String[] cookieArray = cookieStr.split(";");
-                    Map<String, String> cookieMap = new HashMap<String, String>();
+                    Map<String, String> cookieMap = new HashMap<>();
                     for (String cookie : cookieArray) {
                         String[] kv = cookie.split("=");
                         if (kv.length > 1) {
@@ -60,7 +58,6 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                 }
             }
             String result = HttpUtils2.httpPostRequest(url, null, null);
-            System.out.println(result);
             if (checkLogin(bindAccountLogin, result)) {
                 JsonNode resultNode = mapper.readTree(result);
                 Iterator<JsonNode> appIterator = resultNode.get("data").get("List").elements();
@@ -73,7 +70,6 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     BigDecimal actualTotalPrice = checkNode.get("ActualTotalPrice").decimalValue();
                     BigDecimal estimatedTotalPrice = checkNode.get("EstimatedTotalPrice").decimalValue();
                     BigDecimal accountQualityScore = checkNode.get("AccountQualityScore").decimalValue();
-                    String appName = checkNode.get("AppName").asText();
                     PangolinReportBillMonth pangolinReportBillMonth = new PangolinReportBillMonth();
                     pangolinReportBillMonth.setAccountQualityScore(accountQualityScore);
                     pangolinReportBillMonth.setActualTotalPrice(actualTotalPrice);
@@ -100,16 +96,17 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
         }
     }
 
+    @Override
     public void getChannelList(BindAccountLogin bindAccountLogin) {
         String url = "https://pangolin.bytedance.com/api/search/external_default";
         ObjectMapper mapper = new ObjectMapper();
         try {
             List<String> cookieList = mapper.readValue(bindAccountLogin.getCookie(), new TypeReference<List<String>>() {
             });
-            if (cookieList != null && cookieList.size() > 0) {
+            if (cookieList != null && !cookieList.isEmpty()) {
                 for (String cookieStr : cookieList) {
                     String[] cookieArray = cookieStr.split(";");
-                    Map<String, String> cookieMap = new HashMap<String, String>();
+                    Map<String, String> cookieMap = new HashMap<>();
                     for (String cookie : cookieArray) {
                         String[] kv = cookie.split("=");
                         if (kv.length > 1) {
@@ -124,7 +121,6 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                 }
             }
             String result = HttpUtils2.httpGetRequest(url);
-            System.out.println(result);
             if (checkLogin(bindAccountLogin, result)) {
                 JsonNode resultNode = mapper.readTree(result);
                 Iterator<JsonNode> appIterator = resultNode.get("data").get("AppNameList").elements();
@@ -155,16 +151,17 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
         }
     }
 
+    @Override
     public void getActivationList(BindAccountLogin bindAccountLogin, String date, int page) {
         String url = "https://pangolin.bytedance.com/api/activation/list";
         ObjectMapper mapper = new ObjectMapper();
         try {
             List<String> cookieList = mapper.readValue(bindAccountLogin.getCookie(), new TypeReference<List<String>>() {
             });
-            if (cookieList != null && cookieList.size() > 0) {
+            if (cookieList != null && !cookieList.isEmpty()) {
                 for (String cookieStr : cookieList) {
                     String[] cookieArray = cookieStr.split(";");
-                    Map<String, String> cookieMap = new HashMap<String, String>();
+                    Map<String, String> cookieMap = new HashMap<>();
                     for (String cookie : cookieArray) {
                         String[] kv = cookie.split("=");
                         if (kv.length > 1) {
@@ -190,7 +187,6 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
             paramMap.put("search", searchMap);
             paramMap.put("page", pageMap);
             String result = HttpUtils2.httpPostRequest(url, paramMap, null);
-            System.out.println(result);
             if (checkLogin(bindAccountLogin, result)) {
                 JsonNode resultNode = mapper.readTree(result);
                 Iterator<JsonNode> listIterator = resultNode.get("data").get("list").elements();
@@ -231,16 +227,17 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
         }
     }
 
+    @Override
     public void getRealTimeList(BindAccountLogin bindAccountLogin, Long appId) {
         String url = "https://pangolin.bytedance.com/api/real_time/";
         ObjectMapper mapper = new ObjectMapper();
         try {
             List<String> cookieList = mapper.readValue(bindAccountLogin.getCookie(), new TypeReference<List<String>>() {
             });
-            if (cookieList != null && cookieList.size() > 0) {
+            if (cookieList != null && !cookieList.isEmpty()) {
                 for (String cookieStr : cookieList) {
                     String[] cookieArray = cookieStr.split(";");
-                    Map<String, String> cookieMap = new HashMap<String, String>();
+                    Map<String, String> cookieMap = new HashMap<>();
                     for (String cookie : cookieArray) {
                         String[] kv = cookie.split("=");
                         if (kv.length > 1) {
@@ -261,7 +258,6 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
             paramMap.put("channelName", "");
             paramMap.put("appId", appIds);
             String result = HttpUtils2.httpPostRequest(url, paramMap, null);
-            System.out.println(result);
             if (checkLogin(bindAccountLogin, result)) {
                 JsonNode resultNode = mapper.readTree(result);
                 Iterator<String> clickIterator = resultNode.get("data").get("ChartData").get("click_num").fieldNames();
@@ -287,7 +283,6 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                         } else {
                             pangolinReportAppHourService.update(pangolinReportAppHour, queryWrapper);
                         }
-//                        pangolinReportAppHourService.saveOrUpdate(pangolinReportAppHour);
                     }
                 }
                 Iterator<String> activeIterator = resultNode.get("data").get("ChartData").get("active_num").fieldNames();

+ 32 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportAppHourServiceImpl.java

@@ -1,11 +1,43 @@
 package cn.com.ctop.crawler.modules.pangolin.service.impl;
 
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportAppHour;
 import cn.com.ctop.crawler.modules.pangolin.mapper.PangolinReportAppHourMapper;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinReportAppHourService;
+import cn.com.ctop.crawler.modules.pangolin.vo.PangolinReportAppHourVO;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @Service
 public class PangolinReportAppHourServiceImpl extends ServiceImpl<PangolinReportAppHourMapper, PangolinReportAppHour> implements PangolinReportAppHourService {
+    @Autowired
+    private PangolinReportAppHourMapper pangolinReportAppHourMapper;
+
+    @Override
+    public Map<String, Object> getRealTimeData(String userId) {
+        Map<String, Object> resultMap = new HashMap<>();
+        String today = DateUtils.formatDate();
+        //1:查询当天的数据
+        List<PangolinReportAppHourVO> todayList = this.getRealTimeData(userId, today);
+        resultMap.put("today", todayList);
+        //2:查询昨天的数据
+        List<PangolinReportAppHourVO> yestodyList = this.getRealTimeData(userId, DateUtils.addDay(today, -1));
+        resultMap.put("yesterday", yestodyList);
+        //3:查询七天前的数据
+        List<PangolinReportAppHourVO> lastSevenList = this.getRealTimeData(userId, DateUtils.addDay(today, -7));
+        resultMap.put("sevenDaysAgo", lastSevenList);
+        ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS);
+        return resultMap;
+    }
+
+    private List<PangolinReportAppHourVO> getRealTimeData(String userId, String date) {
+        return pangolinReportAppHourMapper.getRealTimeData(userId, date);
+    }
 }

+ 11 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportBillMonthServiceImpl.java

@@ -3,9 +3,20 @@ package cn.com.ctop.crawler.modules.pangolin.service.impl;
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportBillMonth;
 import cn.com.ctop.crawler.modules.pangolin.mapper.PangolinReportBillMonthMapper;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinReportBillMonthService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Map;
+
 @Service
 public class PangolinReportBillMonthServiceImpl extends ServiceImpl<PangolinReportBillMonthMapper, PangolinReportBillMonth> implements PangolinReportBillMonthService {
+    @Autowired
+    private PangolinReportBillMonthMapper pangolinReportBillMonthMapper;
+
+    @Override
+    public Map<String, Object> checkAppList(String userId, JSONObject data) {
+        return null;
+    }
 }

+ 22 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportChannelDailyServiceImpl.java

@@ -1,11 +1,33 @@
 package cn.com.ctop.crawler.modules.pangolin.service.impl;
 
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportChannelDaily;
 import cn.com.ctop.crawler.modules.pangolin.mapper.PangolinReportChannelDailyMapper;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinReportChannelDailyService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @Service
 public class PangolinReportChannelDailyServiceImpl extends ServiceImpl<PangolinReportChannelDailyMapper, PangolinReportChannelDaily> implements PangolinReportChannelDailyService {
+    @Autowired
+    private PangolinReportChannelDailyMapper pangolinReportChannelDailyMapper;
+
+    @Override
+    public Map<String, Object> getActivationList(String userId, JSONObject data) {
+        Map<String, Object> result = new HashMap<>();
+        String startDate = data.getString("startDate");
+        String endDate = data.getString("endDate");
+        String type = data.getString("type");
+        List<PangolinReportChannelDaily> dailyList = pangolinReportChannelDailyMapper.getActivationList(startDate, endDate, userId, type);
+        result.put("activationList", dailyList);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
 }

+ 14 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/vo/PangolinReportAppHourVO.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.crawler.modules.pangolin.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class PangolinReportAppHourVO {
+    private String date;
+    private Integer hour;
+    private BigDecimal clickNum;
+    private BigDecimal activeNum;
+    private BigDecimal activeRate;
+}