# Conflicts:
#	dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java
This commit is contained in:
Vinjor 2024-10-18 17:00:50 +08:00
commit e4d6de291b
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 Integer BATCH_SIZE = 100;
/**资质临期通知模板*/ /**资质临期通知模板*/
public static final String QUALS_INTERIM_PERIOD = "quals_interim_period"; 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"; 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); 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查该班组的员工 * 通过班组长的id查该班组的员工
* *

View File

@ -2,13 +2,18 @@ package cn.iocoder.yudao.module.base.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 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.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.entity.RepairWorker;
import cn.iocoder.yudao.module.base.mapper.RepairWorkerMapper; import cn.iocoder.yudao.module.base.mapper.RepairWorkerMapper;
import cn.iocoder.yudao.module.base.service.RepairWorkerService; import cn.iocoder.yudao.module.base.service.RepairWorkerService;
import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO; import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO; import cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerSaveReqVO; 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.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService; 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.TICKET_EMPLOY;
/** /**
* 维修工人 Service 实现类 * 维修工人 Service 实现类
* *
@ -39,6 +48,12 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
@Resource @Resource
@Lazy @Lazy
private DlRepairTitemService dlRepairTitemService; private DlRepairTitemService dlRepairTitemService;
@Resource
private NotifyMessageSendApi sendApi;
@Autowired
private NotifyMessageSocket notifyMessageSocket;
@Resource
private AdminUserApi userApi;
/** /**
@ -50,7 +65,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
**/ **/
@Override @Override
public void saveWorkers(List<UserDTO> userList) { public void saveWorkers(List<UserDTO> userList) {
if (CollectionUtil.isNotEmpty(userList)){ if (CollectionUtil.isNotEmpty(userList)) {
//获取已有的维修工人ID列表 //获取已有的维修工人ID列表
List<Long> existingWorkerIds = workerMapper.getAllWorkerIds(); List<Long> existingWorkerIds = workerMapper.getAllWorkerIds();
@ -98,18 +113,18 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
**/ **/
@Override @Override
public IPage<RepairWorkerRespVO> queryListPage(RepairWorkerPageReqVO pageReqVO, Page<RepairWorkerRespVO> page) { public IPage<RepairWorkerRespVO> queryListPage(RepairWorkerPageReqVO pageReqVO, Page<RepairWorkerRespVO> page) {
return workerMapper.queryListPage(pageReqVO,page); return workerMapper.queryListPage(pageReqVO, page);
} }
/** /**
* 通过工单ID查到工单ID中所选择的员工信息 * 通过工单ID查到工单ID中所选择的员工信息
* *
* @param ticketId 工单ID
* @author 小李 * @author 小李
* @date 15:53 2024/10/14 * @date 15:53 2024/10/14
* @param ticketId 工单ID
**/ **/
@Override @Override
public List<RepairWorker> listByTicketId(String ticketId){ public List<RepairWorker> listByTicketId(String ticketId) {
// 查工单的项目信息 // 查工单的项目信息
List<DlRepairTitem> titems = dlRepairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>() List<DlRepairTitem> titems = dlRepairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>()
.and(item -> { .and(item -> {
@ -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查该班组的员工 * 通过班组长的id查该班组的员工
* *
@ -129,7 +172,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
* @date 16:55 2024/10/14 * @date 16:55 2024/10/14
**/ **/
@Override @Override
public List<RepairWorker> listByLeads(){ public List<RepairWorker> listByLeads() {
// 取班组长的记录 // 取班组长的记录
RepairWorker worker = baseMapper.selectOne(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId())); RepairWorker worker = baseMapper.selectOne(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId()));
// 根据班组长的工种查所有该工程的工人 // 根据班组长的工种查所有该工程的工人
@ -149,7 +192,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
public boolean getIfLeader() { public boolean getIfLeader() {
Long userId = SecurityFrameworkUtils.getLoginUserId(); Long userId = SecurityFrameworkUtils.getLoginUserId();
LambdaQueryWrapper<RepairWorker> queryWrapper = new LambdaQueryWrapper<RepairWorker>() LambdaQueryWrapper<RepairWorker> queryWrapper = new LambdaQueryWrapper<RepairWorker>()
.eq(RepairWorker::getUserId,userId); .eq(RepairWorker::getUserId, userId);
List<RepairWorker> list = this.list(queryWrapper); List<RepairWorker> list = this.list(queryWrapper);
return !list.isEmpty() && "1".equals(list.get(0).getIsLeads()); return !list.isEmpty() && "1".equals(list.get(0).getIsLeads());
} }

View File

@ -514,6 +514,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
if (update != 1) { if (update != 1) {
throw exception0(500, "工单已开始"); throw exception0(500, "工单已开始");
} }
workerService.sentMessage(reqVO.getNowRepairId(),"您有新的工单要处理");
//最后记录操作日志--指派施工 //最后记录操作日志--指派施工
repairRecordsService.saveRepairRecord(reqVO.getId(),null, RecordTypeEnum.ZPSG.getCode(),"指派施工",null); repairRecordsService.saveRepairRecord(reqVO.getId(),null, RecordTypeEnum.ZPSG.getCode(),"指派施工",null);
} }