|
|
|
|
@ -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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -50,7 +65,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
|
|
|
|
|
**/
|
|
|
|
|
@Override
|
|
|
|
|
public void saveWorkers(List<UserDTO> userList) {
|
|
|
|
|
if (CollectionUtil.isNotEmpty(userList)){
|
|
|
|
|
if (CollectionUtil.isNotEmpty(userList)) {
|
|
|
|
|
//获取已有的维修工人ID列表
|
|
|
|
|
List<Long> existingWorkerIds = workerMapper.getAllWorkerIds();
|
|
|
|
|
|
|
|
|
|
@ -98,18 +113,18 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
|
|
|
|
|
**/
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<RepairWorkerRespVO> queryListPage(RepairWorkerPageReqVO pageReqVO, Page<RepairWorkerRespVO> 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<RepairWorker> listByTicketId(String ticketId){
|
|
|
|
|
public List<RepairWorker> listByTicketId(String ticketId) {
|
|
|
|
|
// 查工单的项目信息
|
|
|
|
|
List<DlRepairTitem> titems = dlRepairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>()
|
|
|
|
|
.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查该班组的员工
|
|
|
|
|
*
|
|
|
|
|
@ -129,7 +172,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
|
|
|
|
|
* @date 16:55 2024/10/14
|
|
|
|
|
**/
|
|
|
|
|
@Override
|
|
|
|
|
public List<RepairWorker> listByLeads(){
|
|
|
|
|
public List<RepairWorker> listByLeads() {
|
|
|
|
|
// 取班组长的记录
|
|
|
|
|
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() {
|
|
|
|
|
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
|
|
LambdaQueryWrapper<RepairWorker> queryWrapper = new LambdaQueryWrapper<RepairWorker>()
|
|
|
|
|
.eq(RepairWorker::getUserId,userId);
|
|
|
|
|
.eq(RepairWorker::getUserId, userId);
|
|
|
|
|
List<RepairWorker> list = this.list(queryWrapper);
|
|
|
|
|
return !list.isEmpty() && "1".equals(list.get(0).getIsLeads());
|
|
|
|
|
}
|
|
|
|
|
|