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