fix:任务列表今明任务/状态筛选取或
This commit is contained in:
@@ -28,4 +28,9 @@ public class UserWorkloadReq {
|
||||
|
||||
private Long userId;
|
||||
|
||||
/*
|
||||
* 用户组id
|
||||
*/
|
||||
private String userGroupId;
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.sdm.common.entity.req.data.QueryFileReq;
|
||||
import com.sdm.common.entity.req.data.UpdatePermissionReq;
|
||||
import com.sdm.common.entity.req.export.*;
|
||||
import com.sdm.common.entity.req.project.SimulationPerformance;
|
||||
import com.sdm.common.entity.req.system.QueryGroupDetailReq;
|
||||
import com.sdm.common.entity.req.system.SendMsgReq;
|
||||
import com.sdm.common.entity.req.system.UserListReq;
|
||||
import com.sdm.common.entity.req.system.UserQueryReq;
|
||||
@@ -29,6 +30,7 @@ import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.common.entity.resp.capability.FlowTemplateResp;
|
||||
import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import com.sdm.common.entity.resp.system.SysUserGroupDetailResp;
|
||||
import com.sdm.common.feign.impl.capability.SimulationFlowFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.data.DataClientFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.MessageFeignClientImpl;
|
||||
@@ -1218,7 +1220,7 @@ public class TaskServiceImpl implements ITaskService {
|
||||
@Override
|
||||
public SdmResponse<List<UserWorkloadResp>> listUserWorkloadsWithinTimeFrame(UserWorkloadReq req) {
|
||||
List<UserWorkloadResp> userWorkloadRespList = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(req.getUserIds())) {
|
||||
if (CollectionUtils.isEmpty(req.getUserIds()) && StringUtils.isEmpty(req.getUserGroupId())) {
|
||||
UserListReq userListReq = new UserListReq();
|
||||
userListReq.setTenantId(ThreadLocalContext.getTenantId());
|
||||
userListReq.setCurrent(1);
|
||||
@@ -1229,6 +1231,22 @@ public class TaskServiceImpl implements ITaskService {
|
||||
}
|
||||
List<Long> userIds = pageDataRespSdmResponse.getData().getData().stream().map(CIDUserResp::getUserId).toList();
|
||||
req.setUserIds(userIds.stream().map(String::valueOf).toList());
|
||||
} else if (CollectionUtils.isEmpty(req.getUserIds()) && StringUtils.isNotEmpty(req.getUserGroupId())) {
|
||||
// 查询用户组下所有成员
|
||||
QueryGroupDetailReq groupDetailReq = new QueryGroupDetailReq();
|
||||
groupDetailReq.setCurrent(1);
|
||||
groupDetailReq.setSize(1000);
|
||||
groupDetailReq.setId(Long.valueOf(req.getUserGroupId()));
|
||||
groupDetailReq.setTenantId(ThreadLocalContext.getTenantId());
|
||||
SdmResponse<SysUserGroupDetailResp> response = sysUserFeignClient.queryGroupDetail(groupDetailReq);
|
||||
if (response.isSuccess() && ObjectUtils.isNotEmpty(response.getData())
|
||||
&& ObjectUtils.isNotEmpty(response.getData().getUsers())
|
||||
&& ObjectUtils.isNotEmpty(response.getData().getUsers().getData())) {
|
||||
List<String> userIds = response.getData().getUsers().getData().stream()
|
||||
.map(u -> u.getUserId() == null ? null : String.valueOf(u.getUserId()))
|
||||
.toList();
|
||||
req.setUserIds(userIds);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(req.getUserIds())) {
|
||||
SdmResponse<List<CIDUserResp>> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(req.getUserIds().stream().map(Long::valueOf).toList()).build());
|
||||
@@ -1246,7 +1264,12 @@ public class TaskServiceImpl implements ITaskService {
|
||||
userWorkloadRespList.add(workloadResp);
|
||||
}
|
||||
}
|
||||
return SdmResponse.success(userWorkloadRespList.stream().sorted(Comparator.comparing(UserWorkloadResp::getTaskNum).reversed()).toList());
|
||||
userWorkloadRespList = userWorkloadRespList.stream()
|
||||
// 处理null值:将taskNum为null的元素排在最后,非null的按taskNum倒序
|
||||
.sorted(Comparator.comparing(UserWorkloadResp::getTaskNum,
|
||||
Comparator.nullsLast(Comparator.reverseOrder())))
|
||||
.toList();
|
||||
return SdmResponse.success(userWorkloadRespList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,23 +61,40 @@
|
||||
<if test="req.progress != null and req.progress != ''">
|
||||
and progress = #{req.progress}
|
||||
</if>
|
||||
<trim prefix="(" suffix=")" prefixOverrides="OR ">
|
||||
<if test="req.exeStatusList != null and req.exeStatusList.size > 0">
|
||||
and exe_status in (
|
||||
<foreach collection='req.exeStatusList' item='exeStatus' index='index' separator=','>
|
||||
#{exeStatus}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 时间条件块:如果状态条件存在,用OR连接;否则直接加时间条件 -->
|
||||
<if test="req.todayTmrTasks != null and req.todayTmrTasks != ''">
|
||||
<if test="req.exeStatusList != null and req.exeStatusList.size > 0">OR</if>
|
||||
<![CDATA[
|
||||
and end_time >= DATE_FORMAT(CURRENT_DATE(),'%Y-%m-%d')
|
||||
and end_time <= DATE_FORMAT(DATE_ADD(CURRENT_DATE(), INTERVAL 2 DAY),'%Y-%m-%d')
|
||||
<if test="(req.exeStatusList != null and req.exeStatusList.size > 0) or (req.todayTmrTasks != null and req.todayTmrTasks != '')">
|
||||
and (
|
||||
<choose>
|
||||
<!-- 只有状态条件 -->
|
||||
<when test="req.exeStatusList != null and req.exeStatusList.size > 0 and (req.todayTmrTasks == null or req.todayTmrTasks == '')">
|
||||
exe_status in (
|
||||
<foreach collection='req.exeStatusList' item='exeStatus' index='index' separator=','>
|
||||
#{exeStatus}
|
||||
</foreach>
|
||||
)
|
||||
</when>
|
||||
<!-- 只有时间条件 -->
|
||||
<when test="(req.exeStatusList == null or req.exeStatusList.size == 0) and req.todayTmrTasks != null and req.todayTmrTasks != ''">
|
||||
<![CDATA[
|
||||
STR_TO_DATE(end_time,'%Y-%m-%d') >= CURRENT_DATE()
|
||||
and STR_TO_DATE(end_time,'%Y-%m-%d') <= DATE_ADD(CURRENT_DATE(), INTERVAL 2 DAY)
|
||||
]]>
|
||||
</if>
|
||||
</trim>
|
||||
</when>
|
||||
<!-- 两个条件都有(并集) -->
|
||||
<otherwise>
|
||||
exe_status in (
|
||||
<foreach collection='req.exeStatusList' item='exeStatus' index='index' separator=','>
|
||||
#{exeStatus}
|
||||
</foreach>
|
||||
)
|
||||
<![CDATA[ OR ]]>
|
||||
<![CDATA[
|
||||
STR_TO_DATE(end_time,'%Y-%m-%d') >= CURRENT_DATE()
|
||||
and STR_TO_DATE(end_time,'%Y-%m-%d') <= DATE_ADD(CURRENT_DATE(), INTERVAL 2 DAY)
|
||||
]]>
|
||||
</otherwise>
|
||||
</choose>
|
||||
)
|
||||
</if>
|
||||
<if test="req.achieveStatusList != null and req.achieveStatusList.size > 0">
|
||||
and achieve_status in (
|
||||
<foreach collection='req.achieveStatusList' item='achieveStatus' index='index' separator=','>
|
||||
|
||||
Reference in New Issue
Block a user