mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2025-01-27 01:27:52 +08:00
工单派工通知代码迁移
This commit is contained in:
parent
9931adad2d
commit
3542a21cf4
5 changed files with 1 additions and 206 deletions
|
@ -128,18 +128,4 @@ public class Constants {
|
|||
return SYS_EVE_TALK_GROUP_USER_LIST + groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param orderNum 获取工单派工内容字符串
|
||||
* @param userName 接收人
|
||||
* @return
|
||||
*/
|
||||
public static String getNoticeServiceUserContent(String orderNum, String userName) {
|
||||
return "尊敬的" + userName + ",您好:<br/>" + "您有一份待接单工单,工单号为:" + orderNum + ",请及时接单。";
|
||||
}
|
||||
|
||||
// 协助人
|
||||
public static String getNoticeCooperationUserContent(String orderNum, String userName) {
|
||||
return "尊敬的" + userName + ",您好:<br/>" + "您有一份协助工单,工单号为:" + orderNum + ",请配合工单接收人完成该售后服务。";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
|
||||
******************************************************************************/
|
||||
|
||||
package com.skyeye.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface MQUserEmailDao {
|
||||
|
||||
Map<String, Object> queryServiceMationBySericeId(@Param("serviceId") String serviceId);
|
||||
|
||||
List<Map<String, Object>> queryCooperationUserNameById(@Param("serviceId") String serviceId);
|
||||
|
||||
int insertNoticeListMation(List<Map<String, Object>> notices);
|
||||
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
|
||||
******************************************************************************/
|
||||
|
||||
package com.skyeye.mq.job.impl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.skyeye.common.constans.CommonConstants;
|
||||
import com.skyeye.common.constans.Constants;
|
||||
import com.skyeye.common.constans.MqConstants;
|
||||
import com.skyeye.common.util.DataCommonUtil;
|
||||
import com.skyeye.common.util.MailUtil;
|
||||
import com.skyeye.common.util.ToolUtil;
|
||||
import com.skyeye.dao.MQUserEmailDao;
|
||||
import com.skyeye.service.JobMateMationService;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: WatiWorkerSendServiceImpl
|
||||
* @Description: 派工通知
|
||||
* @author: skyeye云系列--卫志强
|
||||
* @date: 2021/7/6 22:56
|
||||
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
|
||||
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
|
||||
*/
|
||||
@Component
|
||||
@RocketMQMessageListener(
|
||||
topic = "${topic.wati-worker-send-service}",
|
||||
consumerGroup = "${topic.wati-worker-send-service}",
|
||||
selectorExpression = "${spring.profiles.active}")
|
||||
public class WatiWorkerSendServiceImpl implements RocketMQListener<String> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WatiWorkerSendServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private MQUserEmailDao mqUserEmailDao;
|
||||
|
||||
@Autowired
|
||||
private JobMateMationService jobMateMationService;
|
||||
|
||||
@Override
|
||||
public void onMessage(String data) {
|
||||
Map<String, Object> map = JSONUtil.toBean(data, null);
|
||||
String jobId = map.get("jobMateId").toString();
|
||||
try {
|
||||
// 任务开始
|
||||
jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_PROCESSING, "");
|
||||
//工单id
|
||||
String serviceId = map.get("serviceId").toString();
|
||||
//获取工单接收人和协助人id
|
||||
Map<String, Object> mation = mqUserEmailDao.queryServiceMationBySericeId(serviceId);
|
||||
//如果工单信息不为空
|
||||
if (mation != null) {
|
||||
//调用消息系统添加通知
|
||||
List<Map<String, Object>> notices = new ArrayList<>();
|
||||
String content;
|
||||
//1.接收人通知
|
||||
if (!ToolUtil.isBlank(mation.get("userId").toString())) {
|
||||
//1.1内部消息
|
||||
content = Constants.getNoticeServiceUserContent(mation.get("orderNum").toString(), mation.get("userName").toString());
|
||||
Map<String, Object> notice = new HashMap<>();
|
||||
notice.put("title", "工单派工提醒");
|
||||
notice.put("noticeDesc", "您有一条新的派工信息,请及时阅读。");
|
||||
notice.put("content", content);
|
||||
// 未读消息
|
||||
notice.put("state", "1");
|
||||
notice.put("userId", mation.get("userId").toString());
|
||||
// 消息类型
|
||||
notice.put("type", "3");
|
||||
DataCommonUtil.setCommonData(notice, CommonConstants.ADMIN_USER_ID);
|
||||
notices.add(notice);
|
||||
//1.2发送邮件
|
||||
String email = mation.get("email").toString();
|
||||
if (ToolUtil.isEmail(email) && !ToolUtil.isBlank(email)) {
|
||||
new MailUtil().send(email, "工单派工提醒", content);
|
||||
}
|
||||
}
|
||||
//2.协助人通知
|
||||
if (!ToolUtil.isBlank(mation.get("cooperationUserId").toString())) {
|
||||
//获取协助人
|
||||
List<Map<String, Object>> cooperationUser = mqUserEmailDao.queryCooperationUserNameById(serviceId);
|
||||
|
||||
for (Map<String, Object> user : cooperationUser) {
|
||||
//2.1内部消息
|
||||
content = Constants.getNoticeCooperationUserContent(mation.get("orderNum").toString(), user.get("name").toString());
|
||||
Map<String, Object> notice = new HashMap<>();
|
||||
notice.put("title", "工单派工提醒");
|
||||
notice.put("noticeDesc", "您有一条新的派工信息,请及时阅读。");
|
||||
notice.put("content", content);
|
||||
// 未读消息
|
||||
notice.put("state", "1");
|
||||
notice.put("userId", user.get("id").toString());
|
||||
// 消息类型
|
||||
notice.put("type", "3");
|
||||
DataCommonUtil.setCommonData(notice, CommonConstants.ADMIN_USER_ID);
|
||||
notices.add(notice);
|
||||
//2.2发送邮件
|
||||
String email = user.get("email").toString();
|
||||
if (ToolUtil.isEmail(email) && !ToolUtil.isBlank(email)) {
|
||||
new MailUtil().send(email, "工单派工提醒", content);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!notices.isEmpty()) {
|
||||
mqUserEmailDao.insertNoticeListMation(notices);
|
||||
}
|
||||
}
|
||||
// 任务完成
|
||||
jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_SUCCESS, "");
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Dispatch notice failed, reason is {}.", e);
|
||||
// 任务失败
|
||||
jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_FAIL, "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.skyeye.dao.MQUserEmailDao">
|
||||
|
||||
<select id="queryServiceMationBySericeId" resultType="java.util.Map">
|
||||
SELECT
|
||||
a.id,
|
||||
a.order_num orderNum,
|
||||
b.user_name userName,
|
||||
a.service_user_id userId,
|
||||
IFNULL(b.email, '') email,
|
||||
IFNULL(a.cooperation_user_id, '') cooperationUserId
|
||||
FROM
|
||||
crm_service a,
|
||||
sys_eve_user_staff b
|
||||
WHERE a.id = #{serviceId}
|
||||
AND a.service_user_id = b.user_id
|
||||
</select>
|
||||
|
||||
<select id="queryCooperationUserNameById" resultType="java.util.Map">
|
||||
SELECT
|
||||
b.user_id id,
|
||||
b.user_name `name`,
|
||||
b.email
|
||||
FROM
|
||||
crm_service a,
|
||||
sys_eve_user_staff b
|
||||
WHERE
|
||||
a.id = #{serviceId}
|
||||
AND INSTR(CONCAT(',', a.cooperation_user_id, ','),CONCAT(',', b.user_id, ','))
|
||||
</select>
|
||||
|
||||
<insert id="insertNoticeListMation" parameterType="java.util.Map">
|
||||
insert into sys_eve_user_notice
|
||||
(id, title, `desc`, content, state, receive_id, type, create_id, create_time)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator="," >
|
||||
(#{item.id}, #{item.title}, #{item.noticeDesc}, #{item.content}, #{item.state}, #{item.userId}, #{item.type}, #{item.createId}, #{item.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
|
@ -38,6 +38,4 @@ topic:
|
|||
# 邮件通知的topic
|
||||
ordinary-mail-delivery-service: ORDINARY_MAIL_DELIVERY_SERVICE
|
||||
# 消息通知的topic
|
||||
notice-send-service: NOTICE_SEND_SERVICE
|
||||
# 派工通知的topic
|
||||
wati-worker-send-service: WATI_WORKER_SEND_SERVICE
|
||||
notice-send-service: NOTICE_SEND_SERVICE
|
Loading…
Reference in a new issue