Ver código fonte

初验备案 接口

tags/24080901
PoffyZhang 1 ano atrás
pai
commit
e674a7a726
3 arquivos alterados com 119 adições e 0 exclusões
  1. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/ConstructionController.java
  2. +107
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionManage.java
  3. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/DeclaredProjectExportDTO.java

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/ConstructionController.java Ver arquivo

@@ -59,5 +59,15 @@ public class ConstructionController {
return constructionManage.submitContract(dto);
}

@ApiOperation(value = "待初验备案的项目列表", notes = "待初验备案的项目列表")
@GetMapping("/pre-ins/project-list")
public PageVo<ProjectLibListItemVO> preProjectlist(@ModelAttribute ProjectListReq req) {
return constructionManage.preProjectlist(req);
}

@GetMapping("/pre-ins/export")
@ApiOperation("待初验备案的项目列表导出")
public void exportPreList(ProjectListReq req, HttpServletResponse response){
ExcelDownUtil.downXls(response,req,constructionManage::exportPreList);
}
}

+ 107
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionManage.java Ver arquivo

@@ -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);
}
}
}

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/DeclaredProjectExportDTO.java Ver arquivo

@@ -54,4 +54,6 @@ public class DeclaredProjectExportDTO {
@ExcelProperty("成交时间")
private String transactionTime;

@ExcelProperty("成交时间")
private String deliveryTime;
}

Carregando…
Cancelar
Salvar