16 changed files with 243 additions and 9 deletions
@ -0,0 +1,14 @@ |
|||||
|
package com.project.exam.domain.enums; |
||||
|
|
||||
|
import com.project.base.domain.enums.HasValueEnum; |
||||
|
import lombok.Getter; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
|
||||
|
@RequiredArgsConstructor |
||||
|
@Getter |
||||
|
public enum ExamRecordPassTextEnum implements HasValueEnum<String> { |
||||
|
Pass("通过" , "<span style='color: #333333;'>通过</span>") , |
||||
|
Fail("未通过" , "<span style='color: #ff0000;'>未通过</span>"); |
||||
|
private final String value; |
||||
|
private final String html; |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
package com.project.exam.domain.param; |
||||
|
|
||||
|
import com.project.base.domain.param.BaseParam; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class ExamRecordParam extends BaseParam { |
||||
|
private Long businessId; |
||||
|
private Long lineId; |
||||
|
private Long subLineId; |
||||
|
|
||||
|
private String taskName; |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
package com.project.exam.domain.service; |
||||
|
|
||||
|
import com.project.base.domain.result.PageResult; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
import com.project.exam.domain.dto.ExamRecordDTO; |
||||
|
import com.project.exam.domain.param.ExamRecordParam; |
||||
|
|
||||
|
public interface AdminSearchExamRecordDomainService { |
||||
|
Result<PageResult<ExamRecordDTO>> adminSearch(ExamRecordParam param) throws Exception; |
||||
|
} |
||||
@ -0,0 +1,95 @@ |
|||||
|
package com.project.exam.domain.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.util.BooleanUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.project.base.domain.result.PageResult; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
import com.project.base.domain.utils.PageConverter; |
||||
|
import com.project.exam.domain.dto.ExamRecordDTO; |
||||
|
import com.project.exam.domain.dto.ExamRecordPictureDTO; |
||||
|
import com.project.exam.domain.entity.ExamRecordEntity; |
||||
|
import com.project.exam.domain.entity.ExamRecordPictureEntity; |
||||
|
import com.project.exam.domain.enums.ExamRecordPassTextEnum; |
||||
|
import com.project.exam.domain.param.ExamRecordParam; |
||||
|
import com.project.exam.domain.service.AdminSearchExamRecordDomainService; |
||||
|
import com.project.exam.domain.service.ExamRecordBaseService; |
||||
|
import com.project.exam.domain.service.ExamRecordPictureBaseService; |
||||
|
import com.project.information.domain.entity.ProductLineEntity; |
||||
|
import com.project.information.domain.service.ProductLineBaseService; |
||||
|
import com.project.information.utils.MinIoUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Objects; |
||||
|
|
||||
|
@Service |
||||
|
public class AdminSearchExamRecordDomainServiceImpl implements AdminSearchExamRecordDomainService { |
||||
|
|
||||
|
@Autowired |
||||
|
private ExamRecordBaseService examRecordBaseService; |
||||
|
|
||||
|
@Autowired |
||||
|
private ProductLineBaseService productLineBaseService; |
||||
|
|
||||
|
@Autowired |
||||
|
private ExamRecordPictureBaseService examRecordPictureBaseService; |
||||
|
|
||||
|
@Autowired |
||||
|
private MinIoUtils minIoUtils; |
||||
|
|
||||
|
@Override |
||||
|
public Result<PageResult<ExamRecordDTO>> adminSearch(ExamRecordParam param) throws Exception { |
||||
|
LambdaQueryWrapper<ExamRecordEntity> queryWrapper = new LambdaQueryWrapper<>(); |
||||
|
if (Objects.nonNull(param.getBusinessId())) { |
||||
|
queryWrapper.eq(ExamRecordEntity::getBusinessId , param.getBusinessId()); |
||||
|
} |
||||
|
if (Objects.nonNull(param.getLineId())) { |
||||
|
queryWrapper.eq(ExamRecordEntity::getLineId , param.getLineId()); |
||||
|
} |
||||
|
if (Objects.nonNull(param.getSubLineId())) { |
||||
|
queryWrapper.eq(ExamRecordEntity::getSubLineId , param.getSubLineId()); |
||||
|
} |
||||
|
if (StrUtil.isNotBlank(param.getTaskName())) { |
||||
|
queryWrapper.eq(ExamRecordEntity::getTaskName , param.getTaskName()); |
||||
|
} |
||||
|
|
||||
|
IPage<ExamRecordEntity> examRecordEntityIPage = examRecordBaseService.page( |
||||
|
PageConverter.toMpPage(param), |
||||
|
queryWrapper); |
||||
|
IPage<ExamRecordDTO> examRecordDTOIPage = examRecordEntityIPage.convert(this::buildDTO); |
||||
|
|
||||
|
return Result.page(examRecordDTOIPage); |
||||
|
} |
||||
|
|
||||
|
private ExamRecordDTO buildDTO(ExamRecordEntity entity) { |
||||
|
ExamRecordDTO dto = entity.toDTO(ExamRecordDTO::new); |
||||
|
// 抓拍照片信息,只查三个
|
||||
|
List<ExamRecordPictureDTO> pictureDTOList = examRecordPictureBaseService.lambdaQuery() |
||||
|
.eq(ExamRecordPictureEntity::getExamRecordId, entity.getId()) |
||||
|
.last("LIMIT 3").list() |
||||
|
.stream().map(this::buildPictureDTO).toList(); |
||||
|
dto.setPictureDTOList(pictureDTOList); |
||||
|
if (Objects.nonNull(dto.getSubLineId())) { |
||||
|
ProductLineEntity productLine = productLineBaseService.getById(dto.getSubLineId()); |
||||
|
dto.setSubLineName(productLine.getName()); |
||||
|
} |
||||
|
if (BooleanUtil.isTrue(dto.getPass())) { |
||||
|
dto.setPassText(ExamRecordPassTextEnum.Pass.getValue()); |
||||
|
dto.setPassHtml(ExamRecordPassTextEnum.Pass.getHtml()); |
||||
|
} else { |
||||
|
dto.setPassText(ExamRecordPassTextEnum.Fail.getValue()); |
||||
|
dto.setPassHtml(ExamRecordPassTextEnum.Fail.getHtml()); |
||||
|
} |
||||
|
|
||||
|
return dto; |
||||
|
} |
||||
|
|
||||
|
private ExamRecordPictureDTO buildPictureDTO(ExamRecordPictureEntity entity) { |
||||
|
ExamRecordPictureDTO dto = entity.toDTO(ExamRecordPictureDTO::new); |
||||
|
dto.setPreviewUrl(minIoUtils.getPreviewUrl(entity.getFilePath())); |
||||
|
return dto; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue