REQ-2135: 分类统计

This commit is contained in:
yanglin 2024-03-21 15:33:58 +08:00
parent 848827ad18
commit 0bd8c4d17d
9 changed files with 131 additions and 43 deletions

View File

@ -1,7 +1,6 @@
package cn.axzo.msg.center.message.controller;
import cn.axzo.msg.center.api.response.MessageDetailRes;
import cn.axzo.msg.center.message.domain.dto.PendingMessageStatisticDTO;
import cn.axzo.msg.center.message.domain.param.MessageGroupNodeStatisticParam;
import cn.axzo.msg.center.message.domain.param.PendingMessagePushParam;
import cn.axzo.msg.center.message.service.PendingMessageNewService;
@ -29,7 +28,7 @@ import cn.axzo.msg.center.service.pending.response.AnalysisPage;
import cn.axzo.msg.center.service.pending.response.PendingMessageIterateResponse;
import cn.axzo.msg.center.service.pending.response.PendingMessageResponse;
import cn.axzo.msg.center.service.pending.response.PendingMessageSimpleDTO;
import cn.axzo.msg.center.service.pending.response.PendingMessageStatisticResponse;
import cn.axzo.msg.center.service.pending.response.PendingMessageStatisticResponseV2;
import cn.axzo.msg.center.service.pending.response.PushPendingMessageDTO;
import cn.azxo.framework.common.model.CommonResponse;
import cn.azxo.framework.common.model.Page;
@ -39,7 +38,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.stream.Collectors;
/**
* @description
@ -59,12 +57,10 @@ public class PendingMessageNewController implements PendingMessageClient {
private final TodoSimpleQueryService todoSimpleQueryService;
@Override
public CommonResponse<List<PendingMessageStatisticResponse>> groupStatistic(PendingMessageStatisticRequest request) {
List<PendingMessageStatisticDTO> groupNodes = todoRangeQueryService
public CommonResponse<PendingMessageStatisticResponseV2> groupStatistic(PendingMessageStatisticRequest request) {
PendingMessageStatisticResponseV2 resp = todoRangeQueryService
.countStatGrouped(MessageGroupNodeStatisticParam.from(request));
return CommonResponse.success(groupNodes.stream()
.map(PendingMessageStatisticDTO::toResponse)
.collect(Collectors.toList()));
return CommonResponse.success(resp);
}
@Override

View File

@ -201,10 +201,6 @@ public class MessageTemplateRouterDTO implements Serializable {
* 按钮唯一标识
*/
private String btnCode;
/**
* 自定义按钮编码
*/
private String customCode;
/**
* 预设按钮类型
*/
@ -255,7 +251,6 @@ public class MessageTemplateRouterDTO implements Serializable {
return MessageRouteButtonDTO.builder()
.name(routeButton.getName())
.btnCode(routeButton.getBtnCode())
.customCode(routeButton.getCustomCode())
.presetButtonType(routeButton.getPresetBtnCode())
.templateCode(routeButton.getTemplateCode())
.source(routeButton.getSource())
@ -282,7 +277,6 @@ public class MessageTemplateRouterDTO implements Serializable {
return MessageRouteButtonDTO.builder()
.name(btnRouter.getDesc())
.btnCode(btnRouter.getIdentityCode())
.customCode(btnRouter.getCustomCode())
.presetButtonType(btnRouter.getPresetButtonType())
.templateCode(templateCode)
.source(btnRouter.getSource())
@ -299,7 +293,6 @@ public class MessageTemplateRouterDTO implements Serializable {
return MessageRouteButton.builder()
.name(this.name)
.btnCode(this.btnCode)
.customCode(this.customCode)
.presetBtnCode(this.presetButtonType)
.templateCode(this.templateCode)
.source(this.source)
@ -334,7 +327,6 @@ public class MessageTemplateRouterDTO implements Serializable {
.desc(this.name)
.category(this.category)
.identityCode(this.btnCode)
.customCode(this.customCode)
.presetButtonType(this.presetButtonType)
.source(this.source)
.style(MessageRouterUtil.parseButtonStyle(this.style))
@ -351,7 +343,6 @@ public class MessageTemplateRouterDTO implements Serializable {
return MessageRouteButtonDTO.builder()
.name(this.name)
.btnCode(this.btnCode)
.customCode(this.customCode)
.presetButtonType(this.presetButtonType)
.templateCode(this.templateCode)
.source(this.source)

View File

@ -10,7 +10,6 @@ import cn.axzo.msg.center.domain.entity.TodoBusiness;
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
import cn.axzo.msg.center.inside.notices.config.PendingCalendarCodeConfig;
import cn.axzo.msg.center.message.domain.dto.GroupTreeNodePathDTO;
import cn.axzo.msg.center.message.domain.dto.PendingMessageStatisticDTO;
import cn.axzo.msg.center.message.domain.param.MessageGroupNodeStatisticParam;
import cn.axzo.msg.center.message.service.MessageGroupNodeService;
import cn.axzo.msg.center.message.service.MessageTemplateGroupService;
@ -28,6 +27,9 @@ import cn.axzo.msg.center.service.pending.request.PendingMessagePageRequest;
import cn.axzo.msg.center.service.pending.request.PendingMessagePageRequest.CopiedToMeParam;
import cn.axzo.msg.center.service.pending.response.AnalysisPage;
import cn.axzo.msg.center.service.pending.response.PendingMessageResponse;
import cn.axzo.msg.center.service.pending.response.PendingMessageStatisticResponseV2;
import cn.axzo.msg.center.service.pending.response.PendingMessageStatisticResponseV2.GroupStat;
import cn.axzo.msg.center.service.pending.response.PendingMessageStatisticResponseV2.Stat;
import cn.axzo.msg.center.utils.DateFormatUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -47,6 +49,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.axzo.msg.center.inside.notices.utils.Queries.query;
@ -163,28 +166,40 @@ public class TodoRangeQueryService {
// !! stat
public List<PendingMessageStatisticDTO> countStatGrouped(MessageGroupNodeStatisticParam param) {
public PendingMessageStatisticResponseV2 countStatGrouped(MessageGroupNodeStatisticParam param) {
List<String> groupTreeRootNodeCodes = messageGroupNodeService
.listGroupTreeRootNodeCodes(MessageGroupCategoryEnum.PENDING, param.getTerminalType());
List<GroupTreeNodePathDTO> leafNodePaths = messageGroupNodeService
.leafGroupNodeCodePathsByRootNodeCodes(groupTreeRootNodeCodes);
return leafNodePaths.parallelStream()
.map(e -> {
PendingMessageStatisticDTO dto = PendingMessageStatisticDTO.of(e);
dto.setPendingCount(countStatByPaths(Collections.singletonList(e), param));
return dto;
})
.collect(Collectors.toList());
Function<GroupTreeNodePathDTO, GroupStat> nodeStatFun = node -> {
int executableCount = countStatByPaths(Collections.singletonList(node), param, TodoType.EXECUTABLE);
int copiedToMeCount = countStatByPaths(Collections.singletonList(node), param, TodoType.COPIED_TO_ME);
GroupStat groupStat = new GroupStat();
groupStat.setGroupCode(node.getNodeCode());
groupStat.setGroupName(node.getNodeName());
groupStat.setStat(new Stat(executableCount, copiedToMeCount));
return groupStat;
};
PendingMessageStatisticResponseV2 resp = new PendingMessageStatisticResponseV2();
leafNodePaths.parallelStream().map(nodeStatFun).forEach(resp::addGroupStat);
resp.setTotalStat();
return resp;
}
/**
* app首页
*/
public Integer countStat(MessageGroupNodeStatisticParam param) {
List<String> groupTreeRootNodeCodes = messageGroupNodeService
.listGroupTreeRootNodeCodes(MessageGroupCategoryEnum.PENDING, param.getTerminalType());
List<GroupTreeNodePathDTO> leafNodePaths = messageGroupNodeService.leafGroupNodeCodePathsByRootNodeCodes(groupTreeRootNodeCodes);
return countStatByPaths(leafNodePaths, param);
return countStatByPaths(leafNodePaths, param, TodoType.EXECUTABLE);
}
private int countStatByPaths(Collection<GroupTreeNodePathDTO> groupNodePaths, MessageGroupNodeStatisticParam param) {
private int countStatByPaths(
Collection<GroupTreeNodePathDTO> groupNodePaths,
MessageGroupNodeStatisticParam param,
TodoType todoType) {
List<String> groupNodePathCodes = groupNodePaths.stream()
.map(GroupTreeNodePathDTO::getNodeCodePath)
.collect(Collectors.toList());
@ -195,14 +210,15 @@ public class TodoRangeQueryService {
.in(Todo::getTemplateCode, templateCodes)
.eq(Todo::getExecutorPersonId, param.getOperator().getId())
.eq(Todo::getIsDelete, IsDeletedEnum.NO.getCode())
.and(nested -> nested
.and(todoType == TodoType.EXECUTABLE, nested -> nested
.eq(Todo::getType, TodoType.EXECUTABLE)
.eq(Todo::getState, PendingMessageStateEnum.HAS_BEEN_SENT)
.or()
.eq(Todo::getState, PendingMessageStateEnum.HAS_BEEN_SENT))
.and(todoType == TodoType.COPIED_TO_ME, nested -> nested
.eq(Todo::getType, TodoType.COPIED_TO_ME)
.eq(Todo::getState, PendingMessageStateEnum.CREATED));
appendExecutorOuIdExpr(query, param.getOuId());
return todoMapper.selectCount(query);
Integer count = todoMapper.selectCount(query);
return count == null ? 0 : count;
}
// !! calendar

View File

@ -338,6 +338,7 @@ public class TodoManager {
if (advanceResult.isAdvanced() || todo.getState() == PendingMessageStateEnum.COMPLETED) {
TodoBusiness business = todoBusinessDao.getById(todo.getTodoBusinessId());
PresetButtonPressedMessage message = new PresetButtonPressedMessage();
message.setBtnPressedRequestNo(ctx.getRequestNo());
message.setPresetButtonType(req.getPresetButtonType());
BeanUtils.copyProperties(business, message);
BeanUtils.copyProperties(todo, message);

View File

@ -13,7 +13,6 @@ import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
@ -22,6 +21,10 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
public class PresetButtonPressedMessage extends BaseMqMessage {
/**
* 请求批次号
*/
private String btnPressedRequestNo;
/**
* 预设按钮类型
* AGREE: 待办同意

View File

@ -36,10 +36,6 @@ public class MessageButtonRouteStrategyDTO implements Serializable {
* 按钮唯一标识
*/
private String identityCode;
/**
* 自定义按钮编码
*/
private String customCode;
/**
* 预设按钮类型
*/

View File

@ -21,7 +21,7 @@ import cn.axzo.msg.center.service.pending.response.AnalysisPage;
import cn.axzo.msg.center.service.pending.response.PendingMessageIterateResponse;
import cn.axzo.msg.center.service.pending.response.PendingMessageResponse;
import cn.axzo.msg.center.service.pending.response.PendingMessageSimpleDTO;
import cn.axzo.msg.center.service.pending.response.PendingMessageStatisticResponse;
import cn.axzo.msg.center.service.pending.response.PendingMessageStatisticResponseV2;
import cn.axzo.msg.center.service.pending.response.PushPendingMessageDTO;
import cn.azxo.framework.common.model.CommonResponse;
import cn.azxo.framework.common.model.Page;
@ -54,7 +54,7 @@ public interface PendingMessageClient {
* @return 分类信息及其对应的待处理的待办数量列表
*/
@PostMapping(value = "/pending-message/record/group/statistic", produces = {MediaType.APPLICATION_JSON_VALUE})
CommonResponse<List<PendingMessageStatisticResponse>> groupStatistic(@RequestBody @Valid
CommonResponse<PendingMessageStatisticResponseV2> groupStatistic(@RequestBody @Valid
PendingMessageStatisticRequest request);
/**

View File

@ -0,0 +1,89 @@
package cn.axzo.msg.center.service.pending.response;
import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @description
*
* @author cold_blade
* @date 2023/9/23
* @version 1.0
*/
@Setter
@Getter
public class PendingMessageStatisticResponseV2 implements Serializable {
private static final long serialVersionUID = 972200410809186003L;
/**
* 统计情况总数 (各分类相加)
*/
private Stat totalStat;
/**
* 分类情况
*/
private List<GroupStat> groupStats = new ArrayList<>();
public void addGroupStat(GroupStat groupStat) {
this.groupStats.add(groupStat);
}
public void setTotalStat() {
int totalPendingCount = groupStats.stream()
.map(GroupStat::getStat)
.mapToInt(Stat::getPendingCount)
.sum();
int totalUnreadCount = groupStats.stream()
.map(GroupStat::getStat)
.mapToInt(Stat::getUnreadCount)
.sum();
this.totalStat = new Stat(totalPendingCount, totalUnreadCount);
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class GroupStat {
/**
* 分类名称
*/
private String groupName;
/**
* 分类编码
*/
private String groupCode;
/**
* 分类统计
*/
private Stat stat;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class Stat {
/**
* 代办数量
*/
private int pendingCount;
/**
* 未读数量
*/
private int unreadCount;
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
}

View File

@ -42,10 +42,6 @@ public class MessageRouteButton extends BaseEntityExt<MessageRouteButton> implem
* 按钮唯一标识
*/
private String btnCode;
/**
* 自定义编码
*/
private String customCode;
/**
* 预设按钮类型
*/