Browse Source

操作记录、调操作记录接口code为500000时重调、素材时报获取全部账户

huangxuechao 3 years ago
parent
commit
43ab69ea61

+ 1 - 2
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -1,6 +1,5 @@
 server:
-  port: 8088
-  ip: 39.97.120.42
+  port: 8806
   servlet:
     context-path: /jeecg-boot
     compression:

+ 194 - 3
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -4,8 +4,13 @@ import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOperationRecord;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouOperationRecordMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService2;
+import cn.com.ctop.kuaishou.modules.batch.service.impl.KuaishouInterfaceServiceImpl2;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAccountMaterialReportDaily;
@@ -16,6 +21,8 @@ import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
 import cn.com.ctop.toutiao.modules.report.service.*;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -28,9 +35,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
 import java.text.ParseException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -79,6 +84,8 @@ public class SampleTest {
     @Autowired
     private IETLReportBytedanceVideoService etlReportBytedanceVideoService;
 
+
+
     @Test
     public void loadKuaishouCookie() throws ParseException {
         CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1700996735138951L);
@@ -271,5 +278,189 @@ public class SampleTest {
         countDownLatch.await();
         System.out.println("数据获取完成");
     }
+    @Test
+    public void loadKuaiShouMatHourlyData() throws InterruptedException{
+//        kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(7411077l, tokenService.getOauthTokenByAccountId("7411077").getAccessToken(), "2021-07-02", "2021-07-02", "HOURLY", 1);
+
+        String startDate = "2021-07-19";
+        String endDate = "2021-07-19";
+        System.out.println(DateUtils.now());
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        System.out.println(tokens.size());
+        countDownLatch = new CountDownLatch(tokens.size());
+        tokens.forEach(token -> executorService.submit(() -> {
+            try {
+                kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), startDate, endDate, "HOURLY", 1);
+            }catch (Exception e){
+            }finally {
+                countDownLatch.countDown();
+            }
+        }));
+        countDownLatch.await();
+        System.out.println("数据获取完成");
+        System.out.println(DateUtils.now());
+    }
+
+    @Autowired
+    IKuaishouInterfaceService2 kuaishouInterfaceService2;
+    @Resource
+    private KuaishouOperationRecordMapper kuaishouOperationRecordMapper;
+
+
+    @Test
+    public void dealOperationRecordData() throws InterruptedException {
+        Date beginDate = DateUtils.parseDate("2021-06-01", "yyyy-MM-dd");
+        Date endDate = DateUtils.parseDate("2021-07-19", "yyyy-MM-dd");
+//        Date beginDate = DateUtils.parseDate("2020-04-21", "yyyy-MM-dd");
+//        Date endDate = DateUtils.parseDate("2021-07-17", "yyyy-MM-dd");
+
+        int recordsCount = 0;
+        int newRecordCount = 0;
+
+        while (beginDate.before(endDate)){
+            System.out.println("开始拆分数据,当前时间为:" + beginDate);
+//            List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectCreativeRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));    //开始拆分数据,当前时间为:Tue Apr 28 00:00:00 CST 2020
+//            List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectAccountRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
+//            List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectAppRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
+//            List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectCampaignRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));  //已执行完毕
+//            List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectPackageRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
+            List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectUnitRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));    //已执行完毕
+//            List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectVideoRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
+            if(Check.isNull(records)){
+                System.out.print("     -> 今日的数据为空!!!");
+                beginDate = DateUtils.addDay(beginDate, 1);
+                continue;
+            }
+            recordsCount += records.size();
+            countDownLatch = new CountDownLatch(records.size());
+
+            List<KuaishouOperationRecord> newRecords = new ArrayList<>();
+
+            records.forEach(record -> executorService.submit(() -> {
+                try{
+                    String log = record.getLog();
+                    JSONArray jsonArray = JSONArray.parseArray(log);
+                    for(int i=0;i<jsonArray.size();i++){
+                        JSONObject object = jsonArray.getJSONObject(i);
+                        String originalData = object.getString("original_data");
+                        String updateData = object.getString("update_data");
+                        String fieldName = object.getString("field_name");
+                        KuaishouOperationRecord newRecord = new KuaishouOperationRecord(record);
+                        newRecord.setOriginalData(originalData);
+                        newRecord.setUpdateData(updateData);
+                        newRecord.setFieldName(fieldName);
+
+                        if("".equals(newRecord.getOriginalData()) && "".equals(newRecord.getUpdateData())){
+                            continue;
+                        }
+                        newRecords.add(newRecord);
+                    }
+                }catch (Exception e){
+                }finally {
+
+                    countDownLatch.countDown();
+            }}));
+            countDownLatch.await();
+            newRecordCount += newRecords.size();
+            this.saveOperationRecordListToDb(newRecords);
+            beginDate = DateUtils.addDay(beginDate, 1);
+        }
+        System.out.println("---------------------------------------------------------------");
+        System.out.println("------------获取数据结束"+recordsCount+"条原始数据变成了"+newRecordCount+"条数据------------");
+        System.out.println("---------------------------------------------------------------");
+    }
+
+    private void saveOperationRecordListToDb(List<KuaishouOperationRecord> records) {
+        if (Check.isNull(records)) {
+            return;
+        }
+
+        List<KuaishouOperationRecord> batchList = new ArrayList<>();
+        records.removeAll(Collections.singleton(null));
+        Integer operationTarget = records.get(0).getOperationTarget();
+
+
+
+        for (KuaishouOperationRecord sumPosition : records) {
+            batchList.add(sumPosition);
+
+            if (batchList.size() >= 1000) {
+                if (operationTarget == 1) {
+                    kuaishouOperationRecordMapper.insertOperationRecordInfoAccountNew(batchList);
+                } else if (operationTarget == 2) {
+                    kuaishouOperationRecordMapper.insertOperationRecordInfoCampaignNew(batchList);
+                } else if (operationTarget == 3) {
+                    kuaishouOperationRecordMapper.insertOperationRecordInfoUnitNew(batchList);
+                } else if (operationTarget == 4) {
+                    kuaishouOperationRecordMapper.insertOperationRecordInfoCreativeNew(batchList);
+                } else if (operationTarget == 5) {
+                    kuaishouOperationRecordMapper.insertOperationRecordInfoVideoNew(batchList);
+                } else if (operationTarget == 6) {
+                    kuaishouOperationRecordMapper.insertOperationRecordInfoAppNew(batchList);
+                } else if (operationTarget == 7) {
+                    kuaishouOperationRecordMapper.insertOperationRecordInfoPackageNew(batchList);
+                } else {
+                    System.out.println("未知的目标类型!");
+                }
+                batchList.clear();
+            }
+        }
+        if (!batchList.isEmpty()) {
+
+            if (operationTarget == 1) {
+                kuaishouOperationRecordMapper.insertOperationRecordInfoAccountNew(batchList);
+            } else if (operationTarget == 2) {
+                kuaishouOperationRecordMapper.insertOperationRecordInfoCampaignNew(batchList);
+            } else if (operationTarget == 3) {
+                kuaishouOperationRecordMapper.insertOperationRecordInfoUnitNew(batchList);
+            } else if (operationTarget == 4) {
+                kuaishouOperationRecordMapper.insertOperationRecordInfoCreativeNew(batchList);
+            } else if (operationTarget == 5) {
+                kuaishouOperationRecordMapper.insertOperationRecordInfoVideoNew(batchList);
+            } else if (operationTarget == 6) {
+                kuaishouOperationRecordMapper.insertOperationRecordInfoAppNew(batchList);
+            } else if (operationTarget == 7) {
+                kuaishouOperationRecordMapper.insertOperationRecordInfoPackageNew(batchList);
+            } else {
+                System.out.println("未知的目标类型!");
+            }
+            batchList.clear();
+        }
+
+    }
+    @Autowired
+    KuaishouInterfaceServiceImpl2 kuaishouInterfaceServiceImpl2;
+
+    @Test
+    public void getUnitData(){
+        List<Long> accountIdList = new ArrayList<>();
+        accountIdList.add(9556188l);
+        accountIdList.add(9677284l);
+        accountIdList.add(9677304l);
+        accountIdList.add(10072135l);
+        accountIdList.add(9901975l);
+        accountIdList.add(9677344l);
+        accountIdList.add(9901956l);
+        accountIdList.add(9556431l);
+        accountIdList.add(9767055l);
+        accountIdList.add(10248827l);
+
+        Date beginDate = DateUtils.parseDate("2021-06-01", "yyyy-MM-dd");
+        Date endDate = DateUtils.parseDate("2021-07-19", "yyyy-MM-dd");
+
+        while (beginDate.before(endDate)){
+            for(Long accountId : accountIdList){
+                kuaishouInterfaceServiceImpl2.getOperationRecord( accountId,
+                        tokenService.getOauthTokenByAccountId(String.valueOf(accountId)).getAccessToken(),
+                        3,
+                        DateUtils.formatDate(beginDate,"yyyy-MM-dd"),
+                        DateUtils.formatDate(beginDate,"yyyy-MM-dd"));
+                System.out.println("获取完毕 -> accountId:" + accountId +",日期:" + DateUtils.formatDate(beginDate,"yyyy-MM-dd"));
+
+            }
+            beginDate = DateUtils.addDay(beginDate, 1);
+        }
+        System.out.println("走完了~");
+    }
 
 }

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -159,7 +159,7 @@
         <if test="offlineFlag!=null">
             and matInfo.offline_flag = #{offlineFlag}
         </if>
-        <if test="status=1">
+        <if test="status==1">
             order by matInfo.confirm_time desc
         </if>
         <if test="status!=1">

+ 42 - 34
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouMatDailyReportJob.java

@@ -51,8 +51,6 @@ public class KuaishouMatDailyReportJob {
         }));
         XxlJobHelper.log("快手物料数据同步完成");
     }
-
-
     /**
      * 素材时报
      *
@@ -60,43 +58,53 @@ public class KuaishouMatDailyReportJob {
      */
     @XxlJob("kuaishouMaterialHourReportByStateDate")
     public void kuaishouMaterialHourReportByStateDate() throws Exception {
-        //增加接口的开始和结束日期
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
         String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
         //1:查询当日数据
-        QueryWrapper<KuaiShouProjectData> queryWrapper = new QueryWrapper();
-        queryWrapper.eq("project_status", 0);
-        List<KuaiShouProjectData> list = kuaiShouProjectDataService.list(queryWrapper);
-        if (Check.isNull(list)) {
-            return;
-        }
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(() -> {
+            kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), yesterday, yesterday, "HOURLY", 1);
+        }));
+        XxlJobHelper.log("快手素材时报同步完成");
+        //增加接口的开始和结束日期
+//        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+//        String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+//        //1:查询当日数据
+//        QueryWrapper<KuaiShouProjectData> queryWrapper = new QueryWrapper();
+//        queryWrapper.eq("project_status", 0);
+//        List<KuaiShouProjectData> list = kuaiShouProjectDataService.list(queryWrapper);
+//        if (Check.isNull(list)) {
+//            return;
+//        }
+//
+//        for (KuaiShouProjectData projectData : list) {
+//            Long projectId = projectData.getProjectId();
+//            if (Check.isNull(projectId)) {
+//                continue;
+//            }
+//            QueryWrapper<UserAllocation> allocationQueryWrapper = new QueryWrapper<>();
+//            allocationQueryWrapper.eq("project_id", projectId);
+//            allocationQueryWrapper.eq("account_status", 0);
+//            List<UserAllocation> accountIds = allocationService.list(allocationQueryWrapper);
+//            if (Check.isNull(accountIds)) {
+//                continue;
+//            }
+//            for (UserAllocation allocation : accountIds) {
+//                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
+//                if (Check.isNull(token)) {
+//                    continue;
+//                }
+//
+//                hourExecutorService.submit(new Runnable() {
+//                    @Override
+//                    public void run() {
+//                        kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), yesterday, yesterday, "HOURLY", 1);
+//                    }
+//                });
+//            }
+//        }
 
-        for (KuaiShouProjectData projectData : list) {
-            Long projectId = projectData.getProjectId();
-            if (Check.isNull(projectId)) {
-                continue;
-            }
-            QueryWrapper<UserAllocation> allocationQueryWrapper = new QueryWrapper<>();
-            allocationQueryWrapper.eq("project_id", projectId);
-            allocationQueryWrapper.eq("account_status", 0);
-            List<UserAllocation> accountIds = allocationService.list(allocationQueryWrapper);
-            if (Check.isNull(accountIds)) {
-                continue;
-            }
-            for (UserAllocation allocation : accountIds) {
-                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
-                if (Check.isNull(token)) {
-                    continue;
-                }
 
-                hourExecutorService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), yesterday, yesterday, "HOURLY", 1);
-                    }
-                });
-            }
-        }
     }
 
 }

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

@@ -40,4 +40,24 @@ public class KuaishouOperationRecord {
 	private String statDate;
 
 	private String log;
+
+	public KuaishouOperationRecord(){}
+
+	public KuaishouOperationRecord(KuaishouOperationRecord record){
+		this.accountId = record.getAccountId();
+
+		this.operationTime = record.getOperationTime();
+
+		this.operationType = record.getOperationType();
+
+		this.roleType = record.getRoleType();
+
+		this.objectName = record.getObjectName();
+
+		this.operationTarget = record.getOperationTarget();
+
+		this.objectId = record.getObjectId();
+
+		this.statDate = record.getStatDate();
+	}
 }

+ 43 - 11
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouOperationRecordMapper.java

@@ -12,30 +12,62 @@ public interface KuaishouOperationRecordMapper extends BaseMapper<KuaishouOperat
 
     void deleteOperationRecordInfoAccount(@Param("record")KuaishouOperationRecord record);
 
-    void insertOperationRecordInfoAccount(@Param("records")List<KuaishouOperationRecord> records);
-
     void deleteOperationRecordInfoCampaign(@Param("record")KuaishouOperationRecord record);
 
-    void insertOperationRecordInfoCampaign(@Param("records")List<KuaishouOperationRecord> records);
-
     void deleteOperationRecordInfoUnit(@Param("record")KuaishouOperationRecord record);
 
-    void insertOperationRecordInfoUnit(@Param("records")List<KuaishouOperationRecord> records);
-
     void deleteOperationRecordInfoCreative(@Param("record")KuaishouOperationRecord record);
 
-    void insertOperationRecordInfoCreative(@Param("records")List<KuaishouOperationRecord> records);
-
     void deleteOperationRecordInfoVideo(@Param("record")KuaishouOperationRecord record);
 
-    void insertOperationRecordInfoVideo(@Param("records")List<KuaishouOperationRecord> records);
+    void deleteOperationRecordInfoPackage(@Param("record")KuaishouOperationRecord record);
 
     void deleteOperationRecordInfoApp(@Param("record")KuaishouOperationRecord record);
 
-    void insertOperationRecordInfoApp(@Param("records")List<KuaishouOperationRecord> records);
 
-    void deleteOperationRecordInfoPackage(@Param("record")KuaishouOperationRecord record);
+
+    void insertOperationRecordInfoAccount(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoCampaign(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoUnit(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoCreative(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoVideo(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoApp(@Param("records")List<KuaishouOperationRecord> records);
 
     void insertOperationRecordInfoPackage(@Param("records")List<KuaishouOperationRecord> records);
 
+
+
+    List<KuaishouOperationRecord> selectCreativeRecordByStatDate(@Param("date") String date);
+
+    List<KuaishouOperationRecord> selectAccountRecordByStatDate(@Param("date") String date);
+
+    List<KuaishouOperationRecord> selectAppRecordByStatDate(@Param("date") String date);
+
+    List<KuaishouOperationRecord> selectCampaignRecordByStatDate(@Param("date") String date);
+
+    List<KuaishouOperationRecord> selectPackageRecordByStatDate(@Param("date") String date);
+
+    List<KuaishouOperationRecord> selectUnitRecordByStatDate(@Param("date") String date);
+
+    List<KuaishouOperationRecord> selectVideoRecordByStatDate(@Param("date") String date);
+
+    void insertOperationRecordInfoAccountNew(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoCampaignNew(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoUnitNew(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoCreativeNew(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoVideoNew(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoAppNew(@Param("records")List<KuaishouOperationRecord> records);
+
+    void insertOperationRecordInfoPackageNew(@Param("records")List<KuaishouOperationRecord> records);
+
 }

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

@@ -388,5 +388,272 @@
 
     </insert>
 
+    <select id="selectCreativeRecordByStatDate" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOperationRecord">
+        select * from ctop_kuaishou_operation_record_creative where stat_date = #{date}
+    </select>
+
+    <select id="selectAccountRecordByStatDate" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOperationRecord">
+        select * from ctop_kuaishou_operation_record_account where stat_date = #{date}
+    </select>
+    <select id="selectAppRecordByStatDate" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOperationRecord">
+        select * from ctop_kuaishou_operation_record_app where stat_date = #{date}
+    </select>
+    <select id="selectCampaignRecordByStatDate" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOperationRecord">
+        select * from ctop_kuaishou_operation_record_campaign where stat_date = #{date}
+    </select>
+    <select id="selectPackageRecordByStatDate" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOperationRecord">
+        select * from ctop_kuaishou_operation_record_package where stat_date = #{date}
+    </select>
+    <select id="selectUnitRecordByStatDate" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOperationRecord">
+        select * from ctop_kuaishou_operation_record_unit where stat_date = #{date}
+    </select>
+    <select id="selectVideoRecordByStatDate" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOperationRecord">
+        select * from ctop_kuaishou_operation_record_video where stat_date = #{date}
+    </select>
+
+
+    <insert id="insertOperationRecordInfoAccountNew">
+        replace into
+        ctop_kuaishou_operation_record_account_new
+        (
+        account_id,
+        stat_date,
+        operation_time,
+        operation_type,
+        role_type,
+        account_name,
+        operation_target,
+        field_name,
+        original_data,
+        update_data
+        )
+        values
+        <foreach item="record" index="index" collection="records"  separator="," >
+            (
+            #{record.accountId},
+            #{record.statDate},
+            #{record.operationTime},
+            #{record.operationType},
+            #{record.roleType},
+            #{record.objectName},
+            #{record.operationTarget},
+            #{record.fieldName},
+            #{record.originalData},
+            #{record.updateData}
+            )
+        </foreach>
+
+    </insert>
+
+    <insert id="insertOperationRecordInfoCampaignNew">
+        replace into
+        ctop_kuaishou_operation_record_campaign_new
+        (
+        account_id,
+        stat_date,
+        operation_time,
+        operation_type,
+        role_type,
+        campaign_name,
+        operation_target,
+        campaign_id,
+        field_name,
+        original_data,
+        update_data
+        )
+        values
+        <foreach item="record" index="index" collection="records"  separator="," >
+            (
+            #{record.accountId},
+            #{record.statDate},
+            #{record.operationTime},
+            #{record.operationType},
+            #{record.roleType},
+            #{record.objectName},
+            #{record.operationTarget},
+            #{record.objectId},
+            #{record.fieldName},
+            #{record.originalData},
+            #{record.updateData}
+            )
+        </foreach>
+
+    </insert>
+
+    <insert id="insertOperationRecordInfoUnitNew">
+        replace into
+        ctop_kuaishou_operation_record_unit_new
+        (
+        account_id,
+        stat_date,
+        operation_time,
+        operation_type,
+        role_type,
+        unit_name,
+        operation_target,
+        unit_id,
+        field_name,
+        original_data,
+        update_data
+        )
+        values
+        <foreach item="record" index="index" collection="records"  separator="," >
+            (
+            #{record.accountId},
+            #{record.statDate},
+            #{record.operationTime},
+            #{record.operationType},
+            #{record.roleType},
+            #{record.objectName},
+            #{record.operationTarget},
+            #{record.objectId},
+            #{record.fieldName},
+            #{record.originalData},
+            #{record.updateData}
+            )
+        </foreach>
+
+    </insert>
+
+    <insert id="insertOperationRecordInfoCreativeNew">
+        replace into
+        ctop_kuaishou_operation_record_creative_new
+        (
+        account_id,
+        stat_date,
+        operation_time,
+        operation_type,
+        role_type,
+        creative_name,
+        operation_target,
+        creative_id,
+        field_name,
+        original_data,
+        update_data
+        )
+        values
+        <foreach item="record" index="index" collection="records"  separator="," >
+            (
+            #{record.accountId},
+            #{record.statDate},
+            #{record.operationTime},
+            #{record.operationType},
+            #{record.roleType},
+            #{record.objectName},
+            #{record.operationTarget},
+            #{record.objectId},
+            #{record.fieldName},
+            #{record.originalData},
+            #{record.updateData}
+            )
+        </foreach>
+
+    </insert>
+
+
+    <insert id="insertOperationRecordInfoVideoNew">
+        replace into
+        ctop_kuaishou_operation_record_video_new
+        (
+        account_id,
+        stat_date,
+        operation_time,
+        operation_type,
+        role_type,
+        video_name,
+        operation_target,
+        video_id,
+        field_name,
+        original_data,
+        update_data
+        )
+        values
+        <foreach item="record" index="index" collection="records"  separator="," >
+            (
+            #{record.accountId},
+            #{record.statDate},
+            #{record.operationTime},
+            #{record.operationType},
+            #{record.roleType},
+            #{record.objectName},
+            #{record.operationTarget},
+            #{record.objectId},
+            #{record.fieldName},
+            #{record.originalData},
+            #{record.updateData}
+            )
+        </foreach>
+
+    </insert>
+
 
+    <insert id="insertOperationRecordInfoAppNew">
+        replace into
+        ctop_kuaishou_operation_record_app_new
+        (
+        account_id,
+        stat_date,
+        operation_time,
+        operation_type,
+        role_type,
+        app_name,
+        operation_target,
+        app_id,
+        field_name,
+        original_data,
+        update_data
+        )
+        values
+        <foreach item="record" index="index" collection="records"  separator="," >
+            (
+            #{record.accountId},
+            #{record.statDate},
+            #{record.operationTime},
+            #{record.operationType},
+            #{record.roleType},
+            #{record.objectName},
+            #{record.operationTarget},
+            #{record.objectId},
+            #{record.fieldName},
+            #{record.originalData},
+            #{record.updateData}
+            )
+        </foreach>
+
+    </insert>
+
+    <insert id="insertOperationRecordInfoPackageNew">
+        replace into
+        ctop_kuaishou_operation_record_package_new
+        (
+        account_id,
+        stat_date,
+        operation_time,
+        operation_type,
+        role_type,
+        package_name,
+        operation_target,
+        package_id,
+        field_name,
+        original_data,
+        update_data
+        )
+        values
+        <foreach item="record" index="index" collection="records"  separator="," >
+            (
+            #{record.accountId},
+            #{record.statDate},
+            #{record.operationTime},
+            #{record.operationType},
+            #{record.roleType},
+            #{record.objectName},
+            #{record.operationTarget},
+            #{record.objectId},
+            #{record.fieldName},
+            #{record.originalData},
+            #{record.updateData}
+            )
+        </foreach>
+
+    </insert>
 </mapper>

+ 4 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java

@@ -17,6 +17,7 @@ import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -32,9 +33,9 @@ import java.util.Map;
 @Slf4j
 @Service
 public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShouReportDailyMaterialMapper, KuaiShouReportDailyMaterial> implements IKuaiShouReportDailyMaterialService {
-    @Autowired
+    @Resource
     private KuaiShouReportDailyMaterialMapper dailyMaterialMapper;
-    @Autowired
+    @Resource
     private KuaiShouReportHourlyMaterialMapper hourlyMaterialMapper;
 
     @Override
@@ -69,7 +70,7 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
             return;
         }
         Integer total_count = resultJson.getInteger("total_count");
-        if (total_count == 0) {
+        if (Check.isNull(total_count) || 0 == total_count) {
             return;
         }
         JSONArray details = resultJson.getJSONArray("details");

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

@@ -14,15 +14,17 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.*;
 
 @Slf4j
 @Service
 public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2 {
 
-    @Autowired
+    @Resource
     private KuaishouOperationRecordMapper kuaishouOperationRecordMapper;
 
+
     @Override
     public void getOperationRecord(Long advertiserId, String accessToken, Integer operationTarget, String startDate, String endDate){
 
@@ -122,7 +124,10 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
                     log.error("快手操作记录接口data结果不正确,{} ~ {}, resultJson:{}", startDate, endDate, result);
                 }
             }else{
-                log.error("快手操作记录接口code返回结果不正确,{} ~ {}, resultJson:{}", startDate, endDate, result);
+                if(code == 500000){
+                    getOperationRecordByPage(advertiserId, accessToken,page, pageSize, operationTarget, startDate, endDate);
+                }
+                log.error("快手操作记录接口code返回结果不正确,{} ~ {},再次调用!!! resultJson:{}", startDate, endDate, result);
             }
         } else {
             log.error("快手操作记录接口获取地域列表返回结果为空,{} ~ {}, resultJson:{}", startDate, endDate, result);