Commit 2ddd62e8 by 徐高华

朋友圈

parent 994897de
...@@ -42,6 +42,8 @@ public interface QwMomentPlanAttendMapper { ...@@ -42,6 +42,8 @@ public interface QwMomentPlanAttendMapper {
TaskDetailDTO taskDetail(@Param("planId") Long planId, @Param("clerkId") String execClerkId); TaskDetailDTO taskDetail(@Param("planId") Long planId, @Param("clerkId") String execClerkId);
TabQwMomentPlanAttend getByStaff(@Param("planId") Long planId, @Param("staffId") String staffId);
List<TaskListWxaDTO> taskListWxa(TaskListWxaQDTO qdto); List<TaskListWxaDTO> taskListWxa(TaskListWxaQDTO qdto);
void finishTask(@Param("attendId")Long attendId, @Param("sendTime")Date sendTime ); void finishTask(@Param("attendId")Long attendId, @Param("sendTime")Date sendTime );
......
...@@ -11,6 +11,7 @@ import com.gic.haoban.manage.api.qdto.moment.TaskListWxaQDTO; ...@@ -11,6 +11,7 @@ import com.gic.haoban.manage.api.qdto.moment.TaskListWxaQDTO;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlan; import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlan;
import com.gic.haoban.manage.service.pojo.ClerkStaffBO; import com.gic.haoban.manage.service.pojo.ClerkStaffBO;
import java.util.Date;
import java.util.List; import java.util.List;
public interface QwMomentPlanAttendService { public interface QwMomentPlanAttendService {
...@@ -31,4 +32,6 @@ public interface QwMomentPlanAttendService { ...@@ -31,4 +32,6 @@ public interface QwMomentPlanAttendService {
ServiceResponse<Void> finishTask(SendResultQDTO qdto); ServiceResponse<Void> finishTask(SendResultQDTO qdto);
void updateStatusFlag(TabQwMomentPlan plan) ; void updateStatusFlag(TabQwMomentPlan plan) ;
void finishTaskUpdateData(Long attendId , Long planId , Date sendDate) ;
} }
...@@ -44,4 +44,10 @@ public interface QwMomentPlanService { ...@@ -44,4 +44,10 @@ public interface QwMomentPlanService {
void sendToQiwei(TabQwMomentPlan plan) ; void sendToQiwei(TabQwMomentPlan plan) ;
/**
* 是否已发布
* @param planId
*/
void getQwPublishData(Long planId , String cursor) ;
} }
...@@ -203,8 +203,7 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService ...@@ -203,8 +203,7 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService
if(null == dto) { if(null == dto) {
return ServiceResponse.failure("9999","任务不存在"); return ServiceResponse.failure("9999","任务不存在");
} }
this.qwMomentPlanAttendMapper.finishTask(dto.getAttendId(),qdto.getSendTime()) ; this.finishTaskUpdateData(dto.getAttendId(),planId,qdto.getSendTime()) ;
this.qwMomentPlanMapper.updateClerkNum(planId,-1,-1,1);
String momentId = this.getMomentId(qdto.getStaffId() , qdto.getSendTime()) ; String momentId = this.getMomentId(qdto.getStaffId() , qdto.getSendTime()) ;
if(StringUtils.isNotBlank(momentId)) { if(StringUtils.isNotBlank(momentId)) {
this.qwMomentPlanAttendMapper.updateMomentId(dto.getAttendId(),momentId); this.qwMomentPlanAttendMapper.updateMomentId(dto.getAttendId(),momentId);
...@@ -212,6 +211,16 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService ...@@ -212,6 +211,16 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService
return ServiceResponse.success() ; return ServiceResponse.success() ;
} }
@Override
public void finishTaskUpdateData(Long attendId , Long planId , Date sendDate) {
TabQwMomentPlanAttend attend = this.qwMomentPlanAttendMapper.getById(attendId) ;
if(attend.getTaskStatus()==2) {
return;
}
this.qwMomentPlanAttendMapper.finishTask(attendId,sendDate) ;
this.qwMomentPlanMapper.updateClerkNum(planId,-1,-1,1);
}
public String getMomentId(String staffId , Date sendTime) { public String getMomentId(String staffId , Date sendTime) {
Date startTime = DateUtil.addNumForSecond(sendTime,-10) ; Date startTime = DateUtil.addNumForSecond(sendTime,-10) ;
Date endTime = DateUtil.addNumForMinute(sendTime,1) ; Date endTime = DateUtil.addNumForMinute(sendTime,1) ;
......
...@@ -11,6 +11,7 @@ import com.gic.haoban.manage.service.dao.mapper.moment.QwMomentPlanDataMapper; ...@@ -11,6 +11,7 @@ import com.gic.haoban.manage.service.dao.mapper.moment.QwMomentPlanDataMapper;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanAttend; import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanAttend;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanData; import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanData;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService; import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.moment.QwMomentPlanAttendService;
import com.gic.haoban.manage.service.service.moment.QwMomentPlanDataService; import com.gic.haoban.manage.service.service.moment.QwMomentPlanDataService;
import com.gic.wechat.api.dto.qywx.moment.MomentComments; import com.gic.wechat.api.dto.qywx.moment.MomentComments;
import com.gic.wechat.api.dto.qywx.moment.MomentResultDTO; import com.gic.wechat.api.dto.qywx.moment.MomentResultDTO;
...@@ -31,6 +32,8 @@ public class QwMomentPlanDataServiceImpl implements QwMomentPlanDataService { ...@@ -31,6 +32,8 @@ public class QwMomentPlanDataServiceImpl implements QwMomentPlanDataService {
private ExternalClerkRelatedService externalClerkRelatedService ; private ExternalClerkRelatedService externalClerkRelatedService ;
@Autowired @Autowired
private QwMomentPlanAttendMapper qwMomentPlanAttendMapper ; private QwMomentPlanAttendMapper qwMomentPlanAttendMapper ;
@Autowired
private QwMomentPlanAttendService qwMomentPlanAttendService ;
@Override @Override
public ServiceResponse<Page<QwMomentPlanDataDTO>> dataList(PlanDataListQDTO qdto) { public ServiceResponse<Page<QwMomentPlanDataDTO>> dataList(PlanDataListQDTO qdto) {
...@@ -124,6 +127,9 @@ public class QwMomentPlanDataServiceImpl implements QwMomentPlanDataService { ...@@ -124,6 +127,9 @@ public class QwMomentPlanDataServiceImpl implements QwMomentPlanDataService {
this.qwMomentPlanDataMapper.batchInsert(addList); this.qwMomentPlanDataMapper.batchInsert(addList);
} }
this.qwMomentPlanAttendMapper.updateQwData(task.getPlanId(),task.getClerkId(),likeCount,momentCount) ; this.qwMomentPlanAttendMapper.updateQwData(task.getPlanId(),task.getClerkId(),likeCount,momentCount) ;
if(likeCount > 0 || momentCount > 0 && task.getTaskStatus()==1) {
this.qwMomentPlanAttendService.finishTaskUpdateData(task.getAttendId(), task.getPlanId() , new Date());
}
return ServiceResponse.success(); return ServiceResponse.success();
} }
} }
package com.gic.haoban.manage.service.service.moment.impl; package com.gic.haoban.manage.service.service.moment.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
...@@ -47,7 +48,11 @@ import com.gic.haoban.manage.service.service.notify.PendingTaskService; ...@@ -47,7 +48,11 @@ import com.gic.haoban.manage.service.service.notify.PendingTaskService;
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;
import com.gic.wechat.api.dto.qywx.chat.GroupChatListDTO;
import com.gic.wechat.api.dto.qywx.chat.GroupChatListItemDTO;
import com.gic.wechat.api.dto.qywx.moment.MomentPublishDTO;
import com.gic.wechat.api.dto.qywx.moment.MomentResultDTO; import com.gic.wechat.api.dto.qywx.moment.MomentResultDTO;
import com.gic.wechat.api.dto.qywx.moment.MomentUserDTO;
import com.gic.wechat.api.service.qywx.QywxExternalUserService; import com.gic.wechat.api.service.qywx.QywxExternalUserService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -550,4 +555,41 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService { ...@@ -550,4 +555,41 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
this.pendingTaskService.addOrUpdatePendingTask(bo); this.pendingTaskService.addOrUpdatePendingTask(bo);
} }
@Override
public void getQwPublishData(Long planId, String cursor) {
TabQwMomentPlan plan = this.qwMomentPlanMapper.getById(planId) ;
String momentId = plan.getMomentId() ;
if(StringUtils.isBlank(momentId)) {
return;
}
String wxEnterpriseId = plan.getWxEnterpriseId() ;
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
ServiceResponse<MomentPublishDTO> resp = this.qywxExternalUserService.getPublishList(qwDTO.getThirdCorpid(),
qwDTO.getSelf3thSecret(), momentId,null,qwDTO.isSelf(),qwDTO.getUrlHost()) ;
if(!resp.isSuccess()) {
logger.info("拉取列表异常={}", JSON.toJSON(resp));
return;
}
MomentPublishDTO dto = resp.getResult();
cursor = dto.getNext_cursor();
List<MomentUserDTO> list = dto.getTask_list() ;
for (MomentUserDTO item : list) {
String userid = item.getUserid() ;
int chatStatus = item.getPublish_status() ;
if(chatStatus==1) {
TabHaobanStaff staff = this.staffMapper.selectByUserIdAndEnterpriseId(userid, wxEnterpriseId);
if(null != staff) {
String staffId = staff.getStaffId();
TabQwMomentPlanAttend attend = this.qwMomentPlanAttendMapper.getByStaff(planId, staffId);
if(attend.getTaskStatus()==1) {
this.qwMomentPlanAttendService.finishTaskUpdateData(attend.getAttendId(),attend.getPlanId(),new Date()) ;
}
}
}
}
// 从企微拉取下一批数据
if (org.apache.commons.lang.StringUtils.isNotBlank(cursor)) {
this.getQwPublishData(planId,cursor);
}
}
} }
...@@ -172,6 +172,9 @@ ...@@ -172,6 +172,9 @@
select <include refid="Base_Column_List" /> from tab_haoban_qw_moment_plan_attend where attend_id = #{attendId} select <include refid="Base_Column_List" /> from tab_haoban_qw_moment_plan_attend where attend_id = #{attendId}
</select> </select>
<select id="getByStaff" resultMap="result-map-tabHaobanQwMomentPlanAttend">
select <include refid="Base_Column_List" /> from tab_haoban_qw_moment_plan_attend where plan_id = #{planId} and staff_id =#{staffId}
</select>
<select id="getTotalTask" resultType="int"> <select id="getTotalTask" resultType="int">
select count(1) from tab_haoban_qw_moment_plan_attend a LEFT JOIN tab_haoban_qw_moment_plan b ON a.plan_id = b.plan_id select count(1) from tab_haoban_qw_moment_plan_attend a LEFT JOIN tab_haoban_qw_moment_plan b ON a.plan_id = b.plan_id
...@@ -193,7 +196,6 @@ ...@@ -193,7 +196,6 @@
AND a.clerk_id = #{clerkId} AND a.task_status = 1 and a.delete_flag = 0 AND a.clerk_id = #{clerkId} AND a.task_status = 1 and a.delete_flag = 0
</select> </select>
<update id="delClerks"> <update id="delClerks">
update tab_haoban_qw_moment_plan_attend set delete_flag = 1 , update_time=now() where plan_id = #{planId} update tab_haoban_qw_moment_plan_attend set delete_flag = 1 , update_time=now() where plan_id = #{planId}
<if test="null != list"> <if test="null != list">
......
...@@ -128,8 +128,10 @@ public class MomentTest { ...@@ -128,8 +128,10 @@ public class MomentTest {
@Test @Test
public void data() { public void data() {
Long planId = 772267599454027777L ; Long planId = 773211358316478465L ;
this.qwMomentPlanService.getQwData(planId); // this.qwMomentPlanService.getQwData(planId);
this.qwMomentPlanService.getQwPublishData(planId,null);
} }
......
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