|
@@ -1,12 +1,11 @@ |
|
|
package com.ningdatech.pmapi.projectlib.manage; |
|
|
package com.ningdatech.pmapi.projectlib.manage; |
|
|
|
|
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil; |
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams; |
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
|
|
import cn.hutool.poi.excel.ExcelReader; |
|
|
|
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
|
import com.alibaba.excel.context.AnalysisContext; |
|
|
|
|
|
import com.alibaba.excel.event.AnalysisEventListener; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
@@ -14,7 +13,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
import com.ningdatech.basic.util.ValidUtil; |
|
|
|
|
|
import com.ningdatech.pmapi.common.constant.CommonConst; |
|
|
import com.ningdatech.pmapi.common.constant.CommonConst; |
|
|
import com.ningdatech.pmapi.common.enumeration.CommonEnum; |
|
|
import com.ningdatech.pmapi.common.enumeration.CommonEnum; |
|
|
import com.ningdatech.pmapi.common.helper.UserInfoHelper; |
|
|
import com.ningdatech.pmapi.common.helper.UserInfoHelper; |
|
@@ -23,35 +21,42 @@ import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; |
|
|
import com.ningdatech.pmapi.common.util.ExcelDownUtil; |
|
|
import com.ningdatech.pmapi.common.util.ExcelDownUtil; |
|
|
import com.ningdatech.pmapi.datascope.model.DataScopeDTO; |
|
|
import com.ningdatech.pmapi.datascope.model.DataScopeDTO; |
|
|
import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; |
|
|
import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; |
|
|
import com.ningdatech.pmapi.projectlib.constant.ImportTemplateConstant; |
|
|
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ImportTemplateEnum; |
|
|
|
|
|
|
|
|
import com.ningdatech.pmapi.expert.constant.ExpertUserInfoSensitiveFieldEnum; |
|
|
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectLibFlagEnum; |
|
|
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; |
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; |
|
|
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; |
|
|
import com.ningdatech.pmapi.projectlib.model.dto.AnnualLibImportDTO; |
|
|
import com.ningdatech.pmapi.projectlib.model.dto.AnnualLibImportDTO; |
|
|
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; |
|
|
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; |
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectRenewalFundDeclaration; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectApprovedReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectApprovedReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectIdReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectIdReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.StartProjectDeclareReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.StartProjectDeclareReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.vo.AnnualPlanListItemVO; |
|
|
import com.ningdatech.pmapi.projectlib.model.vo.AnnualPlanListItemVO; |
|
|
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService; |
|
|
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService; |
|
|
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectRenewalFundDeclarationService; |
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; |
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; |
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.IOException; |
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
|
|
import java.net.URLEncoder; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import static com.ningdatech.pmapi.expert.constant.ExpertUserInfoSensitiveFieldEnum.UnitType.list; |
|
|
import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; |
|
|
import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -71,6 +76,7 @@ public class AnnualPlanLibManage { |
|
|
private final StateMachineUtils stateMachine; |
|
|
private final StateMachineUtils stateMachine; |
|
|
private final INdProjectStatusChangeService statusChangeService; |
|
|
private final INdProjectStatusChangeService statusChangeService; |
|
|
private final UserInfoHelper userInfoHelper; |
|
|
private final UserInfoHelper userInfoHelper; |
|
|
|
|
|
private final IProjectRenewalFundDeclarationService projectRenewalFundDeclarationService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 年度计划查询状态 |
|
|
* 年度计划查询状态 |
|
@@ -169,112 +175,6 @@ public class AnnualPlanLibManage { |
|
|
projectService.updateById(project); |
|
|
projectService.updateById(project); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void importAnnualPlan(ImportTemplateEnum template, MultipartFile file) { |
|
|
|
|
|
String contentType = file.getContentType(); |
|
|
|
|
|
if (!contentType.equals(ExcelUtil.XLS_CONTENT_TYPE) && |
|
|
|
|
|
!contentType.equals(ExcelUtil.XLSX_CONTENT_TYPE) |
|
|
|
|
|
) { |
|
|
|
|
|
throw BizException.wrap("导入失败,不支持的文件类型,请按照提供的模板导入文件!"); |
|
|
|
|
|
} |
|
|
|
|
|
try (InputStream inputStream = file.getInputStream(); |
|
|
|
|
|
ExcelReader reader = ExcelUtil.getReader(inputStream)) { |
|
|
|
|
|
Map<String, String> alias; |
|
|
|
|
|
List<String> title = ImportTemplateConstant.getTemplateTitle(template); |
|
|
|
|
|
switch (template) { |
|
|
|
|
|
case ANNUAL_PLAN: |
|
|
|
|
|
alias = new HashMap<>(title.size()); |
|
|
|
|
|
alias.put(title.get(0), "id"); |
|
|
|
|
|
alias.put(title.get(1), "projectId"); |
|
|
|
|
|
alias.put(title.get(2), "projectName"); |
|
|
|
|
|
alias.put(title.get(3), "projectIntroduction"); |
|
|
|
|
|
alias.put(title.get(4), "buildBasis"); |
|
|
|
|
|
alias.put(title.get(5), "isFirst"); |
|
|
|
|
|
alias.put(title.get(6), "buildCycle"); |
|
|
|
|
|
alias.put(title.get(7), "declaredAmount"); |
|
|
|
|
|
alias.put(title.get(8), "annualPlanAmount"); |
|
|
|
|
|
alias.put(title.get(9), "declareHaveAmount"); |
|
|
|
|
|
alias.put(title.get(10), "declareGovOwnFinanceAmount"); |
|
|
|
|
|
alias.put(title.get(11), "declareGovSuperiorFinanceAmount"); |
|
|
|
|
|
alias.put(title.get(12), "declareBankLendingAmount"); |
|
|
|
|
|
alias.put(title.get(13), "declareOtherAmount"); |
|
|
|
|
|
alias.put(title.get(14), "firstQuarter"); |
|
|
|
|
|
alias.put(title.get(15), "secondQuarter"); |
|
|
|
|
|
alias.put(title.get(16), "thirdQuarter"); |
|
|
|
|
|
alias.put(title.get(17), "fourthQuarter"); |
|
|
|
|
|
alias.put(title.get(18), "buildUnitName"); |
|
|
|
|
|
alias.put(title.get(19), "contactName"); |
|
|
|
|
|
alias.put(title.get(20), "responsibleMan"); |
|
|
|
|
|
alias.put(title.get(21), "projectRemarks"); |
|
|
|
|
|
reader.setHeaderAlias(alias); |
|
|
|
|
|
importAnnualPlanData(reader.readAll(AnnualLibImportDTO.class)); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
throw new BizException("不支持的数据导入类型"); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void importAnnualPlanData(List<AnnualLibImportDTO> importDataList) { |
|
|
|
|
|
if (CollectionUtils.isEmpty(importDataList)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
List<Project> projectList = new ArrayList<>(); |
|
|
|
|
|
List<Long> projectIds = CollUtils.fieldList(importDataList, AnnualLibImportDTO::getProjectId); |
|
|
|
|
|
Assert.isTrue(projectIds.size() == importDataList.size(), "项目ID不可重复"); |
|
|
|
|
|
Long userId = LoginUserUtil.getUserId(); |
|
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
|
importDataList.forEach(w -> { |
|
|
|
|
|
Project project = new Project(); |
|
|
|
|
|
project.setCreateBy(userId); |
|
|
|
|
|
project.setCreateOn(now); |
|
|
|
|
|
project.setUpdateBy(userId); |
|
|
|
|
|
project.setUpdateOn(now); |
|
|
|
|
|
|
|
|
|
|
|
project.setId(w.getProjectId()); |
|
|
|
|
|
project.setProjectName(w.getProjectName()); |
|
|
|
|
|
project.setProjectIntroduction(w.getProjectIntroduction()); |
|
|
|
|
|
// 建设依据(立项依据忽略) |
|
|
|
|
|
if (CommonConst.NEW_CONSTRUCTION.equals(w.getIsFirst())){ |
|
|
|
|
|
project.setIsFirst(CommonEnum.YES.getCode()); |
|
|
|
|
|
}else if (CommonConst.CONTINUED_CONSTRUCTION.equals(w.getIsFirst())){ |
|
|
|
|
|
project.setIsFirst(CommonEnum.NO.getCode()); |
|
|
|
|
|
} |
|
|
|
|
|
String buildCycle = w.getBuildCycle(); |
|
|
|
|
|
int index = buildCycle.indexOf(CommonConst.MONTH); |
|
|
|
|
|
if (-1 == index){ |
|
|
|
|
|
throw new BizException("项目ID为:" + w.getProjectId() + "的建设起止年限格式不正确,请按照xx年xx月至xx年xx月的格式输入!"); |
|
|
|
|
|
} |
|
|
|
|
|
String beginTime = buildCycle.substring(0, index + 1); |
|
|
|
|
|
project.setBeginTime(beginTime); |
|
|
|
|
|
String endTime = buildCycle.substring(index + 2); |
|
|
|
|
|
project.setEndTime(endTime); |
|
|
|
|
|
project.setDeclareAmount(w.getDeclaredAmount()); |
|
|
|
|
|
project.setAnnualPlanAmount(w.getAnnualPlanAmount()); |
|
|
|
|
|
project.setDeclareHaveAmount(w.getDeclareHaveAmount()); |
|
|
|
|
|
project.setDeclareGovOwnFinanceAmount(w.getDeclareGovOwnFinanceAmount()); |
|
|
|
|
|
project.setDeclareGovSuperiorFinanceAmount(w.getDeclareGovSuperiorFinanceAmount()); |
|
|
|
|
|
project.setDeclareBankLendingAmount(w.getDeclareBankLendingAmount()); |
|
|
|
|
|
project.setDeclareOtherAmount(w.getDeclareOtherAmount()); |
|
|
|
|
|
project.setEngineeringSpeedOne(w.getFirstQuarter()); |
|
|
|
|
|
project.setEngineeringSpeedTwo(w.getSecondQuarter()); |
|
|
|
|
|
project.setEngineeringSpeedThree(w.getThirdQuarter()); |
|
|
|
|
|
project.setEngineeringSpeedFour(w.getFourthQuarter()); |
|
|
|
|
|
|
|
|
|
|
|
project.setBuildOrgName(w.getBuildUnitName()); |
|
|
|
|
|
project.setContactName(w.getContactName()); |
|
|
|
|
|
project.setResponsibleMan(w.getResponsibleMan()); |
|
|
|
|
|
project.setProjectRemarks(w.getProjectRemarks()); |
|
|
|
|
|
projectList.add(project); |
|
|
|
|
|
}); |
|
|
|
|
|
LambdaQueryWrapper<Project> delQuery = Wrappers.lambdaQuery(Project.class) |
|
|
|
|
|
.in(Project::getId, projectIds); |
|
|
|
|
|
projectService.remove(delQuery); |
|
|
|
|
|
projectService.saveBatch(projectList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void updateAnnualPlan(ProjectDTO req) { |
|
|
public void updateAnnualPlan(ProjectDTO req) { |
|
|
Project project = BeanUtil.copyProperties(req, Project.class); |
|
|
Project project = BeanUtil.copyProperties(req, Project.class); |
|
|
projectService.updateById(project); |
|
|
projectService.updateById(project); |
|
@@ -295,15 +195,12 @@ public class AnnualPlanLibManage { |
|
|
|
|
|
|
|
|
ExcelExportWriter excelExportWriter = new ExcelExportWriter(); |
|
|
ExcelExportWriter excelExportWriter = new ExcelExportWriter(); |
|
|
|
|
|
|
|
|
Integer tableFlag = param.getTableFlag(); |
|
|
|
|
|
if (Objects.isNull(tableFlag)) { |
|
|
|
|
|
throw new BizException("请传入要导出的表格类型!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ProjectLibFlagEnum projectLibFlag = param.getProjectLibFlag(); |
|
|
String fileName = null; |
|
|
String fileName = null; |
|
|
if (tableFlag == 0) { |
|
|
|
|
|
fileName = "年度计划库编辑表"; |
|
|
|
|
|
} else if (tableFlag == 1) { |
|
|
|
|
|
|
|
|
if (ProjectLibFlagEnum.ANNUAL_PLAN.equals(projectLibFlag)){ |
|
|
fileName = "年度计划库列表"; |
|
|
fileName = "年度计划库列表"; |
|
|
|
|
|
}else if (ProjectLibFlagEnum.ANNUAL_PLAN_SUPPLEMENT.equals(projectLibFlag)){ |
|
|
|
|
|
fileName = "年度计划增补库列表"; |
|
|
} |
|
|
} |
|
|
excelExportWriter.setFileName(fileName); |
|
|
excelExportWriter.setFileName(fileName); |
|
|
List<String> sheetsNames = new ArrayList<>(); |
|
|
List<String> sheetsNames = new ArrayList<>(); |
|
@@ -356,4 +253,152 @@ public class AnnualPlanLibManage { |
|
|
} |
|
|
} |
|
|
return user; |
|
|
return user; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void importAnnualPlan(ProjectLibFlagEnum importFlag, MultipartFile file) { |
|
|
|
|
|
Long userId = LoginUserUtil.getUserId(); |
|
|
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
|
|
// 标题行数 |
|
|
|
|
|
params.setTitleRows(2); |
|
|
|
|
|
// 从第几行开始,因为第一、二个大标题被上面的参数给占了,所以不是5 |
|
|
|
|
|
params.setHeadRows(3); |
|
|
|
|
|
// 表格数量 |
|
|
|
|
|
params.setSheetNum(2); |
|
|
|
|
|
List<AnnualLibImportDTO> list = null; |
|
|
|
|
|
try { |
|
|
|
|
|
list = ExcelImportUtil.importExcel(file.getInputStream(), AnnualLibImportDTO.class, params); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new BizException(e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
// 筛选出导入的新建项目 |
|
|
|
|
|
List<AnnualLibImportDTO> newList = list.stream() |
|
|
|
|
|
.filter(d -> CommonConst.NEW_CONSTRUCTION.equals(d.getIsFirst())) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
List<Project> projectList = newList.stream().map(n -> { |
|
|
|
|
|
Project project = new Project(); |
|
|
|
|
|
assemblyProjectInfo(n, project); |
|
|
|
|
|
// 根据传入标志判断是否临时增补 |
|
|
|
|
|
if (ProjectLibFlagEnum.ANNUAL_PLAN.equals(importFlag)){ |
|
|
|
|
|
project.setIsTemporaryAugment(CommonEnum.NO.getCode()); |
|
|
|
|
|
}else if (ProjectLibFlagEnum.ANNUAL_PLAN_SUPPLEMENT.equals(importFlag)){ |
|
|
|
|
|
project.setIsTemporaryAugment(CommonEnum.YES.getCode()); |
|
|
|
|
|
} |
|
|
|
|
|
project.setCreateBy(userId); |
|
|
|
|
|
project.setUpdateBy(userId); |
|
|
|
|
|
project.setCreateOn(LocalDateTime.now()); |
|
|
|
|
|
project.setUpdateOn(LocalDateTime.now()); |
|
|
|
|
|
return project; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
// 保存到项目库中 |
|
|
|
|
|
projectService.saveBatch(projectList); |
|
|
|
|
|
|
|
|
|
|
|
// 筛选出导入的续建项目 |
|
|
|
|
|
List<AnnualLibImportDTO> continuedList = list.stream() |
|
|
|
|
|
.filter(d -> CommonConst.CONTINUED_CONSTRUCTION.equals(d.getIsFirst())) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
List<ProjectRenewalFundDeclaration> renewalFundDeclarationList = continuedList.stream().map(c -> { |
|
|
|
|
|
ProjectRenewalFundDeclaration renewalFundDeclaration = new ProjectRenewalFundDeclaration(); |
|
|
|
|
|
BeanUtils.copyProperties(c, renewalFundDeclaration); |
|
|
|
|
|
renewalFundDeclaration.setAnnualPaymentAmount(c.getAnnualPlanAmount()); |
|
|
|
|
|
renewalFundDeclaration.setOtherAmount(c.getDeclareOtherAmount()); |
|
|
|
|
|
renewalFundDeclaration.setApprovalStatus(ProjectRenewalApprovalStatusEnum.PENDING.name()); |
|
|
|
|
|
renewalFundDeclaration.setCreateOn(LocalDateTime.now()); |
|
|
|
|
|
renewalFundDeclaration.setUpdateOn(LocalDateTime.now()); |
|
|
|
|
|
return renewalFundDeclaration; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
// 保存到续建项目资金库中 |
|
|
|
|
|
projectRenewalFundDeclarationService.saveBatch(renewalFundDeclarationList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void assemblyProjectInfo(AnnualLibImportDTO data, Project project) { |
|
|
|
|
|
project.setId(data.getProjectId()); |
|
|
|
|
|
project.setProjectName(data.getProjectName()); |
|
|
|
|
|
project.setProjectIntroduction(data.getProjectIntroduction()); |
|
|
|
|
|
// 建设依据忽略 |
|
|
|
|
|
project.setIsFirst(CommonConst.NEW_CONSTRUCTION.equals(data.getIsFirst()) ? 1 : 0); |
|
|
|
|
|
String[] dataArr = data.getBuildCycle().split(CommonConst.ZHI); |
|
|
|
|
|
if (CollectionUtils.isEmpty(Arrays.asList(dataArr))){ |
|
|
|
|
|
throw new BizException("项目ID为:" + data.getProjectId() + "的建设起止年限格式不正确,请按照xx年xx月至xx年xx月的格式输入!"); |
|
|
|
|
|
} |
|
|
|
|
|
project.setBeginTime(dataArr[0].trim()); |
|
|
|
|
|
project.setEndTime(dataArr[1].trim()); |
|
|
|
|
|
project.setDeclareAmount(data.getDeclaredAmount()); |
|
|
|
|
|
project.setAnnualPlanAmount(data.getAnnualPlanAmount()); |
|
|
|
|
|
project.setDeclareHaveAmount(data.getDeclareHaveAmount()); |
|
|
|
|
|
project.setDeclareGovOwnFinanceAmount(data.getDeclareGovOwnFinanceAmount()); |
|
|
|
|
|
project.setDeclareGovSuperiorFinanceAmount(data.getDeclareGovSuperiorFinanceAmount()); |
|
|
|
|
|
project.setDeclareBankLendingAmount(data.getDeclareBankLendingAmount()); |
|
|
|
|
|
project.setDeclareOtherAmount(data.getDeclareOtherAmount()); |
|
|
|
|
|
project.setEngineeringSpeedOne(data.getFirstQuarter()); |
|
|
|
|
|
project.setEngineeringSpeedTwo(data.getSecondQuarter()); |
|
|
|
|
|
project.setEngineeringSpeedThree(data.getThirdQuarter()); |
|
|
|
|
|
project.setEngineeringSpeedFour(data.getFourthQuarter()); |
|
|
|
|
|
project.setBuildOrgName(data.getBuildUnitName()); |
|
|
|
|
|
project.setContactName(data.getContactName()); |
|
|
|
|
|
project.setResponsibleMan(data.getResponsibleMan()); |
|
|
|
|
|
project.setProjectRemarks(data.getProjectRemarks()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void exportModifyList(ProjectListReq param, HttpServletResponse response) { |
|
|
|
|
|
ProjectLibFlagEnum projectLibFlag = param.getProjectLibFlag(); |
|
|
|
|
|
int year = LocalDateTime.now().getYear(); |
|
|
|
|
|
Integer isTemporaryAugment = null; |
|
|
|
|
|
String fileName = null; |
|
|
|
|
|
// 设置excel的文件名称和是否增补 |
|
|
|
|
|
if (ProjectLibFlagEnum.ANNUAL_PLAN.equals(projectLibFlag)){ |
|
|
|
|
|
isTemporaryAugment = 0; |
|
|
|
|
|
fileName = "丽水市" + year + "年数字化项目年度计划库编辑表"; |
|
|
|
|
|
}else if (ProjectLibFlagEnum.ANNUAL_PLAN_SUPPLEMENT.equals(projectLibFlag)){ |
|
|
|
|
|
isTemporaryAugment = 1; |
|
|
|
|
|
fileName = "丽水市" + year + "年数字化项目年度计划增补库编辑表"; |
|
|
|
|
|
} |
|
|
|
|
|
param.setIsTemporaryAugment(isTemporaryAugment); |
|
|
|
|
|
param.setStatusList(CollUtils.fieldList(ANNUAL_PLAN_LIST_STATUS, ProjectStatusEnum::getCode)); |
|
|
|
|
|
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(param); |
|
|
|
|
|
query.orderByDesc(Project::getAnnualPlanAddTime); |
|
|
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
|
|
List<AnnualLibImportDTO> list = projects.stream().map(p -> { |
|
|
|
|
|
AnnualLibImportDTO dto = new AnnualLibImportDTO(); |
|
|
|
|
|
BeanUtils.copyProperties(p, dto); |
|
|
|
|
|
dto.setFirstQuarter(p.getEngineeringSpeedOne()); |
|
|
|
|
|
dto.setSecondQuarter(p.getEngineeringSpeedTwo()); |
|
|
|
|
|
dto.setThirdQuarter(p.getEngineeringSpeedThree()); |
|
|
|
|
|
dto.setFourthQuarter(p.getEngineeringSpeedFour()); |
|
|
|
|
|
return dto; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
// 获取本地目录的年度计划编辑表Excel模板 |
|
|
|
|
|
File directory = new File(""); |
|
|
|
|
|
String templateName = "丽水市" + year + "年数字化项目年度计划编辑表"; |
|
|
|
|
|
String templatePath = directory.getAbsolutePath() + File.separator + "template" + File.separator + templateName + ".xls"; |
|
|
|
|
|
TemplateExportParams temp = new TemplateExportParams(templatePath); |
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
|
|
map.put("mapList", list); |
|
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(temp, map); |
|
|
|
|
|
if (workbook == null) { |
|
|
|
|
|
throw new BizException("读取模板失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
// 重置响应对象 |
|
|
|
|
|
response.reset(); |
|
|
|
|
|
try { |
|
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + URLEncoder.encode(Objects.requireNonNull(fileName),"UTF-8") + ".xls"); |
|
|
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
response.setContentType(ExcelUtil.XLS_CONTENT_TYPE); |
|
|
|
|
|
response.setHeader("Pragma", "no-cache"); |
|
|
|
|
|
response.setHeader("Cache-Control", "no-cache"); |
|
|
|
|
|
response.setDateHeader("Expires", 0); |
|
|
|
|
|
// 写出数据输出流到页面 |
|
|
|
|
|
try { |
|
|
|
|
|
OutputStream output = response.getOutputStream(); |
|
|
|
|
|
BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output); |
|
|
|
|
|
workbook.write(bufferedOutPut); |
|
|
|
|
|
bufferedOutPut.flush(); |
|
|
|
|
|
bufferedOutPut.close(); |
|
|
|
|
|
output.close(); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |