This commit is contained in:
PQZ 2024-10-18 16:50:38 +08:00
parent 88dab0293f
commit 88e5379ea2
4 changed files with 61 additions and 6 deletions

View File

@ -55,6 +55,8 @@ public class BaseConstants {
public static final Integer BATCH_SIZE = 100;
/**资质临期通知模板*/
public static final String QUALS_INTERIM_PERIOD = "quals_interim_period";
/**站内信模版*/
public static final String TICKET_EMPLOY = "ticket_employ";
/**资质过期通知模板*/
public static final String QUALS_EXPIRED = "quals_expired";
/** 资产临期通知模板 */

View File

@ -69,6 +69,15 @@ public interface RepairWorkerService extends IService<RepairWorker> {
**/
List<RepairWorker> listByTicketId(String ticketId);
/**
* 向指定用户发送消息
* @author PQZ
* @date 16:27 2024/10/18
* @param userId 用户id
* @param text 消息通知内容
**/
void sentMessage(Long userId,String text);
/**
* 通过班组长的id查该班组的员工
*

View File

@ -2,13 +2,18 @@ package cn.iocoder.yudao.module.base.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.app.controller.admin.NotifyMessageSocket;
import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.mapper.RepairWorkerMapper;
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerSaveReqVO;
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
@ -16,14 +21,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.TICKET_EMPLOY;
/**
* 维修工人 Service 实现类
*
@ -39,6 +48,12 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
@Resource
@Lazy
private DlRepairTitemService dlRepairTitemService;
@Resource
private NotifyMessageSendApi sendApi;
@Autowired
private NotifyMessageSocket notifyMessageSocket;
@Resource
private AdminUserApi userApi;
/**
@ -104,9 +119,9 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
/**
* 通过工单ID查到工单ID中所选择的员工信息
*
* @param ticketId 工单ID
* @author 小李
* @date 15:53 2024/10/14
* @param ticketId 工单ID
**/
@Override
public List<RepairWorker> listByTicketId(String ticketId) {
@ -122,6 +137,34 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
}
/**
* 向指定用户发送消息
*
* @param userId 用户id
* @param text 消息通知内容
* @author PQZ
* @date 16:27 2024/10/18
**/
@Override
public void sentMessage(Long userId, String text) {
try {
//获取当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
// 准备发送参数
Map<String, Object> templateParams = new HashMap<>();
// 发送模版内容
templateParams.put("text", text);
// 发送站内信
sendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
.setUserId(userId)
.setTemplateCode(TICKET_EMPLOY).setTemplateParams(templateParams));
//发送语音提醒
notifyMessageSocket.sendMessage(text, loginUser.getTenantId().toString(), userId.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 通过班组长的id查该班组的员工
*

View File

@ -509,6 +509,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
if (update != 1) {
throw exception0(500, "工单已开始");
}
workerService.sentMessage(reqVO.getNowRepairId(),"您有新的工单要处理");
}
}