提交单据的时候增加校验单号是否重复
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<AccountHead> 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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<DepotHead> 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();
|
||||
|
||||
Reference in New Issue
Block a user