/*
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: Chill 庄骞 (smallchill@163.com)
|
*/
|
package org.springblade.modules.assessment.wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import org.springblade.core.mp.support.BaseEntityWrapper;
|
import org.springblade.core.tool.utils.BeanUtil;
|
import org.springblade.core.tool.utils.SpringUtil;
|
import org.springblade.modules.assessment.entity.AssessmentScoreEntity;
|
import org.springblade.modules.assessment.entity.AssessmentSetDeptEntity;
|
import org.springblade.modules.assessment.entity.AssessmentSetEntity;
|
import org.springblade.modules.assessment.service.IAssessmentScoreService;
|
import org.springblade.modules.assessment.service.IAssessmentSetDeptService;
|
import org.springblade.modules.assessment.service.IAssessmentSetService;
|
import org.springblade.modules.assessment.service.IAssessmentTaskService;
|
import org.springblade.modules.assessment.vo.AssessmentScoreVO;
|
|
import java.util.List;
|
import java.util.Objects;
|
import java.util.stream.Collectors;
|
|
/**
|
* 考核评分 包装类,返回视图层所需的字段
|
*
|
* @author aix
|
* @since 2023-12-13
|
*/
|
public class AssessmentScoreWrapper extends BaseEntityWrapper<AssessmentScoreEntity, AssessmentScoreVO> {
|
|
private static final IAssessmentSetService assessmentSetService;
|
private static final IAssessmentSetDeptService assessmentSetDeptService;
|
private static final IAssessmentScoreService assessmentScoreService;
|
private static final IAssessmentTaskService assessmentTaskService;
|
|
static {
|
assessmentSetService = SpringUtil.getBean(IAssessmentSetService.class);
|
assessmentSetDeptService = SpringUtil.getBean(IAssessmentSetDeptService.class);
|
assessmentScoreService = SpringUtil.getBean(IAssessmentScoreService.class);
|
assessmentTaskService = SpringUtil.getBean(IAssessmentTaskService.class);
|
}
|
|
public static AssessmentScoreWrapper build() {
|
return new AssessmentScoreWrapper();
|
}
|
|
@Override
|
public AssessmentScoreVO entityVO(AssessmentScoreEntity assessmentScore) {
|
AssessmentScoreVO assessmentScoreVO = Objects.requireNonNull(BeanUtil.copy(assessmentScore, AssessmentScoreVO.class));
|
|
//User createUser = UserCache.getUser(assessmentScore.getCreateUser());
|
//User updateUser = UserCache.getUser(assessmentScore.getUpdateUser());
|
//assessmentScoreVO.setCreateUserName(createUser.getName());
|
//assessmentScoreVO.setUpdateUserName(updateUser.getName());
|
|
//考核数量
|
QueryWrapper<AssessmentSetEntity> AssessmentSetEntityWrapper = new QueryWrapper<>();
|
AssessmentSetEntityWrapper.eq("user_id",assessmentScoreVO.getBeId());
|
long userAssCount = assessmentSetService.count(AssessmentSetEntityWrapper);
|
//已经考核数量
|
QueryWrapper<AssessmentScoreEntity> wrapper = new QueryWrapper<>();
|
wrapper.eq("be_id",assessmentScoreVO.getBeId());
|
long assCount = assessmentScoreService.count(wrapper);
|
|
assessmentScoreVO.setIsAssessmentOk(userAssCount == assCount);
|
assessmentScoreVO.setAssessmentTaskVO(AssessmentTaskWrapper.build().entityVO(assessmentTaskService.getById(assessmentScoreVO.getAssessmentTaskId())));
|
return assessmentScoreVO;
|
}
|
|
@Override
|
public List<AssessmentScoreVO> listVO(List<AssessmentScoreEntity> list) {
|
|
return list.stream().map(this::entityVO).collect(Collectors.toList());
|
}
|
|
|
}
|