REQ-2318: 待办交接,端相关
This commit is contained in:
parent
f9a2c4f9ec
commit
68ac34cc2b
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
@ -37,9 +38,10 @@ public class PersonService {
|
||||
return new PersonIdInfo(resp.getData());
|
||||
}
|
||||
|
||||
public Long getPersonIdByPhone(String phone) {
|
||||
public Optional<Long> getPersonIdByPhone(String phone) {
|
||||
CommonResponse<PersonProfileDto> profileResp = userProfileServiceApi
|
||||
.getUnionPersonProfile(null, phone);
|
||||
return BizAssertions.assertResponse(profileResp, "未找根据手机找到人员").getId();
|
||||
PersonProfileDto data = profileResp.getData();
|
||||
return Optional.ofNullable(data == null ? null : data.getId());
|
||||
}
|
||||
}
|
||||
@ -7,13 +7,8 @@ import cn.axzo.msg.center.domain.entity.TodoBusiness;
|
||||
import cn.axzo.msg.center.message.service.impl.person.PersonService;
|
||||
import cn.axzo.msg.center.service.pending.request.AnalysisInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@ -25,40 +20,33 @@ class AnalysisHelper {
|
||||
private final TodoDao todoDao;
|
||||
private final PersonService personService;
|
||||
|
||||
List<TodoBusiness> getAnalyzeBusiness(AnalysisInfo analysis) {
|
||||
if (CollectionUtils.isEmpty(analysis.getBusinessIds()))
|
||||
return Collections.emptyList();
|
||||
return todoBusinessDao.lambdaQuery()
|
||||
.in(TodoBusiness::getId, analysis.getBusinessIds())
|
||||
.list();
|
||||
TodoBusiness getAnalyzeBusiness(AnalysisInfo analysis) {
|
||||
if (analysis == null) return null;
|
||||
return todoBusinessDao.getById(analysis.getBusinessId());
|
||||
}
|
||||
|
||||
List<Todo> getAnalyzeTodo(AnalysisInfo analysis) {
|
||||
ArrayList<Todo> todos = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(analysis.getTodoCodes())) {
|
||||
todos.addAll(todoDao.lambdaQuery()
|
||||
.in(Todo::getIdentityCode, analysis.getTodoCodes())
|
||||
.list());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(analysis.getTodoIds())) {
|
||||
todos.addAll(todoDao.lambdaQuery()
|
||||
.in(Todo::getId, analysis.getTodoIds())
|
||||
.list());
|
||||
}
|
||||
Todo getAnalyzeTodo(AnalysisInfo analysis) {
|
||||
if (analysis.getTodoId() != null)
|
||||
return todoDao.getById(analysis.getTodoId());
|
||||
if (analysis.getTodoCode() != null)
|
||||
return todoDao.lambdaQuery()
|
||||
.eq(Todo::getIdentityCode, analysis.getTodoCode())
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
AnalysisInfo.BizInfo biz = analysis.getBiz();
|
||||
if (biz != null && biz.getBizCode() != null && (biz.getPersonId() != null || biz.getPhone() != null)) {
|
||||
if (biz.getPhone() != null) {
|
||||
Long personId = personService.getPersonIdByPhone(biz.getPhone());
|
||||
if (personId != null) biz.setPersonId(personId);
|
||||
}
|
||||
if (biz.getPhone() != null)
|
||||
personService.getPersonIdByPhone(biz.getPhone())
|
||||
.ifPresent(biz::setPersonId);
|
||||
if (biz.getPersonId() != null) {
|
||||
todos.addAll(todoDao.lambdaQuery()
|
||||
return todoDao.lambdaQuery()
|
||||
.eq(Todo::getBizCode, biz.getBizCode())
|
||||
.eq(Todo::getExecutorPersonId, biz.getPersonId())
|
||||
.list());
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
}
|
||||
}
|
||||
return todos;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,6 +28,7 @@ import cn.axzo.msg.center.service.enums.BizCategoryEnum;
|
||||
import cn.axzo.msg.center.service.enums.PendingMessageRoleCategoryEnum;
|
||||
import cn.axzo.msg.center.service.enums.PendingMessageStateEnum;
|
||||
import cn.axzo.msg.center.service.enums.TodoType;
|
||||
import cn.axzo.msg.center.service.pending.request.AnalysisInfo;
|
||||
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.request.PersonTodoToBeDoneStatRequest;
|
||||
@ -49,13 +50,11 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.function.Function;
|
||||
@ -126,7 +125,7 @@ public class TodoRangeQueryService {
|
||||
.in(TodoBusiness::getTemplateCode, templateCodes)
|
||||
.eq(request.getBizFinalState() != null, TodoBusiness::getBizFinalState, request.getBizFinalState());
|
||||
PageQuerySort.TODO_BUSINESS.appendSortExpr(request, query);
|
||||
return queryAndAnalysis(analysisHelper.getAnalyzeBusiness(request.getA()), () -> {
|
||||
return queryAndAnalysis(request, () -> {
|
||||
IPage<TodoBusiness> page = todoBusinessMapper.selectPage(request.toPage(), query);
|
||||
List<PendingRecordAdapter> messages = todoRespBuilder.buildBusinessAdapters(page.getRecords());
|
||||
return createAnalysisResult(request.getAnalysisToken(), page, messages);
|
||||
@ -177,7 +176,7 @@ public class TodoRangeQueryService {
|
||||
// 用于查询的模版会通过一个单独的字段打印出来, 用于排查问题
|
||||
.in(Todo::getTemplateCode, templateCodes);
|
||||
PageQuerySort.TODO.appendSortExpr(request, query);
|
||||
return queryAndAnalysis(analysisHelper.getAnalyzeTodo(request.getA()), () -> {
|
||||
return queryAndAnalysis(request, () -> {
|
||||
IPage<Todo> page = todoDao.page(request.toPage(), query);
|
||||
List<PendingRecordAdapter> messages = todoRespBuilder.buildTodoAdapters(page.getRecords());
|
||||
return createAnalysisResult(request.getAnalysisToken(), page, messages);
|
||||
@ -185,8 +184,12 @@ public class TodoRangeQueryService {
|
||||
}
|
||||
|
||||
private AnalysisPage<PendingRecordAdapter> queryAndAnalysis(
|
||||
List<?> analyzeItems, Supplier<AnalysisPage<PendingRecordAdapter>> pageQuery) {
|
||||
if (CollectionUtils.isNotEmpty(analyzeItems))
|
||||
PendingMessagePageRequest request, Supplier<AnalysisPage<PendingRecordAdapter>> pageQuery) {
|
||||
AnalysisInfo analysis = request.getA();
|
||||
Object analyzeItem = analysisHelper.getAnalyzeBusiness(analysis);
|
||||
if (analyzeItem == null)
|
||||
analyzeItem = analysisHelper.getAnalyzeTodo(analysis);
|
||||
if (analyzeItem != null || analysis.isCollectSql())
|
||||
CollectSQLInterceptor.enableCollectSQL(new CollectSqlConfig(true));
|
||||
try {
|
||||
Ref<String> execSQL = Ref.create();
|
||||
@ -194,18 +197,15 @@ public class TodoRangeQueryService {
|
||||
execSQL.set(CollectSQLInterceptor.getSQL().orElse(null));
|
||||
// !! analysis
|
||||
result.addAnalysis("query", execSQL::get);
|
||||
Object finalAnalyzeItem = analyzeItem;
|
||||
result.addAnalysis("eval", () -> {
|
||||
String sql = execSQL.get();
|
||||
if (sql == null || CollectionUtils.isEmpty(analyzeItems)) return null;
|
||||
if (sql == null || finalAnalyzeItem == null) return null;
|
||||
SimpleAnalyzer simpleAnalyzer = new SimpleAnalyzer(sql);
|
||||
ArrayList<Map<String, Object>> eval = new ArrayList<>();
|
||||
for (Object analyzeItem : analyzeItems) {
|
||||
HashMap<String, Object> analyzeResult = new HashMap<>();
|
||||
eval.add(analyzeResult);
|
||||
analyzeResult.put("evalItem", analyzeItem);
|
||||
analyzeResult.put("evalResult", simpleAnalyzer.analyze(analyzeItems));
|
||||
}
|
||||
return eval;
|
||||
HashMap<String, Object> analyzeResult = new HashMap<>();
|
||||
analyzeResult.put("evalItem", finalAnalyzeItem);
|
||||
analyzeResult.put("evalResult", simpleAnalyzer.analyze(finalAnalyzeItem));
|
||||
return analyzeResult;
|
||||
});
|
||||
return result;
|
||||
} finally {
|
||||
@ -236,14 +236,17 @@ public class TodoRangeQueryService {
|
||||
// !! stat
|
||||
|
||||
public PersonTodoToBeDoneStatResponse personTodoToBeDoneStat(PersonTodoToBeDoneStatRequest request) {
|
||||
List<Todo> todos = todoDao.getToBeDone(request.getPersonId(), request.getOuId());
|
||||
todos = todoTerminalHelper.maybeFilterByTerminal(todos, request.getTerminals());
|
||||
List<Todo> allTodos = todoDao.getToBeDone(request.getPersonId(), request.getOuId());
|
||||
List<Todo> todos = todoTerminalHelper.maybeFilterByTerminal(allTodos, request.getTerminals());
|
||||
TodoBusinesses businesses = todoBusinessDao.getBusinesses(todos);
|
||||
PersonTodoToBeDoneStatResponse resp = new PersonTodoToBeDoneStatResponse();
|
||||
for (BizCategoryEnum category : BizCategoryEnum.values()) {
|
||||
List<Todo> categoryTodos = businesses.getTodoByCategory(category);
|
||||
resp.addStat(new PersonTodoToBeDoneStatResponse.Stat(category, categoryTodos.size()));
|
||||
}
|
||||
// 有些待办模版可能没有设置分类
|
||||
if (request.isFilterByAllTerminals())
|
||||
resp.setDebugCount(allTodos.size() - todos.size());
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,9 @@ import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description
|
||||
* 应用终端类型枚举
|
||||
@ -38,4 +41,19 @@ public enum AppTerminalTypeEnum {
|
||||
;
|
||||
|
||||
private final String desc;
|
||||
|
||||
/**
|
||||
* @return 管理端终端类型列表
|
||||
*/
|
||||
public static List<AppTerminalTypeEnum> manageTerminals() {
|
||||
return Arrays.asList(B_ENTERPRISE_APP, OMS_WEB_PC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 所有终端
|
||||
*/
|
||||
public static List<AppTerminalTypeEnum> allTerminals() {
|
||||
return Arrays.asList(AppTerminalTypeEnum.values());
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,18 +2,17 @@ package cn.axzo.msg.center.service.pending.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Data
|
||||
public class AnalysisInfo {
|
||||
|
||||
private List<String> todoCodes;
|
||||
private List<Long> todoIds;
|
||||
private List<Long> businessIds;
|
||||
private String todoCode;
|
||||
private Long todoId;
|
||||
private Long businessId;
|
||||
private BizInfo biz;
|
||||
private boolean collectSql;
|
||||
|
||||
@Data
|
||||
public static class BizInfo {
|
||||
|
||||
@ -3,8 +3,10 @@ package cn.axzo.msg.center.service.pending.request;
|
||||
import cn.axzo.msg.center.service.enums.AppTerminalTypeEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -17,6 +19,11 @@ public class PersonTodoToBeDoneStatRequest {
|
||||
private Long ouId;
|
||||
private List<AppTerminalTypeEnum> terminals;
|
||||
|
||||
public boolean isFilterByAllTerminals() {
|
||||
if (CollectionUtils.isEmpty(terminals)) return false;
|
||||
return new HashSet<>(terminals).equals(new HashSet<>(AppTerminalTypeEnum.allTerminals()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JSON.toJSONString(this);
|
||||
|
||||
@ -20,6 +20,11 @@ public class PersonTodoToBeDoneStatResponse {
|
||||
*/
|
||||
private List<Stat> stats = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 排查问题用
|
||||
*/
|
||||
private Integer debugCount;
|
||||
|
||||
public void addStat(Stat stat) {
|
||||
stats.add(stat);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user