Commit e81cbffd by 阮思源

修改下定时发送计划展示

parent e0733afd
...@@ -80,8 +80,10 @@ import com.pcloud.book.group.dto.AdGroupQrcodeDTO; ...@@ -80,8 +80,10 @@ import com.pcloud.book.group.dto.AdGroupQrcodeDTO;
import com.pcloud.book.group.dto.BookGroupDTO; import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookWxQrcodeDTO; import com.pcloud.book.group.dto.BookWxQrcodeDTO;
import com.pcloud.book.group.dto.ClassifyDTO; import com.pcloud.book.group.dto.ClassifyDTO;
import com.pcloud.book.group.dto.GroupQrcodeInfo4Advertising;
import com.pcloud.book.group.dto.GroupQrcodeInfoDTO; import com.pcloud.book.group.dto.GroupQrcodeInfoDTO;
import com.pcloud.book.group.entity.BookGroup; import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.BookGroupClassify;
import com.pcloud.book.group.entity.GroupQrcode; import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.vo.GroupQrcodeVO; import com.pcloud.book.group.vo.GroupQrcodeVO;
import com.pcloud.book.util.common.CommonUtils; import com.pcloud.book.util.common.CommonUtils;
...@@ -1424,6 +1426,7 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -1424,6 +1426,7 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
if (pageBean == null || ListUtils.isEmpty(pageBean.getRecordList())) { if (pageBean == null || ListUtils.isEmpty(pageBean.getRecordList())) {
return new PageBean(0, 0, new ArrayList<>()); return new PageBean(0, 0, new ArrayList<>());
} }
List<Long> wechatAdIds = new ArrayList<>();
// 填充投放数据 // 填充投放数据
for (Object object : pageBean.getRecordList()) { for (Object object : pageBean.getRecordList()) {
AdvertisingSpaceDTO spaceDTO = (AdvertisingSpaceDTO) object; AdvertisingSpaceDTO spaceDTO = (AdvertisingSpaceDTO) object;
...@@ -1460,10 +1463,28 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -1460,10 +1463,28 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
// 填充广告位置名称 // 填充广告位置名称
if (AdPositionEnum.WECHAT_GROUP_MSG.positionCode.equals(spaceDTO.getAdPosition())) { if (AdPositionEnum.WECHAT_GROUP_MSG.positionCode.equals(spaceDTO.getAdPosition())) {
fillAdpositionName4WechatGroupAd(spaceDTO); fillAdpositionName4WechatGroupAd(spaceDTO);
wechatAdIds.add(spaceDTO.getId());
} else { } else {
fillAdpositionName4CommonAd(spaceDTO); fillAdpositionName4CommonAd(spaceDTO);
} }
} }
if (!ListUtils.isEmpty(wechatAdIds)){
List<AdvertisingWechatMsg> adms = advertisingWechatMsgDao.getByAdIds(wechatAdIds);
Map<Long, AdvertisingWechatMsg> wechatAdMap = new HashMap<>();
for (AdvertisingWechatMsg advertisingWechatMsg : adms) {
wechatAdMap.put(advertisingWechatMsg.getAdId(), advertisingWechatMsg);
}
for (Object object : pageBean.getRecordList()) {
AdvertisingSpaceDTO spaceDTO = (AdvertisingSpaceDTO) object;
AdvertisingWechatMsg wechatMsg = wechatAdMap.get(spaceDTO.getId());
if (wechatMsg!=null){
spaceDTO.setAdPic(wechatMsg.getAdPic());
spaceDTO.setAdLink(wechatMsg.getAdLink());
spaceDTO.setAdSlogan(wechatMsg.getAdSlogan());
spaceDTO.setAdTitle(wechatMsg.getAdTitle());
}
}
}
return pageBean; return pageBean;
} }
...@@ -2551,6 +2572,7 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -2551,6 +2572,7 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
//插入计划 //插入计划
advertisingPlanDao.insert(advertisingPlan); advertisingPlanDao.insert(advertisingPlan);
buildPutAndGroup(advertisingPlan); buildPutAndGroup(advertisingPlan);
fillWeixinGroupId(advertisingPlan.getAdvertisingPlanGroups());
//插入计划广告位 //插入计划广告位
advertisingPutDao.batchInsert(advertisingPlan.getAdvertisingPuts()); advertisingPutDao.batchInsert(advertisingPlan.getAdvertisingPuts());
//插入关联想 //插入关联想
...@@ -2562,6 +2584,27 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -2562,6 +2584,27 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
return advertisingPlan.getId(); return advertisingPlan.getId();
} }
@ParamLog("填充微信群名称")
private void fillWeixinGroupId(List<AdvertisingPlanGroup> advertisingPlanGroups) {
if (ListUtils.isEmpty(advertisingPlanGroups)) {
return;
}
List<Long> qrcodeIds = advertisingPlanGroups.stream().filter(s -> s.getQrcodeId() != null).map(AdvertisingPlanGroup::getQrcodeId).distinct().collect(Collectors.toList());
if (ListUtils.isEmpty(qrcodeIds)) {
return;
}
Map<Long, GroupQrcodeInfo4Advertising> map = groupQrcodeDao.getWechatGroupInfoMap(qrcodeIds);
if (map != null) {
}
for (AdvertisingPlanGroup advertisingPlanGroup : advertisingPlanGroups) {
GroupQrcodeInfo4Advertising gr = map.get(advertisingPlanGroup.getQrcodeId());
if (gr != null) {
advertisingPlanGroup.setWeixinGroupName(gr.getGroupName());
}
}
}
@ParamLog("设置定时任务") @ParamLog("设置定时任务")
private void createAdvertisingPlanQuartz(AdvertisingPut advertisingPut) { private void createAdvertisingPlanQuartz(AdvertisingPut advertisingPut) {
Integer putType = advertisingPut.getPutType(); Integer putType = advertisingPut.getPutType();
...@@ -2733,6 +2776,8 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -2733,6 +2776,8 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
List<AdvertisingPlanGroup> advertisingPlanGroupsOld = advertisingPlanGroupDao.getListByPlanId(planId); List<AdvertisingPlanGroup> advertisingPlanGroupsOld = advertisingPlanGroupDao.getListByPlanId(planId);
List<Long> oldAdvertisingPlanGroupIds = advertisingPlanGroupsOld.stream().map(AdvertisingPlanGroup::getId).collect(Collectors.toList()); List<Long> oldAdvertisingPlanGroupIds = advertisingPlanGroupsOld.stream().map(AdvertisingPlanGroup::getId).collect(Collectors.toList());
List<Long> advertisingPlanGroupIdsToDelete = oldAdvertisingPlanGroupIds; List<Long> advertisingPlanGroupIdsToDelete = oldAdvertisingPlanGroupIds;
//填充群名称
fillWeixinGroupId(advertisingPlan.getAdvertisingPlanGroups());
for (AdvertisingPlanGroup advertisingPlanGroup : advertisingPlan.getAdvertisingPlanGroups()) { for (AdvertisingPlanGroup advertisingPlanGroup : advertisingPlan.getAdvertisingPlanGroups()) {
Long planGroupId = advertisingPlanGroup.getId(); Long planGroupId = advertisingPlanGroup.getId();
if (planGroupId == null) { if (planGroupId == null) {
...@@ -2872,6 +2917,12 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -2872,6 +2917,12 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
List<AdvertisingPut> advertisingPuts = advertisingPutDao.getListByPlanIds(planIds); List<AdvertisingPut> advertisingPuts = advertisingPutDao.getListByPlanIds(planIds);
List<Long> spaceIds = advertisingPuts.stream().filter(s -> s.getAdvertisingSpaceId() != null).map(AdvertisingPut::getAdvertisingSpaceId).distinct().collect(Collectors.toList()); List<Long> spaceIds = advertisingPuts.stream().filter(s -> s.getAdvertisingSpaceId() != null).map(AdvertisingPut::getAdvertisingSpaceId).distinct().collect(Collectors.toList());
List<AdvertisingSpace> advertisingSpaces = advertisingSpaceDao.getByIds(spaceIds); List<AdvertisingSpace> advertisingSpaces = advertisingSpaceDao.getByIds(spaceIds);
List<Long> wechatAdIds = advertisingSpaces.stream().filter(s -> AdPositionEnum.WECHAT_GROUP_MSG.positionCode.equals(s.getAdPosition())).map(AdvertisingSpace::getId).collect(Collectors.toList());
List<AdvertisingWechatMsg> adms = advertisingWechatMsgDao.getByAdIds(wechatAdIds);
Map<Long, AdvertisingWechatMsg> wechatAdMap = new HashMap<>();
for (AdvertisingWechatMsg advertisingWechatMsg : adms) {
wechatAdMap.put(advertisingWechatMsg.getAdId(), advertisingWechatMsg);
}
Map<Long, AdvertisingSpace> spaceMap = new HashMap<>(); Map<Long, AdvertisingSpace> spaceMap = new HashMap<>();
for (AdvertisingSpace advertisingSpace : advertisingSpaces) { for (AdvertisingSpace advertisingSpace : advertisingSpaces) {
spaceMap.put(advertisingSpace.getId(), advertisingSpace); spaceMap.put(advertisingSpace.getId(), advertisingSpace);
...@@ -2879,25 +2930,57 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -2879,25 +2930,57 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
//填充广告位 //填充广告位
for (AdvertisingPut advertisingPut : advertisingPuts) { for (AdvertisingPut advertisingPut : advertisingPuts) {
Long spaceId = advertisingPut.getAdvertisingSpaceId(); Long spaceId = advertisingPut.getAdvertisingSpaceId();
advertisingPut.setAdvertisingSpace(spaceMap.get(spaceId)); AdvertisingSpace as = spaceMap.get(spaceId);
AdvertisingWechatMsg wechatMsg = wechatAdMap.get(spaceId);
if (wechatMsg!=null){
as.setAdPic(wechatMsg.getAdPic());
as.setAdLink(wechatMsg.getAdLink());
as.setAdSlogan(wechatMsg.getAdSlogan());
as.setAdTitle(wechatMsg.getAdTitle());
}
advertisingPut.setAdvertisingSpace(as);
} }
//每个计划对应的广告项集合 //每个计划对应的广告项集合
Map<Long, List<AdvertisingPut>> planPutMap = advertisingPuts.stream().collect(Collectors.groupingBy(AdvertisingPut::getAdvertisingPlanId)); Map<Long, List<AdvertisingPut>> planPutMap = advertisingPuts.stream().collect(Collectors.groupingBy(AdvertisingPut::getAdvertisingPlanId));
List<AdvertisingPlanGroup> advertisingPlanGroups = advertisingPlanGroupDao.getListByPlanIds(planIds); List<AdvertisingPlanGroup> advertisingPlanGroups = advertisingPlanGroupDao.getListByPlanIds(planIds);
List<Long> qrcodeIds = advertisingPlanGroups.stream().map(AdvertisingPlanGroup::getQrcodeId).collect(Collectors.toList()); List<Long> qrcodeIds=new ArrayList<>();
List<Long> classifyIds=new ArrayList<>();
List<Long> bookGroupIds=new ArrayList<>();
for (AdvertisingPlanGroup advertisingPlanGroup:advertisingPlanGroups){
qrcodeIds.add(advertisingPlanGroup.getQrcodeId());
classifyIds.add(advertisingPlanGroup.getClassifyId());
bookGroupIds.add(advertisingPlanGroup.getBookGroupId());
}
List<ClassifyDTO> classifyDTOS=bookGroupClassifyDao.getNameWithBookNameByIds(classifyIds);
List<BookGroupDTO> bookGroupDTOS = bookGroupDao.getBookBaseInfoByIds(bookGroupIds);
List<WeixinClassifyInfoDTO> weixinClassifyInfoDTOS = groupQrcodeDao.getGroupInfoByQrcodeId(qrcodeIds); List<WeixinClassifyInfoDTO> weixinClassifyInfoDTOS = groupQrcodeDao.getGroupInfoByQrcodeId(qrcodeIds);
Map<Long, WeixinClassifyInfoDTO> infoMap = new HashMap<>(); Map<Long, WeixinClassifyInfoDTO> infoMap = new HashMap<>();
for (WeixinClassifyInfoDTO weixinClassifyInfoDTO : weixinClassifyInfoDTOS) { for (WeixinClassifyInfoDTO weixinClassifyInfoDTO : weixinClassifyInfoDTOS) {
infoMap.put(weixinClassifyInfoDTO.getQrcodeId(), weixinClassifyInfoDTO); infoMap.put(weixinClassifyInfoDTO.getQrcodeId(), weixinClassifyInfoDTO);
} }
Map<Long, String> classifyMap=new HashMap<>();
for (ClassifyDTO classifyDTO:classifyDTOS){
classifyMap.put(classifyDTO.getId(),classifyDTO.getClassify());
}
Map<Long, BookGroupDTO> bookGroupDTOMap=new HashMap<>();
for (BookGroupDTO bookGroupDTO:bookGroupDTOS){
bookGroupDTOMap.put(bookGroupDTO.getId(),bookGroupDTO);
}
for (AdvertisingPlanGroup advertisingPlanGroup : advertisingPlanGroups) { for (AdvertisingPlanGroup advertisingPlanGroup : advertisingPlanGroups) {
Long qrcodeId = advertisingPlanGroup.getQrcodeId(); Long qrcodeId = advertisingPlanGroup.getQrcodeId();
Long classifyId=advertisingPlanGroup.getClassifyId();
Long bookGroupId=advertisingPlanGroup.getBookGroupId();
WeixinClassifyInfoDTO weixinClassifyInfoDTO = infoMap.get(qrcodeId); WeixinClassifyInfoDTO weixinClassifyInfoDTO = infoMap.get(qrcodeId);
if (weixinClassifyInfoDTO != null) { if (weixinClassifyInfoDTO == null) {
advertisingPlanGroup.setBookName(weixinClassifyInfoDTO.getBookName()); advertisingPlanGroup.setGroupDelete(true);
advertisingPlanGroup.setGroupQrcodeName(weixinClassifyInfoDTO.getGroupQrcodeName()); }else {
advertisingPlanGroup.setClassify(weixinClassifyInfoDTO.getClassify()); advertisingPlanGroup.setGroupDelete(false);
advertisingPlanGroup.setWeixinGroupName(weixinClassifyInfoDTO.getWeixinGroupName()); }
advertisingPlanGroup.setClassify(classifyMap.get(classifyId));
BookGroupDTO bookGroupDTO=bookGroupDTOMap.get(bookGroupId);
if (bookGroupDTO!=null){
advertisingPlanGroup.setBookName(bookGroupDTO.getBookName());
advertisingPlanGroup.setGroupQrcodeName(bookGroupDTO.getGroupQrcodeName());
} }
} }
Map<Long, List<AdvertisingPlanGroup>> planGroupMap = advertisingPlanGroups.stream().collect(Collectors.groupingBy(AdvertisingPlanGroup::getAdvertisingPlanId)); Map<Long, List<AdvertisingPlanGroup>> planGroupMap = advertisingPlanGroups.stream().collect(Collectors.groupingBy(AdvertisingPlanGroup::getAdvertisingPlanId));
......
...@@ -23,4 +23,9 @@ public interface AdvertisingWechatMsgDao extends BaseDao<AdvertisingWechatMsg> { ...@@ -23,4 +23,9 @@ public interface AdvertisingWechatMsgDao extends BaseDao<AdvertisingWechatMsg> {
* @param adId * @param adId
*/ */
public void deleteByAdId(Long adId); public void deleteByAdId(Long adId);
/**
* 根据广告位id集合查询
*/
List<AdvertisingWechatMsg> getByAdIds(List<Long> adIds);
} }
...@@ -26,4 +26,9 @@ public class AdvertisingWechatMsgDaoImpl extends BaseDaoImpl<AdvertisingWechatMs ...@@ -26,4 +26,9 @@ public class AdvertisingWechatMsgDaoImpl extends BaseDaoImpl<AdvertisingWechatMs
public void deleteByAdId(Long adId) { public void deleteByAdId(Long adId) {
getSessionTemplate().delete(getStatement("deleteByAdId"), adId); getSessionTemplate().delete(getStatement("deleteByAdId"), adId);
} }
@Override
public List<AdvertisingWechatMsg> getByAdIds(List<Long> list) {
return getSessionTemplate().selectList(getStatement("getByAdIds"), list);
}
} }
...@@ -52,6 +52,9 @@ public class AdvertisingPlanGroup extends BaseEntity { ...@@ -52,6 +52,9 @@ public class AdvertisingPlanGroup extends BaseEntity {
@ApiModelProperty("微信群名称") @ApiModelProperty("微信群名称")
private String weixinGroupName; private String weixinGroupName;
@ApiModelProperty("微信群是否已删除")
private Boolean groupDelete;
public Long getAdvertisingPlanId() { public Long getAdvertisingPlanId() {
return advertisingPlanId; return advertisingPlanId;
...@@ -157,6 +160,14 @@ public class AdvertisingPlanGroup extends BaseEntity { ...@@ -157,6 +160,14 @@ public class AdvertisingPlanGroup extends BaseEntity {
this.weixinGroupName = weixinGroupName; this.weixinGroupName = weixinGroupName;
} }
public Boolean getGroupDelete() {
return groupDelete;
}
public void setGroupDelete(Boolean groupDelete) {
this.groupDelete = groupDelete;
}
@Override @Override
public String toString() { public String toString() {
return "AdvertisingPlanGroup{" + return "AdvertisingPlanGroup{" +
...@@ -173,6 +184,7 @@ public class AdvertisingPlanGroup extends BaseEntity { ...@@ -173,6 +184,7 @@ public class AdvertisingPlanGroup extends BaseEntity {
", groupQrcodeName='" + groupQrcodeName + '\'' + ", groupQrcodeName='" + groupQrcodeName + '\'' +
", classify='" + classify + '\'' + ", classify='" + classify + '\'' +
", weixinGroupName='" + weixinGroupName + '\'' + ", weixinGroupName='" + weixinGroupName + '\'' +
", groupDelete=" + groupDelete +
"} " + super.toString(); "} " + super.toString();
} }
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<result column="classify_id" property="classifyId" jdbcType="BIGINT"/> <result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
<result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT"/> <result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT"/>
<result column="weixin_group_id" property="weixinGroupId" jdbcType="VARCHAR"/> <result column="weixin_group_id" property="weixinGroupId" jdbcType="VARCHAR"/>
<result column="weixin_group_name" property="weixinGroupName" jdbcType="VARCHAR"/>
<result column="is_delete" property="isDelete" jdbcType="BOOLEAN"/> <result column="is_delete" property="isDelete" jdbcType="BOOLEAN"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/> <result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, advertising_plan_id, book_id, book_group_id, classify_id, qrcode_id, id, advertising_plan_id, book_id, book_group_id, classify_id, qrcode_id,
weixin_group_id, is_delete, create_user, create_time, update_user, update_time weixin_group_id, weixin_group_name, is_delete, create_user, create_time, update_user, update_time
</sql> </sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long"> <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
...@@ -44,6 +45,7 @@ ...@@ -44,6 +45,7 @@
classify_id, classify_id,
qrcode_id, qrcode_id,
weixin_group_id, weixin_group_id,
weixin_group_name,
is_delete, is_delete,
create_user, create_user,
create_time, create_time,
...@@ -57,6 +59,7 @@ ...@@ -57,6 +59,7 @@
#{classifyId,jdbcType=BIGINT}, #{classifyId,jdbcType=BIGINT},
#{qrcodeId,jdbcType=BIGINT}, #{qrcodeId,jdbcType=BIGINT},
#{weixinGroupId,jdbcType=VARCHAR}, #{weixinGroupId,jdbcType=VARCHAR},
#{weixinGroupName,jdbcType=VARCHAR},
0, 0,
#{createUser,jdbcType=BIGINT}, #{createUser,jdbcType=BIGINT},
NOW(), NOW(),
...@@ -84,7 +87,10 @@ ...@@ -84,7 +87,10 @@
qrcode_id = #{qrcodeId,jdbcType=TIMESTAMP}, qrcode_id = #{qrcodeId,jdbcType=TIMESTAMP},
</if> </if>
<if test="weixinGroupId != null"> <if test="weixinGroupId != null">
weixin_group_id = #{weixinGroupId,jdbcType=TIMESTAMP}, weixin_group_id = #{weixinGroupId,jdbcType=VARCHAR},
</if>
<if test="weixinGroupName != null">
weixin_group_id = #{weixinGroupName,jdbcType=VARCHAR},
</if> </if>
<if test="isDelete != null"> <if test="isDelete != null">
is_delete = #{isDelete,jdbcType=BOOLEAN}, is_delete = #{isDelete,jdbcType=BOOLEAN},
...@@ -106,6 +112,7 @@ ...@@ -106,6 +112,7 @@
classify_id, classify_id,
qrcode_id, qrcode_id,
weixin_group_id, weixin_group_id,
weixin_group_name,
is_delete, is_delete,
create_user, create_user,
create_time, create_time,
...@@ -120,6 +127,7 @@ ...@@ -120,6 +127,7 @@
#{item.classifyId,jdbcType=BIGINT}, #{item.classifyId,jdbcType=BIGINT},
#{item.qrcodeId,jdbcType=BIGINT}, #{item.qrcodeId,jdbcType=BIGINT},
#{item.weixinGroupId,jdbcType=VARCHAR}, #{item.weixinGroupId,jdbcType=VARCHAR},
#{item.weixinGroupName,jdbcType=VARCHAR},
0, 0,
#{item.createUser,jdbcType=BIGINT}, #{item.createUser,jdbcType=BIGINT},
NOW(), NOW(),
......
...@@ -72,4 +72,14 @@ ...@@ -72,4 +72,14 @@
where ad_id = #{adId,jdbcType=BIGINT} where ad_id = #{adId,jdbcType=BIGINT}
</delete> </delete>
<!--根据广告id集合查询-->
<select id="getByAdIds" parameterType="list" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
FROM advertising_wechat_msg WHERE ad_id in
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
order by seq asc
</select>
</mapper> </mapper>
\ No newline at end of file
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