feat: 一些调整
This commit is contained in:
parent
507b2e085d
commit
da7331309d
|
|
@ -7,6 +7,10 @@ import cn.hutool.json.JSONUtil;
|
|||
import com.nflg.mobilebroken.admin.pojo.dto.TiketTimeoutDTO;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.constant.MessageSubType;
|
||||
import com.nflg.mobilebroken.common.constant.UserState;
|
||||
import com.nflg.mobilebroken.common.pojo.request.TicketEvaluateAddRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.TicketEvaluateAddVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.TicketEvaluateItemVO;
|
||||
import com.nflg.mobilebroken.repository.entity.*;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import com.nflg.mobilebroken.starter.service.EmailService;
|
||||
|
|
@ -16,12 +20,14 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.mail.MessagingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
|
|
@ -48,15 +54,73 @@ public class TicketScheduledTasks {
|
|||
@Resource
|
||||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
|
||||
@Resource
|
||||
private ITBaseDeviceTypeService deviceTypeService;
|
||||
|
||||
@Resource
|
||||
private EmailService emailService;
|
||||
|
||||
@Resource
|
||||
private IParamConfigService paramConfigService;
|
||||
|
||||
@Resource
|
||||
private ITicketEvaluateService ticketEvaluateService;
|
||||
|
||||
/**
|
||||
* 工单评论邀请邮件
|
||||
* 每天午夜12点执行一次
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void sendInviteCommentEmail() {
|
||||
List<Ticket> tickets=ticketService.getNonComment(7);
|
||||
tickets.forEach(ticket -> {
|
||||
AdminUser createUser = adminUserService.getById(ticket.getUserId());
|
||||
if (Objects.equals(createUser.getState(), UserState.Activated.getState())) {
|
||||
List<Integer> adminUserIds = Arrays.stream(ticket.getHandle().split(","))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
List<AdminUser> adminUsers = adminUserService.listByIds(adminUserIds);
|
||||
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_TICKET_INVITE_COMMENT, Constant.DEFAULT_LANGUAGE_CODE);
|
||||
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_TICKET_INVITE_COMMENT, Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.replace("${no}", ticket.getNo())
|
||||
.replace("${title}", ticket.getTitle())
|
||||
.replace("${createUser}", createUser.getUserName())
|
||||
.replace("${handleUser}", StrUtil.join(",", adminUsers.stream().map(AdminUser::getUserName).collect(Collectors.toList())))
|
||||
.replace("${createTime}", toTimeString(ticket.getCreateTime()))
|
||||
.replace("${msg}", subject);
|
||||
try {
|
||||
sendEamilForAdminUser(adminUsers, subject, content);
|
||||
} catch (Exception e) {
|
||||
log.error("邮件发送失败", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 工单自动评论
|
||||
* 每天午夜12点执行一次
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void autoComment() {
|
||||
List<Ticket> tickets=ticketService.getNonComment(10);
|
||||
TicketEvaluateAddVO vo=dictionaryItemTranslateService.getTicketEvaluateSelect(Constant.DEFAULT_LANGUAGE_CODE);
|
||||
TicketEvaluateAddRequest request = new TicketEvaluateAddRequest();
|
||||
request.setType(1);
|
||||
request.setScore(new BigDecimal("5"));
|
||||
TicketEvaluateItemVO se=vo.getServiceEvaluation().stream()
|
||||
.filter(it->StrUtil.equals(it.getCode(), Constant.DICTIONARY_TYPE_SERVICE_EVALUATION+"Satisfied"))
|
||||
.findFirst().get();
|
||||
request.setServiceEvaluationId(se.getId());
|
||||
request.setServiceEvaluationSelectIds(se.getChildren().stream().map(TicketEvaluateItemVO::getId).collect(Collectors.toList()));
|
||||
TicketEvaluateItemVO pe=vo.getServiceEvaluation().stream()
|
||||
.filter(it->StrUtil.equals(it.getCode(), Constant.DICTIONARY_TYPE_SERVICE_EVALUATION+"Satisfied"))
|
||||
.findFirst().get();
|
||||
request.setProductEvaluationId(pe.getId());
|
||||
request.setProductEvaluationSelectIds(pe.getChildren().stream().map(TicketEvaluateItemVO::getId).collect(Collectors.toList()));
|
||||
tickets.forEach(ticket -> {
|
||||
request.setTicketId(ticket.getId());
|
||||
ticketEvaluateService.add(request);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 工单超时提醒
|
||||
* 每天午夜12点执行一次
|
||||
|
|
|
|||
|
|
@ -36,8 +36,12 @@ public class Constant {
|
|||
|
||||
public static final String DICTIONARY_ITEM_EMAIL_TITLE_TICKET_TIMEOUT="TitleTicketTimeout";
|
||||
|
||||
public static final String DICTIONARY_ITEM_EMAIL_TITLE_TICKET_INVITE_COMMENT="TitleInviteComment";
|
||||
|
||||
public static final String DICTIONARY_ITEM_EMAIL_CONTENT_TICKET_NOTIFY="TicketNotify";
|
||||
|
||||
public static final String DICTIONARY_ITEM_EMAIL_CONTENT_TICKET_INVITE_COMMENT="InviteComment";
|
||||
|
||||
public static final String DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD="TitleResetPassword";
|
||||
|
||||
public static final String DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_ACTIVATION="TitleAccountActivation";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -32,4 +33,8 @@ public class TicketEvaluateAddRequest {
|
|||
|
||||
//反馈
|
||||
private String feedback;
|
||||
|
||||
//来源,0:用户,1:系统
|
||||
@JsonIgnore
|
||||
private Integer type=0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ public class TicketEvaluate implements Serializable {
|
|||
*/
|
||||
private Integer ticketId;
|
||||
|
||||
/**
|
||||
* 来源,0:用户,1:系统
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 售后服务评价
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -45,4 +45,6 @@ public interface ITicketService extends IService<Ticket> {
|
|||
Ticket reopen(Integer id);
|
||||
|
||||
Ticket addTicketHandle(TicketHandleAddRequest request);
|
||||
|
||||
List<Ticket> getNonComment(int days);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public class TicketEvaluateServiceImpl extends ServiceImpl<TicketEvaluateMapper,
|
|||
&& !Objects.equals(ticket.getState(), TicketState.Closed.getState())).throwMessage("工单状态异常");
|
||||
TicketEvaluate ticketEvaluate = new TicketEvaluate()
|
||||
.setTicketId(request.getTicketId())
|
||||
.setType(request.getType())
|
||||
.setServiceEvaluation(request.getServiceEvaluationId())
|
||||
.setServiceEvaluationSelect(StrUtil.join(",", request.getServiceEvaluationSelectIds()))
|
||||
.setProductEvaluation(request.getProductEvaluationId())
|
||||
|
|
|
|||
|
|
@ -112,8 +112,9 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
|
|||
Ticket ticket = getById(request.getTicketId());
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("未找到工单");
|
||||
VUtils.trueThrowBusinessError(!Objects.equals(ticket.getState(), TicketState.PendingProcessing.getState())).throwMessage("工单状态异常");
|
||||
// VUtils.trueThrowBusinessError(Objects.nonNull(ticket.getCqm()) && !Objects.equals(ticket.getCqm(), AdminUserUtil.getUserId()))
|
||||
// .throwMessage("当前工单已归属别的CQM负责人");
|
||||
VUtils.trueThrowBusinessError(adminUserService.getCQM().stream()
|
||||
.noneMatch(u -> Objects.equals(u.getId(), AdminUserUtil.getUserId())))
|
||||
.throwMessage("你不是CQM,无权关闭工单");
|
||||
ticket.setUrgency(TicketUrgency.findByValue(request.getUrgency()).getState());
|
||||
ticket.setQuestion(request.getQuestion());
|
||||
ticket.setState(TicketState.Processing.getState());
|
||||
|
|
@ -168,7 +169,6 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
|
|||
.noneMatch(uid->StrUtil.equals(uid, AdminUserUtil.getUserId().toString())))
|
||||
.throwMessage("你无权操作该工单");
|
||||
ticket.setState(TicketState.ProcessingCompleted.getState());
|
||||
ticket.setSolveTime(LocalDateTime.now());
|
||||
ticket.setCurrentHandle(AdminUserUtil.getUserId());
|
||||
ticket.setUpdateTime(LocalDateTime.now());
|
||||
updateById(ticket);
|
||||
|
|
@ -181,8 +181,13 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
|
|||
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("未找到工单");
|
||||
VUtils.trueThrowBusinessError(!Objects.equals(ticket.getState(), TicketState.ProcessingCompleted.getState()))
|
||||
.throwMessage("工单状态不允许关闭");
|
||||
// VUtils.trueThrowBusinessError(!Objects.equals(ticket.getCqm(), AdminUserUtil.getUserId()))
|
||||
// .throwMessage("当前工单未归属当前CQM负责人");
|
||||
VUtils.trueThrowBusinessError(!ticketEvaluateService.lambdaQuery()
|
||||
.eq(TicketEvaluate::getTicketId, request.getTicketId())
|
||||
.exists())
|
||||
.throwMessage("工单尚未评价,不能关闭");
|
||||
VUtils.trueThrowBusinessError(adminUserService.getCQM().stream()
|
||||
.noneMatch(u -> Objects.equals(u.getId(), AdminUserUtil.getUserId())))
|
||||
.throwMessage("你不是CQM,无权关闭工单");
|
||||
ticket.setState(TicketState.Closed.getState());
|
||||
ticket.setSolution(request.getSolution());
|
||||
ticket.setSolutionAttachments(StrUtil.join(",", request.getAttachments()));
|
||||
|
|
@ -273,4 +278,13 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
|
|||
updateById(ticket);
|
||||
return ticket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Ticket> getNonComment(int days) {
|
||||
return lambdaQuery()
|
||||
.eq(Ticket::getState, TicketState.ProcessingCompleted.getState())
|
||||
.ge(Ticket::getUpdateTime, LocalDateTime.now().minusDays(days))
|
||||
.lt(Ticket::getUpdateTime, LocalDateTime.now().minusDays(days-1))
|
||||
.list();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue