Commit 3ff48c9e by 郑永强

fix 早晚报类型

parent 4d87dac2
......@@ -211,10 +211,8 @@ public class AdNewsBizImpl implements AdNewsBiz {
if (ListUtils.isEmpty(adNewsList)) {
return;
}
// 将多条需要发送的早晚报拼接成300字符一组的消息
contents = this.concatContent(adNewsList);
// 通过机器人小号发送消息到微信群
this.sendAdNewsToWechatGroup(adNewsSet, groupQrcodeFoAdDTOS, contents);
// 构建记录对象
for (GroupQrcodeFoAdDTO groupQrcodeFoAdDTO : groupQrcodeFoAdDTOS) {
for (AdNews adNews : adNewsList) {
adNewsGroupRecord = new AdNewsGroupRecord();
......@@ -240,6 +238,18 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsMessageStatistic.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO));
adNewsMessageStatistics.add(adNewsMessageStatistic);
}
// 记录入库
this.insertRecord(adNewsGroupRecords, adNewsMessageStatistics);
// 拼短链接
// 将多条需要发送的早晚报拼接成300字符一组的消息
contents = this.concatContent(adNewsList);
// 通过机器人小号发送消息到微信群
this.sendAdNewsToWechatGroup(adNewsSet, groupQrcodeFoAdDTOS, contents);
} else if (adNewsSet.getContentFrom() == AdContentFromEnum.CUSTOM.key) {
if (StringUtil.isEmpty(adNewsSet.getMorningContent())) {
......@@ -265,6 +275,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsGroupRecord.setUpdateUser(adNewsSet.getCreateUser());
adNewsGroupRecord.setCustomContent(customContent);
adNewsGroupRecord.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO));
adNewsGroupRecord.setContentType(adNewsSet.getContentType());
adNewsGroupRecords.add(adNewsGroupRecord);
// 统计记录
adNewsMessageStatistic = new AdNewsMessageStatistic();
......@@ -278,7 +289,18 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsMessageStatistic.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO));
adNewsMessageStatistics.add(adNewsMessageStatistic);
}
// 发送记录入库
this.insertRecord(adNewsGroupRecords, adNewsMessageStatistics);
}
}
/**
* 将发送记录入库
*
* @param adNewsGroupRecords
* @param adNewsMessageStatistics
*/
private void insertRecord(List<AdNewsGroupRecord> adNewsGroupRecords, List<AdNewsMessageStatistic> adNewsMessageStatistics) {
adNewsMessageStatisticDao.batchInsert(adNewsMessageStatistics);
// 不会mybatis的主从表批量插入,所以只能这么做
for (AdNewsMessageStatistic item : adNewsMessageStatistics) {
......@@ -341,7 +363,8 @@ public class AdNewsBizImpl implements AdNewsBiz {
Long morningDiff = date.getTime() - morningDateTime.getTime();
Long eveningDiff = date.getTime() - eveningDateTime.getTime();
// 判断正负太麻烦,直接判断绝对值,哪个时间差小就发哪个
return Math.abs(morningDiff) <= Math.abs(eveningDiff) ? adNewsSet.getMorningContent() : adNewsSet.getEveningContent();
adNewsSet.setContentType(Math.abs(morningDiff) <= Math.abs(eveningDiff) ? 0 : 1);
return adNewsSet.getContentType() == 0 ? adNewsSet.getMorningContent() : adNewsSet.getEveningContent();
}
/**
......@@ -575,15 +598,15 @@ public class AdNewsBizImpl implements AdNewsBiz {
if (!ListUtils.isEmpty((adNewsMessageStatisticVOS))) {
List<Long> labelIds = new ArrayList<>();
for (AdNewsMessageStatisticVO item : adNewsMessageStatisticVOS) {
if (item.getDepLabelId() != null) {
if (item.getProLabelId() != null) {
labelIds.add(item.getProLabelId());
}
if (item.getPurLabelId() != null) {
labelIds.add(item.getPurLabelId());
}
if (item.getDepLabelId() != null) {
labelIds.add(item.getDepLabelId());
}
if (item.getPurLabelId() != null) {
labelIds.add(item.getPurLabelId());
}
}
Map<Long, String> labelMap = new HashMap<>();
......@@ -595,12 +618,13 @@ public class AdNewsBizImpl implements AdNewsBiz {
if (item.getProLabelId() != null) {
item.setProLabelName(labelMap.get(item.getProLabelId()));
}
if (item.getPurLabelId() != null) {
item.setPurLabelName(labelMap.get(item.getPurLabelId()));
}
if (item.getDepLabelId() != null) {
item.setDepLabelName(labelMap.get(item.getDepLabelId()));
}
if (item.getPurLabelId() != null) {
item.setPurLabelName(labelMap.get(item.getPurLabelId()));
}
}
}
}
......@@ -611,7 +635,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
@Override
@ParamLog("查询早晚报发送详情")
public List<AdNewsGroupRecordVO> getAdNewsGroupRecord(Long partyId, Long messageStatisticId) {
return adNewsGroupRecordDao.getAdNewsGroupRecord(partyId,messageStatisticId);
return adNewsGroupRecordDao.getAdNewsGroupRecord(partyId, messageStatisticId);
}
}
......
......@@ -43,6 +43,9 @@ public class AdNewsGroupRecord extends BaseEntity{
@ApiModelProperty("自定义内容")
private String customContent;
@ApiModelProperty("内容类型,0:早报;1:晚报")
private Integer contentType;
@ApiModelProperty("insert时父子表标识")
Integer insertMark;
}
......@@ -3,6 +3,7 @@ package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
......@@ -11,6 +12,7 @@ import java.util.List;
* @Author ruansiyuan
* @Date 2019/7/17 16:13
**/
@Data
@ApiModel("编辑新闻发送记录")
public class AdNewsSet extends BaseEntity {
......@@ -58,159 +60,12 @@ public class AdNewsSet extends BaseEntity {
@ApiModelProperty("晚报内容")
private String eveningContent;
@ApiModelProperty("内容类型")
private Integer contentType;
@ApiModelProperty("分类关联集合")
private List<AdNewsGroup> adNewsGroups;
@ApiModelProperty("分类id集合")
private List<Long> classifyIds;
public String getMorningTime() {
return morningTime;
}
public void setMorningTime(String morningTime) {
this.morningTime = morningTime;
}
public String getEveningTime() {
return eveningTime;
}
public void setEveningTime(String eveningTime) {
this.eveningTime = eveningTime;
}
public Boolean getHasMorningOpen() {
return hasMorningOpen;
}
public void setHasMorningOpen(Boolean hasMorningOpen) {
this.hasMorningOpen = hasMorningOpen;
}
public Boolean getHasEveningOpen() {
return hasEveningOpen;
}
public void setHasEveningOpen(Boolean hasEveningOpen) {
this.hasEveningOpen = hasEveningOpen;
}
public Integer getSendCount() {
return sendCount;
}
public void setSendCount(Integer sendCount) {
this.sendCount = sendCount;
}
public String getStartContent() {
return startContent;
}
public void setStartContent(String startContent) {
this.startContent = startContent;
}
public String getEndContent() {
return endContent;
}
public void setEndContent(String endContent) {
this.endContent = endContent;
}
public Boolean getHasStartContent() {
return hasStartContent;
}
public void setHasStartContent(Boolean hasStartContent) {
this.hasStartContent = hasStartContent;
}
public Boolean getHasEndContent() {
return hasEndContent;
}
public void setHasEndContent(Boolean hasEndContent) {
this.hasEndContent = hasEndContent;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
public Integer getContentFrom() {
return contentFrom;
}
public void setContentFrom(Integer contentFrom) {
this.contentFrom = contentFrom;
}
public String getMorningContent() {
return morningContent;
}
public void setMorningContent(String morningContent) {
this.morningContent = morningContent;
}
public String getEveningContent() {
return eveningContent;
}
public void setEveningContent(String eveningContent) {
this.eveningContent = eveningContent;
}
public List<AdNewsGroup> getAdNewsGroups() {
return adNewsGroups;
}
public void setAdNewsGroups(List<AdNewsGroup> adNewsGroups) {
this.adNewsGroups = adNewsGroups;
}
public List<Long> getClassifyIds() {
return classifyIds;
}
public void setClassifyIds(List<Long> classifyIds) {
this.classifyIds = classifyIds;
}
@Override
public String toString() {
return "AdNewsSet{" +
"morningTime='" + morningTime + '\'' +
", eveningTime='" + eveningTime + '\'' +
", hasMorningOpen=" + hasMorningOpen +
", hasEveningOpen=" + hasEveningOpen +
", sendCount=" + sendCount +
", startContent='" + startContent + '\'' +
", endContent='" + endContent + '\'' +
", hasStartContent=" + hasStartContent +
", hasEndContent=" + hasEndContent +
", createUser=" + createUser +
", updateUser=" + updateUser +
", contentFrom=" + contentFrom +
", morningContent='" + morningContent + '\'' +
", eveningContent='" + eveningContent + '\'' +
", adNewsGroups=" + adNewsGroups +
", classifyIds=" + classifyIds +
'}';
}
}
......@@ -72,20 +72,13 @@ public interface AdNewsFacade {
) throws BizException, PermissionException;
@ApiOperation("禁用/解除禁用")
@PostMapping("/saveAdNewsBan")
@GetMapping("/saveAdNewsBan")
ResponseDto<?> saveAdNewsBan(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("adNewsId") @ApiParam("新闻id") Long adNewsId,
@RequestParam("hasBan") @ApiParam("禁止推送") Integer hasBan
) throws BizException, PermissionException;
@ApiOperation("增加公众号反馈")
@PostMapping("/addAdNewsWechat")
ResponseDto<?> addAdNewsWechat(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "wechatName") @ApiParam("公众号名称") String wechatName
) throws BizException, PermissionException;
@ApiOperation("添加编辑选择的公众号")
@PostMapping("/createAdNewsWechatChooseBatch")
ResponseDto<?> createAdNewsWechatChooseBatch(
......@@ -94,7 +87,7 @@ public interface AdNewsFacade {
) throws BizException, PermissionException;
@ApiOperation("移除编辑已选择的公众号")
@PostMapping("/deleteAdNewsWechatChoose")
@GetMapping("/deleteAdNewsWechatChoose")
ResponseDto<?> deleteAdNewsWechatChoose(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "adNewsWechatId") @ApiParam("公众号主键") Long adNewsWechatId
......
......@@ -151,7 +151,7 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
@Override
@ApiOperation("禁用/解除禁用")
@PostMapping("/saveAdNewsBan")
@GetMapping("/saveAdNewsBan")
public ResponseDto<?> saveAdNewsBan(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("adNewsId") @ApiParam("新闻id") Long adNewsId,
......@@ -168,18 +168,6 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
return new ResponseDto<>();
}
@ApiOperation("增加公众号反馈")
@PostMapping("/addAdNewsWechat")
@Override
public ResponseDto<?> addAdNewsWechat(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "wechatName") @ApiParam("公众号id/微信号") String wechatName
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
AdNewsWechat adNewsWechat = new AdNewsWechat(null, wechatName, partyId, false);
return new ResponseDto<>(adNewsBiz.addAdNewsWechat(adNewsWechat));
}
@ApiOperation("添加编辑选择的公众号")
@PostMapping("/createAdNewsWechatChooseBatch")
@Override
......@@ -194,7 +182,7 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
@Override
@ApiOperation("移除编辑已选择的公众号")
@PostMapping("/deleteAdNewsWechatChoose")
@GetMapping("/deleteAdNewsWechatChoose")
public ResponseDto<?> deleteAdNewsWechatChoose(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "adNewsWechatId") @ApiParam("公众号主键") Long adNewsWechatId
......
......@@ -30,4 +30,7 @@ public class AdNewsGroupRecordVO {
@ApiModelProperty("自定义早晚报内容")
private String customContent;
@ApiModelProperty("内容类型,0:早报;1:晚报")
private Integer contentType;
}
......@@ -14,10 +14,11 @@
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="custom_content" property="customContent" jdbcType="VARCHAR"/>
<result column="content_type" property="contentType" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
id, message_statistic_id,qrcode_id, classify_id, book_group_id, ad_news_id, ad_news_set_id, create_user, create_time, update_user, update_time, custom_content
id, message_statistic_id,qrcode_id, classify_id, book_group_id, ad_news_id, ad_news_set_id, create_user, create_time, update_user, update_time, custom_content,content_type
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -35,6 +36,7 @@
b.title,
b.short_url shortUrl,
a.custom_content customContent
a.content_type contentType
FROM
ad_news_group_record a
LEFT JOIN ad_news b ON a.ad_news_id=b.id
......@@ -56,7 +58,8 @@
create_time,
update_user,
update_time,
custom_content
custom_content,
content_type
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{messageStatisticId,jdbcType=BIGINT},
......@@ -69,7 +72,8 @@
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
#{customContent,jdbcType=VARCHAR}
#{customContent,jdbcType=VARCHAR},
#{contentType,jdbcType=INTEGER}
</trim>
</insert>
......@@ -100,6 +104,9 @@
<if test="customContent != null">
custom_content = #{customContent,jdbcType=VARCHAR},
</if>
<if test="contentType != null">
content_type = #{contentType,jdbcType=INTEGER},
</if>
update_time=now()
</set>
where id = #{id,jdbcType=BIGINT}
......@@ -118,7 +125,8 @@
create_time,
update_user,
update_time,
custom_content
custom_content,
content_type
)
values
<foreach collection="list" item="item" index="index" separator="," >
......@@ -133,7 +141,8 @@
NOW(),
#{item.updateUser,jdbcType=BIGINT},
NOW(),
#{item.customContent,jdbcType=VARCHAR}
#{item.customContent,jdbcType=VARCHAR},
#{item.contentType,jdbcType=INTEGER}
)
</foreach>
</insert>
......
......@@ -31,8 +31,8 @@
c.classify classify,
b.group_qrcode_name groupQrcodeName,
e.BOOK_NAME bookName,
b.dep_label_id depLabelId,
b.pro_label_id proLabelId,
b.dep_label_id depLabelId,
b.pur_label_id purLabelId,
a.message_count messageCount,
a.create_time createTime,
......@@ -60,10 +60,10 @@
AND a.create_time <![CDATA[<=]]>#{endTime}
</if>
<if test="proLabelId!=null">
AND b.dep_label_id=#{proLabelId}
AND b.pro_label_id=#{proLabelId}
</if>
<if test="depLabelId!=null">
AND b.pro_label_id=#{depLabelId}
AND b.dep_label_id=#{depLabelId}
</if>
<if test="purLabelId!=null">
AND b.pur_label_id=#{purLabelId}
......
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