From 4562b66fc3e022ecddbcbda7fe9b79f136cb5671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Thu, 2 Mar 2023 22:57:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=8D=95=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=A2=9E=E5=8A=A0=E6=A0=A1=E9=AA=8C=E5=8D=95?= =?UTF-8?q?=E5=8F=B7=E6=98=AF=E5=90=A6=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsh/erp/constants/ExceptionConstants.java | 6 ++++++ .../erp/controller/AccountHeadController.java | 2 +- .../erp/controller/DepotHeadController.java | 2 +- .../accountHead/AccountHeadComponent.java | 2 +- .../accountHead/AccountHeadService.java | 21 +++++++++++++++++-- .../service/depotHead/DepotHeadComponent.java | 2 +- .../service/depotHead/DepotHeadService.java | 21 +++++++++++++++++-- 7 files changed, 48 insertions(+), 8 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 955b4cfb..a0fd1b56 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 @@ -400,6 +400,9 @@ public class ExceptionConstants { //单据录入-商品条码XXX的数量与序列号不一致 public static final int DEPOT_HEAD_SN_NUMBERE_FAILED_CODE = 8000021; public static final String DEPOT_HEAD_SN_NUMBERE_FAILED_MSG = "抱歉,商品条码:%s的数量与序列号不一致"; + //单据录入-单据编号已经存在 + public static final int DEPOT_HEAD_BILL_NUMBER_EXIST_CODE = 8000022; + public static final String DEPOT_HEAD_BILL_NUMBER_EXIST_MSG = "抱歉,单据编号已经存在"; /** * 单据明细信息 @@ -433,6 +436,9 @@ public class ExceptionConstants { //单据删除-只有未审核的单据才能删除 public static final int ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_CODE = 9500004; public static final String ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_MSG = "抱歉,只有未审核的单据才能删除"; + //财务信息录入-单据编号已经存在 + public static final int ACCOUNT_HEAD_BILL_NO_EXIST_CODE = 9500005; + public static final String ACCOUNT_HEAD_BILL_NO_EXIST_MSG = "抱歉,单据编号已经存在"; /** * 财务明细信息 * type = 100 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java index 7b89ea2e..0af6d6b2 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java @@ -104,7 +104,7 @@ public class AccountHeadController { AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx(); try { List list = accountHeadService.getDetailByNumber(billNo); - if(list.size() == 1) { + if(list.size()>0) { ahl = list.get(0); } res.code = 200; diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java index c8f8b88a..ebd58b18 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java @@ -368,7 +368,7 @@ public class DepotHeadController { DepotHeadVo4List dhl = new DepotHeadVo4List(); try { List list = depotHeadService.getDetailByNumber(number); - if(list.size() == 1) { + if(list.size()>0) { dhl = list.get(0); } res.code = 200; diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java b/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java index b37d6d26..601d211b 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java @@ -88,7 +88,7 @@ public class AccountHeadComponent implements ICommonQuery { @Override public int checkIsNameExist(Long id, String name)throws Exception { - return accountHeadService.checkIsNameExist(id, name); + return 0; } } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java index 346dbaf3..79e1f397 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java @@ -225,9 +225,16 @@ public class AccountHeadService { return 1; } - public int checkIsNameExist(Long id, String name)throws Exception { + /** + * 校验单据编号是否存在 + * @param id + * @param billNo + * @return + * @throws Exception + */ + public int checkIsBillNoExist(Long id, String billNo)throws Exception { AccountHeadExample example = new AccountHeadExample(); - example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); + example.createCriteria().andIdNotEqualTo(id).andBillNoEqualTo(billNo).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); List list = null; try{ list = accountHeadMapper.selectByExample(example); @@ -273,6 +280,11 @@ public class AccountHeadService { @Transactional(value = "transactionManager", rollbackFor = Exception.class) public void addAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception { AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); + //校验单号是否重复 + if(checkIsBillNoExist(0L, accountHead.getBillNo())>0) { + throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_BILL_NO_EXIST_CODE, + String.format(ExceptionConstants.ACCOUNT_HEAD_BILL_NO_EXIST_MSG)); + } User userInfo=userService.getCurrentUser(); accountHead.setCreator(userInfo==null?null:userInfo.getId()); if(StringUtil.isEmpty(accountHead.getStatus())) { @@ -299,6 +311,11 @@ public class AccountHeadService { @Transactional(value = "transactionManager", rollbackFor = Exception.class) public void updateAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception { AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); + //校验单号是否重复 + if(checkIsBillNoExist(accountHead.getId(), accountHead.getBillNo())>0) { + throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_BILL_NO_EXIST_CODE, + String.format(ExceptionConstants.ACCOUNT_HEAD_BILL_NO_EXIST_MSG)); + } //获取之前的金额数据 BigDecimal preTotalPrice = getAccountHead(accountHead.getId()).getTotalPrice().abs(); accountHeadMapper.updateByPrimaryKeySelective(accountHead); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java index 850a624c..aabda157 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java @@ -96,7 +96,7 @@ public class DepotHeadComponent implements ICommonQuery { @Override public int checkIsNameExist(Long id, String name)throws Exception { - return depotHeadService.checkIsNameExist(id, name); + return 0; } } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index 237e5715..b1a3db27 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -515,9 +515,16 @@ public class DepotHeadService { return list; } - public int checkIsNameExist(Long id, String name)throws Exception { + /** + * 校验单据编号是否存在 + * @param id + * @param number + * @return + * @throws Exception + */ + public int checkIsBillNumberExist(Long id, String number)throws Exception { DepotHeadExample example = new DepotHeadExample(); - example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); + example.createCriteria().andIdNotEqualTo(id).andNumberEqualTo(number).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); List list = null; try{ list = depotHeadMapper.selectByExample(example); @@ -894,6 +901,11 @@ public class DepotHeadService { HttpServletRequest request) throws Exception { /**处理单据主表数据*/ DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); + //校验单号是否重复 + if(checkIsBillNumberExist(0L, depotHead.getNumber())>0) { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_BILL_NUMBER_EXIST_CODE, + String.format(ExceptionConstants.DEPOT_HEAD_BILL_NUMBER_EXIST_MSG)); + } String subType = depotHead.getSubType(); //结算账户校验 if("采购".equals(subType) || "采购退货".equals(subType) || "销售".equals(subType) || "销售退货".equals(subType)) { @@ -984,6 +996,11 @@ public class DepotHeadService { public void updateDepotHeadAndDetail(String beanJson, String rows,HttpServletRequest request)throws Exception { /**更新单据主表信息*/ DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); + //校验单号是否重复 + if(checkIsBillNumberExist(depotHead.getId(), depotHead.getNumber())>0) { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_BILL_NUMBER_EXIST_CODE, + String.format(ExceptionConstants.DEPOT_HEAD_BILL_NUMBER_EXIST_MSG)); + } //获取之前的金额数据 BigDecimal preTotalPrice = getDepotHead(depotHead.getId()).getTotalPrice().abs(); String subType = depotHead.getSubType();