Commit 1988de28 by danmo

已知bug修改

1 parent 4c3e8efd
......@@ -69,7 +69,7 @@ public class WeTaskFissionController extends BaseController {
@ApiOperation(value = "查询任务宝列表", httpMethod = "GET")
// @PreAuthorize("@ss.hasPermi('wecom:fission:list')")
@GetMapping("/list")
public TableDataInfo<List<WeTaskFission>> list(WeTaskFission weTaskFission) throws ParseException {
public TableDataInfo<List<WeTaskFission>> list(WeTaskFission weTaskFission){
startPage();
List<WeTaskFission> list = weTaskFissionService.selectWeTaskFissionList(weTaskFission);
return getDataTable(list);
......@@ -106,7 +106,7 @@ public class WeTaskFissionController extends BaseController {
// @PreAuthorize("@ss.hasPermi('wecom:fission:export')")
@Log(title = "任务宝", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(WeTaskFission weTaskFission) throws ParseException {
public AjaxResult export(WeTaskFission weTaskFission) {
List<WeTaskFission> list = weTaskFissionService.selectWeTaskFissionList(weTaskFission);
ExcelUtil<WeTaskFission> util = new ExcelUtil<WeTaskFission>(WeTaskFission.class);
return util.exportExcel(list, "fission");
......
......@@ -79,6 +79,12 @@ public class WeGroupMessageTemplate extends BaseEntity {
private Integer source;
/**
* 业务id
*/
@ApiModelProperty("业务id")
private Long businessId;
/**
* 刷新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
......
......@@ -161,7 +161,7 @@ public class WeTaskFission extends BaseEntity {
* 任务裂变活动状态,1 进行中 2 已结束
*/
@Excel(name = "任务裂变活动状态,1 进行中 2 已结束")
@ApiModelProperty(value = "任务裂变活动状态,1 进行中 2 已结束")
@ApiModelProperty(value = "任务裂变活动状态,-1-发送失败 0-待发送 1-进行中 2-已结束")
private Integer fissStatus;
/**
......
package com.linkwechat.wecom.domain.query;
import org.springframework.context.ApplicationEvent;
/**
* @author danmo
* @description
* @date 2021/11/21 19:52
**/
public class WeTaskEventQuery extends ApplicationEvent {
private Long businessId;
private Integer taskSource;
private Integer resultCode;
public WeTaskEventQuery(Object source, Long businessId, Integer taskSource, Integer resultCode) {
super(source);
this.businessId = businessId;
this.taskSource = taskSource;
this.resultCode = resultCode;
}
public Long getBusinessId() {
return businessId;
}
public void setBusinessId(Long businessId) {
this.businessId = businessId;
}
public Integer getTaskSource() {
return taskSource;
}
public void setTaskSource(Integer taskSource) {
this.taskSource = taskSource;
}
public Integer getResultCode() {
return resultCode;
}
public void setResultCode(Integer resultCode) {
this.resultCode = resultCode;
}
}
......@@ -20,6 +20,7 @@ import com.linkwechat.wecom.domain.query.WeAddMsgTemplateQuery;
import com.linkwechat.wecom.service.IWeGroupMessageListService;
import com.linkwechat.wecom.service.IWeGroupMessageTemplateService;
import com.linkwechat.wecom.service.IWeMaterialService;
import com.linkwechat.wecom.service.event.WeEventPublisherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
......@@ -52,9 +53,13 @@ public class WeGroupMessageTaskHandler implements ApplicationRunner {
private IWeMaterialService weMaterialService;
@Autowired
private WeEventPublisherService weEventPublisherService;
@Autowired
private RedisCache redisCache;
private AtomicLong templateId;
private WeAddGroupMessageQuery query;
@Override
public void run(ApplicationArguments args) {
......@@ -72,9 +77,8 @@ public class WeGroupMessageTaskHandler implements ApplicationRunner {
try {
//当时间小于当前时间时删除第一个记录,并发送群发消息
log.info("获取到消息,执行群发任务: {}", item.getValue());
WeAddGroupMessageQuery query = JSONObject.parseObject(item.getValue(), WeAddGroupMessageQuery.class);
query = JSONObject.parseObject(item.getValue(), WeAddGroupMessageQuery.class);
if (query != null) {
templateId = new AtomicLong(query.getId());
Optional.of(query).map(WeAddGroupMessageQuery::getSenderList).orElseGet(ArrayList::new).forEach(sender -> {
WeAddMsgTemplateQuery templateQuery = new WeAddMsgTemplateQuery();
templateQuery.setChat_type(query.getChatType());
......@@ -101,9 +105,12 @@ public class WeGroupMessageTaskHandler implements ApplicationRunner {
}
});
WeGroupMessageTemplate template = new WeGroupMessageTemplate();
template.setId(templateId.get());
template.setId(query.getId());
template.setStatus(1);
groupMessageTemplateService.updateById(template);
if(!ObjectUtil.equal(0,query.getSource())){
weEventPublisherService.callBackTask(query.getBusinessId(),query.getSource(),1);
}
}
} finally {
redisCache.removeRangeCacheZSet(WeConstans.WEGROUPMSGTIMEDTASK_KEY, 0, 0);
......@@ -113,12 +120,15 @@ public class WeGroupMessageTaskHandler implements ApplicationRunner {
} catch (Exception e) {
e.printStackTrace();
//任务异常修改模板状态为失败
if (templateId != null) {
if (query.getId() != null) {
WeGroupMessageTemplate template = new WeGroupMessageTemplate();
template.setId(templateId.get());
template.setId(query.getId());
template.setStatus(-1);
groupMessageTemplateService.updateById(template);
}
if(!ObjectUtil.equal(0,query.getSource())){
weEventPublisherService.callBackTask(query.getBusinessId(),query.getSource(),-1);
}
}
}
}
......
......@@ -33,7 +33,7 @@ public interface IWeTaskFissionService extends IService<WeTaskFission> {
* @param weTaskFission 任务宝
* @return 任务宝集合
*/
public List<WeTaskFission> selectWeTaskFissionList(WeTaskFission weTaskFission) throws ParseException;
public List<WeTaskFission> selectWeTaskFissionList(WeTaskFission weTaskFission);
/**
* 新增任务宝
......
package com.linkwechat.wecom.service.callback;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeTaskFission;
import com.linkwechat.wecom.domain.query.WeTaskEventQuery;
import com.linkwechat.wecom.service.IWeTaskFissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
/**
* @author danmo
* @description 群发回调通知处理
* @date 2021/11/21 19:57
**/
@Service
@Slf4j
public class WeGroupMsgTaskEventService implements ApplicationListener<WeTaskEventQuery> {
@Autowired
private IWeTaskFissionService weTaskFissionService;
@Override
@Async
public void onApplicationEvent(WeTaskEventQuery weTaskEventQuery) {
log.info("群发回调通知处理:weTaskEventQuery:{}", JSONObject.toJSONString(weTaskEventQuery));
Long businessId = weTaskEventQuery.getBusinessId();
Integer taskSource = weTaskEventQuery.getTaskSource();
Integer resultCode = weTaskEventQuery.getResultCode();
if(ObjectUtil.equal(1,taskSource)){
WeTaskFission fission = new WeTaskFission();
fission.setId(businessId);
fission.setFissStatus(resultCode);
weTaskFissionService.updateById(fission);
}
}
}
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.event;
import com.linkwechat.wecom.domain.callback.WeCallBackEvent;
import com.linkwechat.wecom.domain.query.WeCustomerWelcomeQuery;
import com.linkwechat.wecom.domain.query.WeTaskEventQuery;
import com.linkwechat.wecom.domain.query.qr.WeQrCodeEventQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
......@@ -48,4 +49,12 @@ public class WeEventPublisherService implements ApplicationEventPublisherAware {
log.info("刷新活码任务:qrId:{}", qrId);
applicationEventPublisher.publishEvent(new WeQrCodeEventQuery(this, qrId));
}
/**
* 群发任务回调
*/
public void callBackTask(Long businessId,Integer source, Integer resultCode) {
log.info("群发任务回调:businessId:{},source:{},resultCode:{}", businessId,source,resultCode);
applicationEventPublisher.publishEvent(new WeTaskEventQuery(this, businessId,source,resultCode));
}
}
......@@ -108,13 +108,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
* @return 任务宝
*/
@Override
public List<WeTaskFission> selectWeTaskFissionList(WeTaskFission weTaskFission) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf_day = new SimpleDateFormat("yyyy-MM-dd");
if (weTaskFission.getStartTime() != null && weTaskFission.getOverTime() != null) {
weTaskFission.setStartTime(sdf.parse(sdf_day.format(weTaskFission.getStartTime()) + " 00:00:00"));
weTaskFission.setOverTime(sdf.parse(sdf_day.format(weTaskFission.getOverTime()) + " 23:59:59"));
}
public List<WeTaskFission> selectWeTaskFissionList(WeTaskFission weTaskFission){
return weTaskFissionMapper.selectWeTaskFissionList(weTaskFission);
}
......@@ -127,8 +121,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
@Override
@Transactional(rollbackFor = {Exception.class,WeComException.class})
public void insertWeTaskFission(WeTaskFission weTaskFission) {
weTaskFission.setCreateBy(SecurityUtils.getUsername());
weTaskFission.setCreateTime(DateUtils.getNowDate());
weTaskFission.setFissStatus(0);
groupQrcodeHandler(weTaskFission);
int insertResult = weTaskFissionMapper.insertWeTaskFission(weTaskFission);
if (insertResult > 0) {
......@@ -210,6 +203,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
String pageUrlStr = StringUtils.format(pageUrl,weTaskFission.getId(),fissStaffId,weTaskFission.getPostersId());
WeAddGroupMessageQuery messageQuery = new WeAddGroupMessageQuery();
messageQuery.setBusinessId(weTaskFission.getId());
messageQuery.setChatType(1);
messageQuery.setSource(1);
messageQuery.setIsAll(false);
......
......@@ -24,10 +24,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(select wu.user_name from we_user wu where wu.user_id = wgmt.user_id limit 1) as user_name,
wgmt.status,
wgmt.send_time,
(select group_concat(distinct (select wc.name from we_customer wc where wc.external_userid = wgmsr.external_userid limit 1)) as customer_name
from we_group_message_send_result wgmsr where wgmsr.user_id = wgmt.user_id and wgmsr.status = 0) as to_be_customer_name ,
(select group_concat(distinct (select wc.name from we_customer wc where wc.external_userid = wgmsr.external_userid limit 1)) as customer_name
from we_group_message_send_result wgmsr where wgmsr.user_id = wgmt.user_id and wgmsr.status = 1) as already_customer_name
(select count(1) from we_group_message_send_result wgmsr where wgmsr.user_id = wgmt.user_id and wgmsr.msg_template_id = wgmt.msg_template_id and wgmsr.status = 0) as to_be_customer_name,
(select count(1) from we_group_message_send_result wgmsr where wgmsr.user_id = wgmt.user_id and wgmsr.msg_template_id = wgmt.msg_template_id and wgmsr.status = 1) as already_customer_name
from we_group_message_task wgmt
<where>
<if test="id != null">
......
......@@ -41,8 +41,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="taskName != null and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
<if test="fissInfo != null and fissInfo != ''"> and fiss_info = #{fissInfo}</if>
<if test="fissNum != null "> and fiss_num = #{fissNum}</if>
<if test="startTime != null "> and start_time >= #{startTime}</if>
<if test="overTime != null "> <![CDATA[and over_time <= #{overTime}]]></if>
<if test="startTime != null"><!-- 开始时间检索 -->
and date_format(start_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{startTime},'%Y-%m-%d %H:%i:%S')
</if>
<if test="overTime != null"><!-- 结束时间检索 -->
and date_format(over_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{overTime},'%Y-%m-%d %H:%i:%S')
</if>
<if test="customerTagId != null and customerTagId != ''"> and customer_tag_id = #{customerTagId}</if>
<if test="customerTag != null and customerTag != ''"> and customer_tag = #{customerTag}</if>
<if test="postersId != null "> and posters_id = #{postersId}</if>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!