ソースを参照

人群包功能开发,更新人群包状态

zhaoxian 4 年 前
コミット
b8af049b67

+ 1 - 3
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java

@@ -50,7 +50,6 @@ public class CrowdListQueryJob {
                     if (!Check.isNull(data)) {
                     if (!Check.isNull(data)) {
                         JSONArray details = data.getJSONArray("details");
                         JSONArray details = data.getJSONArray("details");
                         if (details.size() > 0) {
                         if (details.size() > 0) {
-                            JSONArray datas = new JSONArray();
                             for (int j = 0; j < details.size(); j++) {
                             for (int j = 0; j < details.size(); j++) {
                                 JSONObject obj = details.getJSONObject(j);
                                 JSONObject obj = details.getJSONObject(j);
                                 if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
                                 if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
@@ -65,10 +64,9 @@ public class CrowdListQueryJob {
                                     }
                                     }
                                     crowdPackService.save(crowdPackEntity);
                                     crowdPackService.save(crowdPackEntity);
                                 } else {
                                 } else {
-                                    datas.add(obj);
+                                    crowdPackMapper.update(obj);
                                 }
                                 }
                             }
                             }
-                            crowdPackMapper.updateBatch(datas);
                         }
                         }
                     }
                     }
                 }
                 }

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouCrowdPackMapper.java

@@ -23,8 +23,6 @@ public interface KuaishouCrowdPackMapper extends BaseMapper<KuaishouCrowdPack> {
 
 
     List<KuaishouCrowdPack> queryListByStatus();
     List<KuaishouCrowdPack> queryListByStatus();
 
 
-    void updateBatch(@Param(value = "details") JSONArray details);
-
     List<JSONObject> queryFailReason(@Param(value = "signature") String signature);
     List<JSONObject> queryFailReason(@Param(value = "signature") String signature);
 
 
     List<JSONObject> queryRelAccounts(@Param(value = "signature") String signature);
     List<JSONObject> queryRelAccounts(@Param(value = "signature") String signature);
@@ -38,4 +36,6 @@ public interface KuaishouCrowdPackMapper extends BaseMapper<KuaishouCrowdPack> {
     KuaishouCrowdPack queryByAccountId(@Param(value = "accountId") Long accountId,@Param(value = "orientationId") Long orientationId);
     KuaishouCrowdPack queryByAccountId(@Param(value = "accountId") Long accountId,@Param(value = "orientationId") Long orientationId);
 
 
     Integer queryAccountCount(@Param(value = "signature") String signature);
     Integer queryAccountCount(@Param(value = "signature") String signature);
+
+    void update(JSONObject obj);
 }
 }

+ 10 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouCrowdPackMapper.xml

@@ -138,7 +138,7 @@
     <select id="queryListByStatus" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
     <select id="queryListByStatus" resultType="cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack">
         SELECT account_id
         SELECT account_id
         FROM ctop_kuaishou_crowd_package
         FROM ctop_kuaishou_crowd_package
-        WHERE `status` !='' and `status` is not null
+        WHERE `status` !=2
         GROUP BY account_id
         GROUP BY account_id
     </select>
     </select>
 
 
@@ -255,6 +255,7 @@
               where orientation_id is not null
               where orientation_id is not null
                 AND signature = #{signature}
                 AND signature = #{signature}
                 AND data_status = 1
                 AND data_status = 1
+                AND `status` !=2
               GROUP BY project_id) t
               GROUP BY project_id) t
     </select>
     </select>
     <select id="queryAccountCount" resultType="java.lang.Integer">
     <select id="queryAccountCount" resultType="java.lang.Integer">
@@ -263,7 +264,8 @@
                  SELECT account_id
                  SELECT account_id
                  FROM ctop_kuaishou_crowd_package
                  FROM ctop_kuaishou_crowd_package
                  WHERE signature = #{signature}
                  WHERE signature = #{signature}
-                   AND data_status = 1
+                   AND `status` !=2
+                 AND data_status = 1
                  GROUP BY account_id) t
                  GROUP BY account_id) t
     </select>
     </select>
 
 
@@ -271,6 +273,7 @@
         SELECT *
         SELECT *
         FROM ctop_kuaishou_crowd_package
         FROM ctop_kuaishou_crowd_package
         where data_status = 1
         where data_status = 1
+        AND `status` !=2
         <if test="accountId!=null">
         <if test="accountId!=null">
             AND account_id = #{accountId}
             AND account_id = #{accountId}
         </if>
         </if>
@@ -280,13 +283,11 @@
         limit 1
         limit 1
     </select>
     </select>
 
 
-    <update id="updateBatch">
-        <foreach collection="details" separator=";" item="item">
-            update ctop_kuaishou_crowd_package
-            set status = #{item.status}
-            where account_id = #{item.account_id}
-            and orientation_id = #{item.orientation_id}
-        </foreach>
+    <update id="update">
+        update ctop_kuaishou_crowd_package
+        set status = #{status}
+        where account_id = #{account_id}
+        and orientation_id = #{orientation_id}
     </update>
     </update>
 
 
     <insert id="replaceBatch">
     <insert id="replaceBatch">

+ 2 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouCrowdPackServiceImpl.java

@@ -156,6 +156,7 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
                     Long aaccount = Long.valueOf(String.valueOf(account));
                     Long aaccount = Long.valueOf(String.valueOf(account));
                     KuaishouCrowdPack crowdPack = crowdPackMapper.queryByAccountId(aaccount, kuaishouCrowdPack.getOrientationId());
                     KuaishouCrowdPack crowdPack = crowdPackMapper.queryByAccountId(aaccount, kuaishouCrowdPack.getOrientationId());
                     if (Check.isNull(crowdPack)) {
                     if (Check.isNull(crowdPack)) {
+                        kuaishouCrowdPack.setDataStatus(0);
                         kuaishouCrowdPack.setAccountId(aaccount);
                         kuaishouCrowdPack.setAccountId(aaccount);
                         kuaishouCrowdPack.setMessage("推送失败");
                         kuaishouCrowdPack.setMessage("推送失败");
                         kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
                         kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
@@ -190,7 +191,6 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
                         if (!Check.isNull(data)) {
                         if (!Check.isNull(data)) {
                             JSONArray details = data.getJSONArray("details");
                             JSONArray details = data.getJSONArray("details");
                             if (details.size() > 0) {
                             if (details.size() > 0) {
-                                JSONArray datas = new JSONArray();
                                 for (int j = 0; j < details.size(); j++) {
                                 for (int j = 0; j < details.size(); j++) {
                                     JSONObject obj = details.getJSONObject(j);
                                     JSONObject obj = details.getJSONObject(j);
                                     if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
                                     if (Check.isNull(crowdPackMapper.queryByAccountId(obj.getLong("account_id"), obj.getLong("orientation_id")))) {
@@ -205,13 +205,9 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
                                         crowdPackEntity.setDataStatus(1);
                                         crowdPackEntity.setDataStatus(1);
                                         this.save(crowdPackEntity);
                                         this.save(crowdPackEntity);
                                     } else {
                                     } else {
-                                        datas.add(obj);
+                                        crowdPackMapper.update(obj);
                                     }
                                     }
                                 }
                                 }
-                                if (datas.size() > 0) {
-                                    log.info("=====================修改日志:{}",datas.toString());
-                                    crowdPackMapper.updateBatch(datas);
-                                }
                             }
                             }
                         }
                         }
                     }
                     }