Browse Source

Merge remote-tracking branch 'origin/master'

syh 5 years ago
parent
commit
a07508f1b4

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

@@ -230,6 +230,7 @@ public class TestController {
                         @Override
                         public void run() {
                             if (!Check.isNull(allocation)) {
+                                log.info("账号id:{}", allocation.getAccountId());
 
                                 QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
                                 oauthTokenQueryWrapper.eq("media_id", 2);
@@ -238,18 +239,22 @@ public class TestController {
                                 if (!Check.isNull(ctopOauthToken)) {
                                     deleteMap.put("account_id", allocation.getAccountId());
                                     deleteMap.put("stat_date", anotherDay);
-                                    reportDailyCreativeStatisticMapper.deleteByMap(deleteMap);
-                                    reportDailyCreativeMapper.deleteByMap(deleteMap);
+                                    //   reportDailyCreativeStatisticMapper.deleteByMap(deleteMap);
+                                    //  reportDailyCreativeMapper.deleteByMap(deleteMap);
 
                                     // 1.计划数据
+                                    log.info("获取计划,账号id:{}", allocation.getAccountId());
                                     kuaishouInterfaceService.getCampaignList(ctopOauthToken, null, null);
                                     // 2:广告组数据
+                                    log.info("获取广告组,账号id:{}", allocation.getAccountId());
                                     kuaishouInterfaceService.getGroupList(ctopOauthToken, null, null);
                                     // 3:创意数据
+                                    log.info("获取创意,账号id:{}", allocation.getAccountId());
                                     kuaishouInterfaceService.getCreativeList(ctopOauthToken, null, null);
 
                                     QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
                                     campaignQueryWrapper.eq("account_id", ctopOauthToken.getAccountId());
+                                    log.info("获取创意报表,账号id:{}", allocation.getAccountId());
                                     List<KuaiShouCampaign> campaigns = campaignService.list(campaignQueryWrapper);
                                     if (!Check.isNull(list)) {
                                         for (KuaiShouCampaign campaign : campaigns) {
@@ -271,6 +276,12 @@ public class TestController {
 
     }
 
+    public static void main(String[] args) throws ParseException {
+        String date = DateUtils.getDate("yyyy-MM-dd");
+        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", date, -1);
+        System.err.println(anotherDay);
+    }
+
 
     @GetMapping(value = "/getPlanAndGroupByAccount")
     public void getPlanAndGroupByAccount(Long accountId) {
@@ -279,51 +290,35 @@ public class TestController {
         oauthTokenQueryWrapper.eq("account_id", accountId);
         oauthTokenQueryWrapper.last("limit 1");
         CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
-        executorService.submit(new Runnable() {
-            @Override
-            public void run() {
-                try {
-
-                    kuaishouInterfaceService.getCampaignList(token, null, null);
-                    //1:获取全量广告组数据
-                    kuaishouInterfaceService.getGroupList(token, null, null);
-
-                    Thread.sleep(1 * 200);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        });
+        try {
+            System.err.println("获取计划,广告组:" + accountId);
+            kuaishouInterfaceService.getCampaignList(token, null, null);
+            //1:获取全量广告组数据
+            kuaishouInterfaceService.getGroupList(token, null, null);
+            System.err.println("获取计划,广告组:" + accountId);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
 
     }
 
 
-    @GetMapping(value = "/gerCreativeByAccount")
+    @GetMapping(value = "/getCreativeByAccount")
     public void gerCreative(Long accountId) {
         QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
         oauthTokenQueryWrapper.eq("media_id", 2);
         oauthTokenQueryWrapper.eq("account_id", accountId);
         oauthTokenQueryWrapper.last("limit 1");
         CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
-        executorService.submit(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    System.err.println("获取创意,accountId:" + token.getAccountId());
-                    // 1.计划数据
-                    kuaishouInterfaceService.getCampaignList(token, null, null);
-                    // 2:广告组数据
-                    kuaishouInterfaceService.getGroupList(token, null, null);
-                    // 3:创意数据
-                    kuaishouInterfaceService.getCreativeList(token, null, null);
 
-                    Thread.sleep(1 * 200);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        });
+        try {
+            System.err.println("获取创意,accountId:" + token.getAccountId());
+            kuaishouInterfaceService.getCreativeList(token, null, null);
+            System.err.println("获取创意结束,accountId:" + token.getAccountId());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
 
     }
@@ -346,8 +341,6 @@ public class TestController {
                 CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
                 System.err.println("创意报表accountId:" + ctopOauthToken.getAccountId());
                 kuaishouInterfaceService.getAdvertiserCreativeReportDaily(ctopOauthToken, startDate, endDate);
-
-
             }
         };
         thread.start();

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java

@@ -340,11 +340,14 @@ public class HttpUtils {
         String strReturn = "";
         try {
             HttpPost httppost = new HttpPost(url);
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(120000).setConnectTimeout(120000).build();
+            httppost.setConfig(requestConfig);
             if (!Check.isNullMap(headers)) {
                 for (String key : headers.keySet()) {
                     httppost.setHeader(key, headers.get(key));
                 }
             }
+
             httppost.setHeader("User-Agent", USER_AGENT);
             if (!Check.isNull(body)) {
                 httppost.setEntity(new StringEntity(body, Charset.forName("UTF-8")));

+ 2 - 1
module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceCreativeDailyReportMapper.java

@@ -3,6 +3,7 @@ package cn.com.ctop.bytedance.mapper;
 import cn.com.ctop.bytedance.entity.BytedanceCreativeDailyReport;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
+import retrofit2.http.PartMap;
 
 import java.util.List;
 import java.util.Map;
@@ -14,7 +15,7 @@ import java.util.Map;
  * @Version: V1.0
  */
 public interface BytedanceCreativeDailyReportMapper extends BaseMapper<BytedanceCreativeDailyReport> {
-    List<BytedanceCreativeDailyReport> bytedanceCreativeDailyReport(Map<String, Object> paramsMap);
+    List<BytedanceCreativeDailyReport> bytedanceCreativeDailyReport(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
 
     List<BytedanceCreativeDailyReport> bytedanceCreativeAccountReport(Map<String, Object> paramsMap);
 

+ 6 - 8
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceCreativeDailyReportMapper.xml

@@ -29,7 +29,7 @@
         left join ctop_bytedance_creative t3 on t2.creative_id = t3.id
         left join ctop_bytedance_video_info t4 on t3.video_id = t4.id
         where
-        t3.id is not NULL
+        t3.id is not NULL and t4.id is not null
         and t1.media_id = '1'
         and t1.account_id != ''
         <if test="userId != null">
@@ -37,14 +37,13 @@
         </if>
 
         <if test="startDate != null">
-            and t2.stat_datetime &gt;= #{startDate}
+            and date_format(t2.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
         </if>
         <if test="endDate != null">
-            and t2.stat_datetime &lt;= #{endDate}
+            and date_format(t2.stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
         </if>
         group by t4.signature
         order by sum(t2.cost) desc
-        limit 100
     </select>
 
     <select id="bytedanceCreativeAccountReport" parameterType="Map"
@@ -79,18 +78,17 @@
                  open="(" separator="," close=")">
             #{item}
         </foreach>
+        and t3.id is not NULL and t4.id is not null
         and t1.media_id = '1'
-        and t1.account_id != ''
         <if test="startDate != null">
-            and t2.stat_datetime &gt;= #{startDate}
+            and date_format(t2.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
         </if>
         <if test="endDate != null">
-            and t2.stat_datetime &lt;= #{endDate}
+            and date_format(t2.stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
         </if>
         and t3.id is not NULL
         group by t4.signature
         order by sum(t2.cost) desc
-        limit 100
     </select>
 
     <insert id="replaceBatch">

+ 10 - 7
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceCreativeDailyReportServiceImpl.java

@@ -2,6 +2,7 @@ package cn.com.ctop.bytedance.service.impl;
 
 import cn.com.ctop.bytedance.entity.BytedanceCreativeDailyReport;
 import cn.com.ctop.bytedance.mapper.BytedanceCreativeDailyReportMapper;
+import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
 import cn.com.ctop.bytedance.service.IBytedanceCreativeDailyReportService;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONArray;
@@ -24,21 +25,23 @@ import java.util.Map;
 public class BytedanceCreativeDailyReportServiceImpl extends ServiceImpl<BytedanceCreativeDailyReportMapper, BytedanceCreativeDailyReport> implements IBytedanceCreativeDailyReportService {
     @Autowired
     private BytedanceCreativeDailyReportMapper bytedanceCreativeDailyReportMapper;
+    @Autowired
+    private MaterialReportMapper materialReportMapper;
 
     @Override
     public List<BytedanceCreativeDailyReport> bytedanceCreativeDailyReportList(JSONObject json) {
         String userId = json.getString("userId");
+        String startDate = json.getString("startDate");
+        String endDate = json.getString("endDate");
         if (Check.isNull(userId)) {
             return null;
         }
-        String nowDate = json.getString("startDate");
-        String endDate = json.getString("endDate");
-        Map<String, Object> paramsMap = new HashMap<>();
-        paramsMap.put("userId", userId);
-        paramsMap.put("startDate", nowDate);
-        paramsMap.put("endDate", endDate);
+        String roleCode = materialReportMapper.getRoleCodeByUserId(json.getString("userId"));
+        if (!"admin".equals(roleCode)) {
+            userId = "";
+        }
 
-        return bytedanceCreativeDailyReportMapper.bytedanceCreativeDailyReport(paramsMap);
+        return bytedanceCreativeDailyReportMapper.bytedanceCreativeDailyReport(userId, startDate, endDate);
     }
 
     @Override

+ 3 - 3
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

@@ -16,7 +16,7 @@
             d4.id as plane_id,
             d4.realname as plane_name
         from ctop_kuaishou_report_daily_creative_statistic a
-        left join ctop_material_info b on a.signature = b.code
+        left join (select id, create_time ,code from ctop_material_info group by code) b on a.signature = b.code
         left join ctop_material_ascription c on b.id = c.material_id
         left join sys_user d1 on c.clip_id = d1.id
         left join sys_user d2 on c.shot_id = d2.id
@@ -481,7 +481,7 @@
         ctop_bytedance_report_creative_daily a
         left join ctop_bytedance_creative b on a.creative_id = b.id
         left join ctop_bytedance_video_info c on b.video_id = c.id
-        left join ctop_material_info d on c.signature = d.code
+        left join (select id, create_time ,code from ctop_material_info group by code) d on c.signature = d.code
         left join ctop_material_ascription e on d.id = e.material_id
         left join sys_user f1 on e.clip_id = f1.id
         left join sys_user f2 on e.shot_id = f2.id
@@ -492,7 +492,7 @@
         date_format(a.stat_datetime, '%Y-%m-%d') &gt;= #{startTime} and
         date_format(a.stat_datetime, '%Y-%m-%d') &lt;= #{endTime} and
         date_format(d.create_time, '%Y-%m-%d') &gt;= #{startDate} and
-        date_format(d.update_time, '%Y-%m-%d') &lt;= #{endDate}
+        date_format(d.create_time, '%Y-%m-%d') &lt;= #{endDate}
         group by c.signature
         having sum(a.cost) >= 5000
     </select>