Quellcode durchsuchen

修改数据库备份定时任务

syh vor 5 Jahren
Ursprung
Commit
c6ac29796e

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

@@ -12,9 +12,9 @@ import java.util.Date;
 
 @Slf4j
 public class BakDataBaseJob implements Job {
-    @Value("${spring.datasource.master.username}")
+    @Value("${spring.datasource.username}")
     private String userName;
-    @Value("${spring.datasource.master.password}")
+    @Value("${spring.datasource.password}")
     private String password;
     @Value("${jeecg.path.bak-database-file}")
     private String filePath;

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

@@ -6,6 +6,9 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+/**
+ * @author 宋英豪
+ */
 public class KuaishouCceDataJob implements Job {
     @Autowired
     private ICrawlerService crawlerService;

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.ctop.entity.Advertiser;
 import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
+import org.jeecg.modules.excelutil.entity.YdPlanAggregateEntity;
 import org.jeecg.modules.excelutil.entity.YdWeekAggregateEntity;
 
 import java.util.List;
@@ -20,5 +21,5 @@ public interface AdvertiserMapper extends BaseMapper<Advertiser> {
 
     YdWeekAggregateEntity getYdWeekStatisticInfo(@Param(value = "projectId") Long projecgId, @Param(value = "start") String lastWeekStart, @Param(value = "end") String lastWeekEnd);
 
-    List<YdWeekAggregateEntity> getYdWeekPlanStatisticInfoBtTen(@Param(value = "projectId") Long projectId, @Param(value = "start") String startDate, @Param(value = "end") String endDate, @Param(value = "accountId") Long accountId);
+    List<YdPlanAggregateEntity> getYdWeekPlanStatisticInfoAll(@Param(value = "start") String startDate, @Param(value = "end") String endDate, @Param(value = "accountId") Long accountId);
 }

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

@@ -90,8 +90,67 @@
             daily.stat_datetime &lt;= #{end}
 
     </select>
-    <select id="getYdWeekPlanStatisticInfoBtTen"
-            resultType="org.jeecg.modules.excelutil.entity.YdWeekAggregateEntity">
-
+    <select id="getYdWeekPlanStatisticInfoAll"
+            resultType="org.jeecg.modules.excelutil.entity.YdPlanAggregateEntity">
+        select
+            allocation.auth_name as accountName,
+            concat(#{start}, '至', #{end})as date,
+            daily.campaign_name as planName,
+            sum(daily.cost) as totalCost,
+            sum(daily.show_num) as show,
+            sum(daily.click) as click,
+            (case
+                when sum(daily.click)!=0 and sum(daily.show_num)!=0
+                then concat(round(sum(daily.click)/sum(daily.show_num)*100,2),'%')
+                else '0%'
+            end
+            )as clickRate,
+            (case
+                when sum(daily.cost)!=0 and sum(daily.click)!=0
+                then round(sum(daily.cost)/sum(daily.click)*100,2)
+                else 0
+                end
+            )as priceAvg,
+            (case
+                when sum(daily.cost)!=0 and sum(daily.show_num)!=0
+                then round(sum(daily.cost)/sum(daily.show_num)*1000,2)
+                else 0
+                end
+            )as ctr,
+            sum(daily.convert_num) as convert,
+            (case
+                when sum(daily.convert_num)!=0 and sum(daily.cost)!=0
+                then round(sum(daily.cost)/sum(daily.convert_num),2)
+                else 0
+                end
+            )as convertPrice,
+            (case
+                when sum(daily.convert_num)!=0 and sum(daily.click)!=0
+                then concat(round(sum(daily.convert_num)/sum(daily.click)*100,2),'%')
+                else '0%'
+                end
+            )as convertRate,
+            (
+                select
+                    group_concat(distinct plan.gender)
+                from
+                    ctop_bytedance_advertise_plan plan
+                    where plan.campaign_id = daily.campaign_id
+            )as sex,
+            (
+                select
+                    group_concat(distinct plan.platform)
+                from
+                    ctop_bytedance_advertise_plan plan
+                where
+                    plan.campaign_id = daily.campaign_id
+            )as platform
+        from ctop_bytedance_report_campaign_daily daily
+        left join ctop_user_allocation allocation on allocation.account_id = daily.advertiser_id
+        where allocation.account_id = #{accountId}
+        and allocation.account_status = 0
+        and daily.stat_datetime &gt;= #{start}
+        and daily.stat_datetime &lt;= #{end}
+        group by daily.campaign_id order by sum(daily.cost) desc
     </select>
 </mapper>

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

@@ -21,6 +21,7 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 广告主信息表
@@ -98,7 +99,10 @@ public class AdvertiserServiceImpl extends ServiceImpl<AdvertiserMapper, Adverti
             SheetInfoVo secondVo = new SheetInfoVo();
             secondVo.setSheetName("主力计划汇总");
             List<YdPlanAggregateEntity> planAggregateEntities = getYdPlanStatisticInfo(projectId, startDate, endDate);
+            secondVo.setDetails(planAggregateEntities);
+            sheetInfoVos.add(secondVo);
             //3:获取每周素材统计
+
             return null;
         } catch (ParseException e) {
             e.printStackTrace();
@@ -111,15 +115,20 @@ public class AdvertiserServiceImpl extends ServiceImpl<AdvertiserMapper, Adverti
         List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, null);
         if (null != allocations && allocations.size() > 0) {
             allocations.forEach(allocation -> {
-                List<YdWeekAggregateEntity> plans = statisticWeekInfoByAccount(allocation, startDate, endDate, projectId);
+                List<YdPlanAggregateEntity> plans = statisticWeekInfoByAccount(allocation, startDate, endDate);
+                result.addAll(plans);
             });
         }
         return result;
     }
 
-    private List<YdWeekAggregateEntity> statisticWeekInfoByAccount(UserAllocation allocation, String startDate, String endDate, Long projectId) {
-        List<YdWeekAggregateEntity> entitiesBtTens = advertiserMapper.getYdWeekPlanStatisticInfoBtTen(projectId, startDate, endDate, allocation.getAccountId());
-        return null;
+    private List<YdPlanAggregateEntity> statisticWeekInfoByAccount(UserAllocation allocation, String startDate, String endDate) {
+        List<YdPlanAggregateEntity> all = advertiserMapper.getYdWeekPlanStatisticInfoAll(startDate, endDate, allocation.getAccountId());
+        List<YdPlanAggregateEntity> big = all.parallelStream().filter(ydPlanAggregateEntity -> new BigDecimal(ydPlanAggregateEntity.getTotalCost()).compareTo(new BigDecimal("10000")) >= 0).collect(Collectors.toList());
+        if (null != big || big.size() > 0) {
+            return big;
+        }
+        return all.parallelStream().limit(5).collect(Collectors.toList());
     }
 
     @Autowired

+ 125 - 13
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/YdPlanAggregateEntity.java

@@ -18,78 +18,190 @@ public class YdPlanAggregateEntity extends BaseRowModel {
     /**
      * 投放时间
      */
-    @ExcelProperty(index = 1, value = "投放时间")
+    @ExcelProperty(index = 2, value = "投放时间")
     private String date;
 
     /**
      * 计划名称
      */
-    @ExcelProperty(index = 1, value = "计划名称")
+    @ExcelProperty(index = 3, value = "计划名称")
     private String planName;
 
     /**
      * 总花费(元)
      */
-    @ExcelProperty(index = 1, value = "总花费(元)")
+    @ExcelProperty(index = 4, value = "总花费(元)")
     private String totalCost;
 
     /**
      * 展示
      */
-    @ExcelProperty(index = 1, value = "展示")
+    @ExcelProperty(index = 5, value = "展示")
     private String show;
 
     /**
      * 点击
      */
-    @ExcelProperty(index = 1, value = "点击")
+    @ExcelProperty(index = 6, value = "点击")
     private String click;
 
     /**
      * 点击率(%)
      */
-    @ExcelProperty(index = 1, value = "点击率(%)")
+    @ExcelProperty(index = 7, value = "点击率(%)")
     private String clickRate;
 
     /**
      * 平均点击单价(元)
      */
-    @ExcelProperty(index = 1, value = "平均点击单价(元)")
+    @ExcelProperty(index = 8, value = "平均点击单价(元)")
     private String priceAvg;
 
     /**
      * 平均千次展现费用(元)
      */
-    @ExcelProperty(index = 1, value = "平均千次展现费用(元)")
+    @ExcelProperty(index = 9, value = "平均千次展现费用(元)")
     private String ctr;
 
     /**
      * 转化数
      */
-    @ExcelProperty(index = 1, value = "转化数")
+    @ExcelProperty(index = 10, value = "转化数")
     private String convert;
 
     /**
      * 转化成本
      */
-    @ExcelProperty(index = 1, value = "转化成本")
+    @ExcelProperty(index = 11, value = "转化成本")
     private String convertPrice;
 
     /**
      * 转化率(%)
      */
-    @ExcelProperty(index = 1, value = "转化率(%)")
+    @ExcelProperty(index = 12, value = "转化率(%)")
     private String convertRate;
 
     /**
      * 投放平台
      */
-    @ExcelProperty(index = 1, value = "投放平台")
+    @ExcelProperty(index = 13, value = "投放平台")
     private String platform;
 
     /**
      * 投放性别
      */
-    @ExcelProperty(index = 1, value = "投放性别")
+    @ExcelProperty(index = 14, value = "投放性别")
     private String sex;
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public void setAccountName(String accountName) {
+        this.accountName = accountName;
+    }
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public String getPlanName() {
+        return planName;
+    }
+
+    public void setPlanName(String planName) {
+        this.planName = planName;
+    }
+
+    public String getTotalCost() {
+        return totalCost;
+    }
+
+    public void setTotalCost(String totalCost) {
+        this.totalCost = totalCost;
+    }
+
+    public String getShow() {
+        return show;
+    }
+
+    public void setShow(String show) {
+        this.show = show;
+    }
+
+    public String getClick() {
+        return click;
+    }
+
+    public void setClick(String click) {
+        this.click = click;
+    }
+
+    public String getClickRate() {
+        return clickRate;
+    }
+
+    public void setClickRate(String clickRate) {
+        this.clickRate = clickRate;
+    }
+
+    public String getPriceAvg() {
+        return priceAvg;
+    }
+
+    public void setPriceAvg(String priceAvg) {
+        this.priceAvg = priceAvg;
+    }
+
+    public String getCtr() {
+        return ctr;
+    }
+
+    public void setCtr(String ctr) {
+        this.ctr = ctr;
+    }
+
+    public String getConvert() {
+        return convert;
+    }
+
+    public void setConvert(String convert) {
+        this.convert = convert;
+    }
+
+    public String getConvertPrice() {
+        return convertPrice;
+    }
+
+    public void setConvertPrice(String convertPrice) {
+        this.convertPrice = convertPrice;
+    }
+
+    public String getConvertRate() {
+        return convertRate;
+    }
+
+    public void setConvertRate(String convertRate) {
+        this.convertRate = convertRate;
+    }
+
+    public String getPlatform() {
+        return platform;
+    }
+
+    public void setPlatform(String platform) {
+        this.platform = platform;
+    }
+
+    public String getSex() {
+        return sex;
+    }
+
+    public void setSex(String sex) {
+        this.sex = sex;
+    }
 }

+ 6 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertisePlan.java

@@ -253,7 +253,12 @@ public class ByteDanceAdvertisePlan {
             if (null != platform && platform.size() > 0) {
                 String plat = "";
                 for (int i = 0; i < platform.size(); i++) {
-                    plat += platform.getString(i) + ",";
+                    String platformStr = platform.getString(i);
+                    if (platformStr.equals("IOS")) {
+                        plat += "ios,";
+                    } else {
+                        plat += "安卓,";
+                    }
                 }
                 this.platform = plat.substring(0, plat.length() - 1);
             }