Parcourir la source

Merge branch 'dev-xym-update-gh-detail' of Server/long-article-recommend into master

xueyiming il y a 7 mois
Parent
commit
8d39fa3703

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/GhDetailVo.java

@@ -24,4 +24,6 @@ public class GhDetailVo {
     private String createTime;
 
     private String updateTime;
+
+    private String channel;
 }

+ 82 - 5
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/model/GhDetail.java

@@ -1,12 +1,7 @@
 package com.tzld.longarticle.recommend.server.repository.model;
 
-import lombok.Data;
-import lombok.ToString;
-
 import java.util.Date;
 
-@Data
-@ToString
 public class GhDetail {
     private Long id;
 
@@ -25,4 +20,86 @@ public class GhDetail {
     private Date createTime;
 
     private Date updateTime;
+
+    private String channel;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getGhId() {
+        return ghId;
+    }
+
+    public void setGhId(String ghId) {
+        this.ghId = ghId == null ? null : ghId.trim();
+    }
+
+    public String getGhName() {
+        return ghName;
+    }
+
+    public void setGhName(String ghName) {
+        this.ghName = ghName == null ? null : ghName.trim();
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getCategory1() {
+        return category1;
+    }
+
+    public void setCategory1(String category1) {
+        this.category1 = category1 == null ? null : category1.trim();
+    }
+
+    public String getCategory2() {
+        return category2;
+    }
+
+    public void setCategory2(String category2) {
+        this.category2 = category2 == null ? null : category2.trim();
+    }
+
+    public Integer getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(Integer isDelete) {
+        this.isDelete = isDelete;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getChannel() {
+        return channel;
+    }
+
+    public void setChannel(String channel) {
+        this.channel = channel == null ? null : channel.trim();
+    }
 }

+ 70 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/model/GhDetailExample.java

@@ -695,6 +695,76 @@ public class GhDetailExample {
             addCriterion("update_time not between", value1, value2, "updateTime");
             return (Criteria) this;
         }
+
+        public Criteria andChannelIsNull() {
+            addCriterion("channel is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelIsNotNull() {
+            addCriterion("channel is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelEqualTo(String value) {
+            addCriterion("channel =", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelNotEqualTo(String value) {
+            addCriterion("channel <>", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelGreaterThan(String value) {
+            addCriterion("channel >", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelGreaterThanOrEqualTo(String value) {
+            addCriterion("channel >=", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelLessThan(String value) {
+            addCriterion("channel <", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelLessThanOrEqualTo(String value) {
+            addCriterion("channel <=", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelLike(String value) {
+            addCriterion("channel like", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelNotLike(String value) {
+            addCriterion("channel not like", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelIn(List<String> values) {
+            addCriterion("channel in", values, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelNotIn(List<String> values) {
+            addCriterion("channel not in", values, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelBetween(String value1, String value2) {
+            addCriterion("channel between", value1, value2, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelNotBetween(String value1, String value2) {
+            addCriterion("channel not between", value1, value2, "channel");
+            return (Criteria) this;
+        }
     }
 
     public static class Criteria extends GeneratedCriteria {

+ 3 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/exterior/impl/GhDetailServiceImpl.java

@@ -64,6 +64,7 @@ public class GhDetailServiceImpl implements GhDetailService {
                 ghDetailVo.setTypeName(GhTypeEnum.getTypeName(ghDetailVo.getType()));
                 ghDetailVo.setCreateTime(DateUtils.getDateString(ghDetail.getCreateTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
                 ghDetailVo.setUpdateTime(DateUtils.getDateString(ghDetail.getUpdateTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
+                ghDetailVo.setChannel(ghDetail.getChannel());
                 ghDetailVos.add(ghDetailVo);
             }
         }
@@ -72,7 +73,6 @@ public class GhDetailServiceImpl implements GhDetailService {
     }
 
 
-
     @Override
     public CommonResponse<Void> addGhDetail(GhDetailVo ghDetailVo) {
         if (ghDetailVo == null
@@ -84,6 +84,7 @@ public class GhDetailServiceImpl implements GhDetailService {
         }
 
         try {
+            ghDetailVo.setAccountId(ghDetailVo.getAccountId().trim());
             GhDetail ghDetail = new GhDetail();
             BeanUtils.copyProperties(ghDetailVo, ghDetail);
             ghDetail.setGhId(ghDetailVo.getAccountId());
@@ -99,6 +100,7 @@ public class GhDetailServiceImpl implements GhDetailService {
     @Override
     public CommonResponse<Void> updateDetail(GhDetailVo ghDetailVo) {
         try {
+            ghDetailVo.setAccountId(ghDetailVo.getAccountId().trim());
             GhDetail ghDetail = new GhDetail();
             BeanUtils.copyProperties(ghDetailVo, ghDetail);
             ghDetail.setGhId(ghDetailVo.getAccountId());

+ 23 - 7
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/strategy/reply/impl/BuckStrategyV1.java

@@ -2,16 +2,16 @@ package com.tzld.longarticle.recommend.server.service.strategy.reply.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.common.enums.GhTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.cgi.ReplyStrategyServiceEnum;
 import com.tzld.longarticle.recommend.server.mapper.growth.AlgGhAutoreplyVideoRankDataMapper;
 import com.tzld.longarticle.recommend.server.mapper.growth.CgiReplyBucketDataMapper;
+import com.tzld.longarticle.recommend.server.mapper.growth.GhDetailMapper;
 import com.tzld.longarticle.recommend.server.model.cgi.*;
-import com.tzld.longarticle.recommend.server.repository.model.AlgGhAutoreplyVideoRankData;
-import com.tzld.longarticle.recommend.server.repository.model.AlgGhAutoreplyVideoRankDataExample;
-import com.tzld.longarticle.recommend.server.repository.model.CgiReplyBucketData;
-import com.tzld.longarticle.recommend.server.repository.model.CgiReplyBucketDataExample;
+import com.tzld.longarticle.recommend.server.repository.model.*;
 import com.tzld.longarticle.recommend.server.service.cgi.TouLiuHttpClientService;
 import com.tzld.longarticle.recommend.server.service.strategy.reply.ReplyStrategyService;
+import com.tzld.longarticle.recommend.server.util.LarkRobotUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -58,6 +58,8 @@ public class BuckStrategyV1 implements ReplyStrategyService {
     private CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
     @Autowired
     private TouLiuHttpClientService httpClientService;
+    @Autowired
+    private GhDetailMapper ghDetailMapper;
 
     @Override
     public ReplyBucketData getResult(BucketDataParam bucketDataParam) {
@@ -67,7 +69,7 @@ public class BuckStrategyV1 implements ReplyStrategyService {
         // 1 处理文章--算法引擎--排序文章数据
 //        getWenzhangData();
         // 2 处理小程序--读取离线数据表--获取策略排序小程序数据
-        List<CgiReplyBucketData> smallDataCgiReplyList = readStrategyOrderSmallData(keyedSet);
+        List<CgiReplyBucketData> smallDataCgiReplyList = readStrategyOrderSmallData(keyedSet, bucketDataParam);
         // 2.1 获取小程序落地页地址 http调用
         smallDataCgiReplyList = setSmallPageUrl(smallDataCgiReplyList);
         log.info(JSON.toJSONString(smallDataCgiReplyList));
@@ -214,7 +216,21 @@ public class BuckStrategyV1 implements ReplyStrategyService {
             SmallPageUrlDetail smallPageUrlDetail = new SmallPageUrlDetail();
             if (CollectionUtils.isEmpty(cgiReplyBucketData)) {
                 // 库里不存在,调用新生成
-                String response = httpClientService.sendAdFlowAddRequest(GET_SMALL_PAGE_URL, videoId, "touliu","tencentgzh","自动","公众号", "自动回复小程序", "位置" + sort, ghId);
+                String putScene = "touliu";
+                String channel = "tencentgzh";
+                GhDetailExample example = new GhDetailExample();
+                example.createCriteria().andGhIdEqualTo(ghId);
+                List<GhDetail> ghDetails = ghDetailMapper.selectByExample(example);
+                if (CollectionUtils.isEmpty(ghDetails)) {
+                    LarkRobotUtil.sendMessage("公众号信息查询失败 ghId=" + ghId);
+                    continue;
+                }
+                GhDetail ghDetail = ghDetails.get(0);
+                if (Objects.equals(ghDetail.getType(), GhTypeEnum.THIRD_PARTY_GH.type)) {
+                    putScene = "dyyjs";
+                    channel = ghDetail.getChannel();
+                }
+                String response = httpClientService.sendAdFlowAddRequest(GET_SMALL_PAGE_URL, videoId, putScene, channel, "自动", "公众号", "自动回复小程序", "位置" + sort, ghId);
                 JSONObject jsonObject = JSON.parseObject(response);
                 if (jsonObject.getInteger("code").equals(0)) {
                     smallPageUrlDetail = jsonObject.getObject("data", SmallPageUrlDetail.class);
@@ -246,7 +262,7 @@ public class BuckStrategyV1 implements ReplyStrategyService {
     }
 
 
-    private List<CgiReplyBucketData> readStrategyOrderSmallData(Set<String> keyedSet) {
+    private List<CgiReplyBucketData> readStrategyOrderSmallData(Set<String> keyedSet, BucketDataParam bucketDataParam) {
         List<CgiReplyBucketData> result = new ArrayList<>();
         for (String key : keyedSet) {
             if ("base".equals(key)) {

+ 19 - 4
long-article-recommend-service/src/main/resources/mapper/growth/GhDetailMapper.xml

@@ -11,6 +11,7 @@
     <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="channel" jdbcType="VARCHAR" property="channel" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -112,10 +113,10 @@
     </selectKey>
     insert into gh_detail (gh_id, gh_name, `type`,
       category1, category2,
-      create_time, update_time)
+      create_time, update_time, channel)
     values (#{ghId,jdbcType=VARCHAR}, #{ghName,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, 
       #{category1,jdbcType=VARCHAR}, #{category2,jdbcType=VARCHAR},
-      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
+      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{channel,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.longarticle.recommend.server.repository.model.GhDetail">
     <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
@@ -147,6 +148,9 @@
       <if test="updateTime != null">
         update_time,
       </if>
+      <if test="channel != null">
+        channel,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="ghId != null">
@@ -173,6 +177,9 @@
       <if test="updateTime != null">
         #{updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="channel != null">
+        #{channel,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.tzld.longarticle.recommend.server.repository.model.GhDetailExample" resultType="java.lang.Long">
@@ -211,6 +218,9 @@
       <if test="row.updateTime != null">
         update_time = #{row.updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="row.channel != null">
+        channel = #{row.channel,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="example != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -226,7 +236,8 @@
       category2 = #{row.category2,jdbcType=VARCHAR},
       is_delete = #{row.isDelete,jdbcType=INTEGER},
       create_time = #{row.createTime,jdbcType=TIMESTAMP},
-      update_time = #{row.updateTime,jdbcType=TIMESTAMP}
+      update_time = #{row.updateTime,jdbcType=TIMESTAMP},
+      channel = #{row.channel,jdbcType=VARCHAR}
     <if test="example != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -258,6 +269,9 @@
       <if test="updateTime != null">
         update_time = #{updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="channel != null">
+        channel = #{channel,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -270,7 +284,8 @@
       category2 = #{category2,jdbcType=VARCHAR},
       is_delete = #{isDelete,jdbcType=INTEGER},
       create_time = #{createTime,jdbcType=TIMESTAMP},
-      update_time = #{updateTime,jdbcType=TIMESTAMP}
+      update_time = #{updateTime,jdbcType=TIMESTAMP},
+      channel = #{channel,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
 </mapper>