Commit 11e905c7 by 徐高华

群发

parent 659aaed0
...@@ -43,4 +43,6 @@ public interface GroupChatPlanApiService { ...@@ -43,4 +43,6 @@ public interface GroupChatPlanApiService {
public ServiceResponse<Page<GroupChatPlanLogDTO>> listLogPage(Long planId, GroupChatPlanSearchQDTO qdto, public ServiceResponse<Page<GroupChatPlanLogDTO>> listLogPage(Long planId, GroupChatPlanSearchQDTO qdto,
BasePageInfo basePageInfo); BasePageInfo basePageInfo);
public ServiceResponse<Void> del(String clerkId, String clerkName, Long planId);
} }
...@@ -2,6 +2,8 @@ package com.gic.haoban.manage.service.dao.mapper.chat; ...@@ -2,6 +2,8 @@ package com.gic.haoban.manage.service.dao.mapper.chat;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param;
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.service.entity.chat.TabGroupChatPlan; import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan;
...@@ -18,7 +20,8 @@ public interface GroupChatPlanMapper { ...@@ -18,7 +20,8 @@ public interface GroupChatPlanMapper {
public int insert(TabGroupChatPlan entity); public int insert(TabGroupChatPlan entity);
public int deleteById(Long planId); public int deleteById(@Param("planId") Long planId, @Param("clerkId") String clerkId,
@Param("clerkName") String clerkName);
public int updateById(TabGroupChatPlan entity); public int updateById(TabGroupChatPlan entity);
......
...@@ -21,4 +21,6 @@ public interface GroupChatPlanService { ...@@ -21,4 +21,6 @@ public interface GroupChatPlanService {
public Page<GroupChatPlanLogDTO> listLogPage(GroupChatPlanSearchQDTO qdto, BasePageInfo basePageInfo); public Page<GroupChatPlanLogDTO> listLogPage(GroupChatPlanSearchQDTO qdto, BasePageInfo basePageInfo);
public void del(String clerkId, String clerkName, Long planId);
} }
\ No newline at end of file
...@@ -50,6 +50,8 @@ import com.gic.haoban.manage.service.service.chat.GroupChatPlanOwnerLogService; ...@@ -50,6 +50,8 @@ 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.mq.sdk.GicMQClient; import com.gic.mq.sdk.GicMQClient;
import com.gic.quartz.api.dto.QuartzTaskDTO;
import com.gic.quartz.api.service.QuartzService;
import com.gic.wechat.api.dto.qywx.QywxSendMessageResultDTO; import com.gic.wechat.api.dto.qywx.QywxSendMessageResultDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
...@@ -81,6 +83,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -81,6 +83,8 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
private ClerkService clerkService; private ClerkService clerkService;
@Autowired @Autowired
private StoreService storeService; private StoreService storeService;
@Autowired
private QuartzService quartzService;
private static GicMQClient mqClient = GICMQClientUtil.getClientInstance(); private static GicMQClient mqClient = GICMQClientUtil.getClientInstance();
...@@ -103,12 +107,16 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -103,12 +107,16 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
// 立即发送 // 立即发送
if (entity.getSendType() == 1) { if (entity.getSendType() == 1) {
this.sendMQ(entity.getPlanId()); this.sendMQ(entity.getPlanId());
}else {
this.addTimer(entity.getPlanId(), entity.getSendTime(), 1);
} }
} else { } else {
this.groupChatPlanMapper.updateById(entity); this.groupChatPlanMapper.updateById(entity);
// 立即发送 // 立即发送
if (entity.getSendType() == 1) { if (entity.getSendType() == 1) {
this.sendMQ(entity.getPlanId()); this.sendMQ(entity.getPlanId());
}else {
this.addTimer(entity.getPlanId(), entity.getSendTime(), 1);
} }
} }
} }
...@@ -191,7 +199,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -191,7 +199,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
JSONResponse respon = qywxSuiteApiService.resultExternalMessage(qwDTO.getThirdCorpid(), JSONResponse respon = qywxSuiteApiService.resultExternalMessage(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), msgid, null, userid); config.getWxSuiteid(), msgid, null, userid);
logger.info("统计返回={}",JSON.toJSONString(respon)); logger.info("统计返回={}", JSON.toJSONString(respon));
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)) {
...@@ -221,6 +229,12 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -221,6 +229,12 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
} }
} }
} }
@Override
public void del(String clerkId, String clerkName, Long planId) {
this.groupChatPlanMapper.deleteById(planId,clerkId,clerkName) ;
this.addTimer(planId, new Date(), 0);
}
@Override @Override
public Page<GroupChatPlanLogDTO> listLogPage(GroupChatPlanSearchQDTO qdto, BasePageInfo basePageInfo) { public Page<GroupChatPlanLogDTO> listLogPage(GroupChatPlanSearchQDTO qdto, BasePageInfo basePageInfo) {
...@@ -267,4 +281,33 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -267,4 +281,33 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
return retPage; return retPage;
} }
public void addTimer(Long planId, Date sendTime, int status) {
QuartzTaskDTO quartzTask = new QuartzTaskDTO();
quartzTask.setTaskStatus(status);
String taskTimeInfo = this.getTaskTime(sendTime);
quartzTask.setTaskTimeInfo(taskTimeInfo);
quartzTask.setTaskService("com.gic.haoban.manage.api.service.chat.GroupChatPlanApiService");
quartzTask.setTaskMethod("doPlanTimer");
quartzTask.setTaskParam(planId + "");
quartzTask.setReferId(planId + "");
try {
quartzService.addOrUpdateQuartzTask(quartzTask);
} catch (Exception e) {
logger.warn("提交定时任务异常", e);
}
}
private String getTaskTime(Date date) {
String timeInfo = DateUtil.dateToStr(date, "yyyyMMddHHmmss");
String year = timeInfo.substring(0, 4);
int month = Integer.parseInt(timeInfo.substring(4, 6));
int day = Integer.parseInt(timeInfo.substring(6, 8));
int hour = Integer.parseInt(timeInfo.substring(8, 10));
int minute = Integer.parseInt(timeInfo.substring(10, 12));
int second = Integer.parseInt(timeInfo.substring(12, 14));
String time = new StringBuilder().append(second).append(" ").append(minute).append(" ").append(hour).append(" ")
.append(day).append(" ").append(month).append(" ").append(year).toString();
return time;
}
} }
\ No newline at end of file
...@@ -75,4 +75,10 @@ public class GroupChatPlanApiServiceImpl implements GroupChatPlanApiService { ...@@ -75,4 +75,10 @@ public class GroupChatPlanApiServiceImpl implements GroupChatPlanApiService {
return ServiceResponse.success(page); return ServiceResponse.success(page);
} }
@Override
public ServiceResponse<Void> del(String clerkId, String clerkName, Long planId) {
this.groupChatPlanService.del(clerkId, clerkName, planId);
return ServiceResponse.success();
}
} }
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<result column="send_count" property="sendCount" /> <result column="send_count" property="sendCount" />
<result column="success_chat_count" property="successChatCount" /> <result column="success_chat_count" property="successChatCount" />
<result column="total_chat_count" property="totalChatCount" /> <result column="total_chat_count" property="totalChatCount" />
<result column="delete_flag" property="deleteFlag"/> <result column="delete_flag" property="deleteFlag" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
plan_id, plan_id,
...@@ -50,10 +50,12 @@ ...@@ -50,10 +50,12 @@
staff_count, staff_count,
send_count, send_count,
success_chat_count, success_chat_count,
total_chat_count , wx_enterprise_id , enterprise_id total_chat_count ,
wx_enterprise_id , enterprise_id
</sql> </sql>
<!-- ===================== 新增 ======================== --> <!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan"> <insert id="insert"
parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan">
<![CDATA[ <![CDATA[
INSERT INTO tab_haoban_group_chat_plan( INSERT INTO tab_haoban_group_chat_plan(
plan_id, plan_id,
...@@ -105,7 +107,9 @@ ...@@ -105,7 +107,9 @@
<!-- =====================删除==================== --> <!-- =====================删除==================== -->
<update id="deleteById" parameterType="long"> <update id="deleteById" parameterType="long">
UPDATE tab_haoban_group_chat_plan SET delete_flag = 1 WHERE plan_id = #{planId} UPDATE
tab_haoban_group_chat_plan SET delete_flag = 1 , modifierId =
#{clerkId} , modifierName = #{clerkName} WHERE plan_id = #{planId}
</update> </update>
...@@ -131,28 +135,40 @@ ...@@ -131,28 +135,40 @@
</update> </update>
<!-- ============ 查询============= --> <!-- ============ 查询============= -->
<select id="selectById" parameterType="long" resultMap="result-map-tabHaobanGroupChatPlan"> <select id="selectById" parameterType="long"
SELECT <include refid="Base_Column_List" /> FROM tab_haoban_group_chat_plan WHERE plan_id = #{planId} and delete_flag = 0 resultMap="result-map-tabHaobanGroupChatPlan">
SELECT
<include refid="Base_Column_List" />
FROM tab_haoban_group_chat_plan WHERE plan_id = #{planId} and
delete_flag = 0
</select> </select>
<select id="list" parameterType="com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO" <select id="list"
parameterType="com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO"
resultMap="result-map-tabHaobanGroupChatPlan"> resultMap="result-map-tabHaobanGroupChatPlan">
select <include refid="Base_Column_List" /> from tab_haoban_group_chat_plan where wx_enterprise_id =#{wxEnterpriseId} select
<include refid="Base_Column_List" />
from tab_haoban_group_chat_plan where wx_enterprise_id
=#{wxEnterpriseId}
and enterprise_id = #{enterpriseId} and delete_flag = 0 and enterprise_id = #{enterpriseId} and delete_flag = 0
<if test="null != status and status==1"> <if test="null != status and status==1">
and start_time <![CDATA[<= ]]> now() and end_time >= now() and start_time <![CDATA[<= ]]>
now() and end_time >= now()
</if> </if>
<if test="null != status and status==2"> <if test="null != status and status==2">
and start_time > now() and start_time > now()
</if> </if>
<if test="null != status and status==3"> <if test="null != status and status==3">
and end_time <![CDATA[<]]> now() and end_time <![CDATA[<]]>
now()
</if> </if>
<if test="null != searchParams"> <if test="null != searchParams">
and name like '%#{searchParams}%' and name like '%#{searchParams}%'
</if> </if>
<if test="null != startDate"> <if test="null != startDate">
and create_time <![CDATA[>=]]> #{startDate} and create_time <![CDATA[<=]]> #{endDate} and create_time <![CDATA[>=]]>
#{startDate} and create_time <![CDATA[<=]]>
#{endDate}
</if> </if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -45,6 +45,13 @@ public class GroupChatPlanController { ...@@ -45,6 +45,13 @@ public class GroupChatPlanController {
return RestResponse.successResult(); return RestResponse.successResult();
} }
@RequestMapping("del")
public RestResponse<Object> del(Long planId) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
this.groupChatPlanApiService.del(loginUser.getClerkId(), loginUser.getClerkName() , planId);
return RestResponse.successResult();
}
@RequestMapping("update") @RequestMapping("update")
public RestResponse<Object> update(@RequestBody GroupChatPlanDTO dto) { public RestResponse<Object> update(@RequestBody GroupChatPlanDTO dto) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser(); WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
......
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