|
|
@@ -286,4 +286,111 @@ public class ConstructionManage { |
|
|
|
|
|
|
|
return "填写成功"; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 待初验项目列表 |
|
|
|
* @param req |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public PageVo<ProjectLibListItemVO> preProjectlist(ProjectListReq req) { |
|
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
|
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); |
|
|
|
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); |
|
|
|
//建设中状态 |
|
|
|
query.eq(Project::getStatus,ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); |
|
|
|
query.eq(Project::getStage,ProjectStatusEnum.PROJECT_APPROVED.getCode()); |
|
|
|
query.eq(Project::getNewest,Boolean.TRUE); |
|
|
|
//交货时间 排序 |
|
|
|
query.isNotNull(Project::getDeliveryTime); |
|
|
|
query.orderByAsc(Project::getDeliveryTime); |
|
|
|
Page<Project> page = projectService.page(req.page(), query); |
|
|
|
long total; |
|
|
|
if ((total = page.getTotal()) == 0) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> projectIds = page.getRecords().stream().map(Project::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class) |
|
|
|
.in(Purchase::getProjectId, projectIds)); |
|
|
|
Map<Long, Purchase> purchaseMap = purchases.stream().collect(Collectors.toMap(Purchase::getProjectId, v -> v)); |
|
|
|
|
|
|
|
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { |
|
|
|
ProjectLibListItemVO item = new ProjectLibListItemVO(); |
|
|
|
item.setId(w.getId()); |
|
|
|
item.setProjectName(w.getProjectName()); |
|
|
|
item.setCreateOn(w.getCreateOn()); |
|
|
|
item.setDeclaredAmount(w.getDeclareAmount()); |
|
|
|
item.setStage(w.getStage()); |
|
|
|
item.setStatus(w.getStatus()); |
|
|
|
item.setProjectType(w.getProjectType()); |
|
|
|
item.setProjectYear(w.getProjectYear()); |
|
|
|
item.setBuildOrg(w.getBuildOrgName()); |
|
|
|
item.setBizDomain(w.getBizDomain()); |
|
|
|
item.setProcessStatus(w.getProcessStatus()); |
|
|
|
item.setInstCode(w.getInstCode()); |
|
|
|
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); |
|
|
|
item.setApprovedAmount(w.getApprovalAmount()); |
|
|
|
item.setApprovalDate(w.getApprovalDate()); |
|
|
|
if(purchaseMap.containsKey(w.getId())){ |
|
|
|
Purchase purchase = purchaseMap.get(w.getId()); |
|
|
|
item.setTransactionAmount(purchase.getTransactionAmount()); |
|
|
|
item.setTransactionTime(purchase.getTransactionTime()); |
|
|
|
} |
|
|
|
item.setDeliveryTime(w.getDeliveryTime()); |
|
|
|
return item; |
|
|
|
}); |
|
|
|
return PageVo.of(records, total); |
|
|
|
} |
|
|
|
|
|
|
|
public void exportPreList(HttpServletResponse response, ProjectListReq param) { |
|
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
|
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); |
|
|
|
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(param); |
|
|
|
//待采购状态 |
|
|
|
query.eq(Project::getStatus,ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); |
|
|
|
query.eq(Project::getStage,ProjectStatusEnum.PROJECT_APPROVED.getCode()); |
|
|
|
query.eq(Project::getNewest,Boolean.TRUE); |
|
|
|
//交货时间 排序 |
|
|
|
query.isNotNull(Project::getDeliveryTime); |
|
|
|
query.orderByAsc(Project::getDeliveryTime); |
|
|
|
List<Project> records = projectService.list(query); |
|
|
|
|
|
|
|
AtomicInteger serialNumber = new AtomicInteger(0); |
|
|
|
List<DeclaredProjectExportDTO> collect = Lists.newArrayList(); |
|
|
|
if(CollUtil.isNotEmpty(records)){ |
|
|
|
List<Long> projectIds = records.stream().map(Project::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class) |
|
|
|
.in(Purchase::getProjectId, projectIds)); |
|
|
|
Map<Long, Purchase> purchaseMap = purchases.stream().collect(Collectors.toMap(Purchase::getProjectId, v -> v)); |
|
|
|
|
|
|
|
collect = records.stream().map(r -> { |
|
|
|
DeclaredProjectExportDTO exportDTO = new DeclaredProjectExportDTO(); |
|
|
|
BeanUtils.copyProperties(r, exportDTO); |
|
|
|
exportDTO.setProjectTypeName(ProjectTypeEnum.getDesc(r.getProjectType())); |
|
|
|
exportDTO.setStatusName(ProjectStatusEnum.getDesc(r.getStatus())); |
|
|
|
String createOnStr = NdDateUtils.format(r.getCreateOn(), "yyyy-MM-dd HH:mm"); |
|
|
|
exportDTO.setCreateOn(createOnStr); |
|
|
|
exportDTO.setSerialNumber(serialNumber.incrementAndGet()); |
|
|
|
exportDTO.setDeliveryTime(r.getDeliveryTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
return exportDTO; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
String fileName = "合同备案项目列表"; |
|
|
|
ExcelDownUtil.setFileName(fileName,response); |
|
|
|
//数据导出处理函数 |
|
|
|
try { |
|
|
|
EasyExcel.write(response.getOutputStream(), DeclaredProjectExportDTO.class) |
|
|
|
.autoCloseStream(false) |
|
|
|
.registerWriteHandler(ExcelExportStyle.formalStyle()) |
|
|
|
.sheet(fileName) |
|
|
|
.doWrite(collect); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |