From 765091e18b4bfa6b4fafe328500ea6613b8aa99b Mon Sep 17 00:00:00 2001 From: OathK1per Date: Wed, 7 Sep 2022 16:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../work/service/ProjectBudgetService.java | 106 ++++++++++-------- 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java index 2726baf..0f85721 100644 --- a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java +++ b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java @@ -979,7 +979,7 @@ public class ProjectBudgetService { return msg; } - private void saveIncomeTemp(Map m, Integer id, List incomeDetailTempList) { + private void saveIncomeTemp(Map m, Integer id, List incomeDetailTempList) throws Exception { ProjectBudgetIncomeDetailTemp temp = new ProjectBudgetIncomeDetailTemp(); String key; Object o1; @@ -993,6 +993,8 @@ public class ProjectBudgetService { temp.setType(2); } else if ("服务类".equals(type)) { temp.setType(3); + } else { + throw new Exception("该类别不存在"); } key = "名称"; o1 = m.get(key); @@ -1000,20 +1002,24 @@ public class ProjectBudgetService { key = "单位"; o1 = m.get(key); temp.setUnit((String) o1); - key = "数量"; - o1 = m.get(key); - if (o1 != null) { - temp.setAmount(Integer.parseInt((String) o1)); - } - key = "单价"; - o1 = m.get(key); - if (o1 != null) { - temp.setPrice(new BigDecimal((String) o1)); - } - key = "税率(%)"; - o1 = m.get(key); - if (o1 != null) { - temp.setTaxRate(new BigDecimal((String) o1)); + try { + key = "数量"; + o1 = m.get(key); + if (o1 != null) { + temp.setAmount(Integer.parseInt((String) o1)); + } + key = "单价"; + o1 = m.get(key); + if (o1 != null) { + temp.setPrice(new BigDecimal((String) o1)); + } + key = "税率(%)"; + o1 = m.get(key); + if (o1 != null) { + temp.setTaxRate(new BigDecimal((String) o1)); + } + } catch (Exception e) { + throw new Exception("数量、单价、税率需为数字"); } incomeDetailTempList.add(temp); } @@ -1048,7 +1054,7 @@ public class ProjectBudgetService { return msg; } - private void saveCostTemp(Map m, Integer id, List costDetailTempList) { + private void saveCostTemp(Map m, Integer id, List costDetailTempList) throws Exception { ProjectBudgetCostDetailTemp temp = new ProjectBudgetCostDetailTemp(); String key; Object o1; @@ -1064,6 +1070,8 @@ public class ProjectBudgetService { temp.setType(3); } else if ("其他".equals(type)) { temp.setType(4); + } else { + throw new Exception("该大类不存在"); } key = "类别"; o1 = m.get(key); @@ -1071,6 +1079,8 @@ public class ProjectBudgetService { ProcurementType procurementType = procurementTypeRepository.findByName(category); if (procurementType != null && procurementType.getType() == temp.getType()) { temp.setCategory(procurementType.getId()); + } else { + throw new Exception("该类别不存在或者与大类不匹配"); } key = "名称"; o1 = m.get(key); @@ -1078,21 +1088,6 @@ public class ProjectBudgetService { key = "单位"; o1 = m.get(key); temp.setUnit((String) o1); - key = "数量"; - o1 = m.get(key); - if (o1 != null) { - temp.setAmount(Integer.parseInt((String) o1)); - } - key = "单价"; - o1 = m.get(key); - if (o1 != null) { - temp.setPrice(new BigDecimal((String) o1)); - } - key = "税率(%)"; - o1 = m.get(key); - if (o1 != null) { - temp.setTaxRate(new BigDecimal((String) o1)); - } key = "签约方"; o1 = m.get(key); temp.setContractParty((String) o1); @@ -1106,20 +1101,43 @@ public class ProjectBudgetService { } else { temp.setIsUnderwritten(0); } - key = "预估垫资金额(元)"; - o1 = m.get(key); - if (o1 != null) { - temp.setUnderwrittenAmount(new BigDecimal((String) o1)); + try { + key = "数量"; + o1 = m.get(key); + if (o1 != null) { + temp.setAmount(Integer.parseInt((String) o1)); + } + key = "单价"; + o1 = m.get(key); + if (o1 != null) { + temp.setPrice(new BigDecimal((String) o1)); + } + key = "税率(%)"; + o1 = m.get(key); + if (o1 != null) { + temp.setTaxRate(new BigDecimal((String) o1)); + } + key = "预估垫资金额(元)"; + o1 = m.get(key); + if (o1 != null) { + temp.setUnderwrittenAmount(new BigDecimal((String) o1)); + } + key = "支出金额(元)"; + o1 = m.get(key); + if (o1 != null) { + temp.setPayAmount(new BigDecimal((String) o1)); + } + } catch (Exception e) { + throw new Exception("数量、单价、税率、预估垫资金额和支出金额需为数字"); } - key = "支出时间"; - o1 = m.get(key); - if (o1 != null) { - temp.setPayTime(DateKit.getDate((String) o1, DateKit.DATE_FORMAT)); - } - key = "支出金额(元)"; - o1 = m.get(key); - if (o1 != null) { - temp.setPayAmount(new BigDecimal((String) o1)); + try { + key = "支出时间"; + o1 = m.get(key); + if (o1 != null) { + temp.setPayTime(DateKit.getDate((String) o1, DateKit.DATE_FORMAT)); + } + } catch (Exception e) { + throw new Exception("支出时间需为时间格式yyyy-MM-dd"); } key = "付款方式"; o1 = m.get(key);