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 05a1946a..a8e393cc 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 @@ -87,6 +87,17 @@ public interface RepairWorkerService extends IService { **/ void sentMessage(Long userId,String text); + /** + * 向指定用户发送消息(用户,非员工) + * + * @author 小李 + * @date 16:52 2024/11/6 + * @param ticketId 工单ID + * @param text 消息通知内容 + * @param isSMS 是否需要发短信 + **/ + void sentMessageToCus(String ticketId, String text, Boolean isSMS); + /** * 通过班组长的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 fc10bb08..5128a232 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 @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.base.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.common.RepairRoleEnum; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.security.core.LoginUser; @@ -13,6 +14,8 @@ 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.custom.entity.CustomerMain; +import cn.iocoder.yudao.module.custom.service.CustomerMainService; import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; @@ -20,9 +23,14 @@ import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDT import cn.iocoder.yudao.module.system.api.permission.PermissionApi; import cn.iocoder.yudao.module.system.api.permission.RoleApi; import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; +import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets; import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; +import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService; import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService; +import cn.iocoder.yudao.util.SendSmsUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -31,6 +39,7 @@ 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 org.yaml.snakeyaml.events.Event; import javax.annotation.Resource; import java.io.IOException; @@ -69,6 +78,14 @@ public class RepairWorkerServiceImpl extends ServiceImpl roleIds = permissionApi.getRoleIdsByUserId(userId); @@ -173,12 +190,12 @@ public class RepairWorkerServiceImpl extends ServiceImpl queryListPage(RepairWorkerPageReqVO pageReqVO, Page page) { - IPage respVOIPage= workerMapper.queryListPage(pageReqVO, page); - if(!respVOIPage.getRecords().isEmpty()){ + IPage respVOIPage = workerMapper.queryListPage(pageReqVO, page); + if (!respVOIPage.getRecords().isEmpty()) { // 单位字典 List recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_WORK_TYPE); - Map typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel)); - respVOIPage.getRecords().stream().peek(item->item.setWorkTypeText(typeMap.get(item.getWorkType()))).collect(Collectors.toList()); + Map typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel)); + respVOIPage.getRecords().stream().peek(item -> item.setWorkTypeText(typeMap.get(item.getWorkType()))).collect(Collectors.toList()); } return respVOIPage; } @@ -201,11 +218,11 @@ public class RepairWorkerServiceImpl extends ServiceImpl ids = titems.stream().flatMap(item -> Arrays.stream(item.getRepairIds().split(","))).collect(Collectors.toSet()); List repairWorkerList = baseMapper.selectList(new LambdaQueryWrapper().in(RepairWorker::getUserId, ids)); - if(!repairWorkerList.isEmpty()){ + if (!repairWorkerList.isEmpty()) { // 单位字典 List recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_WORK_TYPE); - Map typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel)); - repairWorkerList.stream().peek(item->item.setWorkTypeText(typeMap.get(item.getWorkType()))).collect(Collectors.toList()); + Map typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel)); + repairWorkerList.stream().peek(item -> item.setWorkTypeText(typeMap.get(item.getWorkType()))).collect(Collectors.toList()); } //翻译工种 return repairWorkerList; @@ -241,6 +258,42 @@ public class RepairWorkerServiceImpl extends ServiceImpl templateParams = new HashMap<>(); + // 发送模版内容 + templateParams.put("text", text); + // 发送站内信 + sendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO() + .setUserId(customerMain.getUserId()) + .setTemplateCode(TICKET_EMPLOY).setTemplateParams(templateParams)); + //发送语音提醒 + notifyMessageSocket.sendMessage(text, TenantContextHolder.getRequiredTenantId().toString(), String.valueOf(customerMain.getUserId())); + + // 发送短信 + if (isSMS) { + SendSmsUtil.sendMsgCommon(new String[]{text}, customerMain.getPhoneNumber(), "1400852709", "蓝安汽车小程序", "2143603"); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + /** * 通过班组长的id查该班组的员工 * 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 5b63d2bc..cf02e416 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 @@ -301,6 +301,11 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl() @@ -944,6 +950,15 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId()).last("limit 1")); + List dataList = dictDataApi.getDictDataList("repair_work_type"); + DictDataRespDTO dictDataRespDTO = dataList.stream().filter(item -> item.getValue().equals(worker.getWorkType())).findFirst().orElse(null); + String message = String.format("您的爱车%s已由%s %s接单了", tickets.getCarNo(), (dictDataRespDTO != null ? dictDataRespDTO.getLabel() : "维修工"), worker.getUserName()); + repairWorkerService.sentMessageToCus(id, message, false); } /** @@ -1078,6 +1093,22 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId()).last("limit 1")); + List dataList = dictDataApi.getDictDataList("repair_work_type"); + DictDataRespDTO dictDataRespDTO = dataList.stream().filter(item -> item.getValue().equals(worker.getWorkType())).findFirst().orElse(null); + String newMessage = String.format( + "您的爱车%s已由%s %s%s", + tickets.getCarNo(), + (dictDataRespDTO != null ? dictDataRespDTO.getLabel() : "维修工"), + worker.getUserName(), + (respVO.getRecordType().equals(RecordTypeEnum.KSSG.getCode()) ? "开始施工" : "施工完成") + ); + repairWorkerService.sentMessageToCus(tickets.getId(), newMessage, false); + } } private String createMessage(String who, String no, String projectName, String type, String finishType, String nextName) { @@ -1191,6 +1222,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl