Commit b9300210 by 郑永强

增加早晚报推送规则逻辑

parent c5e514b4
...@@ -17,4 +17,30 @@ public interface AdNewsDao extends BaseDao<AdNews> { ...@@ -17,4 +17,30 @@ public interface AdNewsDao extends BaseDao<AdNews> {
* @return * @return
*/ */
List<AdNews> getNewsToSendBySetIdAndAdviser4Own(Long adNewsSetId, Long adviserId, Integer top); List<AdNews> getNewsToSendBySetIdAndAdviser4Own(Long adNewsSetId, Long adviserId, Integer top);
/**
* 根据标签匹配新闻————新闻标题
* @param adNewsSetId
* @param adviserId
* @param beginTime
* @param proLabelName
* @param depLabelName
* @param purLabelName
* @param top
* @return
*/
List<AdNews> getNewsByLabelName(Long adNewsSetId, Long adviserId, String beginTime, String proLabelName, String depLabelName, String purLabelName, Integer top);
/**
* 根据标签匹配新闻————公众号名称
* @param adNewsSetId
* @param adviserId
* @param beginTime
* @param proLabelName
* @param depLabelName
* @param purLabelName
* @param top
* @return
*/
List<AdNews> getNews4WechatByLabelName(Long adNewsSetId, Long adviserId, String beginTime, String proLabelName, String depLabelName, String purLabelName, Integer top);
} }
...@@ -33,4 +33,30 @@ public class AdNewsDaoImpl extends BaseDaoImpl<AdNews> implements AdNewsDao { ...@@ -33,4 +33,30 @@ public class AdNewsDaoImpl extends BaseDaoImpl<AdNews> implements AdNewsDao {
map.put("top", top); map.put("top", top);
return super.getSqlSession().selectList(getStatement("getNewsToSendBySetIdAndAdviser4Own"), map); return super.getSqlSession().selectList(getStatement("getNewsToSendBySetIdAndAdviser4Own"), map);
} }
@Override
public List<AdNews> getNewsByLabelName(Long adNewsSetId, Long adviserId, String beginTime, String proLabelName, String depLabelName, String purLabelName, Integer top) {
Map<String, Object> map = new HashMap<>();
map.put("adNewsSetId", adNewsSetId);
map.put("adviserId", adviserId);
map.put("beginTime", beginTime);
map.put("proLabelName", proLabelName);
map.put("depLabelName", depLabelName);
map.put("purLabelName", purLabelName);
map.put("top", top);
return super.getSqlSession().selectList(getStatement("getNewsByLabelName"), map);
}
@Override
public List<AdNews> getNews4WechatByLabelName(Long adNewsSetId, Long adviserId,String beginTime, String proLabelName, String depLabelName, String purLabelName, Integer top) {
Map<String, Object> map = new HashMap<>();
map.put("adNewsSetId", adNewsSetId);
map.put("adviserId", adviserId);
map.put("beginTime", beginTime);
map.put("proLabelName", proLabelName);
map.put("depLabelName", depLabelName);
map.put("purLabelName", purLabelName);
map.put("top", top);
return super.getSqlSession().selectList(getStatement("getNews4WechatByLabelName"), map);
}
} }
package com.pcloud.book.group.dto; package com.pcloud.book.group.dto;
import com.pcloud.book.adnews.entity.AdNews;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* @Description * @Description
* @Author ruansiyuan * @Author ruansiyuan
* @Date 2019/7/18 15:09 * @Date 2019/7/18 15:09
**/ **/
@Data
public class GroupQrcodeFoAdDTO implements Serializable { public class GroupQrcodeFoAdDTO implements Serializable {
private static final long serialVersionUID = 7018070035247234809L; private static final long serialVersionUID = 7018070035247234809L;
...@@ -18,45 +23,25 @@ public class GroupQrcodeFoAdDTO implements Serializable { ...@@ -18,45 +23,25 @@ public class GroupQrcodeFoAdDTO implements Serializable {
private String weixinGroupId; private String weixinGroupId;
public Long getQrcodeId() { // 专业id
return qrcodeId; private Long proLabelId;
}
// 深度id
public void setQrcodeId(Long qrcodeId) { private Long depLabelId;
this.qrcodeId = qrcodeId;
} // 目的id
private Long purLabelId;
public Long getClassifyId() {
return classifyId; // 专业
} private String proLabelName;
public void setClassifyId(Long classifyId) { // 深度
this.classifyId = classifyId; private String depLabelName;
}
// 目的
public Long getBookGroupId() { private String purLabelName;
return bookGroupId;
} // 需要发送的早晚报
private List<AdNews> adNewsList;
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public String getWeixinGroupId() {
return weixinGroupId;
}
public void setWeixinGroupId(String weixinGroupId) {
this.weixinGroupId = weixinGroupId;
}
@Override
public String toString() {
return "GroupQrcodeFoAdDTO{" +
"qrcodeId=" + qrcodeId +
", classifyId=" + classifyId +
", bookGroupId=" + bookGroupId +
", weixinGroupId='" + weixinGroupId + '\'' +
'}';
}
} }
...@@ -143,6 +143,54 @@ ...@@ -143,6 +143,54 @@
LIMIT #{top} LIMIT #{top}
</select> </select>
<!--查找要发送的新闻(新闻标题匹配标签)-->
<!--
1、ad_news_ban 排除掉禁止发送的
2、ad_news_group_record 排除掉已发送的
-->
<select id="getNewsByLabelName" parameterType="map" resultMap="BaseResultMap">
SELECT
a.id, a.type, a.news_from, a.title, a.publisher, a.url, a.short_url, a.news_date, a.create_time,0 content_from
FROM
ad_news a
INNER JOIN ad_news_wechat b ON a.news_from = b.news_from AND b.is_delete = 0
INNER JOIN ad_news_wechat_choose c ON c.ad_news_wechat_id = b.id AND c.is_delete = 0 AND c.adviser_id = #{adviserId}
WHERE
NOT EXISTS ( SELECT 1 FROM ad_news_ban e WHERE a.id = e.ad_news_id AND e.adviser_id = c.adviser_id )
AND NOT EXISTS (SELECT 1 from ad_news_group_record f WHERE f.ad_news_id=a.id and f.ad_news_set_id=#{adNewsSetId})
AND a.create_time >= #{beginTime}
AND (a.title LIKE CONCAT('%', #{proLabelName},'%')
OR a.title LIKE CONCAT('%', #{depLabelName},'%')
OR a.title LIKE CONCAT('%', #{purLabelName},'%'))
ORDER BY
a.id DESC
LIMIT #{top}
</select>
<!--查找要发送的新闻(公众号名称匹配标签)-->
<!--
1、ad_news_ban 排除掉禁止发送的
2、ad_news_group_record 排除掉已发送的
-->
<select id="getNews4WechatByLabelName" parameterType="map" resultMap="BaseResultMap">
SELECT
a.id, a.type, a.news_from, a.title, a.publisher, a.url, a.short_url, a.news_date, a.create_time,0 content_from
FROM
ad_news a
INNER JOIN ad_news_wechat b ON a.news_from = b.news_from AND b.is_delete = 0
INNER JOIN ad_news_wechat_choose c ON c.ad_news_wechat_id = b.id AND c.is_delete = 0 AND c.adviser_id = #{adviserId}
WHERE
NOT EXISTS ( SELECT 1 FROM ad_news_ban e WHERE a.id = e.ad_news_id AND e.adviser_id = c.adviser_id )
AND NOT EXISTS (SELECT 1 from ad_news_group_record f WHERE f.ad_news_id=a.id and f.ad_news_set_id=#{adNewsSetId})
AND a.create_time >= #{beginTime}
AND (b.wechat_name LIKE CONCAT('%', #{proLabelName},'%')
OR b.wechat_name LIKE CONCAT('%', #{depLabelName},'%')
OR b.wechat_name LIKE CONCAT('%', #{purLabelName},'%'))
ORDER BY
a.id DESC
LIMIT #{top}
</select>
<!--获取素材库列表--> <!--获取素材库列表-->
<select id="getAdNewsList" parameterType="map" resultType="com.pcloud.book.adnews.entity.AdNews"> <select id="getAdNewsList" parameterType="map" resultType="com.pcloud.book.adnews.entity.AdNews">
SELECT SELECT
......
...@@ -537,13 +537,18 @@ ...@@ -537,13 +537,18 @@
t.id qrcodeId, t.id qrcodeId,
t.weixin_group_id weixinGroupId, t.weixin_group_id weixinGroupId,
t1.id classifyId, t1.id classifyId,
t1.book_group_id bookGroupId t1.book_group_id bookGroupId,
t2.pro_label_id proLabelId,
t2.dep_label_id depLabelId,
t2.pur_label_id purLabelId
FROM FROM
book_group_qrcode t book_group_qrcode t
INNER JOIN book_group_classify t1 ON t.classify_id = t1.id INNER JOIN book_group_classify t1 ON t.classify_id = t1.id
INNER JOIN book_group t2 ON t2.id = t1.book_group_id
WHERE WHERE
t.is_delete = 0 t.is_delete = 0
AND t1.is_delete = 0 AND t1.is_delete = 0
AND t2.is_delete = 0
AND t1.id IN AND t1.id IN
<foreach collection = "list" index="index" item = "item" open = "(" separator= "," close = ")"> <foreach collection = "list" index="index" item = "item" open = "(" separator= "," close = ")">
#{item} #{item}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment