|
@@ -6,10 +6,14 @@ import cn.efunbox.manage.base.enums.ManageTypeEnum;
|
|
|
import cn.efunbox.manage.base.repository.*;
|
|
|
import cn.efunbox.manage.base.service.ManageService;
|
|
|
import cn.efunbox.manage.base.vo.ManageVO;
|
|
|
+import cn.efunbox.manage.common.entity.page.OnePage;
|
|
|
import cn.efunbox.manage.common.result.ApiCode;
|
|
|
import cn.efunbox.manage.common.result.ApiResult;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.Mapping;
|
|
@@ -48,7 +52,8 @@ public class ManageServiceImpl implements ManageService {
|
|
|
CostTypeRepository costTypeRepository;
|
|
|
|
|
|
@Override
|
|
|
- public ApiResult list(ManageVO manageVO) {
|
|
|
+ public ApiResult list(ManageVO manageVO, Integer pageNo, Integer pageSize) {
|
|
|
+ Pageable pageable = new PageRequest(pageNo - 1, pageSize);
|
|
|
Specification querySpecifi = new Specification<Manage>() {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<Manage> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
|
@@ -84,6 +89,12 @@ public class ManageServiceImpl implements ManageService {
|
|
|
if(Objects.nonNull(manageVO.getEndTime())){
|
|
|
predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("happenTime"), manageVO.getEndTime()));
|
|
|
}
|
|
|
+ if(Objects.nonNull(manageVO.getMinAmount())){
|
|
|
+ predicates.add(criteriaBuilder.ge(root.get("amount"), manageVO.getMinAmount()));
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(manageVO.getMaxAmount())){
|
|
|
+ predicates.add(criteriaBuilder.le(root.get("amount"), manageVO.getMaxAmount()));
|
|
|
+ }
|
|
|
if(manageVO.getDeptIds() != null && manageVO.getDeptIds().size() > 0){
|
|
|
List<Predicate> list = new ArrayList<>();
|
|
|
if (manageVO.getDeptIds() != null && manageVO.getDeptIds().size() > 0) {
|
|
@@ -98,7 +109,11 @@ public class ManageServiceImpl implements ManageService {
|
|
|
return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
}
|
|
|
};
|
|
|
- List<Manage> manages = manageRepository.findAll(querySpecifi);
|
|
|
+ Long count = manageRepository.count(querySpecifi);
|
|
|
+ if (count == 0) {
|
|
|
+ return ApiResult.ok(null);
|
|
|
+ }
|
|
|
+ Page<Manage> manages = manageRepository.findAll(querySpecifi, pageable);
|
|
|
if(Objects.isNull(manages)){
|
|
|
return ApiResult.error(ApiCode.UNKNOWN_ERROR);
|
|
|
|
|
@@ -108,7 +123,7 @@ public class ManageServiceImpl implements ManageService {
|
|
|
List<Long> productIds = new ArrayList<>();
|
|
|
List<Long> companyIds = new ArrayList<>();
|
|
|
List<Long> costTypeIds = new ArrayList<>();
|
|
|
- manages.stream().forEach(m -> {
|
|
|
+ for(Manage m : manages){
|
|
|
if(Objects.nonNull(m.getDeptId())){
|
|
|
deptIds.add(m.getDeptId());
|
|
|
}
|
|
@@ -150,7 +165,8 @@ public class ManageServiceImpl implements ManageService {
|
|
|
if(Objects.nonNull(m.getToDeptId())){
|
|
|
deptIds.add(m.getToDeptId());
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
//部门
|
|
|
List<Department> departments = departmentRepository.findByIds(deptIds);
|
|
|
Map<Long, Department> departmentMap = new HashMap<>();
|
|
@@ -182,7 +198,7 @@ public class ManageServiceImpl implements ManageService {
|
|
|
costTypeMap.put(costType.getId(), costType);
|
|
|
});
|
|
|
|
|
|
- manages.stream().forEach(m -> {
|
|
|
+ for(Manage m : manages){
|
|
|
m.setDepartment(departmentMap.get(m.getDeptId()));
|
|
|
m.setProject(projectMap.get(m.getProjectId()));
|
|
|
m.setProduct(producMap.get(m.getProductId()));
|
|
@@ -207,7 +223,7 @@ public class ManageServiceImpl implements ManageService {
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
- });
|
|
|
+ };
|
|
|
return ApiResult.ok(manages);
|
|
|
}
|
|
|
|