|
@@ -0,0 +1,382 @@
|
|
|
|
|
+package com.sckw.system.service;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import com.sckw.core.exception.SystemException;
|
|
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
|
|
+import com.sckw.core.web.constant.HttpStatus;
|
|
|
|
|
+import com.sckw.core.web.context.LoginUserHolder;
|
|
|
|
|
+import com.sckw.core.web.model.LoginUserInfo;
|
|
|
|
|
+import com.sckw.core.web.response.result.PageDataResult;
|
|
|
|
|
+import com.sckw.system.model.TComplaint;
|
|
|
|
|
+import com.sckw.system.model.TComplaintAttachment;
|
|
|
|
|
+import com.sckw.system.model.TComplaintHandleLog;
|
|
|
|
|
+import com.sckw.system.model.vo.req.ComplaintAppListReqVo;
|
|
|
|
|
+import com.sckw.system.model.vo.req.ComplaintAppSubmitReqVo;
|
|
|
|
|
+import com.sckw.system.model.vo.req.ComplaintManagePageReqVo;
|
|
|
|
|
+import com.sckw.system.model.vo.req.ComplaintProcessReqVo;
|
|
|
|
|
+import com.sckw.system.model.vo.res.*;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@Service
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+public class KwsComplaintService {
|
|
|
|
|
+
|
|
|
|
|
+ private static final DateTimeFormatter DATE_NO_DASH = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
|
+
|
|
|
|
|
+ private final TComplaintService tComplaintService;
|
|
|
|
|
+ private final TComplaintAttachmentService tComplaintAttachmentService;
|
|
|
|
|
+ private final TComplaintHandleLogService tComplaintHandleLogService;
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public ComplaintDetailResVo submitAppComplaint(ComplaintAppSubmitReqVo reqVo) {
|
|
|
|
|
+ LoginUserInfo loginUserInfo = LoginUserHolder.get();
|
|
|
|
|
+
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+
|
|
|
|
|
+ TComplaint complaint = new TComplaint();
|
|
|
|
|
+ complaint.setComplaintNo(buildComplaintNo(now));
|
|
|
|
|
+ complaint.setChannel(1);
|
|
|
|
|
+ complaint.setTypeCode(reqVo.getTypeCode());
|
|
|
|
|
+ complaint.setTargetName(reqVo.getTargetName());
|
|
|
|
|
+ if (Objects.nonNull(loginUserInfo)) {
|
|
|
|
|
+ complaint.setSubmitterId(loginUserInfo.getId());
|
|
|
|
|
+ complaint.setSubmitterName(loginUserInfo.getUserName());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ complaint.setIsAnonymous(Boolean.TRUE.equals(reqVo.getIsAnonymous()));
|
|
|
|
|
+ complaint.setContent(reqVo.getContent());
|
|
|
|
|
+ complaint.setStatus(0);
|
|
|
|
|
+ complaint.setOccurTime(reqVo.getOccurTime());
|
|
|
|
|
+
|
|
|
|
|
+ complaint.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ complaint.setCreateTime(now);
|
|
|
|
|
+ complaint.setDelFlag(Global.UN_DELETED);
|
|
|
|
|
+
|
|
|
|
|
+ if (!tComplaintService.save(complaint)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, "提交投诉失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StrUtil.isNotBlank(reqVo.getFileUrl())) {
|
|
|
|
|
+ TComplaintAttachment attachment = new TComplaintAttachment();
|
|
|
|
|
+ attachment.setComplaintId(complaint.getId());
|
|
|
|
|
+ attachment.setFileUrl(reqVo.getFileUrl());
|
|
|
|
|
+ attachment.setFileName(reqVo.getFileName());
|
|
|
|
|
+ attachment.setFileType(reqVo.getFileType());
|
|
|
|
|
+ attachment.setFileSize(reqVo.getFileSize());
|
|
|
|
|
+ attachment.setSortNo(1);
|
|
|
|
|
+ attachment.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ attachment.setCreateTime(now);
|
|
|
|
|
+ attachment.setDelFlag(Global.UN_DELETED);
|
|
|
|
|
+ if (!tComplaintAttachmentService.save(attachment)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, "保存投诉附件失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return buildComplaintDetail(complaint, true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public PageDataResult<ComplaintAppItemResVo> appComplaintPage(ComplaintAppListReqVo reqVo) {
|
|
|
|
|
+ Page<TComplaint> page = new Page<>(reqVo.getPageNum(), reqVo.getPageSize());
|
|
|
|
|
+ LambdaQueryWrapper<TComplaint> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(TComplaint::getDelFlag, Global.UN_DELETED)
|
|
|
|
|
+ .eq(TComplaint::getCreateBy, LoginUserHolder.getUserId())
|
|
|
|
|
+ .orderByDesc(TComplaint::getCreateTime);
|
|
|
|
|
+
|
|
|
|
|
+ if (reqVo.getStatus() != null && reqVo.getStatus() >= 0) {
|
|
|
|
|
+ wrapper.eq(TComplaint::getStatus, reqVo.getStatus());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Page<TComplaint> complaintPage = tComplaintService.page(page, wrapper);
|
|
|
|
|
+ return PageDataResult.of(page, complaintPage.getRecords().stream().map(this::toAppItem).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ComplaintAppDetailResVo appComplaintDetail(Long complaintId) {
|
|
|
|
|
+ TComplaint complaint = tComplaintService.getById(complaintId);
|
|
|
|
|
+ if (Objects.isNull(complaint) || !Objects.equals(complaint.getDelFlag(), Global.UN_DELETED)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, "投诉记录不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ ComplaintDetailResVo detail = buildComplaintDetail(complaint, true);
|
|
|
|
|
+ return toAppDetail(detail);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public PageDataResult<ComplaintManageItemResVo> manageComplaintPage(ComplaintManagePageReqVo reqVo) {
|
|
|
|
|
+ Page<TComplaint> page = new Page<>(reqVo.getPageNum(), reqVo.getPageSize());
|
|
|
|
|
+ LambdaQueryWrapper<TComplaint> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(TComplaint::getDelFlag, Global.UN_DELETED)
|
|
|
|
|
+ .orderByDesc(TComplaint::getOccurTime);
|
|
|
|
|
+
|
|
|
|
|
+ if (StrUtil.isNotBlank(reqVo.getComplaintNo())) {
|
|
|
|
|
+ wrapper.like(TComplaint::getComplaintNo, reqVo.getComplaintNo().trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (reqVo.getTypeCode() != null) {
|
|
|
|
|
+ wrapper.eq(TComplaint::getTypeCode, reqVo.getTypeCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(reqVo.getTargetName())) {
|
|
|
|
|
+ wrapper.like(TComplaint::getTargetName, reqVo.getTargetName().trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(reqVo.getSubmitterKeyword())) {
|
|
|
|
|
+ wrapper.eq(TComplaint::getIsAnonymous, 0);
|
|
|
|
|
+ wrapper.like(TComplaint::getSubmitterName, reqVo.getSubmitterKeyword().trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (reqVo.getStatus() != null && reqVo.getStatus() >= 0) {
|
|
|
|
|
+ wrapper.eq(TComplaint::getStatus, reqVo.getStatus());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LocalDateTime startTime = parseStartDate(reqVo.getStartDate());
|
|
|
|
|
+ LocalDateTime endTimeExclusive = parseEndDateExclusive(reqVo.getEndDate());
|
|
|
|
|
+ if (startTime != null) {
|
|
|
|
|
+ wrapper.ge(TComplaint::getOccurTime, startTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (endTimeExclusive != null) {
|
|
|
|
|
+ wrapper.lt(TComplaint::getOccurTime, endTimeExclusive);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Page<TComplaint> complaintPage = tComplaintService.page(page, wrapper);
|
|
|
|
|
+ return PageDataResult.of(page, complaintPage.getRecords().stream().map(this::toManageItem).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ComplaintDetailResVo manageComplaintDetail(Long complaintId) {
|
|
|
|
|
+ TComplaint complaint = tComplaintService.getById(complaintId);
|
|
|
|
|
+ if (Objects.isNull(complaint) || !Objects.equals(complaint.getDelFlag(), Global.UN_DELETED)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, "投诉记录不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ return buildComplaintDetail(complaint, true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public Boolean processComplaint(ComplaintProcessReqVo reqVo) {
|
|
|
|
|
+ TComplaint complaint = tComplaintService.getById(reqVo.getId());
|
|
|
|
|
+ if (Objects.isNull(complaint) || !Objects.equals(complaint.getDelFlag(), Global.UN_DELETED)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, "投诉记录不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ Integer fromStatus = complaint.getStatus();
|
|
|
|
|
+
|
|
|
|
|
+ Long operatorId = LoginUserHolder.getUserId();
|
|
|
|
|
+ String operatorName = LoginUserHolder.getUserName();
|
|
|
|
|
+
|
|
|
|
|
+ boolean updated = tComplaintService.lambdaUpdate()
|
|
|
|
|
+ .eq(TComplaint::getId, reqVo.getId())
|
|
|
|
|
+ .set(TComplaint::getStatus, 1)
|
|
|
|
|
+ .set(TComplaint::getProcessedAt, now)
|
|
|
|
|
+ .set(TComplaint::getProcessorId, operatorId)
|
|
|
|
|
+ .set(TComplaint::getProcessorName, operatorName)
|
|
|
|
|
+ .set(TComplaint::getProcessReply, reqVo.getProcessReply())
|
|
|
|
|
+ .set(TComplaint::getUpdateBy, operatorId)
|
|
|
|
|
+ .set(TComplaint::getUpdateTime, now)
|
|
|
|
|
+ .update();
|
|
|
|
|
+
|
|
|
|
|
+ if (!updated) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, "处理投诉失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ TComplaintHandleLog log = new TComplaintHandleLog();
|
|
|
|
|
+ log.setComplaintId(reqVo.getId());
|
|
|
|
|
+ log.setAction("PROCESS");
|
|
|
|
|
+ log.setFromStatus(fromStatus == null ? 0 : fromStatus);
|
|
|
|
|
+ log.setToStatus(1);
|
|
|
|
|
+ log.setOperatorId(operatorId);
|
|
|
|
|
+ log.setOperatorName(operatorName);
|
|
|
|
|
+ log.setRemark(reqVo.getProcessReply());
|
|
|
|
|
+ log.setCreateBy(operatorId);
|
|
|
|
|
+ log.setCreateTime(now);
|
|
|
|
|
+ log.setUpdateBy(operatorId);
|
|
|
|
|
+ log.setUpdateTime(now);
|
|
|
|
|
+ log.setDelFlag(Global.UN_DELETED);
|
|
|
|
|
+ if (!tComplaintHandleLogService.save(log)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, "保存处理记录失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private ComplaintAppItemResVo toAppItem(TComplaint complaint) {
|
|
|
|
|
+ ComplaintAppItemResVo vo = new ComplaintAppItemResVo();
|
|
|
|
|
+ vo.setId(complaint.getId());
|
|
|
|
|
+ vo.setComplaintNo(complaint.getComplaintNo());
|
|
|
|
|
+ vo.setTypeCode(complaint.getTypeCode());
|
|
|
|
|
+ vo.setTypeName(typeName(complaint.getTypeCode()));
|
|
|
|
|
+ vo.setTargetName(complaint.getTargetName());
|
|
|
|
|
+ vo.setOccurTime(complaint.getOccurTime());
|
|
|
|
|
+ vo.setStatus(complaint.getStatus());
|
|
|
|
|
+ vo.setStatusName(statusName(complaint.getStatus()));
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private ComplaintManageItemResVo toManageItem(TComplaint complaint) {
|
|
|
|
|
+ ComplaintManageItemResVo vo = new ComplaintManageItemResVo();
|
|
|
|
|
+ vo.setId(complaint.getId());
|
|
|
|
|
+ vo.setComplaintNo(complaint.getComplaintNo());
|
|
|
|
|
+ vo.setTypeCode(complaint.getTypeCode());
|
|
|
|
|
+ vo.setTypeName(typeName(complaint.getTypeCode()));
|
|
|
|
|
+ vo.setTargetName(complaint.getTargetName());
|
|
|
|
|
+ vo.setSubmitterNameDisplay(Boolean.TRUE.equals(complaint.getIsAnonymous()) ? "匿名" : complaint.getSubmitterName());
|
|
|
|
|
+ vo.setOccurTime(complaint.getOccurTime());
|
|
|
|
|
+ vo.setStatus(complaint.getStatus());
|
|
|
|
|
+ vo.setStatusName(statusName(complaint.getStatus()));
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private ComplaintDetailResVo buildComplaintDetail(TComplaint complaint, boolean maskSubmitter) {
|
|
|
|
|
+ ComplaintDetailResVo res = new ComplaintDetailResVo();
|
|
|
|
|
+ res.setId(complaint.getId());
|
|
|
|
|
+ res.setComplaintNo(complaint.getComplaintNo());
|
|
|
|
|
+ res.setChannel(complaint.getChannel());
|
|
|
|
|
+ res.setTypeCode(complaint.getTypeCode());
|
|
|
|
|
+ res.setTypeName(typeName(complaint.getTypeCode()));
|
|
|
|
|
+ res.setTargetName(complaint.getTargetName());
|
|
|
|
|
+ res.setSubmitterId(complaint.getSubmitterId());
|
|
|
|
|
+ res.setSubmitterName(maskSubmitter && Boolean.TRUE.equals(complaint.getIsAnonymous()) ? "匿名" : complaint.getSubmitterName());
|
|
|
|
|
+ res.setIsAnonymous(Boolean.TRUE.equals(complaint.getIsAnonymous()));
|
|
|
|
|
+ res.setContent(complaint.getContent());
|
|
|
|
|
+ res.setStatus(complaint.getStatus());
|
|
|
|
|
+ res.setStatusName(statusName(complaint.getStatus()));
|
|
|
|
|
+ res.setOccurTime(complaint.getOccurTime());
|
|
|
|
|
+ res.setProcessedAt(complaint.getProcessedAt());
|
|
|
|
|
+ res.setProcessorId(complaint.getProcessorId());
|
|
|
|
|
+ res.setProcessorName(complaint.getProcessorName());
|
|
|
|
|
+ res.setProcessReply(complaint.getProcessReply());
|
|
|
|
|
+
|
|
|
|
|
+ List<TComplaintAttachment> attachments = tComplaintAttachmentService.lambdaQuery()
|
|
|
|
|
+ .eq(TComplaintAttachment::getDelFlag, Global.UN_DELETED)
|
|
|
|
|
+ .eq(TComplaintAttachment::getComplaintId, complaint.getId())
|
|
|
|
|
+ .orderByAsc(TComplaintAttachment::getSortNo)
|
|
|
|
|
+ .list();
|
|
|
|
|
+ if (CollUtil.isEmpty(attachments)) {
|
|
|
|
|
+ res.setAttachments(new ArrayList<>());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ res.setAttachments(attachments.stream().map(this::toAttachment).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<TComplaintHandleLog> logs = tComplaintHandleLogService.lambdaQuery()
|
|
|
|
|
+ .eq(TComplaintHandleLog::getDelFlag, Global.UN_DELETED)
|
|
|
|
|
+ .eq(TComplaintHandleLog::getComplaintId, complaint.getId())
|
|
|
|
|
+ .orderByDesc(TComplaintHandleLog::getCreateTime)
|
|
|
|
|
+ .list();
|
|
|
|
|
+ if (CollUtil.isEmpty(logs)) {
|
|
|
|
|
+ res.setHandleLogs(new ArrayList<>());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ res.setHandleLogs(logs.stream().map(this::toHandleLog).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private ComplaintAttachmentResVo toAttachment(TComplaintAttachment attachment) {
|
|
|
|
|
+ ComplaintAttachmentResVo vo = new ComplaintAttachmentResVo();
|
|
|
|
|
+ vo.setId(attachment.getId());
|
|
|
|
|
+ vo.setFileUrl(attachment.getFileUrl());
|
|
|
|
|
+ vo.setFileName(attachment.getFileName());
|
|
|
|
|
+ vo.setFileType(attachment.getFileType());
|
|
|
|
|
+ vo.setFileSize(attachment.getFileSize());
|
|
|
|
|
+ vo.setSortNo(attachment.getSortNo());
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private ComplaintHandleLogResVo toHandleLog(TComplaintHandleLog log) {
|
|
|
|
|
+ ComplaintHandleLogResVo vo = new ComplaintHandleLogResVo();
|
|
|
|
|
+ vo.setId(log.getId());
|
|
|
|
|
+ vo.setAction(log.getAction());
|
|
|
|
|
+ vo.setFromStatus(log.getFromStatus());
|
|
|
|
|
+ vo.setToStatus(log.getToStatus());
|
|
|
|
|
+ vo.setOperatorId(log.getOperatorId());
|
|
|
|
|
+ vo.setOperatorName(log.getOperatorName());
|
|
|
|
|
+ vo.setRemark(log.getRemark());
|
|
|
|
|
+ vo.setCreateTime(log.getCreateTime());
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private ComplaintAppDetailResVo toAppDetail(ComplaintDetailResVo detail) {
|
|
|
|
|
+ ComplaintAppDetailResVo vo = new ComplaintAppDetailResVo();
|
|
|
|
|
+ vo.setId(detail.getId());
|
|
|
|
|
+ vo.setComplaintNo(detail.getComplaintNo());
|
|
|
|
|
+ vo.setTypeCode(detail.getTypeCode());
|
|
|
|
|
+ vo.setTypeName(detail.getTypeName());
|
|
|
|
|
+ vo.setTargetName(detail.getTargetName());
|
|
|
|
|
+ vo.setIsAnonymous(detail.getIsAnonymous());
|
|
|
|
|
+ vo.setSubmitterName(detail.getSubmitterName());
|
|
|
|
|
+ vo.setContent(detail.getContent());
|
|
|
|
|
+ vo.setAttachments(detail.getAttachments());
|
|
|
|
|
+ vo.setStatus(detail.getStatus());
|
|
|
|
|
+ vo.setStatusName(detail.getStatusName());
|
|
|
|
|
+ vo.setOccurTime(detail.getOccurTime());
|
|
|
|
|
+ vo.setProcessedAt(detail.getProcessedAt());
|
|
|
|
|
+ vo.setProcessReply(detail.getProcessReply());
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String statusName(Integer status) {
|
|
|
|
|
+ if (status == null) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ return status == 1 ? "已处理" : "待处理";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String typeName(Integer typeCode) {
|
|
|
|
|
+ if (typeCode == null) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ return switch (typeCode) {
|
|
|
|
|
+ case 1 -> "违规";
|
|
|
|
|
+ case 2 -> "服务态度";
|
|
|
|
|
+ case 3 -> "其他";
|
|
|
|
|
+ default -> String.valueOf(typeCode);
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String buildTempComplaintNo(LocalDateTime now) {
|
|
|
|
|
+ String date = now.toLocalDate().format(DATE_NO_DASH);
|
|
|
|
|
+ String suffix = String.valueOf(System.nanoTime());
|
|
|
|
|
+ if (suffix.length() > 12) {
|
|
|
|
|
+ suffix = suffix.substring(suffix.length() - 12);
|
|
|
|
|
+ }
|
|
|
|
|
+ return "CT" + date + "TMP" + suffix;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String buildComplaintNo(LocalDateTime now) {
|
|
|
|
|
+ String date = now.toLocalDate().format(DATE_NO_DASH);
|
|
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
|
|
+ String suffix = String.format("%06d", ThreadLocalRandom.current().nextInt(0, 1_000_000));
|
|
|
|
|
+ String no = "CT" + date + suffix;
|
|
|
|
|
+ boolean exists = tComplaintService.lambdaQuery()
|
|
|
|
|
+ .eq(TComplaint::getComplaintNo, no)
|
|
|
|
|
+ .exists();
|
|
|
|
|
+ if (!exists) {
|
|
|
|
|
+ return no;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return buildTempComplaintNo(now);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private LocalDateTime parseStartDate(String startDate) {
|
|
|
|
|
+ if (StrUtil.isBlank(startDate)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return LocalDate.parse(startDate.trim()).atStartOfDay();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private LocalDateTime parseEndDateExclusive(String endDate) {
|
|
|
|
|
+ if (StrUtil.isBlank(endDate)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return LocalDate.parse(endDate.trim()).plusDays(1).atStartOfDay();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|