|
@@ -1,12 +1,16 @@
|
|
|
package cn.efunbox.manage.base.service.impl;
|
|
|
|
|
|
import cn.efunbox.manage.base.entity.*;
|
|
|
+import cn.efunbox.manage.base.enums.BaseStatusEnum;
|
|
|
import cn.efunbox.manage.base.enums.CompanyTypeEnum;
|
|
|
+import cn.efunbox.manage.base.enums.IncomeStatusEnum;
|
|
|
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.enums.BaseOrderEnum;
|
|
|
+import cn.efunbox.manage.common.helper.SortHelper;
|
|
|
import cn.efunbox.manage.common.result.ApiCode;
|
|
|
import cn.efunbox.manage.common.result.ApiResult;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -53,8 +57,8 @@ public class ManageServiceImpl implements ManageService {
|
|
|
|
|
|
@Override
|
|
|
public ApiResult list(ManageVO manageVO, Integer pageNo, Integer pageSize) {
|
|
|
- Pageable pageable = new PageRequest(pageNo - 1, pageSize);
|
|
|
- Specification querySpecifi = new Specification<Manage>() {
|
|
|
+ Pageable pageable = new PageRequest(pageNo - 1, pageSize, SortHelper.sortMap2Sort(new LinkedHashMap<String, BaseOrderEnum>(){{put("happenTime", BaseOrderEnum.DESC);put("gmtModified", BaseOrderEnum.DESC);}}));
|
|
|
+ Specification specification = new Specification<Manage>() {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<Manage> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
|
|
|
|
@@ -74,12 +78,35 @@ public class ManageServiceImpl implements ManageService {
|
|
|
if(Objects.nonNull(manageVO.getType())){
|
|
|
predicates.add(criteriaBuilder.equal(root.get("type"), manageVO.getType()));
|
|
|
}
|
|
|
- if(Objects.nonNull(manageVO.getCostTypeId()) && 0 != manageVO.getCostTypeId()){
|
|
|
- predicates.add(criteriaBuilder.equal(root.get("costTypeId"), manageVO.getCostTypeId()));
|
|
|
+ if(manageVO.getCostTypeId() != null && manageVO.getCostTypeId().size() > 0){
|
|
|
+ List<Predicate> list = new ArrayList<>();
|
|
|
+ if (manageVO.getCostTypeId() != null && manageVO.getCostTypeId().size() > 0) {
|
|
|
+ CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("costTypeId"));
|
|
|
+ for (Long id : manageVO.getCostTypeId()) {
|
|
|
+ in.value(id);
|
|
|
+ }
|
|
|
+ list.add(in);
|
|
|
+ }
|
|
|
+ predicates.addAll(list);
|
|
|
}
|
|
|
- if(Objects.nonNull(manageVO.getIncomeStatus())){
|
|
|
- predicates.add(criteriaBuilder.equal(root.get("incomeStatus"), manageVO.getIncomeStatus()));
|
|
|
+// if(Objects.nonNull(manageVO.getCostTypeId()) && 0 != manageVO.getCostTypeId()){
|
|
|
+// predicates.add(criteriaBuilder.equal(root.get("costTypeId"), manageVO.getCostTypeId()));
|
|
|
+// }
|
|
|
+ if(manageVO.getIncomeStatus() != null && manageVO.getIncomeStatus().size() > 0){
|
|
|
+ List<Predicate> list = new ArrayList<>();
|
|
|
+ if (manageVO.getIncomeStatus() != null && manageVO.getIncomeStatus().size() > 0) {
|
|
|
+ CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("incomeStatus"));
|
|
|
+ for (IncomeStatusEnum incomeStatus : manageVO.getIncomeStatus()) {
|
|
|
+ in.value(incomeStatus);
|
|
|
+ }
|
|
|
+ list.add(in);
|
|
|
+ }
|
|
|
+ predicates.addAll(list);
|
|
|
}
|
|
|
+// if(Objects.nonNull(manageVO.getIncomeStatus())){
|
|
|
+// predicates.add(criteriaBuilder.equal(root.get("incomeStatus"), manageVO.getIncomeStatus()));
|
|
|
+// }
|
|
|
+
|
|
|
if(Objects.nonNull(manageVO.getStatus())){
|
|
|
predicates.add(criteriaBuilder.equal(root.get("status"), manageVO.getStatus()));
|
|
|
}
|
|
@@ -109,11 +136,11 @@ public class ManageServiceImpl implements ManageService {
|
|
|
return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
}
|
|
|
};
|
|
|
- Long count = manageRepository.count(querySpecifi);
|
|
|
+ Long count = manageRepository.count(specification);
|
|
|
if (count == 0) {
|
|
|
return ApiResult.ok(null);
|
|
|
}
|
|
|
- Page<Manage> manages = manageRepository.findAll(querySpecifi, pageable);
|
|
|
+ Page<Manage> manages = manageRepository.findAll(specification, pageable);
|
|
|
if(Objects.isNull(manages)){
|
|
|
return ApiResult.error(ApiCode.UNKNOWN_ERROR);
|
|
|
|