|
|
@@ -456,47 +456,47 @@ public class RepairApplicationFormServiceImpl
|
|
|
List<String> mails = new ArrayList<>();
|
|
|
List<String> receiverList = new ArrayList<String>();
|
|
|
|
|
|
- // 发送短信通知给所有维修,且必须是正式环境
|
|
|
- SysUserDTO sysUserDTO = new SysUserDTO();
|
|
|
- sysUserDTO.setRoleCode(SysRoleCodeEnum.Maintenance.name());
|
|
|
- List<SysUserVO> sysUserVOList = sysUserService.getDeptChildrenRoleUser(sysUserDTO);
|
|
|
- if (CollectionUtil.isNotEmpty(sysUserVOList)) {
|
|
|
- for (SysUserVO sysUserVO : sysUserVOList) {
|
|
|
- // 站内信需要用户id
|
|
|
- userIds.add(sysUserVO.getUserId());
|
|
|
- if (StringUtils.isNotBlank(sysUserVO.getWxOpenid())) {
|
|
|
- // 微信id
|
|
|
- openIds.add(sysUserVO.getWxOpenid());
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(sysUserVO.getPhone())) {
|
|
|
- // 手机
|
|
|
- receiverList.add(sysUserVO.getPhone());
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(sysUserVO.getEmail())) {
|
|
|
- // 邮箱
|
|
|
- mails.add(sysUserVO.getEmail());
|
|
|
+ // 报修通知收件人:设备第一维修人 + 维修主管(角色MM) + 机台使用人,不再群发所有维修人员
|
|
|
+ LinkedHashSet<String> notifyUserIds = new LinkedHashSet<>();
|
|
|
+ // 1)设备第一维修人
|
|
|
+ if (StringUtils.isNotBlank(sb.getRepairUser())) {
|
|
|
+ notifyUserIds.add(sb.getRepairUser());
|
|
|
+ }
|
|
|
+ // 2)维修主管:MM 角色全部用户
|
|
|
+ SysUserDTO mmQuery = new SysUserDTO();
|
|
|
+ mmQuery.setRoleCode(SysRoleCodeEnum.MM.name());
|
|
|
+ List<SysUserVO> mmUserList = userMapper.selectDeptRoleUser(mmQuery);
|
|
|
+ if (CollectionUtil.isNotEmpty(mmUserList)) {
|
|
|
+ for (SysUserVO mmUser : mmUserList) {
|
|
|
+ if (StringUtils.isNotBlank(mmUser.getUserId())) {
|
|
|
+ notifyUserIds.add(mmUser.getUserId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 给设备使用机台发消息,完成的时候,也发消息
|
|
|
+ // 3)设备机台使用人
|
|
|
if (StringUtils.isNotBlank(info.getSaveUser())) {
|
|
|
- SysUser saveUser = sysUserService.getModelById(info.getSaveUser());
|
|
|
- if (saveUser != null) {
|
|
|
- // 站内信需要用户id
|
|
|
- userIds.add(saveUser.getUserId());
|
|
|
- if (StringUtils.isNotBlank(saveUser.getWxOpenId())) {
|
|
|
- // 微信id
|
|
|
- openIds.add(saveUser.getWxOpenId());
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(saveUser.getPhone())) {
|
|
|
- // 手机
|
|
|
- receiverList.add(saveUser.getPhone());
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(saveUser.getEmail())) {
|
|
|
- // 邮箱
|
|
|
- mails.add(saveUser.getEmail());
|
|
|
- }
|
|
|
+ notifyUserIds.add(info.getSaveUser());
|
|
|
+ }
|
|
|
+ // 去重后统一收集各渠道接收人(站内信/微信/邮件/短信)
|
|
|
+ for (String notifyUserId : notifyUserIds) {
|
|
|
+ SysUser notifyUser = sysUserService.getModelById(notifyUserId);
|
|
|
+ if (notifyUser == null) {
|
|
|
+ log.warn("报修通知:用户 {} 不存在,跳过", notifyUserId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 站内信需要用户id
|
|
|
+ userIds.add(notifyUser.getUserId());
|
|
|
+ if (StringUtils.isNotBlank(notifyUser.getWxOpenId())) {
|
|
|
+ // 微信id
|
|
|
+ openIds.add(notifyUser.getWxOpenId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(notifyUser.getPhone())) {
|
|
|
+ // 手机
|
|
|
+ receiverList.add(notifyUser.getPhone());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(notifyUser.getEmail())) {
|
|
|
+ // 邮箱
|
|
|
+ mails.add(notifyUser.getEmail());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -520,7 +520,7 @@ public class RepairApplicationFormServiceImpl
|
|
|
}
|
|
|
String repairUrl = domain + "repair/form?no=" + model.getNo();
|
|
|
|
|
|
- // 通过给当天值班维修人员
|
|
|
+ // 发给第一维修人、维修主管及机台使用人
|
|
|
SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
model.getId(),
|
|
|
@@ -534,7 +534,7 @@ public class RepairApplicationFormServiceImpl
|
|
|
log.error("报修通知班长发送失败, 报修id: " + model.getId(), e);
|
|
|
}
|
|
|
|
|
|
- // 发送微信通知给所有维修人角色
|
|
|
+ // 发送微信通知给第一维修人/维修主管/机台使用人
|
|
|
if (CollectionUtil.isNotEmpty(openIds) && BeanUtils.isProd()) {
|
|
|
String mobileDomain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN_MOBILE.name());
|
|
|
if (StringUtils.isBlank(mobileDomain)) {
|
|
|
@@ -1075,6 +1075,94 @@ public class RepairApplicationFormServiceImpl
|
|
|
sbInfoDTO.setChangeReason("维修完成恢复使用");
|
|
|
sbInfoDTO.setActualUser(applicationForm.getRepairUserName());
|
|
|
sbInfoService.updateStatus(sbInfoDTO);
|
|
|
+
|
|
|
+ // 维修完成通知报修人:邮件+站内信+微信,任何异常不影响完成主流程
|
|
|
+ try {
|
|
|
+ sendFinishNoticeToReporter(applicationForm);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("维修完成通知报修人发送失败, 报修id: " + applicationForm.getId(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 维修完成后通知报修人:邮件+站内信+微信
|
|
|
+ * 报修人取报修单的 userId(提交时根据报修人/机台使用人确定)
|
|
|
+ *
|
|
|
+ * @param applicationForm 已完成的报修单
|
|
|
+ */
|
|
|
+ private void sendFinishNoticeToReporter(RepairApplicationForm applicationForm) {
|
|
|
+ String reporterId = applicationForm.getUserId();
|
|
|
+ if (StringUtils.isBlank(reporterId)) {
|
|
|
+ log.warn("报修单 {} 无报修人id,跳过维修完成通知", applicationForm.getNo());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SysUser reporter = sysUserService.getModelById(reporterId);
|
|
|
+ if (reporter == null) {
|
|
|
+ log.warn("报修单 {} 报修人 {} 不存在,跳过维修完成通知", applicationForm.getNo(), reporterId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SbInfoVO sbInfoVO = sbInfoService.getById(applicationForm.getSbId());
|
|
|
+ RepairApplicationFormDTO model = BeanConverterUtil.copyObjectProperties(applicationForm,
|
|
|
+ RepairApplicationFormDTO.class);
|
|
|
+ // 维修人姓名
|
|
|
+ String repairUserName = null;
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getRepairUserId())) {
|
|
|
+ SysUser repairUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
|
|
|
+ if (repairUser != null) {
|
|
|
+ repairUserName = repairUser.getRealName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // PC 详情链接(域名未配置时降级为无链接)
|
|
|
+ String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
|
|
|
+ String repairUrl = null;
|
|
|
+ if (StringUtils.isNotBlank(domain)) {
|
|
|
+ if (!domain.endsWith("/")) {
|
|
|
+ domain = domain + "/";
|
|
|
+ }
|
|
|
+ repairUrl = domain + "repair/form?no=" + applicationForm.getNo();
|
|
|
+ }
|
|
|
+ String sbName = sbInfoVO != null ? sbInfoVO.getName() : "未知";
|
|
|
+ String sbNo = sbInfoVO != null ? sbInfoVO.getNo() : "无";
|
|
|
+ StringBuilder content = new StringBuilder();
|
|
|
+ content.append("<div>您的报修单已维修完成,请知晓:</div>");
|
|
|
+ content.append("<div>报修单号:").append(applicationForm.getNo()).append("</div>");
|
|
|
+ content.append("<div>设备名称:").append(StringUtils.isBlank(sbName) ? "未知" : sbName).append("</div>");
|
|
|
+ content.append("<div>设备编号:").append(StringUtils.isBlank(sbNo) ? "无" : sbNo).append("</div>");
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getSbCph())) {
|
|
|
+ content.append("<div>使用位置:").append(applicationForm.getSbCph()).append("</div>");
|
|
|
+ }
|
|
|
+ content.append("<div>报修内容:")
|
|
|
+ .append(StringUtils.isBlank(applicationForm.getContent()) ? "无" : applicationForm.getContent())
|
|
|
+ .append("</div>");
|
|
|
+ if (StringUtils.isNotBlank(repairUserName)) {
|
|
|
+ content.append("<div>维修人:").append(repairUserName).append("</div>");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getRepairContent())) {
|
|
|
+ content.append("<div>维修内容:").append(applicationForm.getRepairContent()).append("</div>");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(repairUrl)) {
|
|
|
+ content.append("<div><a href=\"").append(repairUrl)
|
|
|
+ .append("\" target=\"_blank\">点击查看详情</a></div>");
|
|
|
+ }
|
|
|
+ List<String> mails = StringUtils.isNotBlank(reporter.getEmail())
|
|
|
+ ? ListUtils.newArrayList(reporter.getEmail().trim()) : new ArrayList<>();
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_FINISH.getValue(),
|
|
|
+ applicationForm.getId(), content.toString(), applicationForm.getId(),
|
|
|
+ ListUtils.newArrayList(reporter.getUserId()), mails));
|
|
|
+
|
|
|
+ // 发送微信通知给报修人
|
|
|
+ if (StringUtils.isNotBlank(reporter.getWxOpenId()) && BeanUtils.isProd()) {
|
|
|
+ String mobileDomain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN_MOBILE.name());
|
|
|
+ if (StringUtils.isNotBlank(mobileDomain)) {
|
|
|
+ if (!mobileDomain.endsWith("/")) {
|
|
|
+ mobileDomain = mobileDomain + "/";
|
|
|
+ }
|
|
|
+ String mobileRepairUrl = mobileDomain + "pages/repair-detail/repair-detail?detailId="
|
|
|
+ + applicationForm.getId();
|
|
|
+ WeChatMessageUtil.repairFinishMessage(reporter.getWxOpenId(), mobileRepairUrl, model, sbInfoVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|