给单据的序列号和批号增加重复的校验
This commit is contained in:
@@ -326,9 +326,7 @@ public class ExceptionConstants {
|
||||
//比例格式错误
|
||||
public static final int MATERIAL_RATIO_NOT_INTEGER_CODE = 8000016;
|
||||
public static final String MATERIAL_RATIO_NOT_INTEGER_MSG = "第%s行比例格式错误";
|
||||
//商品的批号不能为空
|
||||
public static final int MATERIAL_BATCH_NUMBERE_EMPTY_CODE = 8000017;
|
||||
public static final String MATERIAL_BATCH_NUMBERE_EMPTY_MSG = "抱歉,商品条码:%s的批号不能为空";
|
||||
|
||||
/**
|
||||
* 单据信息
|
||||
* type = 85
|
||||
@@ -375,6 +373,12 @@ public class ExceptionConstants {
|
||||
//单据录入-商品条码XXX的数量需要修改下
|
||||
public static final int DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_CODE = 85000014;
|
||||
public static final String DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_MSG = "商品条码%s的数量需要修改下";
|
||||
//单据录入-商品的批号不能为空
|
||||
public static final int DEPOT_HEAD_BATCH_NUMBERE_EMPTY_CODE = 8000015;
|
||||
public static final String DEPOT_HEAD_BATCH_NUMBERE_EMPTY_MSG = "抱歉,商品条码:%s的批号不能为空";
|
||||
//单据录入-商品的批号重复
|
||||
public static final int DEPOT_HEAD_BATCH_NUMBERE_EXISTS_CODE = 8000016;
|
||||
public static final String DEPOT_HEAD_BATCH_NUMBERE_EXISTS_MSG = "抱歉,商品条码:%s的批号已存在";
|
||||
/**
|
||||
* 单据明细信息
|
||||
* type = 90
|
||||
@@ -426,7 +430,7 @@ public class ExceptionConstants {
|
||||
* */
|
||||
/**序列号已存在*/
|
||||
public static final int SERIAL_NUMBERE_ALREADY_EXISTS_CODE = 10500000;
|
||||
public static final String SERIAL_NUMBERE_ALREADY_EXISTS_MSG = "序列号已存在";
|
||||
public static final String SERIAL_NUMBERE_ALREADY_EXISTS_MSG = "序列号:%s已存在";
|
||||
/**序列号不能为为空*/
|
||||
public static final int SERIAL_NUMBERE_NOT_BE_EMPTY_CODE = 10500001;
|
||||
public static final String SERIAL_NUMBERE_NOT_BE_EMPTY_MSG = "序列号不能为为空";
|
||||
|
||||
@@ -166,4 +166,9 @@ public interface DepotItemMapperEx {
|
||||
List<DepotItemVo4MaterialAndSum> getBatchBillDetailMaterialSum(
|
||||
@Param("linkNumber") String linkNumber,
|
||||
@Param("type") String type);
|
||||
|
||||
Long getCountByMaterialAndBatchNumber(
|
||||
@Param("meId") Long meId,
|
||||
@Param("batchNumber") String batchNumber,
|
||||
@Param("type") String type);
|
||||
}
|
||||
|
||||
@@ -419,12 +419,20 @@ public class DepotItemService {
|
||||
}
|
||||
}
|
||||
if (StringUtil.isExist(rowObj.get("batchNumber"))) {
|
||||
//入库的时候批号不能重复
|
||||
Long bnCount = depotItemMapperEx.getCountByMaterialAndBatchNumber(materialExtend.getId(), rowObj.getString("batchNumber"), "入库");
|
||||
if(bnCount == 0) {
|
||||
depotItem.setBatchNumber(rowObj.getString("batchNumber"));
|
||||
} else {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_BATCH_NUMBERE_EXISTS_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_HEAD_BATCH_NUMBERE_EXISTS_MSG, barCode));
|
||||
}
|
||||
|
||||
} else {
|
||||
//批号不能为空
|
||||
if(BusinessConstants.ENABLE_BATCH_NUMBER_ENABLED.equals(material.getEnableBatchNumber())) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_BATCH_NUMBERE_EMPTY_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_BATCH_NUMBERE_EMPTY_MSG, barCode));
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_BATCH_NUMBERE_EMPTY_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_HEAD_BATCH_NUMBERE_EMPTY_MSG, barCode));
|
||||
}
|
||||
}
|
||||
if (StringUtil.isExist(rowObj.get("expirationDate"))) {
|
||||
|
||||
@@ -418,6 +418,9 @@ public class SerialNumberService {
|
||||
serialNumber.setUpdater(userInfo == null ? null : userInfo.getId());
|
||||
serialNumber.setInBillNo(inBillNo);
|
||||
serialNumberMapper.insertSelective(serialNumber);
|
||||
} else {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.SERIAL_NUMBERE_ALREADY_EXISTS_CODE,
|
||||
String.format(ExceptionConstants.SERIAL_NUMBERE_ALREADY_EXISTS_MSG, sn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,4 +635,14 @@
|
||||
and ifnull(dh.delete_flag,'0') !='1'
|
||||
group by di.material_extend_id
|
||||
</select>
|
||||
|
||||
<select id="getCountByMaterialAndBatchNumber" resultType="java.lang.Long">
|
||||
select count(di.id) from
|
||||
jsh_depot_head dh
|
||||
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
|
||||
where 1=1
|
||||
and ifnull(dh.delete_flag,'0') !='1'
|
||||
and di.material_extend_id=#{meId}
|
||||
and di.batch_number=#{batchNumber}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user