|
@@ -11,6 +11,7 @@ import org.springblade.control.mapper.ProjectInfoMapper;
|
|
|
import org.springblade.control.service.*;
|
|
|
import org.springblade.control.vo.AllProjectStatsVO;
|
|
|
import org.springblade.control.vo.ControlProjectInfoVO;
|
|
|
+import org.springblade.control.vo.ProjectReimburseVO;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
@@ -26,10 +27,10 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -165,7 +166,9 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, C
|
|
|
AllProjectStatsVO vo = baseMapper.allProjectStats();
|
|
|
//获取截至目前所有维护支出
|
|
|
BigDecimal cost2 = budgetService.getAllMaintainCost2();
|
|
|
- vo.setAllPracticalDisburse(vo.getAllPracticalDisburse().add(cost2));
|
|
|
+ //所有的报销支出
|
|
|
+ BigDecimal decimal = this.getThisYearReimburse(0);
|
|
|
+ vo.setAllPracticalDisburse(vo.getAllPracticalDisburse().add(cost2).add(decimal));
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
@@ -175,20 +178,35 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, C
|
|
|
@Override
|
|
|
public List<AllProjectStatsVO> ProjectListStats() {
|
|
|
List<AllProjectStatsVO> vos = baseMapper.ProjectListStats();
|
|
|
+ //获取维护支出
|
|
|
Map<Long, BigDecimal> map = budgetService.getAllMaintainCost5();
|
|
|
Boolean isMaintain = true;
|
|
|
if (map == null || map.size() <= 0){
|
|
|
isMaintain = false;
|
|
|
}
|
|
|
+ //报销支出
|
|
|
+ Map<Long, BigDecimal> reimburseMap = this.getYearReimburseByYear(0);
|
|
|
+ Boolean isReimburse = true;
|
|
|
+ if (reimburseMap == null || reimburseMap.size() <= 0){
|
|
|
+ isReimburse = false;
|
|
|
+ }
|
|
|
for (AllProjectStatsVO vo : vos) {
|
|
|
if (isMaintain) {
|
|
|
BigDecimal decimal = map.get(vo.getProjectId());
|
|
|
+ //维护支出
|
|
|
if (decimal != null) {
|
|
|
if (vo.getPracticalPayCost() == null){
|
|
|
vo.setPracticalPayCost(new BigDecimal(0));
|
|
|
}
|
|
|
vo.setPracticalPayCost(vo.getPracticalPayCost().add(decimal));
|
|
|
}
|
|
|
+ //计算报销
|
|
|
+ if (isReimburse){
|
|
|
+ BigDecimal decimals = reimburseMap.get(vo.getProjectId());
|
|
|
+ if (decimals != null){
|
|
|
+ vo.setPracticalPayCost(vo.getPracticalPayCost().add(decimals));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return vos;
|
|
@@ -214,6 +232,13 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, C
|
|
|
if (map == null || map.size() <= 0){
|
|
|
isMaintain = false;
|
|
|
}
|
|
|
+
|
|
|
+ //报销支出
|
|
|
+ Map<Integer, BigDecimal> reimburseMap = this.getProjectReimburseByCostType(id);
|
|
|
+ Boolean isReimburse = true;
|
|
|
+ if (reimburseMap == null || reimburseMap.size() <= 0){
|
|
|
+ isReimburse = false;
|
|
|
+ }
|
|
|
//获取项目所有实际费用
|
|
|
List<ProjectCostBudget> practicalList = budgetService.getAllPracticalBudgetByProjectId(id);
|
|
|
if (budgets != null && budgets.size() > 0){
|
|
@@ -255,6 +280,13 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, C
|
|
|
practicalCost = practicalCost.add(decimal);
|
|
|
}
|
|
|
}
|
|
|
+ //加上每个部门的报销支出
|
|
|
+ if (isReimburse){
|
|
|
+ BigDecimal decimals = reimburseMap.get(i);
|
|
|
+ if (decimals != null){
|
|
|
+ practicalCost = practicalCost.add(decimals);
|
|
|
+ }
|
|
|
+ }
|
|
|
vo.setPracticalCost(practicalCost);
|
|
|
list.add(vo);
|
|
|
}
|
|
@@ -307,5 +339,169 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, C
|
|
|
return baseMapper.getImplementUser();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取当年所有的报销
|
|
|
+ * @param year
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BigDecimal getThisYearReimburse(int year) {
|
|
|
+ BigDecimal decimal = baseMapper.getThisYearReimburse(year);
|
|
|
+ if (decimal == null){
|
|
|
+ decimal = new BigDecimal(0);
|
|
|
+ }
|
|
|
+ return decimal;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有项目截至当年的报销支出,分月返回
|
|
|
+ * @param year
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<Long, List<BigDecimal>> getYearReimburseByMonth(int year) {
|
|
|
+ List<EMFinancialReimbursementInfo> list = baseMapper.getYearReimburseByMonth(year);
|
|
|
+ if (list != null && list.size() > 0){
|
|
|
+ Map<Long, List<BigDecimal>> result = new HashMap<>();
|
|
|
+ //按项目分组
|
|
|
+ Map<Long, List<EMFinancialReimbursementInfo>> map = list.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(EMFinancialReimbursementInfo::getProjectId));
|
|
|
+ //再计算每个月的总报销额
|
|
|
+ //循环项目
|
|
|
+ for (Long aLong : map.keySet()) {
|
|
|
+ List<BigDecimal> decimals = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 12; i++) {
|
|
|
+ decimals.add(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ List<EMFinancialReimbursementInfo> infoList = map.get(aLong);
|
|
|
+ //循环项目下的所有报销
|
|
|
+ for (EMFinancialReimbursementInfo info : infoList) {
|
|
|
+ Date frDate = info.getFrDate();
|
|
|
+ Instant instant = frDate.toInstant();
|
|
|
+ ZoneId zoneId = ZoneId.systemDefault();
|
|
|
+ LocalDate localDate = instant.atZone(zoneId).toLocalDate();
|
|
|
+ decimals.set(localDate.getMonthValue() - 1,decimals.get(localDate.getMonthValue() - 1).add(info.getFrMoney()));
|
|
|
+ }
|
|
|
+ result.put(aLong,decimals);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有项目截至当年的报销支出,按年返回
|
|
|
+ * @param year
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<Long, BigDecimal> getYearReimburseByYear(int year) {
|
|
|
+ List<EMFinancialReimbursementInfo> list = baseMapper.getYearReimburseByMonth(year);
|
|
|
+ if (list != null && list.size() > 0){
|
|
|
+ Map<Long, BigDecimal> result = new HashMap<>();
|
|
|
+ //按项目分组
|
|
|
+ Map<Long, List<EMFinancialReimbursementInfo>> map = list.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(EMFinancialReimbursementInfo::getProjectId));
|
|
|
+ //再计算每个月的总报销额
|
|
|
+ //循环项目
|
|
|
+ for (Long aLong : map.keySet()) {
|
|
|
+ BigDecimal big = new BigDecimal(0);
|
|
|
+ List<EMFinancialReimbursementInfo> infoList = map.get(aLong);
|
|
|
+ //循环项目下的所有报销
|
|
|
+ for (EMFinancialReimbursementInfo info : infoList) {
|
|
|
+ big = big.add(info.getFrMoney());
|
|
|
+ }
|
|
|
+ result.put(aLong,big);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取指定项目截至报销支出,按项目进程返回
|
|
|
+ * @param projectId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<Long, BigDecimal> getProjectReimburseByProcess(Long projectId) {
|
|
|
+ //获取项目的所有关联进程的报销
|
|
|
+ List<ProjectReimburseVO> infos = baseMapper.getProjectReimburse(projectId);
|
|
|
+ if (infos == null || infos.size() <= 0){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //按照项目进程分组
|
|
|
+ Map<Long, List<ProjectReimburseVO>> map = infos.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(ProjectReimburseVO::getProjectProcess));
|
|
|
+ Map<Long, BigDecimal> decimalMap = new HashMap<>();
|
|
|
+ //统计每个进程的报销总和
|
|
|
+ for (Long aLong : map.keySet()) {
|
|
|
+ BigDecimal big = new BigDecimal(0);
|
|
|
+ List<ProjectReimburseVO> list = map.get(aLong);
|
|
|
+ for (ProjectReimburseVO vo : list) {
|
|
|
+ big = big.add(vo.getFrMoney());
|
|
|
+ }
|
|
|
+ decimalMap.put(aLong,big);
|
|
|
+ }
|
|
|
+ return decimalMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取指定项目截至报销支出,按费用分类返回
|
|
|
+ * @param projectId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<Integer, BigDecimal> getProjectReimburseByCostType(Long projectId) {
|
|
|
+ //获取项目的所有关联进程的报销
|
|
|
+ List<ProjectReimburseVO> infos = baseMapper.getProjectReimburse2(projectId);
|
|
|
+ if (infos == null || infos.size() <= 0){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //按照项目费用分类分组
|
|
|
+ Map<Integer, List<ProjectReimburseVO>> map = infos.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(ProjectReimburseVO::getCostType));
|
|
|
+ Map<Integer, BigDecimal> decimalMap = new HashMap<>();
|
|
|
+ //统计每个分类的报销总和
|
|
|
+ for (Integer aLong : map.keySet()) {
|
|
|
+ BigDecimal big = new BigDecimal(0);
|
|
|
+ List<ProjectReimburseVO> list = map.get(aLong);
|
|
|
+ for (ProjectReimburseVO vo : list) {
|
|
|
+ big = big.add(vo.getFrMoney());
|
|
|
+ }
|
|
|
+ decimalMap.put(aLong,big);
|
|
|
+ }
|
|
|
+ return decimalMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据项目id获取项目截至目前-某个费用分类的的报销支出,按项目环节返回
|
|
|
+ * @param projectId
|
|
|
+ * @param costType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<Long, BigDecimal> getProjectReimburseByCostType(Long projectId, Integer costType) {
|
|
|
+ //获取项目的所有关联进程的报销
|
|
|
+ List<ProjectReimburseVO> infos = baseMapper.getProjectReimburse3(projectId, costType);
|
|
|
+ if (infos == null || infos.size() <= 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //按照项目进程分组
|
|
|
+ Map<Long, List<ProjectReimburseVO>> map = infos.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(ProjectReimburseVO::getProjectProcess));
|
|
|
+ Map<Long, BigDecimal> decimalMap = new HashMap<>();
|
|
|
+ //统计每个进程的报销总和
|
|
|
+ for (Long aLong : map.keySet()) {
|
|
|
+ BigDecimal big = new BigDecimal(0);
|
|
|
+ List<ProjectReimburseVO> list = map.get(aLong);
|
|
|
+ for (ProjectReimburseVO vo : list) {
|
|
|
+ big = big.add(vo.getFrMoney());
|
|
|
+ }
|
|
|
+ decimalMap.put(aLong, big);
|
|
|
+ }
|
|
|
+ return decimalMap;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|