feat(training): 添加按记录ID列表查询培训申请审批详情功能
parent
ee9d9f650d
commit
173b18d707
|
|
@ -1,5 +1,6 @@
|
|||
package com.zcloud.edu.command.query.training;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
import com.zcloud.edu.command.convertor.training.TrainingApplyProcessCoConvertor;
|
||||
import com.zcloud.edu.command.convertor.training.TrainingApplyRecordCoConvertor;
|
||||
|
|
@ -26,7 +27,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -68,18 +69,33 @@ public class TrainingApplyRecordQueryExe {
|
|||
PageResponse<TrainingApplyRecordDO> pageResponse = trainingApplyRecordRepository.listPageSql(params);
|
||||
List<TrainingApplyRecordCO> examCenterCOS = trainingApplyRecordCoConvertor.converDOsToCOs(pageResponse.getData());
|
||||
|
||||
if(CollUtil.isEmpty(examCenterCOS)){
|
||||
return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
|
||||
}
|
||||
//获取所有委托人
|
||||
List<String> recordIdList = examCenterCOS.stream().map(TrainingApplyRecordCO::getTrainingApplyRecordId).collect(Collectors.toList());
|
||||
List<TrainingApplyProcessDO> trainingApplyProcessDOs = trainingApplyProcessRepository.getApproveDetailListByRecordIdList(recordIdList);
|
||||
//按照recordId分组
|
||||
Map<String, List<TrainingApplyProcessDO>> trainingApplyProcessDOMap = trainingApplyProcessDOs.stream()
|
||||
.collect(Collectors.groupingBy(TrainingApplyProcessDO::getTrainingApplyRecordId));
|
||||
|
||||
boolean isCorrectCorp = corpInfoRepository.checkCorp();
|
||||
//只有审批人和审批人的企业能进行审批
|
||||
examCenterCOS.forEach(info->{
|
||||
//只有审批人和审批人的企业能进行审批
|
||||
boolean isCorrectCorp = corpInfoRepository.checkCorp();
|
||||
boolean hasApprovalPermission = isCorrectCorp
|
||||
? AuthContext.getTenantId().equals(info.getApprovalCorpinfoId())
|
||||
: AuthContext.getUserId().equals(info.getApprovalUserId());
|
||||
//只有审批人和审批人的企业能进行审批 ,还有委托人
|
||||
boolean hasApprovalPermission;
|
||||
if (isCorrectCorp) {
|
||||
//企业审批人:比较企业 ID
|
||||
hasApprovalPermission = AuthContext.getTenantId().equals(info.getApprovalCorpinfoId());
|
||||
} else {
|
||||
//委托人:检查是否在审批流程中
|
||||
List<TrainingApplyProcessDO> processList = trainingApplyProcessDOMap.get(info.getTrainingApplyRecordId());
|
||||
hasApprovalPermission = processList != null && processList.contains(AuthContext.getUserId());
|
||||
}
|
||||
|
||||
if (hasApprovalPermission) {
|
||||
info.setIsApproval(true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,5 +56,12 @@ public class TrainingApplyProcessRepositoryImpl extends BaseRepositoryImpl<Train
|
|||
public List<TrainingApplyProcessDO> getApproveDetailList(String trainingApplyRecordId) {
|
||||
return trainingApplyProcessMapper.selectApproveDetailList(trainingApplyRecordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrainingApplyProcessDO> getApproveDetailListByRecordIdList(List<String> recordIdList) {
|
||||
QueryWrapper<TrainingApplyProcessDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("training_apply_record_id", recordIdList);
|
||||
return trainingApplyProcessMapper.selectList(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,5 +30,6 @@ public interface TrainingApplyProcessRepository extends BaseRepository<TrainingA
|
|||
*/
|
||||
List<TrainingApplyProcessDO> getApproveDetailList(String trainingApplyRecordId);
|
||||
|
||||
List<TrainingApplyProcessDO> getApproveDetailListByRecordIdList(List<String> recordIdList);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue