解决序列号在采购入库后再删除,序列号还存在的bug
This commit is contained in:
@@ -400,6 +400,9 @@ public class ExceptionConstants {
|
|||||||
//单据录入-单据当前状态下不能修改
|
//单据录入-单据当前状态下不能修改
|
||||||
public static final int DEPOT_HEAD_BILL_CANNOT_EDIT_CODE = 8500023;
|
public static final int DEPOT_HEAD_BILL_CANNOT_EDIT_CODE = 8500023;
|
||||||
public static final String DEPOT_HEAD_BILL_CANNOT_EDIT_MSG = "抱歉,单据当前状态下不能修改";
|
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的序列号已经出库,不能删除";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单据明细信息
|
* 单据明细信息
|
||||||
|
|||||||
@@ -238,4 +238,7 @@ public interface DepotHeadMapperEx {
|
|||||||
|
|
||||||
void setAccountIdToNull(
|
void setAccountIdToNull(
|
||||||
@Param("id") Long id);
|
@Param("id") Long id);
|
||||||
|
|
||||||
|
int getSerialNumberBySell(
|
||||||
|
@Param("number") String number);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -403,17 +403,29 @@ public class DepotHeadService {
|
|||||||
//只有未审核的单据才能被删除
|
//只有未审核的单据才能被删除
|
||||||
if("0".equals(depotHead.getStatus())) {
|
if("0".equals(depotHead.getStatus())) {
|
||||||
User userInfo = userService.getCurrentUser();
|
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())
|
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
|
||||||
&& !BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())) {
|
&& !BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())) {
|
||||||
//查询单据子表列表
|
//查询单据子表列表
|
||||||
List<DepotItem> depotItemList = null;
|
List<DepotItem> depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(depotHead.getId(), BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED);
|
||||||
try {
|
|
||||||
depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(depotHead.getId(), BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED);
|
|
||||||
} catch (Exception e) {
|
|
||||||
JshException.readFail(logger, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**回收序列号*/
|
/**回收序列号*/
|
||||||
if (depotItemList != null && depotItemList.size() > 0) {
|
if (depotItemList != null && depotItemList.size() > 0) {
|
||||||
for (DepotItem depotItem : depotItemList) {
|
for (DepotItem depotItem : depotItemList) {
|
||||||
|
|||||||
@@ -1077,4 +1077,11 @@
|
|||||||
where dh.id=#{id}
|
where dh.id=#{id}
|
||||||
and ifnull(dh.delete_flag,'0') !='1'
|
and ifnull(dh.delete_flag,'0') !='1'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="getSerialNumberBySell" resultType="java.lang.Integer">
|
||||||
|
select count(s.id) from jsh_depot_head dh
|
||||||
|
left join jsh_serial_number s on dh.number=s.in_bill_no
|
||||||
|
where dh.number = #{number}
|
||||||
|
and (s.out_bill_no is not null or s.out_bill_no!='')
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user