From 4f7ae569e9ed8c9dbd445ceb4360ba460e1c8c4a Mon Sep 17 00:00:00 2001 From: chenhao <852066789@qq.com> Date: Wed, 30 Oct 2024 11:52:49 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=94=B6=E5=85=A5=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E8=A1=A8:=201:=E4=BA=A7=E5=93=81=E5=A4=A7=E7=B1=BB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/ProjectBudgetCostDetailBase.java | 6 ++--- .../work/service/ProjectBudgetService.java | 22 ++++++++++--------- .../work/service/ProjectProcessService.java | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) 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);