Procházet zdrojové kódy

增加计划信息

xueyiming před 8 měsíci
rodič
revize
8156cc430f

+ 11 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/po/PlanAccount.java

@@ -51,6 +51,8 @@ public class PlanAccount {
 
     private Integer sendCount;
 
+    private Integer isDelete;
+
     private Date createTime;
 
     private Date updateTime;
@@ -247,6 +249,14 @@ public class PlanAccount {
         this.sendCount = sendCount;
     }
 
+    public Integer getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(Integer isDelete) {
+        this.isDelete = isDelete;
+    }
+
     public Date getCreateTime() {
         return createTime;
     }
@@ -293,6 +303,7 @@ public class PlanAccount {
         sb.append(", matchStatus=").append(matchStatus);
         sb.append(", retryCount=").append(retryCount);
         sb.append(", sendCount=").append(sendCount);
+        sb.append(", isDelete=").append(isDelete);
         sb.append(", createTime=").append(createTime);
         sb.append(", updateTime=").append(updateTime);
         sb.append("]");

+ 60 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/model/po/PlanAccountExample.java

@@ -1666,6 +1666,66 @@ public class PlanAccountExample {
             return (Criteria) this;
         }
 
+        public Criteria andIsDeleteIsNull() {
+            addCriterion("is_delete is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNotNull() {
+            addCriterion("is_delete is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteEqualTo(Integer value) {
+            addCriterion("is_delete =", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotEqualTo(Integer value) {
+            addCriterion("is_delete <>", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThan(Integer value) {
+            addCriterion("is_delete >", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThanOrEqualTo(Integer value) {
+            addCriterion("is_delete >=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThan(Integer value) {
+            addCriterion("is_delete <", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThanOrEqualTo(Integer value) {
+            addCriterion("is_delete <=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIn(List<Integer> values) {
+            addCriterion("is_delete in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotIn(List<Integer> values) {
+            addCriterion("is_delete not in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete not between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
         public Criteria andCreateTimeIsNull() {
             addCriterion("create_time is null");
             return (Criteria) this;

+ 2 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/PlanAccountService.java

@@ -9,6 +9,8 @@ public interface PlanAccountService {
 
     void saveOrUpdatePlanAccount(PlanAccount planAccount);
 
+    void saveOrUpdatePlan(Plan plan);
+
     List<PlanAccount> getMatchPlanAccount();
 
     List<Plan> getPlanList();

+ 27 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CoreServiceImpl.java

@@ -78,8 +78,13 @@ public class CoreServiceImpl implements CoreService {
 
     @Override
     public void initPlanAccount() {
+        List<Plan> planList = planAccountService.getPlanList();
+        Set<String> planIdSet = planList.stream().map(Plan::getPlanId).collect(Collectors.toSet());
         List<LongArticleSystemPlan> allLongArticleSystemPlans = aigcService.getAllLongArticleSystemPlan();
         for (LongArticleSystemPlan longArticleSystemPlan : allLongArticleSystemPlans) {
+            Plan plan = createPlan(longArticleSystemPlan);
+            planAccountService.saveOrUpdatePlan(plan);
+            planIdSet.remove(longArticleSystemPlan.getId());
             //获取排序策略
             Map<String, String> sortStgMap = new HashMap<>();
             List<GzhArticleSortTaskParam> gzhArticleSortTask = longArticleSystemPlan.getGzhArticleSortTask();
@@ -131,6 +136,28 @@ public class CoreServiceImpl implements CoreService {
                 planAccountService.saveOrUpdatePlanAccount(planAccount);
             }
         }
+        if(CollectionUtils.isEmpty(planIdSet)){
+            return;
+        }
+        //TODO  更新计划状态和计划账号为删除
+    }
+
+    private Plan createPlan(LongArticleSystemPlan longArticleSystemPlan) {
+        Plan plan = new Plan();
+        plan.setPlanId(longArticleSystemPlan.getId());
+        plan.setPlanName(longArticleSystemPlan.getName());
+        plan.setPublishRate(longArticleSystemPlan.getPublishRate());
+        plan.setPublishDate(longArticleSystemPlan.getPublishDate());
+        plan.setPublishWindowStart(longArticleSystemPlan.getPublishWindowStart());
+        plan.setPublishWindowEnd(longArticleSystemPlan.getPublishWindowEnd());
+        plan.setPublishTimeInterval(longArticleSystemPlan.getPublishTimeInterval());
+        plan.setPublishNum(longArticleSystemPlan.getPublishNum());
+        plan.setPublishPreNum(longArticleSystemPlan.getPublishPerNum());
+        plan.setPublishPreMinNum(longArticleSystemPlan.getPublishPerMinNum());
+        plan.setPublishPushTime(longArticleSystemPlan.getPublishPushTime());
+        plan.setPushType(longArticleSystemPlan.getPushType());
+        plan.setMiniprogramInsertFlag(longArticleSystemPlan.getMiniprogramInsertFlag());
+        return plan;
     }
 
     @Override

+ 18 - 2
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/PlanAccountServiceImpl.java

@@ -38,16 +38,28 @@ public class PlanAccountServiceImpl implements PlanAccountService {
         }
     }
 
+    @Override
+    public void saveOrUpdatePlan(Plan plan) {
+        PlanExample example = new PlanExample();
+        example.createCriteria().andPlanIdEqualTo(plan.getPlanId());
+        List<Plan> plans = planMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(plans)) {
+            planMapper.insertSelective(plan);
+        } else {
+            plan.setId(plans.get(0).getId());
+            planMapper.updateByPrimaryKeySelective(plan);
+        }
+    }
+
     public List<PlanAccount> getMatchPlanAccount() {
         PlanAccountExample example = new PlanAccountExample();
         example.createCriteria().andCreateTimeGreaterThan(DateUtil.getThatDayDate())
-                .andMatchStatusEqualTo(0);
+                .andMatchStatusEqualTo(0).andIsDeleteEqualTo(0);
         return planAccountMapper.selectByExample(example);
     }
 
     public List<Plan> getPlanList() {
         PlanExample example = new PlanExample();
-        example.createCriteria().andCreateTimeGreaterThan(DateUtil.getThatDayDate());
         List<Plan> plans = planMapper.selectByExample(example);
         if (CollectionUtils.isEmpty(plans)) {
             return new ArrayList<>();
@@ -55,6 +67,10 @@ public class PlanAccountServiceImpl implements PlanAccountService {
         return plans;
     }
 
+    public void delPlan(String planId){
+
+    }
+
 
     @Override
     public void updateMatchStatus(Integer status, Long id) {

+ 20 - 5
long-article-server/src/main/resources/mapper/PlanAccountMapper.xml

@@ -26,6 +26,7 @@
     <result column="match_status" jdbcType="INTEGER" property="matchStatus" />
     <result column="retry_count" jdbcType="INTEGER" property="retryCount" />
     <result column="send_count" jdbcType="INTEGER" property="sendCount" />
+    <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
   </resultMap>
@@ -92,7 +93,7 @@
     publish_window_start, publish_window_end, publish_time_interval, publish_num, publish_pre_num, 
     publish_pre_min_num, publish_push_time, push_type, miniprogram_insert_flag, mini_strategy, 
     miniprogram_use_type, sort_strategy, `status`, match_status, retry_count, send_count, 
-    create_time, update_time
+    is_delete, create_time, update_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.longarticle.model.po.PlanAccountExample" resultMap="BaseResultMap">
     select
@@ -136,8 +137,8 @@
       publish_push_time, push_type, miniprogram_insert_flag, 
       mini_strategy, miniprogram_use_type, sort_strategy, 
       `status`, match_status, retry_count, 
-      send_count, create_time, update_time
-      )
+      send_count, is_delete, create_time, 
+      update_time)
     values (#{id,jdbcType=BIGINT}, #{planId,jdbcType=VARCHAR}, #{planName,jdbcType=VARCHAR}, 
       #{accountId,jdbcType=VARCHAR}, #{accountName,jdbcType=VARCHAR}, #{ghId,jdbcType=VARCHAR}, 
       #{publishRate,jdbcType=INTEGER}, #{publishDate,jdbcType=VARCHAR}, #{publishWindowStart,jdbcType=VARCHAR}, 
@@ -146,8 +147,8 @@
       #{publishPushTime,jdbcType=VARCHAR}, #{pushType,jdbcType=INTEGER}, #{miniprogramInsertFlag,jdbcType=INTEGER}, 
       #{miniStrategy,jdbcType=VARCHAR}, #{miniprogramUseType,jdbcType=INTEGER}, #{sortStrategy,jdbcType=VARCHAR}, 
       #{status,jdbcType=INTEGER}, #{matchStatus,jdbcType=INTEGER}, #{retryCount,jdbcType=INTEGER}, 
-      #{sendCount,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
-      )
+      #{sendCount,jdbcType=INTEGER}, #{isDelete,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.longarticle.model.po.PlanAccount">
     insert into long_articles_plan_account
@@ -224,6 +225,9 @@
       <if test="sendCount != null">
         send_count,
       </if>
+      <if test="isDelete != null">
+        is_delete,
+      </if>
       <if test="createTime != null">
         create_time,
       </if>
@@ -304,6 +308,9 @@
       <if test="sendCount != null">
         #{sendCount,jdbcType=INTEGER},
       </if>
+      <if test="isDelete != null">
+        #{isDelete,jdbcType=INTEGER},
+      </if>
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -393,6 +400,9 @@
       <if test="record.sendCount != null">
         send_count = #{record.sendCount,jdbcType=INTEGER},
       </if>
+      <if test="record.isDelete != null">
+        is_delete = #{record.isDelete,jdbcType=INTEGER},
+      </if>
       <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
       </if>
@@ -430,6 +440,7 @@
       match_status = #{record.matchStatus,jdbcType=INTEGER},
       retry_count = #{record.retryCount,jdbcType=INTEGER},
       send_count = #{record.sendCount,jdbcType=INTEGER},
+      is_delete = #{record.isDelete,jdbcType=INTEGER},
       create_time = #{record.createTime,jdbcType=TIMESTAMP},
       update_time = #{record.updateTime,jdbcType=TIMESTAMP}
     <if test="_parameter != null">
@@ -508,6 +519,9 @@
       <if test="sendCount != null">
         send_count = #{sendCount,jdbcType=INTEGER},
       </if>
+      <if test="isDelete != null">
+        is_delete = #{isDelete,jdbcType=INTEGER},
+      </if>
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -542,6 +556,7 @@
       match_status = #{matchStatus,jdbcType=INTEGER},
       retry_count = #{retryCount,jdbcType=INTEGER},
       send_count = #{sendCount,jdbcType=INTEGER},
+      is_delete = #{isDelete,jdbcType=INTEGER},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       update_time = #{updateTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}

+ 2 - 2
long-article-server/src/main/resources/mybatis-generator-config.xml

@@ -60,8 +60,8 @@
 <!--            <columnOverride column="cover_url" javaType="java.lang.String" jdbcType="LONGVARCHAR" />-->
 <!--        </table>-->
 <!--        <table tableName="long_articles_root_source_id" domainObjectName="RootSource" alias=""/>-->
-<!--        <table tableName="long_articles_plan_account" domainObjectName="PlanAccount" alias=""/>-->
-            <table tableName="long_articles_plan" domainObjectName="Plan" alias=""/>
+        <table tableName="long_articles_plan_account" domainObjectName="PlanAccount" alias=""/>
+<!--            <table tableName="long_articles_plan" domainObjectName="Plan" alias=""/>-->
 
 <!--                <table tableName="long_articles_publish_content" domainObjectName="PublishContent" alias=""/>-->
 <!--                <table tableName="long_articles_publish_miniprogram" domainObjectName="PublishMiniprogram" alias=""/>-->