Commit 0ad53210 by 徐高华

代办

parent caee4bbf
...@@ -33,6 +33,7 @@ public class GroupChatPlanOwnerLogDTO implements Serializable{ ...@@ -33,6 +33,7 @@ public class GroupChatPlanOwnerLogDTO implements Serializable{
private Integer sendStatus; private Integer sendStatus;
private Integer totalCount; private Integer totalCount;
private Integer sendCount; private Integer sendCount;
private Integer failCount ;
private java.util.Date createTime; private java.util.Date createTime;
private java.util.Date updateTime; private java.util.Date updateTime;
private String remark ; private String remark ;
...@@ -40,7 +41,15 @@ public class GroupChatPlanOwnerLogDTO implements Serializable{ ...@@ -40,7 +41,15 @@ public class GroupChatPlanOwnerLogDTO implements Serializable{
private Date expireDate ; private Date expireDate ;
private Date sendTime ; private Date sendTime ;
public String getPlanName() { public Integer getFailCount() {
return failCount;
}
public void setFailCount(Integer failCount) {
this.failCount = failCount;
}
public String getPlanName() {
return planName; return planName;
} }
......
...@@ -25,7 +25,7 @@ public interface GroupChatPlanOwnerLogMapper { ...@@ -25,7 +25,7 @@ public interface GroupChatPlanOwnerLogMapper {
public TabGroupChatPlanOwnerLog selectById(Long ownerLogId); public TabGroupChatPlanOwnerLog selectById(Long ownerLogId);
public void updateSendCount(@Param("id") Long id, @Param("sendCount") int sendCount, public void updateSendCount(@Param("id") Long id, @Param("sendCount") int sendCount, @Param("failCount") int failCount,
@Param("sendTime") Date sendTime); @Param("sendTime") Date sendTime);
public List<GroupChatPlanOwnerLogDTO> listPage(GroupChatPlanSearchQDTO qdto); public List<GroupChatPlanOwnerLogDTO> listPage(GroupChatPlanSearchQDTO qdto);
......
...@@ -25,6 +25,7 @@ public class TabGroupChatPlanOwnerLog implements Serializable { ...@@ -25,6 +25,7 @@ public class TabGroupChatPlanOwnerLog implements Serializable {
private String clerkId; private String clerkId;
/**1已发送 0待发送*/ /**1已发送 0待发送*/
private Integer sendStatus; private Integer sendStatus;
private Integer failCount ;
private Integer totalCount; private Integer totalCount;
private Integer sendCount; private Integer sendCount;
private java.util.Date createTime; private java.util.Date createTime;
...@@ -36,6 +37,14 @@ public class TabGroupChatPlanOwnerLog implements Serializable { ...@@ -36,6 +37,14 @@ public class TabGroupChatPlanOwnerLog implements Serializable {
private Date sendTime; private Date sendTime;
private Date expireDate; private Date expireDate;
public Integer getFailCount() {
return failCount;
}
public void setFailCount(Integer failCount) {
this.failCount = failCount;
}
public Date getExpireDate() { public Date getExpireDate() {
return expireDate; return expireDate;
} }
......
...@@ -12,9 +12,9 @@ import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog; ...@@ -12,9 +12,9 @@ import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog;
public interface GroupChatPlanOwnerLogService { public interface GroupChatPlanOwnerLogService {
public void save(GroupChatPlanOwnerLogDTO dto); public GroupChatPlanOwnerLogDTO save(GroupChatPlanOwnerLogDTO dto);
public void updateSendCount(Long id, int sendCount, Date sendTime); public void updateSendCount(Long id, int sendCount, Date sendTime, int failCount);
TabGroupChatPlanOwnerLog getById(Long ownerLogId); TabGroupChatPlanOwnerLog getById(Long ownerLogId);
......
...@@ -56,8 +56,8 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe ...@@ -56,8 +56,8 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
} }
@Override @Override
public void updateSendCount(Long id, int sendCount, Date sendTime) { public void updateSendCount(Long id, int sendCount, Date sendTime , int failCount) {
this.groupChatPlanOwnerLogMapper.updateSendCount(id, sendCount, sendTime); this.groupChatPlanOwnerLogMapper.updateSendCount(id, sendCount, failCount ,sendTime);
} }
@Override @Override
...@@ -108,7 +108,7 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe ...@@ -108,7 +108,7 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
} }
@Override @Override
public void save(GroupChatPlanOwnerLogDTO dto) { public GroupChatPlanOwnerLogDTO save(GroupChatPlanOwnerLogDTO dto) {
TabGroupChatPlanOwnerLog log = EntityUtil.changeEntityByJSON(TabGroupChatPlanOwnerLog.class, dto); TabGroupChatPlanOwnerLog log = EntityUtil.changeEntityByJSON(TabGroupChatPlanOwnerLog.class, dto);
log.setOwnerLogId(UniqueIdUtils.uniqueLong()); log.setOwnerLogId(UniqueIdUtils.uniqueLong());
log.setSendStatus(0); log.setSendStatus(0);
...@@ -133,6 +133,7 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe ...@@ -133,6 +133,7 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
} }
} }
this.groupChatPlanOwnerLogMapper.insert(log); this.groupChatPlanOwnerLogMapper.insert(log);
return EntityUtil.changeEntityByJSON(GroupChatPlanOwnerLogDTO.class, log) ;
} }
@Override @Override
......
...@@ -9,6 +9,7 @@ import java.util.stream.Collectors; ...@@ -9,6 +9,7 @@ import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.MDC;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -34,6 +35,7 @@ import com.gic.haoban.manage.api.dto.chat.GroupChatPlanDTO; ...@@ -34,6 +35,7 @@ import com.gic.haoban.manage.api.dto.chat.GroupChatPlanDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatPlanLogDTO; import com.gic.haoban.manage.api.dto.chat.GroupChatPlanLogDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatPlanOwnerLogDTO; import com.gic.haoban.manage.api.dto.chat.GroupChatPlanOwnerLogDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO; import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO;
import com.gic.haoban.manage.api.enums.PendingTaskTypeEnum;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper; import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatOwnerMapper; import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatOwnerMapper;
...@@ -44,6 +46,7 @@ import com.gic.haoban.manage.service.entity.chat.TabGroupChatOwner; ...@@ -44,6 +46,7 @@ import com.gic.haoban.manage.service.entity.chat.TabGroupChatOwner;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan; import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanLog; import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanLog;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog; import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog;
import com.gic.haoban.manage.service.pojo.bo.PendingTaskBO;
import com.gic.haoban.manage.service.pojo.bo.chat.GroupChatBO; import com.gic.haoban.manage.service.pojo.bo.chat.GroupChatBO;
import com.gic.haoban.manage.service.pojo.bo.chat.GroupChatPlanBO; import com.gic.haoban.manage.service.pojo.bo.chat.GroupChatPlanBO;
import com.gic.haoban.manage.service.service.QywxSendService; import com.gic.haoban.manage.service.service.QywxSendService;
...@@ -51,6 +54,8 @@ import com.gic.haoban.manage.service.service.WxEnterpriseService; ...@@ -51,6 +54,8 @@ import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.chat.GroupChatPlanOwnerLogService; import com.gic.haoban.manage.service.service.chat.GroupChatPlanOwnerLogService;
import com.gic.haoban.manage.service.service.chat.GroupChatPlanService; import com.gic.haoban.manage.service.service.chat.GroupChatPlanService;
import com.gic.haoban.manage.service.service.chat.GroupChatService; import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.notify.PendingTaskService;
import com.gic.haoban.task.api.enums.TaskTypeEnum;
import com.gic.mq.sdk.GicMQClient; import com.gic.mq.sdk.GicMQClient;
import com.gic.quartz.api.dto.QuartzTaskDTO; import com.gic.quartz.api.dto.QuartzTaskDTO;
import com.gic.quartz.api.service.QuartzService; import com.gic.quartz.api.service.QuartzService;
...@@ -89,6 +94,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -89,6 +94,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
private QuartzService quartzService; private QuartzService quartzService;
@Autowired @Autowired
private GroupChatOwnerMapper groupChatOwnerMapper; private GroupChatOwnerMapper groupChatOwnerMapper;
@Autowired
private PendingTaskService pendingTaskService;
private static GicMQClient mqClient = GICMQClientUtil.getClientInstance(); private static GicMQClient mqClient = GICMQClientUtil.getClientInstance();
...@@ -172,6 +179,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -172,6 +179,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
for (int i = 0; i < staffIdList.length; i++) { for (int i = 0; i < staffIdList.length; i++) {
String staffId = staffIdList[i]; String staffId = staffIdList[i];
ServiceResponse<String> sendResp = qywxSendService.sendChatMessage(wxEnterpriseId, staffId, madidList); ServiceResponse<String> sendResp = qywxSendService.sendChatMessage(wxEnterpriseId, staffId, madidList);
// 群主群数量
TabGroupChatOwner owner = this.groupChatOwnerMapper.selectByStaffId(staffId);
GroupChatPlanOwnerLogDTO ownerDTO = new GroupChatPlanOwnerLogDTO(); GroupChatPlanOwnerLogDTO ownerDTO = new GroupChatPlanOwnerLogDTO();
if (sendResp.isSuccess()) { if (sendResp.isSuccess()) {
String msgid = sendResp.getResult(); String msgid = sendResp.getResult();
...@@ -181,26 +190,44 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -181,26 +190,44 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
ownerDTO.setRemark(sendResp.getMessage()); ownerDTO.setRemark(sendResp.getMessage());
ownerDTO.setSendStatus(0); ownerDTO.setSendStatus(0);
} }
// 群主群数量
TabGroupChatOwner owner = this.groupChatOwnerMapper.selectByStaffId(staffId);
ownerDTO.setExpireDate(DateUtil.addDay(new Date(), plan.getExpireDays())); ownerDTO.setExpireDate(DateUtil.addDay(new Date(), plan.getExpireDays()));
ownerDTO.setTotalCount(owner.getChatCount()); ownerDTO.setTotalCount(owner.getChatCount());
ownerDTO.setWxEnterpriseId(wxEnterpriseId); ownerDTO.setWxEnterpriseId(wxEnterpriseId);
ownerDTO.setEnterpriseId(enterpriseId); ownerDTO.setEnterpriseId(enterpriseId);
ownerDTO.setStaffId(staffId); ownerDTO.setStaffId(staffId);
ownerDTO.setPlanId(planId); ownerDTO.setPlanId(planId);
this.groupChatPlanOwnerLogService.save(ownerDTO); ownerDTO = this.groupChatPlanOwnerLogService.save(ownerDTO);
// 代办
if (StringUtils.isNotBlank(ownerDTO.getClerkId())) {
this.savePendTask(ownerDTO, plan);
}
} }
} }
private void savePendTask(GroupChatPlanOwnerLogDTO ownerDTO, TabGroupChatPlan plan) {
logger.info("创建待办数据:{}", JSON.toJSONString(ownerDTO));
PendingTaskBO task = new PendingTaskBO();
task.setRelationId(ownerDTO.getOwnerLogId() + "");
task.setBusinessId(ownerDTO.getPlanId() + "");
task.setTaskType(PendingTaskTypeEnum.GROUP_CHAT.getType());
task.setTitle(plan.getName());
task.setInvalidTime(ownerDTO.getExpireDate());
task.setDescription(plan.getRemark());
task.setStoreId(ownerDTO.getStoreId());
task.setClerkId(ownerDTO.getClerkId());
task.setEnterpriseId(task.getEnterpriseId());
task.setOverdueTime(ownerDTO.getExpireDate());
this.pendingTaskService.addOrUpdatePendingTask(task);
}
@Override @Override
public void doPlanSendInfoTimer(String params) { public void doPlanSendInfoTimer(String params) {
List<TabGroupChatPlanOwnerLog> logList = this.groupChatPlanOwnerLogService.listForTimer(); List<TabGroupChatPlanOwnerLog> logList = this.groupChatPlanOwnerLogService.listForTimer();
for (TabGroupChatPlanOwnerLog log : logList) { for (TabGroupChatPlanOwnerLog log : logList) {
Long ownerLogId = log.getOwnerLogId(); Long ownerLogId = log.getOwnerLogId();
try{ try {
this.doPlanSendInfo(ownerLogId); this.doPlanSendInfo(ownerLogId);
}catch(Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
...@@ -228,10 +255,14 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -228,10 +255,14 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
if (respon.getErrorCode() == 0) { if (respon.getErrorCode() == 0) {
List<QywxSendMessageResultDTO> list = (List<QywxSendMessageResultDTO>) respon.getList(); List<QywxSendMessageResultDTO> list = (List<QywxSendMessageResultDTO>) respon.getList();
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
int sendCount = list.size(); int sendCount = 0;
this.groupChatPlanOwnerLogService.updateSendCount(ownerLog.getOwnerLogId(), sendCount, int failCount = 0;
list.get(0).getSendTime());
for (QywxSendMessageResultDTO item : list) { for (QywxSendMessageResultDTO item : list) {
if (item.getStatus() == 2) {
sendCount++;
} else {
failCount++;
}
String wxChatId = item.getChatId(); String wxChatId = item.getChatId();
Date sendTime = item.getSendTime(); Date sendTime = item.getSendTime();
TabGroupChatPlanLog entity = new TabGroupChatPlanLog(); TabGroupChatPlanLog entity = new TabGroupChatPlanLog();
...@@ -249,6 +280,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -249,6 +280,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
entity.setSendStatus(1); entity.setSendStatus(1);
this.groupChatPlanLogMapper.insert(entity); this.groupChatPlanLogMapper.insert(entity);
} }
this.groupChatPlanOwnerLogService.updateSendCount(ownerLog.getOwnerLogId(), sendCount,
list.get(0).getSendTime(), failCount);
} }
} }
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<result column="done_flag" property="doneFlag"/> <result column="done_flag" property="doneFlag"/>
<result column="send_time" property="sendTime"/> <result column="send_time" property="sendTime"/>
<result column="expire_date" property="expireDate"/> <result column="expire_date" property="expireDate"/>
<result column="fail_count" property="failCount"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
owner_log_id, owner_log_id,
...@@ -33,7 +34,7 @@ ...@@ -33,7 +34,7 @@
total_count, total_count,
send_count, send_count,
create_time, create_time,
update_time , remark , msgid , delete_flag , done_flag , send_time , expire_date update_time , remark , msgid , delete_flag , done_flag , send_time , expire_date , fail_count
</sql> </sql>
<!-- ===================== 新增 ======================== --> <!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog"> <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog">
...@@ -71,7 +72,7 @@ ...@@ -71,7 +72,7 @@
<!-- ==================更新 ========== --> <!-- ==================更新 ========== -->
<update id="updateSendCount"> <update id="updateSendCount">
<![CDATA[ <![CDATA[
UPDATE tab_haoban_group_chat_plan_owner_log SET send_count = #{sendCount} , UPDATE tab_haoban_group_chat_plan_owner_log SET send_count = #{sendCount} , fail_count =#{failCount} ,
send_status = 2 , send_time = #{sendTime} , send_status = 2 , send_time = #{sendTime} ,
update_time = now() where owner_log_id = #{id} update_time = now() where owner_log_id = #{id}
]]> ]]>
......
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