提交单据的时候增加校验单号是否重复

This commit is contained in:
季圣华
2023-03-02 22:57:24 +08:00
parent d70be28df7
commit 4562b66fc3
7 changed files with 48 additions and 8 deletions

View File

@@ -400,6 +400,9 @@ public class ExceptionConstants {
//单据录入-商品条码XXX的数量与序列号不一致 //单据录入-商品条码XXX的数量与序列号不一致
public static final int DEPOT_HEAD_SN_NUMBERE_FAILED_CODE = 8000021; 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 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 int ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_CODE = 9500004;
public static final String ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_MSG = "抱歉,只有未审核的单据才能删除"; 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 * type = 100

View File

@@ -104,7 +104,7 @@ public class AccountHeadController {
AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx(); AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx();
try { try {
List<AccountHeadVo4ListEx> list = accountHeadService.getDetailByNumber(billNo); List<AccountHeadVo4ListEx> list = accountHeadService.getDetailByNumber(billNo);
if(list.size() == 1) { if(list.size()>0) {
ahl = list.get(0); ahl = list.get(0);
} }
res.code = 200; res.code = 200;

View File

@@ -368,7 +368,7 @@ public class DepotHeadController {
DepotHeadVo4List dhl = new DepotHeadVo4List(); DepotHeadVo4List dhl = new DepotHeadVo4List();
try { try {
List<DepotHeadVo4List> list = depotHeadService.getDetailByNumber(number); List<DepotHeadVo4List> list = depotHeadService.getDetailByNumber(number);
if(list.size() == 1) { if(list.size()>0) {
dhl = list.get(0); dhl = list.get(0);
} }
res.code = 200; res.code = 200;

View File

@@ -88,7 +88,7 @@ public class AccountHeadComponent implements ICommonQuery {
@Override @Override
public int checkIsNameExist(Long id, String name)throws Exception { public int checkIsNameExist(Long id, String name)throws Exception {
return accountHeadService.checkIsNameExist(id, name); return 0;
} }
} }

View File

@@ -225,9 +225,16 @@ public class AccountHeadService {
return 1; 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(); 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<AccountHead> list = null; List<AccountHead> list = null;
try{ try{
list = accountHeadMapper.selectByExample(example); list = accountHeadMapper.selectByExample(example);
@@ -273,6 +280,11 @@ public class AccountHeadService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception { public void addAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); 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(); User userInfo=userService.getCurrentUser();
accountHead.setCreator(userInfo==null?null:userInfo.getId()); accountHead.setCreator(userInfo==null?null:userInfo.getId());
if(StringUtil.isEmpty(accountHead.getStatus())) { if(StringUtil.isEmpty(accountHead.getStatus())) {
@@ -299,6 +311,11 @@ public class AccountHeadService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception { public void updateAccountHeadAndDetail(String beanJson, String rows, HttpServletRequest request) throws Exception {
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); 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(); BigDecimal preTotalPrice = getAccountHead(accountHead.getId()).getTotalPrice().abs();
accountHeadMapper.updateByPrimaryKeySelective(accountHead); accountHeadMapper.updateByPrimaryKeySelective(accountHead);

View File

@@ -96,7 +96,7 @@ public class DepotHeadComponent implements ICommonQuery {
@Override @Override
public int checkIsNameExist(Long id, String name)throws Exception { public int checkIsNameExist(Long id, String name)throws Exception {
return depotHeadService.checkIsNameExist(id, name); return 0;
} }
} }

View File

@@ -515,9 +515,16 @@ public class DepotHeadService {
return list; 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(); 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<DepotHead> list = null; List<DepotHead> list = null;
try{ try{
list = depotHeadMapper.selectByExample(example); list = depotHeadMapper.selectByExample(example);
@@ -894,6 +901,11 @@ public class DepotHeadService {
HttpServletRequest request) throws Exception { HttpServletRequest request) throws Exception {
/**处理单据主表数据*/ /**处理单据主表数据*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); 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(); String subType = depotHead.getSubType();
//结算账户校验 //结算账户校验
if("采购".equals(subType) || "采购退货".equals(subType) || "销售".equals(subType) || "销售退货".equals(subType)) { 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 { public void updateDepotHeadAndDetail(String beanJson, String rows,HttpServletRequest request)throws Exception {
/**更新单据主表信息*/ /**更新单据主表信息*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); 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(); BigDecimal preTotalPrice = getDepotHead(depotHead.getId()).getTotalPrice().abs();
String subType = depotHead.getSubType(); String subType = depotHead.getSubType();