给转账单据做明细和付款账户的重复提示

This commit is contained in:
jishenghua 2024-09-25 22:31:59 +08:00
parent 14a7e8c530
commit 80f9ec4633
3 changed files with 26 additions and 3 deletions

View File

@ -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时最大的数据条数
* */

View File

@ -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

View File

@ -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())) {