Commit 8aced829 by 宋祥

Merge branch 'ruansiyuan' into 'master'

修改7月封板bug

See merge request rays/pcloud-book!84
parents 7de8449a 9666dd2e
......@@ -14,6 +14,7 @@ import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.QrcodeUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.httpclient.UrlUtils;
......@@ -108,6 +109,10 @@ public class WXGroupLearningReportListener {
LOGGER.info("发送文字消息开始"+sendTextMessageVO.toString());
WxGroupSDK.sendTextMessage(sendTextMessageVO);
LOGGER.info("发送文字消息结束"+sendTextMessageVO.toString());
if (ListUtils.isEmpty(learningScoreDTOS)) {
LOGGER.info("没有排行记录,不发送图片groupQrcodeId=" + groupQrcodeId);
return;
}
SendPicMessageVO sendPicMessageVO = new SendPicMessageVO();
sendPicMessageVO.setPicUrl(imageUrl);
sendPicMessageVO.setGroupId(wechatGroupId);
......
......@@ -443,18 +443,8 @@ public class PushBizImpl implements PushBiz {
throw new BookBizException(BookBizException.ERROR, "未找到该群发!");
}
pushDao.update(push);
//删除之前的关联表
pushGroupDao.deleteByPushId(push.getId(), push.getUpdateUser());
//填充关联模型字段
fillPushGroupParam(push);
//插入新纪录
pushGroupDao.batchInsert(push.getPushGroups());
//删除之前的群发消息项
pushItemDao.deleteByPushId(push.getId(), push.getUpdateUser());
//填充消息项模型
fillPushItemParam(push);
//插入群发消息项
pushItemDao.batchInsert(push.getPushItems());
dealUpdatePushGroup(push);
dealUpdatePushItem(push);
//判断是否需要删除群发定时任务
if (isNeedupdatepushSchedule(pushOld, push)) {
//删除之前的群发定时任务,重新设置群发
......@@ -463,6 +453,74 @@ public class PushBizImpl implements PushBiz {
}
}
@ParamLog("处理更新关联表")
private void dealUpdatePushGroup(Push push) {
List<PushGroup> pushGroupsOld = pushGroupDao.getListByPushId(push.getId());
List<Long> pushGroupIdToDelete = new ArrayList<>();
if (!ListUtils.isEmpty(pushGroupsOld)) {
pushGroupIdToDelete = pushGroupsOld.stream().map(PushGroup::getId).collect(Collectors.toList());
}
List<PushGroup> pushGroups = push.getPushGroups();
List<PushGroup> pushGroupsToAdd = new ArrayList<>();
List<Long> pushGroupIdToUpdate = new ArrayList<>();
for (PushGroup pushGroup : pushGroups) {
if (pushGroup.getId() != null) {
//更新
pushGroup.setUpdateUser(push.getUpdateUser());
pushGroupDao.update(pushGroup);
pushGroupIdToUpdate.add(pushGroup.getId());
} else {
//新增
pushGroupsToAdd.add(pushGroup);
}
}
if (!ListUtils.isEmpty(pushGroupIdToUpdate)) {
pushGroupIdToDelete.removeAll(pushGroupIdToUpdate);
}
if (!ListUtils.isEmpty(pushGroupsToAdd)) {
//填充关联模型字段
fillPushGroupParam(push);
pushGroupDao.batchInsert(pushGroupsToAdd);
}
if (!ListUtils.isEmpty(pushGroupIdToDelete)) {
pushGroupDao.deleteByIds(pushGroupIdToDelete, push.getUpdateUser());
}
}
@ParamLog("处理更新关联表")
private void dealUpdatePushItem(Push push) {
List<PushItem> pushItemsOld = pushItemDao.getListByPushId(push.getId());
List<Long> pushItemIdsToDelete = new ArrayList<>();
if (!ListUtils.isEmpty(pushItemsOld)) {
pushItemIdsToDelete = pushItemsOld.stream().map(PushItem::getId).collect(Collectors.toList());
}
List<PushItem> pushItems = push.getPushItems();
List<PushItem> pushItemsToAdd = new ArrayList<>();
List<Long> pushItemIdToUpdate = new ArrayList<>();
for (PushItem pushItem : pushItems) {
if (pushItem.getId() != null) {
//更新
pushItem.setUpdateUser(push.getUpdateUser());
pushItemDao.update(pushItem);
pushItemIdToUpdate.add(pushItem.getId());
} else {
//新增
pushItemsToAdd.add(pushItem);
}
}
if (!ListUtils.isEmpty(pushItemIdToUpdate)) {
pushItemIdsToDelete.removeAll(pushItemIdToUpdate);
}
if (!ListUtils.isEmpty(pushItemsToAdd)) {
//填充关联模型字段
fillPushItemParam(push);
pushItemDao.batchInsert(pushItemsToAdd);
}
if (!ListUtils.isEmpty(pushItemIdsToDelete)) {
pushItemDao.deleteByIds(pushItemIdsToDelete, push.getUpdateUser());
}
}
/**
* 删除群发定时任务
*/
......@@ -984,7 +1042,20 @@ public class PushBizImpl implements PushBiz {
push.setId(pushId);
push.setCreateUser(partyId);
push.setUpdateUser(partyId);
push.setPushGroups(pushGroups);
List<PushGroup> list = new ArrayList<>();
list.addAll(pushGroups);
List<PushGroup> pushGroupsOld = pushGroupDao.getListByPushId(pushId);
if (!ListUtils.isEmpty(pushGroupsOld)) {
for (PushGroup pushGroup : list) {
for (PushGroup pushGroupIn : pushGroupsOld) {
if (pushGroup.getBookGroupQrcodeId().equals(pushGroupIn.getBookGroupQrcodeId())
&& pushGroup.getClassifyId().equals(pushGroupIn.getClassifyId())) {
pushGroup.setId(pushGroupIn.getId());
}
}
}
}
push.setPushGroups(list);
push.setPushItems(pushPlanItemDTO.getPushItems());
//没有id是新增
if (pushId != null) {
......
......@@ -71,4 +71,9 @@ public interface PushItemDao extends BaseDao<PushItem> {
* @return
*/
List<PushItem> getAllListByPushIds(List<Long> pushIds);
/**
* 根据id集合删除
*/
void deleteByIds(List<Long> ids, Long partyId);
}
......@@ -73,4 +73,12 @@ public class PushItemDaoImpl extends BaseDaoImpl<PushItem> implements PushItemDa
map.put("pushIds",pushIds);
return super.getSqlSession().selectList(getStatement("getAllListByPushIds"), map);
}
@Override
public void deleteByIds(List<Long> ids, Long partyId) {
Map<String, Object> map = new HashMap<>();
map.put("ids",ids);
map.put("partyId",partyId);
super.getSqlSession().update(getStatement("deleteByIds"), map);
}
}
......@@ -259,4 +259,18 @@
</foreach>
order by push_id asc, seq_num asc
</select>
<!--批量删除-->
<update id="deleteByIds" parameterType="map">
UPDATE
push_item
SET is_delete = 1,
update_user = #{partyId},
update_time = now()
WHERE id in
<foreach collection="ids" index="index" item="item" open="(" separator=","
close=")">
${item}
</foreach>
</update>
</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