|
@@ -3,16 +3,20 @@ package com.ningdatech.pmapi.meeting.manage; |
|
|
import cn.hutool.core.lang.Assert; |
|
|
import cn.hutool.core.lang.Assert; |
|
|
import cn.hutool.core.lang.UUID; |
|
|
import cn.hutool.core.lang.UUID; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
|
|
import com.ningdatech.pmapi.common.model.FreemarkerBatchExportDTO; |
|
|
import com.ningdatech.pmapi.common.util.FreemarkerWordUtil; |
|
|
import com.ningdatech.pmapi.common.util.FreemarkerWordUtil; |
|
|
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; |
|
|
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; |
|
|
|
|
|
import com.ningdatech.pmapi.expert.manage.ExpertReviewManage; |
|
|
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; |
|
|
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.MeetingInnerProject; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.MeetingInnerProject; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.MeetingOuterProject; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.MeetingOuterProject; |
|
|
import com.ningdatech.pmapi.meeting.entity.dto.*; |
|
|
import com.ningdatech.pmapi.meeting.entity.dto.*; |
|
|
|
|
|
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; |
|
|
import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; |
|
|
import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; |
|
|
import com.ningdatech.pmapi.meeting.service.IMeetingInnerProjectService; |
|
|
import com.ningdatech.pmapi.meeting.service.IMeetingInnerProjectService; |
|
|
import com.ningdatech.pmapi.meeting.service.IMeetingOuterProjectService; |
|
|
import com.ningdatech.pmapi.meeting.service.IMeetingOuterProjectService; |
|
@@ -29,11 +33,13 @@ import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Collections; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.function.Function; |
|
|
import java.util.function.Function; |
|
|
import java.util.function.Supplier; |
|
|
import java.util.function.Supplier; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* <p> |
|
|
* <p> |
|
@@ -54,6 +60,7 @@ public class ExpertExportManage { |
|
|
private final IMeetingOuterProjectService meetingOuterProjectService; |
|
|
private final IMeetingOuterProjectService meetingOuterProjectService; |
|
|
private final IExpertUserFullInfoService expertUserInfoService; |
|
|
private final IExpertUserFullInfoService expertUserInfoService; |
|
|
private final IProjectService projectService; |
|
|
private final IProjectService projectService; |
|
|
|
|
|
private final ExpertReviewManage expertReviewManage; |
|
|
|
|
|
|
|
|
//================================================================================================================== |
|
|
//================================================================================================================== |
|
|
|
|
|
|
|
@@ -78,6 +85,16 @@ public class ExpertExportManage { |
|
|
|
|
|
|
|
|
static Supplier<String> wordName = () -> UUID.randomUUID().toString(true) + ".doc"; |
|
|
static Supplier<String> wordName = () -> UUID.randomUUID().toString(true) + ".doc"; |
|
|
|
|
|
|
|
|
|
|
|
private List<MeetingExpert> listExpertsByAgreeOrLeave(Long meetingId) { |
|
|
|
|
|
Page<MeetingExpert> page = Page.of(1, 20); |
|
|
|
|
|
meetingExpertService.pageExpertByStatusAndMeetingId(page, meetingId, null, null); |
|
|
|
|
|
if (page.getTotal() == 0) { |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
|
|
|
page.getRecords().removeIf(w -> !(ExpertAttendStatusEnum.AGREED.eq(w.getStatus()) || ExpertAttendStatusEnum.ON_LEAVE.eq(w.getStatus()))); |
|
|
|
|
|
return page.getRecords(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//================================================================================================================== |
|
|
//================================================================================================================== |
|
|
|
|
|
|
|
|
public void exportFeeForExpert(Long meetingId, HttpServletResponse response) { |
|
|
public void exportFeeForExpert(Long meetingId, HttpServletResponse response) { |
|
@@ -130,22 +147,41 @@ public class ExpertExportManage { |
|
|
public void expertReviewTable(Long meetingId, HttpServletResponse response) { |
|
|
public void expertReviewTable(Long meetingId, HttpServletResponse response) { |
|
|
try { |
|
|
try { |
|
|
Meeting meeting = meetingService.getById(meetingId); |
|
|
Meeting meeting = meetingService.getById(meetingId); |
|
|
ExpertReviewTableDTO data = new ExpertReviewTableDTO(); |
|
|
|
|
|
data.setMeetingTime(DateUtil.localDateTimeFormat(meeting.getStartTime(), "yyyy年M月d日")); |
|
|
|
|
|
data.setMeetingAddress(meeting.getMeetingAddress()); |
|
|
|
|
|
data.setHoldOrg(meeting.getHoldOrg()); |
|
|
|
|
|
List<String> projectNames = new ArrayList<>(); |
|
|
|
|
|
|
|
|
String startTime = DateUtil.localDateTimeFormat(meeting.getStartTime(), "yyyy年M月d日"); |
|
|
|
|
|
List<FreemarkerBatchExportDTO> fbeList; |
|
|
if (meeting.getIsInnerProject()) { |
|
|
if (meeting.getIsInnerProject()) { |
|
|
List<MeetingInnerProject> inners = meetingInnerProjectService.listByMeetingId(meetingId); |
|
|
List<MeetingInnerProject> inners = meetingInnerProjectService.listByMeetingId(meetingId); |
|
|
List<Long> projectIds = CollUtils.fieldList(inners, MeetingInnerProject::getProjectId); |
|
|
List<Long> projectIds = CollUtils.fieldList(inners, MeetingInnerProject::getProjectId); |
|
|
List<Project> projects = projectService.listByIds(projectIds); |
|
|
List<Project> projects = projectService.listByIds(projectIds); |
|
|
projects.forEach(w -> projectNames.add(w.getProjectName())); |
|
|
|
|
|
|
|
|
fbeList = projects.stream().map(w -> { |
|
|
|
|
|
FreemarkerBatchExportDTO fbe = new FreemarkerBatchExportDTO(); |
|
|
|
|
|
ExpertReviewTableDTO currData = new ExpertReviewTableDTO(); |
|
|
|
|
|
currData.setHoldOrg(meeting.getHoldOrg()); |
|
|
|
|
|
currData.setMeetingTime(startTime); |
|
|
|
|
|
currData.setMeetingAddress(meeting.getMeetingAddress()); |
|
|
|
|
|
currData.setProjectName(w.getProjectName()); |
|
|
|
|
|
fbe.setData(currData); |
|
|
|
|
|
fbe.setTemplate(EXPERT_REVIEW); |
|
|
|
|
|
fbe.setFileName(w.getProjectName() + ".doc"); |
|
|
|
|
|
return fbe; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
} else { |
|
|
} else { |
|
|
List<MeetingOuterProject> inners = meetingOuterProjectService.listByMeetingId(meetingId); |
|
|
List<MeetingOuterProject> inners = meetingOuterProjectService.listByMeetingId(meetingId); |
|
|
inners.forEach(w -> projectNames.add(w.getProjectName())); |
|
|
|
|
|
|
|
|
fbeList = inners.stream().map(w -> { |
|
|
|
|
|
FreemarkerBatchExportDTO fbe = new FreemarkerBatchExportDTO(); |
|
|
|
|
|
ExpertReviewTableDTO currData = new ExpertReviewTableDTO(); |
|
|
|
|
|
currData.setHoldOrg(meeting.getHoldOrg()); |
|
|
|
|
|
currData.setMeetingTime(startTime); |
|
|
|
|
|
currData.setMeetingAddress(meeting.getMeetingAddress()); |
|
|
|
|
|
currData.setProjectName(w.getProjectName()); |
|
|
|
|
|
fbe.setData(currData); |
|
|
|
|
|
fbe.setTemplate(EXPERT_REVIEW); |
|
|
|
|
|
fbe.setFileName(w.getProjectName() + ".doc"); |
|
|
|
|
|
return fbe; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
} |
|
|
} |
|
|
data.setProjectName(StrUtil.join("、", projectNames)); |
|
|
|
|
|
FreemarkerWordUtil.export(wordName.get(), data, response, EXPERT_REVIEW); |
|
|
|
|
|
|
|
|
String exportFileName = meeting.getName() + "专家评审表.zip"; |
|
|
|
|
|
FreemarkerWordUtil.exportBatch(response, fbeList, exportFileName); |
|
|
} catch (TemplateException | IOException e) { |
|
|
} catch (TemplateException | IOException e) { |
|
|
log.error("专家评审单导出异常:{}", meetingId, e); |
|
|
log.error("专家评审单导出异常:{}", meetingId, e); |
|
|
throw BizException.wrap("专家评审单导出失败"); |
|
|
throw BizException.wrap("专家评审单导出失败"); |
|
@@ -171,13 +207,17 @@ public class ExpertExportManage { |
|
|
data.setProjectName(StrUtil.join("、", projectNames)); |
|
|
data.setProjectName(StrUtil.join("、", projectNames)); |
|
|
data.setExperts(new ArrayList<>()); |
|
|
data.setExperts(new ArrayList<>()); |
|
|
// 设置专家信息 |
|
|
// 设置专家信息 |
|
|
List<MeetingExpert> experts = meetingExpertService.listAgreedExperts(meetingId); |
|
|
|
|
|
|
|
|
List<MeetingExpert> experts = listExpertsByAgreeOrLeave(meetingId); |
|
|
List<Long> expertIds = CollUtils.fieldList(experts, MeetingExpert::getExpertId); |
|
|
List<Long> expertIds = CollUtils.fieldList(experts, MeetingExpert::getExpertId); |
|
|
List<ExpertUserFullInfo> expertInfos = expertUserInfoService.listByUserId(expertIds); |
|
|
List<ExpertUserFullInfo> expertInfos = expertUserInfoService.listByUserId(expertIds); |
|
|
Map<Long, ExpertUserFullInfo> expertMap = CollUtils.listToMap(expertInfos, ExpertUserFullInfo::getUserId); |
|
|
Map<Long, ExpertUserFullInfo> expertMap = CollUtils.listToMap(expertInfos, ExpertUserFullInfo::getUserId); |
|
|
experts.forEach(w -> { |
|
|
experts.forEach(w -> { |
|
|
ExpertInfoDTO expert = new ExpertInfoDTO(); |
|
|
ExpertInfoDTO expert = new ExpertInfoDTO(); |
|
|
expert.setName(w.getExpertName()); |
|
|
|
|
|
|
|
|
if (ExpertAttendStatusEnum.ON_LEAVE.eq(w.getStatus())) { |
|
|
|
|
|
expert.setBank(w.getExpertName() + "(请假)"); |
|
|
|
|
|
} else { |
|
|
|
|
|
expert.setName(w.getExpertName()); |
|
|
|
|
|
} |
|
|
ExpertUserFullInfo expertUser = expertMap.get(w.getExpertId()); |
|
|
ExpertUserFullInfo expertUser = expertMap.get(w.getExpertId()); |
|
|
if (expertUser != null) { |
|
|
if (expertUser != null) { |
|
|
expert.setCompany(expertUser.getCompany()); |
|
|
expert.setCompany(expertUser.getCompany()); |
|
@@ -217,7 +257,7 @@ public class ExpertExportManage { |
|
|
} |
|
|
} |
|
|
data.setExperts(new ArrayList<>()); |
|
|
data.setExperts(new ArrayList<>()); |
|
|
// 设置专家信息 |
|
|
// 设置专家信息 |
|
|
List<MeetingExpert> experts = meetingExpertService.listAgreedExperts(meetingId); |
|
|
|
|
|
|
|
|
List<MeetingExpert> experts = listExpertsByAgreeOrLeave(meetingId); |
|
|
List<Long> expertIds = CollUtils.fieldList(experts, MeetingExpert::getExpertId); |
|
|
List<Long> expertIds = CollUtils.fieldList(experts, MeetingExpert::getExpertId); |
|
|
List<ExpertUserFullInfo> expertInfos = expertUserInfoService.listByUserId(expertIds); |
|
|
List<ExpertUserFullInfo> expertInfos = expertUserInfoService.listByUserId(expertIds); |
|
|
Map<Long, ExpertUserFullInfo> expertMap = CollUtils.listToMap(expertInfos, ExpertUserFullInfo::getUserId); |
|
|
Map<Long, ExpertUserFullInfo> expertMap = CollUtils.listToMap(expertInfos, ExpertUserFullInfo::getUserId); |
|
@@ -225,7 +265,11 @@ public class ExpertExportManage { |
|
|
experts.forEach(w -> { |
|
|
experts.forEach(w -> { |
|
|
ExpertInfoDTO expert = new ExpertInfoDTO(); |
|
|
ExpertInfoDTO expert = new ExpertInfoDTO(); |
|
|
expert.setNo(integer.incrementAndGet()); |
|
|
expert.setNo(integer.incrementAndGet()); |
|
|
expert.setName(w.getExpertName()); |
|
|
|
|
|
|
|
|
if (ExpertAttendStatusEnum.ON_LEAVE.eq(w.getStatus())) { |
|
|
|
|
|
expert.setBank(w.getExpertName() + "(请假)"); |
|
|
|
|
|
} else { |
|
|
|
|
|
expert.setName(w.getExpertName()); |
|
|
|
|
|
} |
|
|
expert.setMobile(w.getMobile()); |
|
|
expert.setMobile(w.getMobile()); |
|
|
ExpertUserFullInfo expertUser = expertMap.get(w.getExpertId()); |
|
|
ExpertUserFullInfo expertUser = expertMap.get(w.getExpertId()); |
|
|
if (expertUser != null) { |
|
|
if (expertUser != null) { |
|
|