| | |
| | | */ |
| | | package org.springblade.modules.evaluate.wrapper; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.google.common.reflect.TypeToken; |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.assessment.wrapper.CandidateJsonObj; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.modules.evaluate.entity.EvaluateCandidateEntity; |
| | | import org.springblade.modules.evaluate.entity.EvaluateResultEntity; |
| | | import org.springblade.modules.evaluate.entity.EvaluateTaskEntity; |
| | | import org.springblade.modules.evaluate.service.IEvaluateCandidateService; |
| | | import org.springblade.modules.evaluate.service.IEvaluateResultService; |
| | | import org.springblade.modules.evaluate.vo.EvaluateTaskVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 评优任务表 包装类,返回视图层所需的字段 |
| | |
| | | * @since 2023-12-08 |
| | | */ |
| | | public class EvaluateTaskWrapper extends BaseEntityWrapper<EvaluateTaskEntity, EvaluateTaskVO> { |
| | | |
| | | private static final IEvaluateCandidateService evaluateCandidateService; |
| | | private static final IEvaluateResultService evaluateResultService; |
| | | |
| | | static { |
| | | evaluateCandidateService = SpringUtil.getBean(IEvaluateCandidateService.class); |
| | | evaluateResultService = SpringUtil.getBean(IEvaluateResultService.class); |
| | | } |
| | | |
| | | public static EvaluateTaskWrapper build() { |
| | | return new EvaluateTaskWrapper(); |
| | |
| | | return evaluateTaskVO; |
| | | } |
| | | |
| | | public EvaluateTaskEntity entityPO(EvaluateTaskVO vo) { |
| | | EvaluateTaskEntity po = Objects.requireNonNull(BeanUtil.copy(vo, EvaluateTaskEntity.class)); |
| | | return po; |
| | | } |
| | | |
| | | public IPage<EvaluateTaskVO> companyListPageVO(IPage pages,Long userId) { |
| | | List<EvaluateTaskVO> records = listVO(pages.getRecords()); |
| | | |
| | | for (EvaluateTaskVO vo:records) { |
| | | if (vo.getEvaluateState() == 1) { |
| | | QueryWrapper<EvaluateCandidateEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("evaluate_task_id", vo.getId()); |
| | | List<EvaluateCandidateEntity> candidateEntitieList = evaluateCandidateService.list(queryWrapper); |
| | | List<Map<String,Object>> users = new ArrayList<>(); |
| | | for (EvaluateCandidateEntity evaluateCandidate:candidateEntitieList) { |
| | | Map<String,Object> user = new HashMap<>(); |
| | | user.put("id",evaluateCandidate.getUserId()); |
| | | user.put("name",evaluateCandidate.getUserName()); |
| | | users.add(user); |
| | | } |
| | | vo.setSelfCandidate(users); |
| | | |
| | | //是否评论完成 |
| | | QueryWrapper<EvaluateResultEntity> resultEntityQueryWrapper = new QueryWrapper<>(); |
| | | resultEntityQueryWrapper.eq("score_user_id", userId); |
| | | resultEntityQueryWrapper.eq("type", 2); |
| | | resultEntityQueryWrapper.eq("evaluate_task_id", vo.getId()); |
| | | long reqCount = evaluateResultService.count(resultEntityQueryWrapper); |
| | | |
| | | vo.setIsEvaluateOk(reqCount > 0); |
| | | if (reqCount > 0) { |
| | | vo.setEvaluateResultVO(EvaluateResultWrapper.build().entityVO(evaluateResultService.getOne(resultEntityQueryWrapper))); |
| | | } |
| | | } |
| | | } |
| | | |
| | | IPage<EvaluateTaskVO> pageVo = new Page<>(pages.getCurrent(), pages.getSize(), pages.getTotal()); |
| | | pageVo.setRecords(records); |
| | | return pageVo; |
| | | } |
| | | |
| | | |
| | | } |