|
|
@@ -0,0 +1,56 @@ |
|
|
|
package com.ningdatech.pmapi.declared.manage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.pmapi.declared.entity.dto.DeclaredProjectParamDto; |
|
|
|
import com.wflow.bean.entity.NdDeclaredProject; |
|
|
|
import com.wflow.bean.vo.NdDeclaredProjectVo; |
|
|
|
import com.wflow.service.NdDeclaredProjectService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Classname DeclaredProjectManage |
|
|
|
* @Description |
|
|
|
* @Date 2023/2/1 14:48 |
|
|
|
* @Author PoffyZhang |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@Slf4j |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class DeclaredProjectManage { |
|
|
|
|
|
|
|
private final NdDeclaredProjectService declaredProjectService; |
|
|
|
|
|
|
|
public PageVo<NdDeclaredProjectVo> page(DeclaredProjectParamDto params) { |
|
|
|
Page<NdDeclaredProject> page = params.page(); |
|
|
|
LambdaQueryWrapper<NdDeclaredProject> wrapper = Wrappers.lambdaQuery(NdDeclaredProject.class) |
|
|
|
.ge(Objects.nonNull(params.getStartTime()), NdDeclaredProject::getCreateOn, params.getStartTime()) |
|
|
|
.le(Objects.nonNull(params.getEndTime()), NdDeclaredProject::getCreateOn, params.getEndTime()) |
|
|
|
.eq(Objects.nonNull(params.getProjectType()), NdDeclaredProject::getProjectType, params.getProjectType()) |
|
|
|
.eq(Objects.nonNull(params.getProjectYear()), NdDeclaredProject::getProjectYear, params.getProjectYear()) |
|
|
|
.eq(Objects.nonNull(params.getProjectStatusFirst()), NdDeclaredProject::getProjectStatusFirst, params.getProjectStatusFirst()) |
|
|
|
.eq(Objects.nonNull(params.getProjectStatusSecond()), NdDeclaredProject::getProjectStatusSecond, params.getProjectStatusSecond()) |
|
|
|
.like(StringUtils.isNotBlank(params.getProjectName()), NdDeclaredProject::getProjectName, params.getProjectName()) |
|
|
|
.orderByDesc(NdDeclaredProject::getUpdateOn); |
|
|
|
declaredProjectService.page(page,wrapper); |
|
|
|
if(0L == page.getTotal()){ |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<NdDeclaredProjectVo> res = page.getRecords().stream().map(record -> { |
|
|
|
NdDeclaredProjectVo vo = new NdDeclaredProjectVo(); |
|
|
|
BeanUtils.copyProperties(record, vo); |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return PageVo.of(res,page.getTotal()); |
|
|
|
} |
|
|
|
} |