| | |
| | | package com.ycl.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.ycl.common.enums.business.FileTypeEnum; |
| | | import com.ycl.common.enums.business.ImportanceTypeEnum; |
| | | import com.ycl.common.enums.business.ProjectCategoryEnum; |
| | | import com.ycl.common.exception.base.BaseException; |
| | | import com.ycl.common.utils.CopyUtils; |
| | | import com.ycl.common.utils.DateUtils; |
| | | import com.ycl.common.utils.SecurityUtils; |
| | | import com.ycl.common.utils.StringUtils; |
| | | import com.ycl.common.utils.bean.BeanUtils; |
| | | import com.ycl.common.utils.excel.OutputExcelUtils; |
| | | import com.ycl.domain.entity.*; |
| | | import com.ycl.domain.excel.ProjectExcelTemplate; |
| | | import com.ycl.domain.form.DocumentInfoForm; |
| | | import com.ycl.domain.form.ProjectInfoForm; |
| | | import com.ycl.domain.query.ProjectExportQuery; |
| | | import com.ycl.domain.query.ProjectInfoQuery; |
| | | import com.ycl.domain.vo.*; |
| | | import com.ycl.framework.utils.PageUtil; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | query.setProjectEndTime(DateUtils.getDayEnd(query.getProjectEndTime())); |
| | | } |
| | | String projectCategory = query.getProjectCategory(); |
| | | //实施阶段有两个值放在sql处理 |
| | | if (ProjectCategoryEnum.RESERVE.getType().equals(projectCategory)) { |
| | | query.setProjectStatus(ProjectCategoryEnum.RESERVE.getStatus()); |
| | | query.setReserveOrPrevious(ProjectCategoryEnum.RESERVE.getCode()); |
| | |
| | | return Result.ok().data(false); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void export(HttpServletResponse response, ProjectExportQuery query) { |
| | | List<ProjectVO> data = baseMapper.selectProjectDetailByIds(query.getDataIdList()); |
| | | List<ProjectExcelTemplate> excelList = new ArrayList<>(); |
| | | //字典作翻译 |
| | | data.forEach(item->{ |
| | | ProjectExcelTemplate excel = new ProjectExcelTemplate(); |
| | | BeanUtils.copyProperties(item,excel); |
| | | //项目阶段 |
| | | excel.setProjectPhase(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(),item.getProcessId()!=null)); |
| | | excelList.add(excel); |
| | | }); |
| | | //补充文件的字段 |
| | | Set<Integer> indexes = OutputExcelUtils.getSelectFields(query.getFieldList(), ProjectExcelTemplate.class); |
| | | //不需要附件 |
| | | if(!query.getRequireFile()) { |
| | | try (ServletOutputStream outputStream = response.getOutputStream()) { |
| | | EasyExcel.write(outputStream, ProjectExcelTemplate.class).includeColumnIndexes(indexes).sheet("项目列表").doWrite(excelList); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | throw new BaseException("导出失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | //TODO:需要附件 |
| | | } |
| | | } |