瀏覽代碼

人群包同步时,添加先删除的操作!

zhaoxian 4 年之前
父節點
當前提交
8a2504ed07

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

@@ -16,4 +16,6 @@ import java.util.List;
 public interface KuaishouPopulationMapper extends BaseMapper<KuaishouPopulation> {
 
     void replaceBatch(@Param("addList") List<KuaishouPopulation> addList);
+
+    void deleteByAccountId(@Param("accountId") Long accountId);
 }

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

@@ -32,4 +32,10 @@
             )
         </foreach>
     </insert>
+
+    <delete id="deleteByAccountId">
+        delete
+        from ctop_kuaishou_population
+        where account_id = #{accountId}
+    </delete>
 </mapper>

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

@@ -179,6 +179,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaishouPopulationGroupService populationGroupService;
     @Autowired
     private IKuaishouAppPackageService appPackageService;
+
     @Override
     public void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
         try {
@@ -2797,7 +2798,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
                         }
                     }
-                    populationService.replaceBatch(addList);
+                    if (!Check.isNull(addList)) {
+                        populationService.replaceBatch(addList);
+                    }
                     getPopulationList(accountId, accessToken, page + 1);
                 } else {
                     log.error("获取人群包管理返回数据为空,accountId:{}", accountId);

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouPopulationServiceImpl.java

@@ -355,6 +355,7 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
 
     @Override
     public void replaceBatch(List<KuaishouPopulation> addList) {
+        populationMapper.deleteByAccountId(addList.get(0).getAccountId());
         populationMapper.replaceBatch(addList);
     }
 }