From 5ffaf4ce0e9071c9ae4bc2afaa71e79c4d942031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Mon, 31 May 2021 01:09:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E6=8D=AE=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jsh/erp/constants/ExceptionConstants.java | 6 ++++++ .../jsh/erp/service/accountItem/AccountItemService.java | 7 ++++++- .../com/jsh/erp/service/depotItem/DepotItemService.java | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java index ede32eeb..c8e4535c 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java @@ -306,6 +306,9 @@ public class ExceptionConstants { //单据录入-调入仓库不能为空 public static final int DEPOT_HEAD_ANOTHER_DEPOT_FAILED_CODE = 8500005; public static final String DEPOT_HEAD_ANOTHER_DEPOT_FAILED_MSG = "调入仓库不能为空"; + //单据录入-明细不能为空 + public static final int DEPOT_HEAD_ROW_FAILED_CODE = 8500006; + public static final String DEPOT_HEAD_ROW_FAILED_MSG = "单据明细不能为空"; /** * 单据明细信息 * type = 90 @@ -332,6 +335,9 @@ public class ExceptionConstants { //修改财务信息失败 public static final int ACCOUNT_HEAD_EDIT_FAILED_CODE = 9500002; public static final String ACCOUNT_HEAD_EDIT_FAILED_MSG = "修改财务信息失败"; + //单据录入-明细不能为空 + public static final int ACCOUNT_HEAD_ROW_FAILED_CODE = 9500003; + public static final String ACCOUNT_HEAD_ROW_FAILED_MSG = "单据明细不能为空"; /** * 财务明细信息 * type = 100 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java index 2b5b269b..fd9c5593 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java @@ -3,12 +3,14 @@ package com.jsh.erp.service.accountItem; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.AccountItem; import com.jsh.erp.datasource.entities.AccountItemExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.AccountItemMapper; import com.jsh.erp.datasource.mappers.AccountItemMapperEx; import com.jsh.erp.datasource.vo.AccountItemVo4List; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.JshException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; @@ -186,7 +188,7 @@ public class AccountItemService { //删除单据的明细 deleteAccountItemHeadId(headerId); JSONArray rowArr = JSONArray.parseArray(rows); - if (null != rowArr) { + if (null != rowArr && rowArr.size()>0) { for (int i = 0; i < rowArr.size(); i++) { AccountItem accountItem = new AccountItem(); JSONObject tempInsertedJson = JSONObject.parseObject(rowArr.getString(i)); @@ -209,6 +211,9 @@ public class AccountItemService { accountItem.setRemark(tempInsertedJson.getString("remark")); this.insertAccountItemWithObj(accountItem); } + } else { + throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_ROW_FAILED_CODE, + String.format(ExceptionConstants.ACCOUNT_HEAD_ROW_FAILED_MSG)); } } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java index d258fa0a..2fc17c8a 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java @@ -316,7 +316,7 @@ public class DepotItemService { //删除单据的明细 deleteDepotItemHeadId(headerId); JSONArray rowArr = JSONArray.parseArray(rows); - if (null != rowArr) { + if (null != rowArr && rowArr.size()>0) { for (int i = 0; i < rowArr.size(); i++) { DepotItem depotItem = new DepotItem(); JSONObject rowObj = JSONObject.parseObject(rowArr.getString(i)); @@ -411,6 +411,9 @@ public class DepotItemService { //更新当前库存 updateCurrentStock(depotItem,tenantId); } + } else { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_ROW_FAILED_CODE, + String.format(ExceptionConstants.DEPOT_HEAD_ROW_FAILED_MSG)); } }