Commit b3c0fbe8 by 王志超

feat: 变更行动工单列表,组装主单数据

parent e4b66ced
Pipeline #86121 failed with stages
in 42 seconds
......@@ -45,6 +45,7 @@ import com.netease.mail.yanxuan.change.biz.service.rpc.IusService;
import com.netease.mail.yanxuan.change.biz.service.rpc.QCService;
import com.netease.mail.yanxuan.change.biz.service.rpc.SupplierSendService;
import com.netease.mail.yanxuan.change.biz.service.rpc.SupplierService;
import com.netease.mail.yanxuan.change.biz.util.PageUtils;
import com.netease.mail.yanxuan.change.common.bean.CommonConstants;
import com.netease.mail.yanxuan.change.common.bean.RequestLocalBean;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
......@@ -1227,7 +1228,7 @@ public class ChangeFlowBiz {
log.info("recordIds: {}", recordIds);
if (CollectionUtils.isEmpty(recordIds)) {
ChangeFlowListVO changeFlowListVO = new ChangeFlowListVO();
PageVO pageVO = buildPageVo(0L, pageSize, page);
PageVO pageVO = PageUtils.buildPageVo(0L, pageSize, page);
changeFlowListVO.setPageVo(pageVO);
changeFlowListVO.setChangeFlowList(new ArrayList<>());
return changeFlowListVO;
......@@ -1308,7 +1309,7 @@ public class ChangeFlowBiz {
return changeFlowVO;
}).collect(Collectors.toList());
}
PageVO pageVO = buildPageVo(changeRecordPageInfo.getTotal(), pageSize, page);
PageVO pageVO = PageUtils.buildPageVo(changeRecordPageInfo.getTotal(), pageSize, page);
ChangeFlowListVO changeFlowListVO = new ChangeFlowListVO();
changeFlowListVO.setPageVo(pageVO);
try {
......@@ -1352,26 +1353,6 @@ public class ChangeFlowBiz {
return changeFlowListVO;
}
/**
* 构建分页信息
*
* @param total
* @param pageSize
* @param page
* @return
*/
private PageVO buildPageVo(Long total, Integer pageSize, Integer page) {
Integer totalCount = Math.toIntExact(total);
int totalPage;
int i = totalCount % pageSize;
if (i != 0) {
totalPage = totalCount / pageSize + 1;
} else {
totalPage = totalCount / pageSize;
}
return PageVO.builder().page(page).totalPage(totalPage).pageSize(pageSize).pageCount(pageSize)
.totalCount(totalCount).build();
}
public UserBaseContainerDTO getOperator(InterfaceInputDTO interfaceInput) {
log.info("[getOperator] interfaceInput:{}", JSON.toJSONString(interfaceInput));
......
......@@ -10,6 +10,7 @@ import com.netease.mail.yanxuan.change.biz.service.rpc.FlowService;
import com.netease.mail.yanxuan.change.biz.service.rpc.IusService;
import com.netease.mail.yanxuan.change.integration.flow.ius.IusRpcService;
import com.netease.mail.yanxuan.change.common.bean.CommonConstants;
import com.netease.mail.yanxuan.change.biz.util.PageUtils;
import com.netease.mail.yanxuan.change.common.bean.RequestLocalBean;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.common.enums.ChangeFlowEnum;
......@@ -360,7 +361,7 @@ public class ChangeSubFlowBiz {
List<Long> changeRecordIds = filterFlowRecordIds(queryReq);
if (CollectionUtils.isEmpty(changeRecordIds)) {
// 如果主单查询结果为空,直接返回
PageVO pageVO = buildPageVo(0L, pageSize, page);
PageVO pageVO = PageUtils.buildPageVo(0L, pageSize, page);
ChangeSubFlowListVO result = new ChangeSubFlowListVO();
result.setPageVo(pageVO);
result.setChangeSubFlowList(new ArrayList<>());
......@@ -375,7 +376,7 @@ public class ChangeSubFlowBiz {
List<String> subFlowIds = filterSubFlowIdsByExecCondition(queryReq);
if (CollectionUtils.isEmpty(subFlowIds)) {
// 如果子单ID列表为空,直接返回
PageVO pageVO = buildPageVo(0L, pageSize, page);
PageVO pageVO = PageUtils.buildPageVo(0L, pageSize, page);
ChangeSubFlowListVO result = new ChangeSubFlowListVO();
result.setPageVo(pageVO);
result.setChangeSubFlowList(new ArrayList<>());
......@@ -397,38 +398,31 @@ public class ChangeSubFlowBiz {
List<ChangeSubFlowVO> list = new ArrayList<>();
if (CollectionUtils.isNotEmpty(subFlowRecords)) {
// 批量获取主单信息
List<Long> subFlowChangeRecordIds = subFlowRecords.stream()
.map(ChangeSubFlowRecord::getChangeRecordId)
.distinct()
.collect(Collectors.toList());
List<Long> changeRecordIds = subFlowRecords.stream().map(ChangeSubFlowRecord::getChangeRecordId).distinct()
.collect(Collectors.toList());
final Map<Long, ChangeRecord> changeRecordMap;
if (CollectionUtils.isNotEmpty(subFlowChangeRecordIds)) {
List<ChangeRecord> subFlowChangeRecords = subFlowChangeRecordIds.stream()
.map(changeFlowService::getById)
.filter(Objects::nonNull)
.collect(Collectors.toList());
changeRecordMap = subFlowChangeRecords.stream()
.collect(Collectors.toMap(ChangeRecord::getId, r -> r));
if (CollectionUtils.isNotEmpty(changeRecordIds)) {
List<ChangeRecord> changeRecords = changeFlowService.getByIds(changeRecordIds);
changeRecordMap = changeRecords.stream().filter(Objects::nonNull)
.collect(Collectors.toMap(ChangeRecord::getId, r -> r));
} else {
changeRecordMap = new HashMap<>();
}
// 批量获取行动项信息(用于获取行动人、部门、完成时间等)
List<Long> subFlowRecordIds = subFlowRecords.stream()
.map(ChangeSubFlowRecord::getId)
.collect(Collectors.toList());
List<Long> subFlowRecordIds = subFlowRecords.stream().map(ChangeSubFlowRecord::getId)
.collect(Collectors.toList());
Map<Long, List<ChangeExecRecord>> execRecordMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(subFlowRecordIds)) {
for (Long subFlowRecordId : subFlowRecordIds) {
List<ChangeExecRecord> execRecords = changeFlowExecService.getBySubFlowRecordId(subFlowRecordId);
if (CollectionUtils.isNotEmpty(execRecords)) {
execRecordMap.put(subFlowRecordId, execRecords);
}
List<ChangeExecRecord> allExecRecords = changeFlowExecService.getBySubFlowRecordIds(subFlowRecordIds);
if (CollectionUtils.isNotEmpty(allExecRecords)) {
execRecordMap = allExecRecords.stream().filter(exec -> exec.getSubFlowRecordId() != null)
.collect(Collectors.groupingBy(ChangeExecRecord::getSubFlowRecordId));
}
}
// 构建返回列表
for (ChangeSubFlowRecord subFlowRecord : subFlowRecords) {
for (ChangeSubFlowRecord subFlowRecord: subFlowRecords) {
ChangeSubFlowVO vo = new ChangeSubFlowVO();
vo.setSubFlowId(subFlowRecord.getSubFlowId());
vo.setStatus(subFlowRecord.getStatus());
......@@ -460,22 +454,20 @@ public class ChangeSubFlowBiz {
// 批量查询用户名信息
try {
Set<String> userEmails = list.stream()
.map(ChangeSubFlowVO::getChangeExecUserEmail)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
Set<String> userEmails = list.stream().map(ChangeSubFlowVO::getChangeExecUserEmail)
.filter(StringUtils::isNotBlank).collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(userEmails)) {
AjaxResponse<List<IusUserInfoRsp>> userListInfo = iusRpcService.queryUserListInfo(
UserQueryDTO.builder().uids(new ArrayList<>(userEmails)).build());
AjaxResponse<List<IusUserInfoRsp>> userListInfo = iusRpcService
.queryUserListInfo(UserQueryDTO.builder().uids(new ArrayList<>(userEmails)).build());
List<IusUserInfoRsp> userData = userListInfo.getData();
Map<String, String> userNameMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(userData)) {
userNameMap = userData.stream()
.collect(Collectors.toMap(IusUserInfoRsp::getUid, IusUserInfoRsp::getName));
.collect(Collectors.toMap(IusUserInfoRsp::getUid, IusUserInfoRsp::getName));
}
// 填充用户名和展示信息
for (ChangeSubFlowVO vo : list) {
for (ChangeSubFlowVO vo: list) {
String email = vo.getChangeExecUserEmail();
if (StringUtils.isNotBlank(email)) {
String name = userNameMap.get(email);
......@@ -501,7 +493,7 @@ public class ChangeSubFlowBiz {
}
}
PageVO pageVO = buildPageVo(subFlowRecordPageInfo.getTotal(), pageSize, page);
PageVO pageVO = PageUtils.buildPageVo(subFlowRecordPageInfo.getTotal(), pageSize, page);
ChangeSubFlowListVO result = new ChangeSubFlowListVO();
result.setPageVo(pageVO);
result.setChangeSubFlowList(list);
......@@ -567,24 +559,4 @@ public class ChangeSubFlowBiz {
.collect(Collectors.toList());
}
/**
* 构建分页信息
*
* @param total 总记录数
* @param pageSize 每页大小
* @param page 当前页码
* @return 分页信息
*/
private PageVO buildPageVo(Long total, Integer pageSize, Integer page) {
Integer totalCount = Math.toIntExact(total);
int totalPage;
int i = totalCount % pageSize;
if (i != 0) {
totalPage = totalCount / pageSize + 1;
} else {
totalPage = totalCount / pageSize;
}
return PageVO.builder().page(page).totalPage(totalPage).pageSize(pageSize).pageCount(pageSize)
.totalCount(totalCount).build();
}
}
......@@ -58,6 +58,13 @@ public interface ChangeFlowExecService {
List<ChangeExecRecord> getBySubFlowRecordId(Long subFlowRecordId);
/**
* 批量根据变更行动工单记录ID列表查询行动项列表
* @param subFlowRecordIds 变更行动工单记录ID列表
* @return 行动项列表
*/
List<ChangeExecRecord> getBySubFlowRecordIds(List<Long> subFlowRecordIds);
/**
* 根据变更行动人和部门查询变更行动工单记录ID列表(合并查询)
* @param changeExecUser 变更行动人(邮箱),可为空
* @param changeExecDepartment 变更行动部门,可为空
......
......@@ -52,6 +52,13 @@ public interface ChangeFlowService {
ChangeRecord getById(Long id);
/**
* 批量根据ID列表查询工单详情
* @param ids ID列表
* @return 工单详情列表
*/
List<ChangeRecord> getByIds(List<Long> ids);
/**
* 根据状态及时间获取数据
*
* @param entityId
......
......@@ -86,6 +86,14 @@ public class ChangeFlowExecServiceImpl implements ChangeFlowExecService {
}
@Override
public List<ChangeExecRecord> getBySubFlowRecordIds(List<Long> subFlowRecordIds) {
if (CollectionUtils.isEmpty(subFlowRecordIds)) {
return new ArrayList<>();
}
return changeExecRecordMapper.selectBySubFlowRecordIds(subFlowRecordIds);
}
@Override
public List<Long> querySubFlowRecordIdsByExecCondition(String changeExecUser, String changeExecDepartment) {
// 如果两个条件都为空,返回空列表
if (StringUtils.isBlank(changeExecUser) && StringUtils.isBlank(changeExecDepartment)) {
......
......@@ -6,8 +6,10 @@
*/
package com.netease.mail.yanxuan.change.biz.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -56,6 +58,14 @@ public class ChangeFlowServiceImpl implements ChangeFlowService {
}
@Override
public List<ChangeRecord> getByIds(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
}
return changeRecordMapper.selectByIds(ids);
}
@Override
public List<ChangeRecord> getByStatusAndTime(Long entityId, Integer sendEmail, String nodeId1, String nodeId2, long tomorrowSpecificTime) {
return changeRecordMapper.getByStatusAndTime(entityId, sendEmail, nodeId1, nodeId2, tomorrowSpecificTime);
}
......
......@@ -52,6 +52,19 @@ public interface ChangeExecRecordMapper extends tk.mybatis.mapper.common.Mapper<
List<ChangeExecRecord> selectBySubFlowRecordId(@Param("subFlowRecordId") Long subFlowRecordId);
/**
* 批量根据变更行动工单记录ID列表查询行动项列表
* @param subFlowRecordIds 变更行动工单记录ID列表
* @return 行动项列表
*/
@Select("<script>" +
"SELECT * FROM TB_YX_QC_CHANGE_EXEC_RECORD WHERE sub_flow_record_id IN " +
"<foreach collection='subFlowRecordIds' item='id' open='(' separator=',' close=')'>" +
"#{id}" +
"</foreach>" +
"</script>")
List<ChangeExecRecord> selectBySubFlowRecordIds(@Param("subFlowRecordIds") List<Long> subFlowRecordIds);
/**
* 根据变更行动人和部门查询变更行动工单记录ID列表(合并查询)
* @param changeExecUser 变更行动人(邮箱),可为空
* @param changeExecDepartment 变更行动部门,可为空
......
......@@ -25,6 +25,19 @@ public interface ChangeRecordMapper extends tk.mybatis.mapper.common.Mapper<Chan
@Select("select * from TB_YX_QC_CHANGE_RECORD where `flow_id` = #{flowId} limit 1")
ChangeRecord selectByFlowId(@Param("flowId") Long flowId);
/**
* 批量根据ID列表查询变更记录
* @param ids ID列表
* @return 变更记录列表
*/
@Select("<script>" +
"SELECT * FROM TB_YX_QC_CHANGE_RECORD WHERE id IN " +
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
"#{id}" +
"</foreach>" +
"</script>")
List<ChangeRecord> selectByIds(@Param("ids") List<Long> ids);
List<ChangeRecord> selectByCondition(ChangeFlowListQueryReq changeFlowListQueryReq);
List<ChangeRecord> selectByConditionAndLimit(ChangeFlowListQueryReq changeFlowListQueryReq);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment