feat: 一些调整
This commit is contained in:
parent
36b1d04197
commit
7e58f808cc
|
|
@ -1,6 +1,5 @@
|
|||
package com.nflg.mobilebroken.admin.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
|
|
@ -9,16 +8,21 @@ import com.nflg.mobilebroken.common.pojo.request.AdminMessageSearchRequest;
|
|||
import com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.PageUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
||||
import com.nflg.mobilebroken.repository.service.IAdminMessageService;
|
||||
import com.nflg.mobilebroken.repository.service.IAdminUserService;
|
||||
import com.nflg.mobilebroken.repository.entity.AppUser;
|
||||
import com.nflg.mobilebroken.repository.entity.AppUserApplyfor;
|
||||
import com.nflg.mobilebroken.repository.entity.Ticket;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.security.Principal;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 消息相关接口
|
||||
|
|
@ -35,6 +39,15 @@ public class MessageController extends ControllerBase {
|
|||
@Resource
|
||||
private IAdminUserService adminUserService;
|
||||
|
||||
@Resource
|
||||
private ITicketService ticketService;
|
||||
|
||||
@Resource
|
||||
private IAppUserService appUserService;
|
||||
|
||||
@Resource
|
||||
private IAppUserApplyforService appUserApplyforService;
|
||||
|
||||
/**
|
||||
* 搜索消息
|
||||
* @param request 请求参数
|
||||
|
|
@ -42,18 +55,22 @@ public class MessageController extends ControllerBase {
|
|||
*/
|
||||
@PostMapping("searchMessages")
|
||||
@ApiMark(moduleName = "消息管理", apiName = "搜索消息")
|
||||
public ApiResult<PageData<AdminMessageVO>> searchMessages(@RequestHeader(value = "authorization", required = false) String token, @RequestBody AdminMessageSearchRequest request) {
|
||||
IPage<AdminMessageVO> pageData = adminMessageService.search(AdminUserUtil.getUserId(), request);
|
||||
PageUtil.convert(pageData, d -> {
|
||||
if (StrUtil.isNotBlank(d.getTicketHandleByIds())) {
|
||||
d.setTicketHandleBy(adminUserService.listByIds(StrUtil.split(d.getTicketHandleByIds(), ","))
|
||||
.stream()
|
||||
.map(AdminUser::getUserName)
|
||||
.collect(Collectors.toList()));
|
||||
public ApiResult<PageData<AdminMessageVO>> searchMessages(@Valid @RequestBody AdminMessageSearchRequest request, Principal principal) {
|
||||
IPage<AdminMessageVO> datas = adminMessageService.search(AdminUserUtil.getUserId(), request);
|
||||
return ApiResult.success(PageUtil.convert(datas, d -> {
|
||||
if (Objects.equals(d.getSource(), 0)) {
|
||||
Ticket ticket = ticketService.getById(d.getSourceId());
|
||||
AppUser appUser = appUserService.getById(ticket.getUserId());
|
||||
d.setSourceCreateTime(ticket.getCreateTime());
|
||||
d.setSourceCreateUserName(appUser.getName());
|
||||
} else if (Objects.equals(d.getSource(), 1)) {
|
||||
AppUserApplyfor appUserApplyfor = appUserApplyforService.getById(d.getSourceId());
|
||||
AppUser appUser = appUserService.getById(appUserApplyfor.getCreateBy());
|
||||
d.setSourceCreateTime(appUserApplyfor.getCreateTime());
|
||||
d.setSourceCreateUserName(appUser.getName());
|
||||
}
|
||||
return d;
|
||||
});
|
||||
return ApiResult.success(pageData);
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.nflg.mobilebroken.common.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum MessageSubType {
|
||||
|
||||
AccountApplication(0, "账号申请"),
|
||||
AccountActivation(1, "账号启用"),
|
||||
AccountExtension(2, "账号延期"),
|
||||
TicketToBeAssigned(3, "工单待分派"),
|
||||
TicketAssignment(4, "工单分派"),
|
||||
TicketNewMessage(5, "工单新消息"),
|
||||
TicketCompletion(6, "工单完成"),
|
||||
TicketClosed(7, "工单关闭"),
|
||||
TicketCancellation(8, "工单撤销"),
|
||||
TicketReopen(9, "工单重启");
|
||||
|
||||
private final Integer state;
|
||||
private final String description;
|
||||
|
||||
public static MessageSubType findByValue(Integer value) {
|
||||
for (MessageSubType valueEnum : MessageSubType.values()) {
|
||||
if (valueEnum.getState().equals(value)) {
|
||||
return valueEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,10 +7,8 @@ import lombok.Getter;
|
|||
@AllArgsConstructor
|
||||
public enum MessageType {
|
||||
|
||||
AccountVerification(0, "账号审核"),
|
||||
WorkOrderAssignment(1, "工单分派"),
|
||||
WorkOrderFollowUp(2, "工单跟进"),
|
||||
WorkOrderClosed(3, "工单关闭");
|
||||
AccountExamine(0, "账号审核"),
|
||||
WorkOrderAssignment(1, "工单处理");
|
||||
|
||||
private final Integer state;
|
||||
private final String description;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@ import lombok.EqualsAndHashCode;
|
|||
@Data
|
||||
public class AdminMessageSearchRequest extends PageRequest {
|
||||
|
||||
//标题
|
||||
private String title;
|
||||
//编号
|
||||
private String no;
|
||||
|
||||
//任务类别,0:全部,1:账号审核,2:工单分派,3:工单跟进,4:工单关闭
|
||||
//任务类别,0:账号审核;1:工单处理
|
||||
private Integer type;
|
||||
|
||||
//任务事项,0:账号申请;1:账号启用;2:账号延期;3:工单待分派;4:工单分派;5:工单新消息;6:工单完成;7:工单关闭,8:工单撤销,9:工单重启
|
||||
private Integer subType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
package com.nflg.mobilebroken.common.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.nflg.mobilebroken.common.constant.MessageSubType;
|
||||
import com.nflg.mobilebroken.common.constant.MessageType;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
|
|
@ -14,40 +13,41 @@ public class AdminMessageVO {
|
|||
|
||||
private Integer id;
|
||||
|
||||
//任务id
|
||||
private Integer ticketId;
|
||||
|
||||
//任务编号
|
||||
private String ticketNo;
|
||||
private String no;
|
||||
|
||||
//任务事项
|
||||
private String content;
|
||||
//来源,0:工单;1:代理商账户
|
||||
private Integer source;
|
||||
|
||||
//任务类别
|
||||
@JsonIgnore
|
||||
//来源id
|
||||
private Integer sourceId;
|
||||
|
||||
//任务事项,0:账号申请;1:账号启用;2:账号延期;3:工单待分派;4:工单分派;5:工单新消息;6:工单完成;7:工单关闭,8:工单撤销,9:工单重启
|
||||
private Integer subType;
|
||||
|
||||
//任务事项描述
|
||||
private String subTypeDesc;
|
||||
//任务类别,0:账号审核;1:工单处理
|
||||
private Integer type;
|
||||
|
||||
//任务类别名称
|
||||
private String typeName;
|
||||
|
||||
public String getTypeName() {
|
||||
return MessageType.findByValue(type).getDescription();
|
||||
}
|
||||
//任务类别描述
|
||||
private String typeDesc;
|
||||
//提交人
|
||||
private String sourceCreateUserName;
|
||||
//提交时间
|
||||
private LocalDateTime sourceCreateTime;
|
||||
|
||||
//消息时间
|
||||
private LocalDateTime createTime;
|
||||
|
||||
//提交人
|
||||
private String createUserName;
|
||||
|
||||
//任务提交时间
|
||||
private LocalDateTime ticketCreateTime;
|
||||
|
||||
@JsonIgnore
|
||||
private String ticketHandleByIds;
|
||||
|
||||
//待处理人
|
||||
private List<String> ticketHandleBy;
|
||||
private String userName;
|
||||
|
||||
public String getSubTypeDesc() {
|
||||
return MessageSubType.findByValue(subType).getDescription();
|
||||
}
|
||||
|
||||
public String gettypeDesc() {
|
||||
return MessageType.findByValue(type).getDescription();
|
||||
}
|
||||
|
||||
//是否已读
|
||||
private boolean isRead;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ package com.nflg.mobilebroken.repository.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
|
|
@ -29,9 +30,19 @@ public class AdminMessage implements Serializable {
|
|||
private Integer id;
|
||||
|
||||
/**
|
||||
* 工单id
|
||||
* 任务编号
|
||||
*/
|
||||
private Integer ticketId;
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 来源,0:工单;1:代理商账户
|
||||
*/
|
||||
private Integer source;
|
||||
|
||||
/**
|
||||
* 来源id
|
||||
*/
|
||||
private Integer sourceId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
|
|
@ -39,14 +50,14 @@ public class AdminMessage implements Serializable {
|
|||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 任务类别,0:账号审核;1:工单分派;2:工单跟进;3:工单关闭
|
||||
* 任务类别,0:账号审核;1:工单处理
|
||||
*/
|
||||
private Byte type;
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 提醒事项
|
||||
* 任务事项,0:账号申请;1:账号启用;2:账号延期;3:工单待分派;4:工单分派;5:工单新消息;6:工单完成;7:工单关闭,8:工单撤销,9:工单重启
|
||||
*/
|
||||
private String content;
|
||||
private Integer subType;
|
||||
|
||||
/**
|
||||
* 是否已读
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.mobilebroken.common.constant.MessageSubType;
|
||||
import com.nflg.mobilebroken.common.constant.MessageType;
|
||||
import com.nflg.mobilebroken.common.pojo.request.AdminMessageSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminMessage;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
||||
import com.nflg.mobilebroken.repository.entity.Ticket;
|
||||
import com.nflg.mobilebroken.repository.mapper.AdminMessageMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IAdminMessageService;
|
||||
import com.nflg.mobilebroken.repository.service.IAdminUserService;
|
||||
import com.nflg.mobilebroken.repository.service.ITicketService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -34,6 +37,9 @@ public class AdminMessageServiceImpl extends ServiceImpl<AdminMessageMapper, Adm
|
|||
@Resource
|
||||
private IAdminUserService adminUserService;
|
||||
|
||||
@Resource
|
||||
private ITicketService ticketService;
|
||||
|
||||
@Override
|
||||
public IPage<AdminMessageVO> search(Integer userId, AdminMessageSearchRequest request) {
|
||||
return baseMapper.search(userId, request, new Page<>(request.getPage(), request.getPageSize()));
|
||||
|
|
@ -62,13 +68,18 @@ public class AdminMessageServiceImpl extends ServiceImpl<AdminMessageMapper, Adm
|
|||
if (CollectionUtil.isEmpty(cqmUsers)) {
|
||||
log.error("未设置CQM负责人");
|
||||
} else {
|
||||
List<AdminMessage> messages = cqmUsers.stream().map(c -> new AdminMessage()
|
||||
.setUserId(c.getId())
|
||||
.setTicketId(ticketId)
|
||||
.setIsRead(false)
|
||||
.setType(MessageType.WorkOrderAssignment.getState().byteValue())
|
||||
.setContent("工单待分配")
|
||||
.setCreateTime(LocalDateTime.now())).collect(Collectors.toList());
|
||||
Ticket ticket = ticketService.getById(ticketId);
|
||||
List<AdminMessage> messages = cqmUsers.stream()
|
||||
.map(c -> new AdminMessage()
|
||||
.setNo(ticket.getNo())
|
||||
.setUserId(c.getId())
|
||||
.setSourceId(ticketId)
|
||||
.setSource(0)
|
||||
.setType(MessageType.WorkOrderAssignment.getState())
|
||||
.setSubType(MessageSubType.TicketToBeAssigned.getState())
|
||||
.setIsRead(false)
|
||||
.setCreateTime(LocalDateTime.now()))
|
||||
.collect(Collectors.toList());
|
||||
saveBatch(messages);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,19 @@
|
|||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.AdminMessageMapper">
|
||||
|
||||
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.AdminMessageVO">
|
||||
SELECT m.id,t.id AS 'ticketId',t.`no` AS 'ticketNo',m.content,m.type,m.create_time AS 'createTime',
|
||||
u.`name` AS 'createUserName',t.create_time AS 'ticketCreateTime',t.handle AS 'ticketHandleByIds',
|
||||
m.is_read AS 'isRead'
|
||||
SELECT m.id,m.no,m.source,m.source_id AS 'sourceId',m.type,m.sub_type AS 'subType',m.create_time AS 'createTime',
|
||||
u.user_name AS 'userName',m.is_read AS 'isRead'
|
||||
FROM admin_message m
|
||||
INNER JOIN ticket t ON m.ticket_id=t.id
|
||||
INNER JOIN app_user u ON t.user_id=u.id
|
||||
INNER JOIN admin_user u ON t.user_id=u.id
|
||||
WHERE m.user_id=#{userId}
|
||||
<if test="request.type != null">
|
||||
AND m.type=#{request.type}
|
||||
</if>
|
||||
<if test="request.title != null and request.title != ''">
|
||||
AND (t.title LIKE CONCAT('%',#{request.title},'%') OR t.no LIKE CONCAT('%',#{request.title},'%'))
|
||||
<if test="request.subType != null">
|
||||
AND m.sub_type=#{request.subType}
|
||||
</if>
|
||||
<if test="request.no != null and request.no != ''">
|
||||
AND m.no LIKE CONCAT('%',#{request.no},'%')
|
||||
</if>
|
||||
ORDER BY m.id DESC
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue