Commit 8f93bd66 by 徐高华

计划查询

parent 44ebfd57
......@@ -21,6 +21,14 @@ public class ChatOwnerTotalDTO implements Serializable {
private java.util.Date endTime;
private int sendCount;
private int notSendCount;
// 计划状态 1进行中 2已结束
public int getPlanStatus() {
if (this.getEndTime().before(endTime)) {
return 1;
}
return 2;
}
public Long getPlanId() {
return planId;
......
......@@ -36,7 +36,7 @@ public interface GroupChatPlanOwnerLogMapper {
public List<GroupChatPlanOwnerLogDTO> listPage(GroupChatPlanSearchQDTO qdto);
public List<TabGroupChatPlanOwnerLog> listForTimer();
public List<Long> listForTimer();
public List<ChatOwnerTotalDTO> listOwnerLogPageForWxaTotal(GroupChatPlanSearchQDTO qdto);
......
......@@ -25,7 +25,7 @@ public class TabGroupChatPlanOwnerLog implements Serializable {
private String clerkId;
/**1已发送 0待发送*/
private Integer sendStatus;
private Integer failCount ;
private Integer failCount;
private Integer totalCount;
private Integer sendCount;
private java.util.Date createTime;
......@@ -35,7 +35,6 @@ public class TabGroupChatPlanOwnerLog implements Serializable {
private Integer doneFlag;
private Integer deleteFlag;
private Date sendTime;
private Date expireDate;
public Integer getFailCount() {
return failCount;
......@@ -45,14 +44,6 @@ public class TabGroupChatPlanOwnerLog implements Serializable {
this.failCount = failCount;
}
public Date getExpireDate() {
return expireDate;
}
public void setExpireDate(Date expireDate) {
this.expireDate = expireDate;
}
public Date getSendTime() {
return sendTime;
}
......
......@@ -16,8 +16,8 @@ public interface GroupChatPlanOwnerLogService {
public void batchAdd(String staffIdList, TabGroupChatPlan entity);
public void update(TabGroupChatPlanOwnerLog entity);
public void deleteByStaffIds(Long planId,List<String> staffIdList) ;
public void deleteByStaffIds(Long planId, String delStaffIds);
public void updateSendCount(Long id, int sendCount, Date sendTime, int failCount);
......@@ -26,7 +26,7 @@ public interface GroupChatPlanOwnerLogService {
public Page<GroupChatPlanOwnerLogDTO> listPage(Long planId, GroupChatPlanSearchQDTO qdto,
BasePageInfo basePageInfo);
List<TabGroupChatPlanOwnerLog> listForTimer();
List<Long> listForTimer();
public Page<ChatOwnerTotalDTO> listOwnerLogPageForWxaTotal(GroupChatPlanSearchQDTO qdto, BasePageInfo basePageInfo);
......
package com.gic.haoban.manage.service.service.chat.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -18,7 +19,6 @@ import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.dto.StoreDTO;
......@@ -129,23 +129,6 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
log.setUpdateTime(new Date());
log.setSendCount(0);
log.setStaffId(staffId);
TabGroupChatOwner owner = this.groupChatOwnerMapper.selectByStaffId(staffId);
log.setTotalCount(owner.getChatCount());
TabHaobanClerkMainStoreRelated mainStore = this.clerkMainStoreRelatedService.getMainStoreByStaffId(staffId,
entity.getWxEnterpriseId());
if (null == mainStore) {
log.setRemark("区经/未配置主门店");
} else {
StaffClerkRelationDTO clerk = this.staffClerkRelationService.getOneBindByStoreId(staffId,
mainStore.getStoreId());
if (null != clerk) {
log.setClerkId(clerk.getClerkId());
log.setStoreId(mainStore.getStoreId());
} else {
log.setRemark("无关联导购");
logger.info("导购关联数据不存在,staffid={},storeid={}", staffId, mainStore.getStoreId());
}
}
logList.add(log);
}
this.groupChatPlanOwnerLogMapper.batchInsert(logList);
......@@ -153,18 +136,38 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
@Override
public void update(TabGroupChatPlanOwnerLog entity) {
String staffId = entity.getStaffId() ;
TabGroupChatOwner owner = this.groupChatOwnerMapper.selectByStaffId(staffId);
entity.setTotalCount(owner.getChatCount());
TabHaobanClerkMainStoreRelated mainStore = this.clerkMainStoreRelatedService.getMainStoreByStaffId(staffId,
entity.getWxEnterpriseId());
if (null == mainStore) {
entity.setRemark("区经/未配置主门店");
} else {
StaffClerkRelationDTO clerk = this.staffClerkRelationService.getOneBindByStoreId(staffId,
mainStore.getStoreId());
if (null != clerk) {
entity.setClerkId(clerk.getClerkId());
entity.setStoreId(mainStore.getStoreId());
} else {
entity.setRemark("无关联导购");
logger.info("导购关联数据不存在,staffid={},storeid={}", staffId, mainStore.getStoreId());
}
}
this.groupChatPlanOwnerLogMapper.update(entity);
}
@Override
public List<TabGroupChatPlanOwnerLog> listForTimer() {
List<TabGroupChatPlanOwnerLog> list = this.groupChatPlanOwnerLogMapper.listForTimer();
public List<Long> listForTimer() {
List<Long> list = this.groupChatPlanOwnerLogMapper.listForTimer();
return list;
}
@Override
public void deleteByStaffIds(Long planId, List<String> staffIdList) {
this.groupChatPlanOwnerLogMapper.deleteByStaffIds(planId, staffIdList);
public void deleteByStaffIds(Long planId, String delStaffIds) {
String[] arr = delStaffIds.split(",");
List<String> delStaffIdList = Arrays.asList(arr);
this.groupChatPlanOwnerLogMapper.deleteByStaffIds(planId, delStaffIdList);
}
@Override
......
package com.gic.haoban.manage.service.service.chat.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -106,47 +105,43 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
@Override
public void save(GroupChatPlanDTO dto) {
TabGroupChatPlan entity = EntityUtil.changeEntityByJSON(TabGroupChatPlan.class, dto);
Long planId = dto.getPlanId();
TabGroupChatPlan entity = EntityUtil.changeEntityByJSON(TabGroupChatPlan.class, dto);
if (entity.getSendType() == 1) {
entity.setSendTime(new Date());
}
entity.setStartTime(entity.getSendTime());
Date date = DateUtil.addDay(new Date(), entity.getExpireDays());
entity.setEndTime(DateUtil.getEndTimeOfDay(date));
String staffIdList = dto.getStaffIdList();
if (null == planId) {
planId = UniqueIdUtils.uniqueLong();
entity.setPlanId(planId);
if (entity.getSendType() == 1) {
entity.setSendTime(new Date());
}
entity.setStatusFlag(1);
entity.setStaffCount(dto.getStaffIdList().split(",").length);
entity.setStaffCount(staffIdList.split(",").length);
entity.setSendCount(0);
entity.setSuccessChatCount(0);
entity.setTotalChatCount(0);
this.groupChatPlanMapper.insert(entity);
// 新增群主日志
this.groupChatPlanOwnerLogService.batchAdd(dto.getStaffIdList(), entity);
// 立即发送
if (entity.getSendType() == 1) {
this.sendMQ(entity.getPlanId());
} else {
this.addOrDelTimer(entity.getPlanId(), entity.getSendTime(), 1);
}
} else {
this.groupChatPlanMapper.updateById(entity);
// 删除本次删除的
if (StringUtils.isNotBlank(dto.getDelStaffIdList())) {
String arr = dto.getDelStaffIdList();
List<String> delStaffIdList = Arrays.asList(arr);
String delStaffIdList = dto.getDelStaffIdList();
if (StringUtils.isNotBlank(delStaffIdList)) {
this.groupChatPlanOwnerLogService.deleteByStaffIds(planId, delStaffIdList);
}
// 新增本次新增的
if (StringUtils.isNotBlank(dto.getStaffIdList())) {
String staffIdList = dto.getStaffIdList();
if (StringUtils.isNotBlank(staffIdList)) {
this.groupChatPlanOwnerLogService.batchAdd(staffIdList, entity);
}
// 立即发送
if (entity.getSendType() == 1) {
this.sendMQ(entity.getPlanId());
} else {
this.addOrDelTimer(entity.getPlanId(), entity.getSendTime(), 1);
}
}
// 立即发送
if (entity.getSendType() == 1) {
this.sendMQ(entity.getPlanId());
} else {
this.addOrDelTimer(entity.getPlanId(), entity.getSendTime(), 1);
}
}
......@@ -203,7 +198,6 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
ownerLog.setRemark(sendResp.getMessage());
ownerLog.setSendStatus(0);
}
ownerLog.setExpireDate(DateUtil.addDay(new Date(), plan.getExpireDays()));
this.groupChatPlanOwnerLogService.update(ownerLog);
// 代办
if (StringUtils.isNotBlank(ownerLog.getClerkId())) {
......@@ -230,10 +224,9 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
@Override
public void doPlanSendInfoTimer(String params) {
List<TabGroupChatPlanOwnerLog> logList = this.groupChatPlanOwnerLogService.listForTimer();
logger.info("定时处理群发结果,条数={}", logList.size());
for (TabGroupChatPlanOwnerLog log : logList) {
Long ownerLogId = log.getOwnerLogId();
List<Long> idList = this.groupChatPlanOwnerLogService.listForTimer();
logger.info("定时处理群发结果,条数={}", idList.size());
for (Long ownerLogId : idList) {
try {
this.doPlanSendInfo(ownerLogId);
} catch (Exception e) {
......@@ -249,8 +242,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
String wxEnterpriseId = ownerLog.getWxEnterpriseId();
String enterpriseId = ownerLog.getEnterpriseId();
String msgid = ownerLog.getMsgid();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
String staffId = ownerLog.getStaffId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
TabHaobanStaff staff = this.staffMapper.selectByPrimaryKey(staffId);
String userid = staff.getWxUserId();
if (qwDTO.needOpenUserId3th()) {
......
......@@ -19,7 +19,6 @@
<result column="delete_flag" property="deleteFlag"/>
<result column="done_flag" property="doneFlag"/>
<result column="send_time" property="sendTime"/>
<result column="expire_date" property="expireDate"/>
<result column="fail_count" property="failCount"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -34,7 +33,7 @@
total_count,
send_count,
create_time,
update_time , remark , msgid , delete_flag , done_flag , send_time , expire_date , fail_count
update_time , remark , msgid , delete_flag , done_flag , send_time , fail_count
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog">
......@@ -51,7 +50,7 @@
total_count,
send_count,
create_time,
update_time , remark , msgid , delete_flag , done_flag , expire_date
update_time , remark , msgid , delete_flag , done_flag
)VALUES(
#{ownerLogId,jdbcType=BIGINT},
#{planId,jdbcType=BIGINT},
......@@ -64,7 +63,7 @@
#{totalCount},
#{sendCount},
#{createTime},
#{updateTime} , #{remark} , #{msgid} , 0 , 0 , #{expireDate}
#{updateTime} , #{remark} , #{msgid} , 0 , 0
)
]]>
</insert>
......@@ -82,7 +81,7 @@
total_count,
send_count,
create_time,
update_time , remark , msgid , delete_flag , done_flag , expire_date
update_time , remark , msgid , delete_flag , done_flag
)VALUES
<foreach collection="list" item="item" separator="," >
( #{item.ownerLogId,jdbcType=BIGINT},
......@@ -96,7 +95,7 @@
#{item.totalCount},
#{item.sendCount},
#{item.createTime},
#{item.updateTime} , #{item.remark} , #{item.msgid} , 0 , 0 , #{item.expireDate}
#{item.updateTime} , #{item.remark} , #{item.msgid} , 0 , 0
)
</foreach>
</insert>
......@@ -114,8 +113,7 @@
remark=#{remark},
msgid=#{msgid},
done_flag=#{doneFlag},
send_time=#{sendTime},
expire_date=#{expireDate}
send_time=#{sendTime}
owner_log_id = #{ownerLogId}
]]>
</update>
......@@ -142,9 +140,9 @@
SELECT <include refid="Base_Column_List"/> FROM tab_haoban_group_chat_plan_owner_log WHERE owner_log_id = #{ownerLogId} and delete_flag = 0
</select>
<select id="listForTimer" resultMap="result-map-tabHaobanGroupChatPlanOwnerLog">
SELECT <include refid="Base_Column_List"/> FROM tab_haoban_group_chat_plan_owner_log WHERE create_time >= DATE_ADD(NOW(),INTERVAL -60 day) and done_flag = 0 and delete_flag = 0
<select id="listForTimer" resultType="long">
SELECT a.owner_log_id FROM tab_haoban_group_chat_plan_owner_log a left join tab_haoban_group_chat_plan b on a.plan_id = b.plan_id
WHERE b.end_time >= DATE_ADD(NOW(),INTERVAL -12 hour) and a.done_flag = 0 and a.delete_flag = 0 and b.delete_flag = 0
</select>
<select id="listPage" parameterType="com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO" resultType="com.gic.haoban.manage.api.dto.chat.GroupChatPlanOwnerLogDTO">
......@@ -157,7 +155,6 @@
a.send_count sendCount ,
a.send_time sendTime ,
a.create_time createTime ,
a.expire_date expireDate ,
a.done_flag doneFlag ,
a.msgid msgid
from tab_haoban_group_chat_plan_owner_log a left join tab_haoban_staff b on a.staff_id = b.staff_id
......@@ -198,7 +195,9 @@
a.send_count sendCount ,
a.send_time sendTime ,
a.create_time createTime ,
a.expire_date expireDate ,
b.end_time expireDate ,
b.end_time endTime ,
b.start_time startTime ,
a.done_flag doneFlag ,
a.msgid msgid
from tab_haoban_group_chat_plan_owner_log a left join tab_haoban_group_chat_plan b on a.plan_id = b.plan_id
......
......@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo;
......@@ -60,6 +61,7 @@ public class GroupChatPlanController {
if (StringUtils.isNotBlank(dto.getStaffIdList())) {
return RestResponse.failure("9999", "请选择群主");
}
logger.info("新增参数={}",JSON.toJSONString(dto));
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
dto.setCreatorId(loginUser.getClerkId());
dto.setCreatorName(loginUser.getClerkName());
......@@ -83,6 +85,7 @@ public class GroupChatPlanController {
@RequestMapping("update")
public RestResponse<Object> update(@RequestBody GroupChatPlanDTO dto) {
logger.info("更新参数={}",JSON.toJSONString(dto));
ServiceResponse<GroupChatPlanDTO> resp = this.groupChatPlanApiService.detail(dto.getPlanId());
GroupChatPlanDTO plan = resp.getResult();
if (null == plan) {
......
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