Browse Source

操作记录

hcst_sunzhen 4 years ago
parent
commit
40d3b556be

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

@@ -9,10 +9,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
-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 cn.com.ctop.toutiao.modules.report.service.*;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.api.R;
 import lombok.extern.slf4j.Slf4j;
@@ -858,9 +855,6 @@ public class TestController {
 
     }
 
-
-
-
     @GetMapping(value = "/getOperationRecord")
     public Result getOperationRecord(@Param("accountId")Long accountId, @Param("operationTarget")Integer operationTarget, @Param("startDate")String startDate, @Param("endDate")String endDate){
         Result result = new Result();
@@ -897,7 +891,7 @@ public class TestController {
                         public void run() {
                             log.info("获取操作记录开始:accountId:{},startDate:{},endDate:{}", token.getAccountId(), startDate, endDate);
                             kuaishouInterfaceService2.getOperationRecord(token.getAccountId(), token.getAccessToken(), operationTarget, startDate, endDate);
-                            log.info("获取操作记录开始:accountId:{}", token.getAccountId());
+                            log.info("获取操作记录结束:accountId:{}", token.getAccountId());
                      }
                     });
                 });
@@ -923,5 +917,27 @@ public class TestController {
         return result;
     }
 
+    //@Autowired
+    //public IBytedanceInterfaceService bytedanceInterfaceService;
+    //
+    //@GetMapping(value = "/searchLog")
+    //public Result searchLog(@Param("accountId")Long accountId, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("operationTarget")Integer operationTarget) {
+    //    Result result = new Result();
+    //
+    //    QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+    //    queryWrapper.eq("account_id", accountId);
+    //    CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
+    //    if (null == token) {
+    //        log.error("定时获取快手操作记录数据异常:未获取到可用的token");
+    //        result.setSuccess(false);
+    //        result.setMessage("定时获取快手操作记录数据异常:未获取到可用的toke");
+    //        return result;
+    //    }
+    //
+    //    bytedanceInterfaceService.searchLog(accountId, token, operationTarget,startDate, endDate);
+    //
+    //    return result;
+    //}
+
 
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouOperationRecord.java

@@ -38,4 +38,6 @@ public class KuaishouOperationRecord {
 	private String updateData;
 
 	private String statDate;
+
+	private String log;
 }

+ 21 - 49
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouOperationRecordMapper.xml

@@ -25,7 +25,7 @@
     </delete>
 
     <insert id="insertOperationRecordInfoAccount">
-        insert into
+        replace into
         ctop_kuaishou_operation_record_account
         (
             account_id,
@@ -36,9 +36,7 @@
             object_name,
             operation_target,
             object_id,
-            field_name,
-            original_data,
-            update_data
+            log
         )
         values
         <foreach item="record" index="index" collection="records"  separator="," >
@@ -51,9 +49,7 @@
                 #{record.objectName},
                 #{record.operationTarget},
                 #{record.objectId},
-                #{record.fieldName},
-                #{record.originalData},
-                #{record.updateData}
+                #{record.log}
             )
         </foreach>
 
@@ -86,7 +82,7 @@
     </delete>
 
     <insert id="insertOperationRecordInfoCampaign">
-        insert into
+        replace into
         ctop_kuaishou_operation_record_campaign
         (
         account_id,
@@ -97,9 +93,7 @@
         object_name,
         operation_target,
         object_id,
-        field_name,
-        original_data,
-        update_data
+        log
         )
         values
         <foreach item="record" index="index" collection="records"  separator="," >
@@ -112,9 +106,7 @@
             #{record.objectName},
             #{record.operationTarget},
             #{record.objectId},
-            #{record.fieldName},
-            #{record.originalData},
-            #{record.updateData}
+            #{record.log}
             )
         </foreach>
 
@@ -144,7 +136,7 @@
     </delete>
 
     <insert id="insertOperationRecordInfoUnit">
-        insert into
+        replace into
         ctop_kuaishou_operation_record_unit
         (
         account_id,
@@ -155,9 +147,7 @@
         object_name,
         operation_target,
         object_id,
-        field_name,
-        original_data,
-        update_data
+        log
         )
         values
         <foreach item="record" index="index" collection="records"  separator="," >
@@ -170,9 +160,7 @@
             #{record.objectName},
             #{record.operationTarget},
             #{record.objectId},
-            #{record.fieldName},
-            #{record.originalData},
-            #{record.updateData}
+            #{record.log}
             )
         </foreach>
 
@@ -204,7 +192,7 @@
     </delete>
 
     <insert id="insertOperationRecordInfoCreative">
-        insert into
+        replace into
         ctop_kuaishou_operation_record_creative
         (
         account_id,
@@ -215,9 +203,7 @@
         object_name,
         operation_target,
         object_id,
-        field_name,
-        original_data,
-        update_data
+        log
         )
         values
         <foreach item="record" index="index" collection="records"  separator="," >
@@ -230,9 +216,7 @@
             #{record.objectName},
             #{record.operationTarget},
             #{record.objectId},
-            #{record.fieldName},
-            #{record.originalData},
-            #{record.updateData}
+            #{record.log}
             )
         </foreach>
 
@@ -263,7 +247,7 @@
     </delete>
 
     <insert id="insertOperationRecordInfoVideo">
-        insert into
+        replace into
         ctop_kuaishou_operation_record_video
         (
         account_id,
@@ -274,9 +258,7 @@
         object_name,
         operation_target,
         object_id,
-        field_name,
-        original_data,
-        update_data
+        log
         )
         values
         <foreach item="record" index="index" collection="records"  separator="," >
@@ -289,9 +271,7 @@
             #{record.objectName},
             #{record.operationTarget},
             #{record.objectId},
-            #{record.fieldName},
-            #{record.originalData},
-            #{record.updateData}
+            #{record.log}
             )
         </foreach>
 
@@ -323,7 +303,7 @@
     </delete>
 
     <insert id="insertOperationRecordInfoApp">
-        insert into
+        replace into
         ctop_kuaishou_operation_record_app
         (
         account_id,
@@ -334,9 +314,7 @@
         object_name,
         operation_target,
         object_id,
-        field_name,
-        original_data,
-        update_data
+        log
         )
         values
         <foreach item="record" index="index" collection="records"  separator="," >
@@ -349,9 +327,7 @@
             #{record.objectName},
             #{record.operationTarget},
             #{record.objectId},
-            #{record.fieldName},
-            #{record.originalData},
-            #{record.updateData}
+            #{record.log}
             )
         </foreach>
 
@@ -382,7 +358,7 @@
     </delete>
 
     <insert id="insertOperationRecordInfoPackage">
-        insert into
+        replace into
         ctop_kuaishou_operation_record_package
         (
         account_id,
@@ -393,9 +369,7 @@
         object_name,
         operation_target,
         object_id,
-        field_name,
-        original_data,
-        update_data
+        log
         )
         values
         <foreach item="record" index="index" collection="records"  separator="," >
@@ -408,9 +382,7 @@
             #{record.objectName},
             #{record.operationTarget},
             #{record.objectId},
-            #{record.fieldName},
-            #{record.originalData},
-            #{record.updateData}
+            #{record.log}
             )
         </foreach>
 

+ 24 - 21
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl2.java

@@ -73,23 +73,25 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
                             String objectId = dataJson.getString("object_id");
                             String objectName = dataJson.getString("object_name");
 
-                            if (page == 1 && i==0) { //如果页数为1,删除原来的数据
-                                KuaishouOperationRecord recordDelete = new KuaishouOperationRecord();
-                                recordDelete.setStatDate(startDate);//按天删除记录
-                                recordDelete.setAccountId(advertiserId);
-                                //recordDelete.setOperationTime(operationTime);
-                                //recordDelete.setOperationType(operationType);
-                                //recordDelete.setRoleType(roleType);
-                                //recordDelete.setObjectName(objectName);
-                                //recordDelete.setOperationTarget(operationTarget);
-                                //recordDelete.setObjectId(objectId);
-                                operationRecordDelete(recordDelete,operationTarget);
-                            }
-
-                            JSONArray contentLogArray =  dataJson.getJSONArray("content_log");
-                            int jsize =  contentLogArray.size();
-                            for(int j=0; j<jsize;j++){
-                                JSONObject log = contentLogArray.getJSONObject(j);
+                            //if (page == 1 && i==0) { //如果页数为1,删除原来的数据
+                            //    KuaishouOperationRecord recordDelete = new KuaishouOperationRecord();
+                            //    recordDelete.setStatDate(startDate);//按天删除记录
+                            //    recordDelete.setAccountId(advertiserId);
+                            //    //recordDelete.setOperationTime(operationTime);
+                            //    //recordDelete.setOperationType(operationType);
+                            //    //recordDelete.setRoleType(roleType);
+                            //    //recordDelete.setObjectName(objectName);
+                            //    //recordDelete.setOperationTarget(operationTarget);
+                            //    //recordDelete.setObjectId(objectId);
+                            //    operationRecordDelete(recordDelete,operationTarget);
+                            //}
+
+                            String contentLogArrayString =  dataJson.getString("content_log");
+
+                            //int jsize =  contentLogArray.size();
+                            //for(int j=0; j<jsize;j++){
+                            //    JSONObject log = contentLogArray.getJSONObject(j);
+
                                 KuaishouOperationRecord record = new KuaishouOperationRecord();
                                 record.setAccountId(advertiserId);
                                 record.setStatDate(startDate);
@@ -99,12 +101,13 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
                                 record.setObjectName(objectName);
                                 record.setOperationTarget(operationTarget);
                                 record.setObjectId(objectId);
-                                record.setFieldName(log.getString("field_name"));
-                                record.setOriginalData(log.getString("original_data"));
-                                record.setUpdateData(log.getString("update_data"));
+                                record.setLog(contentLogArrayString);
+                                //record.setFieldName(log.getString("field_name"));
+                                //record.setOriginalData(log.getString("original_data"));
+                                //record.setUpdateData(log.getString("update_data"));
 
                                 recordList.add(record);
-                            }
+                            //}
                         }
                     }
                     if(recordList !=null && recordList.size()!=0){