diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetCostDetailBase.java b/src/main/java/cn/palmte/work/model/ProjectBudgetCostDetailBase.java index 935de5e..f8adfed 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetCostDetailBase.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetCostDetailBase.java @@ -25,7 +25,7 @@ public class ProjectBudgetCostDetailBase { private int projectId; private int type; - private int category; + private String category; private String name; private String attr; @@ -92,11 +92,11 @@ public class ProjectBudgetCostDetailBase { this.type = type; } - public int getCategory() { + public String getCategory() { return category; } - public void setCategory(int category) { + public void setCategory(String category) { this.category = category; } diff --git a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java index 9009c00..8bf22da 100644 --- a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java +++ b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java @@ -1042,15 +1042,16 @@ public class ProjectBudgetService { List projectBudgetCostDetails = projectBudgetCostDetailRepository.findAllByProjectIdEquals(p.getId()); if (projectBudgetCostDetails.size() > 0) { ProcurementType huizhiType = procurementTypeRepository.findByName("汇智产品"); - BigDecimal huizhi = projectBudgetCostDetails.stream().filter(a -> a.getCategory() == huizhiType.getId()).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); + BigDecimal huizhi = projectBudgetCostDetails.stream().filter(a ->a.getCategory().equals(huizhiType.getId().toString())).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); budget.setHuizhiProductAmountBudget(huizhi); ProcurementType huazhiType = procurementTypeRepository.findByName("华智产品"); - BigDecimal huazhi = projectBudgetCostDetails.stream().filter(a -> a.getCategory() == huazhiType.getId()).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); + BigDecimal huazhi = projectBudgetCostDetails.stream().filter(a -> a.getCategory().equals(huazhiType.getId().toString())).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); budget.setHuazhiProductAmountBudget(huazhi); ProcurementType huasanType = procurementTypeRepository.findByName("华三产品"); - BigDecimal huasan = projectBudgetCostDetails.stream().filter(a -> a.getCategory() == huasanType.getId()).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); + BigDecimal huasan = projectBudgetCostDetails.stream().filter(a -> a.getCategory().equals(huasanType.getId().toString())).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); budget.setHuasanProductAmountBudget(huasan); - BigDecimal other = projectBudgetCostDetails.stream().filter(a -> a.getCategory() != huizhiType.getId() && a.getCategory() != huazhiType.getId() && a.getCategory() != huasanType.getId()).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); + BigDecimal other = projectBudgetCostDetails.stream().filter(a -> !a.getCategory().equals( huizhiType.getId().toString()) && !a.getCategory().equals(huazhiType.getId().toString()) + && !a.getCategory().equals(huasanType.getId().toString())).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); budget.setZiguangOtherAmountBudget(other); } } @@ -1089,15 +1090,16 @@ public class ProjectBudgetService { List projectBudgetCostDetails = projectBudgetCostDetailRepository.findAllByProjectIdEquals(p.getId()); if (projectBudgetCostDetails.size() > 0) { ProcurementType huizhiType = procurementTypeRepository.findByName("汇智产品"); - BigDecimal huizhi = projectBudgetCostDetails.stream().filter(a -> a.getCategory() == huizhiType.getId()).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); + BigDecimal huizhi = projectBudgetCostDetails.stream().filter(a -> a.getCategory().equals(huizhiType.getId().toString())).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); extend.setHuizhiProductAmount(huizhi); ProcurementType huazhiType = procurementTypeRepository.findByName("华智产品"); - BigDecimal huazhi = projectBudgetCostDetails.stream().filter(a -> a.getCategory() == huazhiType.getId()).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); + BigDecimal huazhi = projectBudgetCostDetails.stream().filter(a -> a.getCategory().equals(huazhiType.getId().toString())).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); extend.setHuazhiProductAmount(huazhi); ProcurementType huasanType = procurementTypeRepository.findByName("华三产品"); - BigDecimal huasan = projectBudgetCostDetails.stream().filter(a -> a.getCategory() == huasanType.getId()).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); + BigDecimal huasan = projectBudgetCostDetails.stream().filter(a -> a.getCategory().equals(huasanType.getId().toString())).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); extend.setHuasanProductAmount(huasan); - BigDecimal other = projectBudgetCostDetails.stream().filter(a -> a.getCategory() != huizhiType.getId() && a.getCategory() != huazhiType.getId() && a.getCategory() != huasanType.getId()).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); + BigDecimal other = projectBudgetCostDetails.stream().filter(a -> !a.getCategory().equals( huizhiType.getId().toString()) && !a.getCategory().equals(huazhiType.getId().toString()) + && !a.getCategory().equals(huasanType.getId().toString())).map(ProjectBudgetCostDetail::getTotalTaxInclude).reduce(new BigDecimal(0), BigDecimal::add); extend.setZiguangOtherAmount(other); } @@ -1298,8 +1300,8 @@ public class ProjectBudgetService { o1 = m.get(key); String category = (String) o1; ProcurementType procurementType = procurementTypeRepository.findByName(category); - if (procurementType != null && procurementType.getType() == temp.getType()) { - temp.setCategory(procurementType.getId()); + if (procurementType != null && (procurementType.getType() == temp.getType() && temp.getType()!=4)) { + temp.setCategory(procurementType.getId().toString()); } else { throw new Exception("该采购类别不存在或者与采购成本项目不匹配"); } diff --git a/src/main/java/cn/palmte/work/service/ProjectProcessService.java b/src/main/java/cn/palmte/work/service/ProjectProcessService.java index 2223542..4ee5905 100644 --- a/src/main/java/cn/palmte/work/service/ProjectProcessService.java +++ b/src/main/java/cn/palmte/work/service/ProjectProcessService.java @@ -342,7 +342,7 @@ public class ProjectProcessService { } private String getCategory(ProjectBudgetCostDetail costDetail) { - int category = costDetail.getCategory(); + String category = costDetail.getCategory(); TypedQuery query = entityManager.createQuery( "from ProcurementType where id=:category and isDeleted=0 and enabled=1", ProcurementType.class); query.setParameter("category", category);