| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.platform.domain.dto.ReportImportDTO; |
| | | import com.ycl.platform.domain.entity.Report; |
| | | import com.ycl.platform.domain.entity.YwPeople; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.entity.YwUnit; |
| | | import com.ycl.platform.domain.form.ReportAuditingForm; |
| | | import com.ycl.platform.domain.form.ReportForm; |
| | | import com.ycl.platform.domain.query.ReportQuery; |
| | |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.utils.DateUtils; |
| | | import com.ycl.utils.SecurityUtils; |
| | | import com.ycl.utils.html.EscapeUtil; |
| | | import com.ycl.utils.poi.ExcelUtil; |
| | | import com.ycl.utils.uuid.IdUtils; |
| | | import enumeration.general.ErrorTypeEnum; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | return Result.ok().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public List<ReportVO> export(ReportQuery query) { |
| | | |
| | | if (StringUtils.isNotBlank(query.getPointId())) { |
| | | LambdaQueryWrapper<YwPoint> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.like(YwPoint::getPointName, query.getPointId()); |
| | | query.setPointIdList(ywpointMapper.selectList(queryWrapper).stream().map(YwPoint::getId).collect(Collectors.toList())); |
| | | if(CollectionUtils.isEmpty(query.getPointIdList())) { |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | if (StringUtils.isNotBlank(query.getPeopleId())) { |
| | | LambdaQueryWrapper<YwPeople> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.like(YwPeople::getYwPersonName, query.getPeopleId()); |
| | | query.setPeopleIdList(peopleMapper.selectList(queryWrapper).stream().map(YwPeople::getId).collect(Collectors.toList())); |
| | | if(CollectionUtils.isEmpty(query.getPeopleIdList())) { |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | IPage<Report> page = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .eq(StringUtils.isNotBlank(query.getReportType()), Report::getReportType, query.getReportType()) |
| | | // .le(Objects.nonNull(query.getBeginCreateTime()), Report::getBeginCreateTime, query.getBeginCreateTime()) |
| | | // .ge(Objects.nonNull(query.getEndCreateTime()), Report::getEndCreateTime, query.getEndCreateTime()) |
| | | // .in(!CollectionUtils.isEmpty(query.getPointIdList()), Report::getPointId, query.getPointIdList()) |
| | | .in(!CollectionUtils.isEmpty(query.getPeopleIdList()), Report::getPeopleId, query.getPeopleIdList()) |
| | | .orderByDesc(Report::getCreateTime) |
| | | .page(PageUtil.getPage(query, Report.class)); |
| | | |
| | | List<ReportVO> vos = page.getRecords().stream() |
| | | .map( |
| | | entity -> { |
| | | ReportVO vo = ReportVO.getVoByEntity(entity, null); |
| | | YwUnit unit = unitMapper.selectById(vo.getUnitId()); |
| | | vo.setUnitName(unit.getUnitName()); |
| | | YwPeople ywPeople = peopleMapper.selectById(vo.getPeopleId()); |
| | | vo.setPeopleName(ywPeople.getYwPersonName()); |
| | | // YwPoint ywPoint = ywpointMapper.selectById(vo.getPointId()); |
| | | // vo.setPointName(ywPoint.getPointName()); |
| | | return vo; |
| | | } |
| | | ) |
| | | .collect(Collectors.toList()); |
| | | return vos; |
| | | IPage<ReportVO> page = PageUtil.getPage(query, ReportVO.class); |
| | | page.setSize(-1); |
| | | baseMapper.page(page, query); |
| | | page.getRecords().forEach(item -> { |
| | | item.setErrorType(ErrorTypeEnum.getEnumValue(item.getErrorType())); |
| | | item.setReportContent(EscapeUtil.clean(item.getReportContent())); |
| | | }); |
| | | return page.getRecords(); |
| | | } |
| | | |
| | | |