解决序列号在采购入库后再删除,序列号还存在的bug

This commit is contained in:
季圣华
2023-05-15 23:38:19 +08:00
parent 5baab7fe48
commit 8a255839b7
4 changed files with 32 additions and 7 deletions

View File

@@ -400,6 +400,9 @@ public class ExceptionConstants {
//单据录入-单据当前状态下不能修改
public static final int DEPOT_HEAD_BILL_CANNOT_EDIT_CODE = 8500023;
public static final String DEPOT_HEAD_BILL_CANNOT_EDIT_MSG = "抱歉,单据当前状态下不能修改";
//单据删除-单据中的序列号已经出库,不能删除
public static final int DEPOT_HEAD_SERIAL_IS_SELL_CODE = 8500024;
public static final String DEPOT_HEAD_SERIAL_IS_SELL_MSG = "抱歉,单据%s的序列号已经出库不能删除";
/**
* 单据明细信息

View File

@@ -238,4 +238,7 @@ public interface DepotHeadMapperEx {
void setAccountIdToNull(
@Param("id") Long id);
int getSerialNumberBySell(
@Param("number") String number);
}

View File

@@ -403,17 +403,29 @@ public class DepotHeadService {
//只有未审核的单据才能被删除
if("0".equals(depotHead.getStatus())) {
User userInfo = userService.getCurrentUser();
//删除入库单据,先校验序列号是否出库,如果未出库则同时删除序列号,如果已出库则不能删除单据
if (BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType())) {
List<DepotItem> depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(depotHead.getId(), BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED);
if (depotItemList != null && depotItemList.size() > 0) {
//单据明细里面存在序列号商品
int serialNumberSellCount = depotHeadMapperEx.getSerialNumberBySell(depotHead.getNumber());
if (serialNumberSellCount > 0) {
//已出库则不能删除单据
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_SERIAL_IS_SELL_CODE,
String.format(ExceptionConstants.DEPOT_HEAD_SERIAL_IS_SELL_MSG, depotHead.getNumber()));
} else {
//删除序列号
SerialNumberExample example = new SerialNumberExample();
example.createCriteria().andInBillNoEqualTo(depotHead.getNumber());
serialNumberService.deleteByExample(example);
}
}
}
//删除出库数据回收序列号
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
&& !BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())) {
//查询单据子表列表
List<DepotItem> depotItemList = null;
try {
depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(depotHead.getId(), BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED);
} catch (Exception e) {
JshException.readFail(logger, e);
}
List<DepotItem> depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(depotHead.getId(), BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED);
/**回收序列号*/
if (depotItemList != null && depotItemList.size() > 0) {
for (DepotItem depotItem : depotItemList) {