From 88e5379ea2bf82a02a85ea51c492ff6c54ee64f2 Mon Sep 17 00:00:00 2001 From: PQZ Date: Fri, 18 Oct 2024 16:50:38 +0800 Subject: [PATCH] 111 --- .../iocoder/yudao/common/BaseConstants.java | 2 + .../base/service/RepairWorkerService.java | 9 +++ .../service/impl/RepairWorkerServiceImpl.java | 55 +++++++++++++++++-- .../impl/DlRepairTicketsServiceImpl.java | 1 + 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java index 564a4167..f104692e 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java @@ -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"; /** 资产临期通知模板 */ diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java index 730e7e3d..c267c455 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairWorkerService.java @@ -69,6 +69,15 @@ public interface RepairWorkerService extends IService { **/ List listByTicketId(String ticketId); + /** + * 向指定用户发送消息 + * @author PQZ + * @date 16:27 2024/10/18 + * @param userId 用户id + * @param text 消息通知内容 + **/ + void sentMessage(Long userId,String text); + /** * 通过班组长的id查该班组的员工 * diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java index c06edd16..3fc5a4dd 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java @@ -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 userList) { - if (CollectionUtil.isNotEmpty(userList)){ + if (CollectionUtil.isNotEmpty(userList)) { //获取已有的维修工人ID列表 List existingWorkerIds = workerMapper.getAllWorkerIds(); @@ -98,18 +113,18 @@ public class RepairWorkerServiceImpl extends ServiceImpl queryListPage(RepairWorkerPageReqVO pageReqVO, Page page) { - return workerMapper.queryListPage(pageReqVO,page); + return workerMapper.queryListPage(pageReqVO, page); } /** * 通过工单ID查到工单ID中所选择的员工信息 * + * @param ticketId 工单ID * @author 小李 * @date 15:53 2024/10/14 - * @param ticketId 工单ID **/ @Override - public List listByTicketId(String ticketId){ + public List listByTicketId(String ticketId) { // 查工单的项目信息 List titems = dlRepairTitemService.list(new LambdaQueryWrapper() .and(item -> { @@ -122,6 +137,34 @@ public class RepairWorkerServiceImpl extends ServiceImpl 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查该班组的员工 * @@ -129,7 +172,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl listByLeads(){ + public List listByLeads() { // 取班组长的记录 RepairWorker worker = baseMapper.selectOne(new LambdaQueryWrapper().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId())); // 根据班组长的工种查所有该工程的工人 @@ -149,7 +192,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper() - .eq(RepairWorker::getUserId,userId); + .eq(RepairWorker::getUserId, userId); List list = this.list(queryWrapper); return !list.isEmpty() && "1".equals(list.get(0).getIsLeads()); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index 9cdd4c24..d322a4c4 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -509,6 +509,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl