Commit 7038de94 by 王志超

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

parent b3c0fbe8
...@@ -386,6 +386,8 @@ public class ChangeFlowBiz { ...@@ -386,6 +386,8 @@ public class ChangeFlowBiz {
.subFlowNode(subNodeId) .subFlowNode(subNodeId)
.status(ChangeSubFlowStatusEnum.WAIT_CONFIRM_ACTION_PLAN.getStatus()) .status(ChangeSubFlowStatusEnum.WAIT_CONFIRM_ACTION_PLAN.getStatus())
.approver(approverJson) .approver(approverJson)
.changeExecUserEmail(execUserEmail)
.changeExecDepartment(execDepartment)
.createTime(DateUtils.getCurrentTime()) .createTime(DateUtils.getCurrentTime())
.updateTime(DateUtils.getCurrentTime()) .updateTime(DateUtils.getCurrentTime())
.build(); .build();
...@@ -1213,15 +1215,6 @@ public class ChangeFlowBiz { ...@@ -1213,15 +1215,6 @@ public class ChangeFlowBiz {
log.info("[query] page:{}, pageSize:{}, changeFlowListQueryReq:{}", page, pageSize, log.info("[query] page:{}, pageSize:{}, changeFlowListQueryReq:{}", page, pageSize,
JSON.toJSONString(changeFlowListQueryReq)); JSON.toJSONString(changeFlowListQueryReq));
// 数据可见范围:仅查看我跟进的工单(默认true)
if (changeFlowListQueryReq.getOnlyMyFollowed()) {
String currentUser = RequestLocalBean.getUid();
if (StringUtils.isNotBlank(currentUser)) {
changeFlowListQueryReq.setCurrentUser(currentUser);
log.info("[query] 数据可见范围:仅查看我跟进的工单, currentUser:{}", currentUser);
}
}
if (StringUtils.isNotBlank(changeFlowListQueryReq.getChangeExecUser())) { if (StringUtils.isNotBlank(changeFlowListQueryReq.getChangeExecUser())) {
List<Long> recordIds = changeFlowExecService.queryByExecUser(changeFlowListQueryReq.getChangeExecUser()); List<Long> recordIds = changeFlowExecService.queryByExecUser(changeFlowListQueryReq.getChangeExecUser());
changeFlowListQueryReq.setChangeRecordIds(recordIds); changeFlowListQueryReq.setChangeRecordIds(recordIds);
...@@ -1234,6 +1227,16 @@ public class ChangeFlowBiz { ...@@ -1234,6 +1227,16 @@ public class ChangeFlowBiz {
return changeFlowListVO; return changeFlowListVO;
} }
} }
// 数据可见范围:仅查看我跟进的工单(默认true)
if (changeFlowListQueryReq.getOnlyMyFollowed()) {
String currentUser = RequestLocalBean.getUid();
if (StringUtils.isNotBlank(currentUser)) {
changeFlowListQueryReq.setCurrentUser(currentUser);
log.info("[query] 数据可见范围:仅查看我跟进的工单, currentUser:{}", currentUser);
}
}
//进行分页 //进行分页
PageHelper.startPage(page, pageSize); PageHelper.startPage(page, pageSize);
PageInfo<ChangeRecord> changeRecordPageInfo = new PageInfo<>( PageInfo<ChangeRecord> changeRecordPageInfo = new PageInfo<>(
......
...@@ -370,22 +370,8 @@ public class ChangeSubFlowBiz { ...@@ -370,22 +370,8 @@ public class ChangeSubFlowBiz {
queryReq.setChangeRecordIds(changeRecordIds); queryReq.setChangeRecordIds(changeRecordIds);
} }
// 根据行动项条件(changeExecUser, changeExecDepartment)查询执行项,获取 subFlowId 列表 // 清空主单相关的查询条件,因为已经通过 changeRecordIds 过滤了
if (StringUtils.isNotBlank(queryReq.getChangeExecUser()) // changeExecUser 和 changeExecDepartment 直接在子单表中查询,不需要额外处理
|| StringUtils.isNotBlank(queryReq.getChangeExecDepartment())) {
List<String> subFlowIds = filterSubFlowIdsByExecCondition(queryReq);
if (CollectionUtils.isEmpty(subFlowIds)) {
// 如果子单ID列表为空,直接返回
PageVO pageVO = PageUtils.buildPageVo(0L, pageSize, page);
ChangeSubFlowListVO result = new ChangeSubFlowListVO();
result.setPageVo(pageVO);
result.setChangeSubFlowList(new ArrayList<>());
return result;
}
queryReq.setSubFlowIds(subFlowIds);
}
// 清空主单和行动项相关的查询条件,因为已经通过 changeRecordIds 和 subFlowIds 过滤了
queryReq.setOnlyMyFollowed(null); queryReq.setOnlyMyFollowed(null);
queryReq.setCurrentUser(null); queryReq.setCurrentUser(null);
...@@ -532,31 +518,4 @@ public class ChangeSubFlowBiz { ...@@ -532,31 +518,4 @@ public class ChangeSubFlowBiz {
return changeRecords.stream().map(ChangeRecord::getId).distinct().collect(Collectors.toList()); return changeRecords.stream().map(ChangeRecord::getId).distinct().collect(Collectors.toList());
} }
/**
* 根据行动项条件(changeExecUser, changeExecDepartment)查询执行项,获取 subFlowId 列表
*
* @param queryReq 查询条件
* @return subFlowId 列表
*/
private List<String> filterSubFlowIdsByExecCondition(ChangeSubFlowListQueryReq queryReq) {
// 使用合并查询,根据字段是否为 null 来查询
List<Long> subFlowRecordIds = changeFlowExecService
.querySubFlowRecordIdsByExecCondition(queryReq.getChangeExecUser(), queryReq.getChangeExecDepartment());
// 如果行动项查询结果为空,返回空列表
if (CollectionUtils.isEmpty(subFlowRecordIds)) {
return new ArrayList<>();
}
// 根据 subFlowRecordId 批量查询子单,获取 subFlowId 列表
List<ChangeSubFlowRecord> subFlowRecords = changeSubFlowRecordMapper.selectByIds(subFlowRecordIds);
if (CollectionUtils.isEmpty(subFlowRecords)) {
return new ArrayList<>();
}
return subFlowRecords.stream().map(ChangeSubFlowRecord::getSubFlowId).filter(StringUtils::isNotBlank).distinct()
.collect(Collectors.toList());
}
} }
package com.netease.mail.yanxuan.change.biz.util;
import com.netease.mail.yanxuan.change.dal.meta.model.vo.PageVO;
/**
* 分页工具类
* @Author system
* @Date 2024/01/01
*/
public class PageUtils {
/**
* 构建分页信息
* 根据总记录数、每页大小和当前页码构建分页VO
*
* @param total 总记录数
* @param pageSize 每页大小
* @param page 当前页码
* @return 分页信息
*/
public static 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();
}
}
...@@ -64,6 +64,16 @@ public class ChangeSubFlowRecord { ...@@ -64,6 +64,16 @@ public class ChangeSubFlowRecord {
private String approver; private String approver;
/** /**
* 变更行动人邮箱(用于查询和展示,新建时从行动项获取)
*/
private String changeExecUserEmail;
/**
* 变更行动部门(用于查询和展示,新建时从行动项获取)
*/
private String changeExecDepartment;
/**
* 创建时间 * 创建时间
*/ */
private Long createTime; private Long createTime;
......
...@@ -8,6 +8,7 @@ package com.netease.mail.yanxuan.change.dal.mapper; ...@@ -8,6 +8,7 @@ package com.netease.mail.yanxuan.change.dal.mapper;
import java.util.List; import java.util.List;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeSubFlowListQueryReq;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
...@@ -70,7 +71,7 @@ public interface ChangeSubFlowRecordMapper extends tk.mybatis.mapper.common.Mapp ...@@ -70,7 +71,7 @@ public interface ChangeSubFlowRecordMapper extends tk.mybatis.mapper.common.Mapp
* @param queryReq 查询条件 * @param queryReq 查询条件
* @return 变更行动工单列表 * @return 变更行动工单列表
*/ */
List<ChangeSubFlowRecord> selectByCondition(com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeSubFlowListQueryReq queryReq); List<ChangeSubFlowRecord> selectByCondition(ChangeSubFlowListQueryReq queryReq);
} }
...@@ -8,12 +8,14 @@ ...@@ -8,12 +8,14 @@
<result column="sub_flow_node" jdbcType="VARCHAR" property="subFlowNode" /> <result column="sub_flow_node" jdbcType="VARCHAR" property="subFlowNode" />
<result column="status" jdbcType="INTEGER" property="status" /> <result column="status" jdbcType="INTEGER" property="status" />
<result column="approver" jdbcType="VARCHAR" property="approver" /> <result column="approver" jdbcType="VARCHAR" property="approver" />
<result column="change_exec_user_email" jdbcType="VARCHAR" property="changeExecUserEmail" />
<result column="change_exec_department" jdbcType="VARCHAR" property="changeExecDepartment" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" /> <result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, change_record_id, sub_flow_id, sub_flow_node, status, approver, create_time, update_time id, change_record_id, sub_flow_id, sub_flow_node, status, approver, change_exec_user_email, change_exec_department, create_time, update_time
</sql> </sql>
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeSubFlowListQueryReq"> <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeSubFlowListQueryReq">
...@@ -44,6 +46,15 @@ ...@@ -44,6 +46,15 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="currentUser != null and currentUser != ''">
and (change_exec_user_email LIKE CONCAT('%"', #{currentUser}, '"%') or approver LIKE CONCAT('%"', #{currentUser}, '"%')
</if>
<if test="changeExecUser != null and changeExecUser != ''">
and change_exec_user_email LIKE CONCAT('%', #{changeExecUser}, '%')
</if>
<if test="changeExecDepartment != null and changeExecDepartment != ''">
and change_exec_department LIKE CONCAT('%', #{changeExecDepartment}, '%')
</if>
</where> </where>
order by create_time desc order by create_time desc
</select> </select>
......
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