From 80f9ec46332d9237101493e1e58bde864c4b4e66 Mon Sep 17 00:00:00 2001 From: jishenghua <752718920@qq.com> Date: Wed, 25 Sep 2024 22:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E8=BD=AC=E8=B4=A6=E5=8D=95=E6=8D=AE?= =?UTF-8?q?=E5=81=9A=E6=98=8E=E7=BB=86=E5=92=8C=E4=BB=98=E6=AC=BE=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E7=9A=84=E9=87=8D=E5=A4=8D=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsh/erp/constants/BusinessConstants.java | 3 ++- .../jsh/erp/constants/ExceptionConstants.java | 3 +++ .../accountHead/AccountHeadService.java | 23 +++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java index ae9ca6f0a..76e7d43bd 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java @@ -104,10 +104,11 @@ public class BusinessConstants { public static final String BILL_TYPE_PRODUCE_IN = "生产入库"; /** * 财务单据分类 - * 收款、付款 + * 收款、付款、转账 * */ public static final String TYPE_MONEY_IN = "收款"; public static final String TYPE_MONEY_OUT = "付款"; + public static final String TYPE_GIRO = "转账"; /** * 批量插入sql时最大的数据条数 * */ 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 3b18a4f51..a25522ceb 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 @@ -491,6 +491,9 @@ public class ExceptionConstants { //财务信息录入-单据编号已经存在 public static final int ACCOUNT_HEAD_BILL_NO_EXIST_CODE = 9500005; public static final String ACCOUNT_HEAD_BILL_NO_EXIST_MSG = "抱歉,单据编号已经存在"; + //财务信息录入-付款账户和明细中的账户重复 + public static final int ACCOUNT_HEAD_ACCOUNT_REPEAT_CODE = 9500006; + public static final String ACCOUNT_HEAD_ACCOUNT_REPEAT_MSG = "抱歉,付款账户:%s和明细中的账户重复"; /** * 财务明细信息 * type = 100 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 27012fd79..d56bbc629 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 @@ -1,5 +1,6 @@ package com.jsh.erp.service.accountHead; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.ExceptionConstants; @@ -7,6 +8,7 @@ import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.mappers.AccountHeadMapper; import com.jsh.erp.datasource.mappers.AccountHeadMapperEx; import com.jsh.erp.datasource.mappers.AccountItemMapperEx; +import com.jsh.erp.datasource.mappers.AccountMapper; import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.JshException; import com.jsh.erp.service.accountItem.AccountItemService; @@ -45,8 +47,6 @@ public class AccountHeadService { @Resource private AccountItemService accountItemService; @Resource - private DepotHeadService depotHeadService; - @Resource private UserService userService; @Resource private SupplierService supplierService; @@ -54,6 +54,8 @@ public class AccountHeadService { private LogService logService; @Resource private AccountItemMapperEx accountItemMapperEx; + @Resource + private AccountMapper accountMapper; public AccountHead getAccountHead(long id) throws Exception { AccountHead result=null; @@ -297,6 +299,23 @@ public class AccountHeadService { throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_BILL_NO_EXIST_CODE, String.format(ExceptionConstants.ACCOUNT_HEAD_BILL_NO_EXIST_MSG)); } + //校验付款账户和明细中的账户重复(转账单据) + if(BusinessConstants.TYPE_GIRO.equals(accountHead.getType())) { + JSONArray rowArr = JSONArray.parseArray(rows); + if (null != rowArr && rowArr.size()>0) { + for (int i = 0; i < rowArr.size(); i++) { + JSONObject object = JSONObject.parseObject(rowArr.getString(i)); + if (object.get("accountId") != null && !object.get("accountId").equals("")) { + Long accoutId = object.getLong("accountId"); + String accountName = accountMapper.selectByPrimaryKey(accoutId).getName(); + if(accoutId.equals(accountHead.getAccountId())) { + throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_ACCOUNT_REPEAT_CODE, + String.format(ExceptionConstants.ACCOUNT_HEAD_ACCOUNT_REPEAT_MSG, accountName)); + } + } + } + } + } User userInfo=userService.getCurrentUser(); accountHead.setCreator(userInfo==null?null:userInfo.getId()); if(StringUtil.isEmpty(accountHead.getStatus())) {