|
@@ -3,6 +3,7 @@ package cn.efunbox.manage.base.service.impl;
|
|
import cn.efunbox.manage.base.entity.*;
|
|
import cn.efunbox.manage.base.entity.*;
|
|
import cn.efunbox.manage.base.enums.BaseStatusEnum;
|
|
import cn.efunbox.manage.base.enums.BaseStatusEnum;
|
|
import cn.efunbox.manage.base.enums.IncomeStatusEnum;
|
|
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.repository.*;
|
|
import cn.efunbox.manage.base.service.ManageService;
|
|
import cn.efunbox.manage.base.service.ManageService;
|
|
import cn.efunbox.manage.base.vo.ManageVO;
|
|
import cn.efunbox.manage.base.vo.ManageVO;
|
|
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -48,10 +50,10 @@ public class ManageServiceImpl implements ManageService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ApiResult list(ManageVO manageVO) {
|
|
public ApiResult list(ManageVO manageVO) {
|
|
- Pageable pageable = new PageRequest(manageVO.getPageNo() - 1, manageVO.getPageSize(), SortHelper.sortMap2Sort(new LinkedHashMap<String, BaseOrderEnum>(){{put("gmtModified", BaseOrderEnum.DESC);}}));
|
|
|
|
|
|
+ Pageable pageable = new PageRequest(manageVO.getPageNo() - 1, manageVO.getPageSize(), SortHelper.sortMap2Sort(new LinkedHashMap<String, BaseOrderEnum>(){{put("status", BaseOrderEnum.ASC);put("gmtModified", BaseOrderEnum.DESC);}}));
|
|
// manageVO.setStatus(BaseStatusEnum.NORMAL);
|
|
// manageVO.setStatus(BaseStatusEnum.NORMAL);
|
|
if(!manageVO.getIsEntry()){
|
|
if(!manageVO.getIsEntry()){
|
|
- pageable = new PageRequest(manageVO.getPageNo() - 1,manageVO.getPageSize(), SortHelper.sortMap2Sort(new LinkedHashMap<String, BaseOrderEnum>(){{put("happenTime", BaseOrderEnum.DESC);}}));
|
|
|
|
|
|
+ pageable = new PageRequest(manageVO.getPageNo() - 1,manageVO.getPageSize(), SortHelper.sortMap2Sort(new LinkedHashMap<String, BaseOrderEnum>(){{put("status", BaseOrderEnum.ASC);put("happenTime", BaseOrderEnum.DESC);}}));
|
|
manageVO.setStatus(BaseStatusEnum.NORMAL);
|
|
manageVO.setStatus(BaseStatusEnum.NORMAL);
|
|
}
|
|
}
|
|
Specification specification = (Specification<Manage>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
Specification specification = (Specification<Manage>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
@@ -178,6 +180,17 @@ public class ManageServiceImpl implements ManageService {
|
|
return ApiResult.ok(null);
|
|
return ApiResult.ok(null);
|
|
}
|
|
}
|
|
Page<Manage> manages = manageRepository.findAll(specification, pageable);
|
|
Page<Manage> manages = manageRepository.findAll(specification, pageable);
|
|
|
|
+ List<Manage> totalManages = manageRepository.findAll(specification);
|
|
|
|
+ BigDecimal sum = new BigDecimal("0");
|
|
|
|
+ for (Manage manage: totalManages) {
|
|
|
|
+ if (Objects.equals(manage.getType(), ManageTypeEnum.COST)){
|
|
|
|
+ sum = sum.subtract(new BigDecimal(Double.toString(manage.getAmount())));
|
|
|
|
+ System.out.println(sum);
|
|
|
|
+ }else {
|
|
|
|
+ sum = sum.add(new BigDecimal(Double.toString(manage.getAmount())));
|
|
|
|
+ System.out.println(sum);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if(Objects.isNull(manages)){
|
|
if(Objects.isNull(manages)){
|
|
return ApiResult.error(ApiCode.UNKNOWN_ERROR);
|
|
return ApiResult.error(ApiCode.UNKNOWN_ERROR);
|
|
|
|
|
|
@@ -188,6 +201,7 @@ public class ManageServiceImpl implements ManageService {
|
|
List<Long> companyIds = new ArrayList<>();
|
|
List<Long> companyIds = new ArrayList<>();
|
|
List<Long> costTypeIds = new ArrayList<>();
|
|
List<Long> costTypeIds = new ArrayList<>();
|
|
for(Manage m : manages){
|
|
for(Manage m : manages){
|
|
|
|
+ m.setTotalAmount(sum.doubleValue());
|
|
if(Objects.nonNull(m.getDeptId())){
|
|
if(Objects.nonNull(m.getDeptId())){
|
|
deptIds.add(m.getDeptId());
|
|
deptIds.add(m.getDeptId());
|
|
}
|
|
}
|