在出库的时候判断:序列号不存在或者已经出库

This commit is contained in:
季圣华
2023-11-28 22:56:51 +08:00
parent d5dc24429b
commit c016e3dd7f
4 changed files with 36 additions and 71 deletions

View File

@@ -484,15 +484,9 @@ public class ExceptionConstants {
/**序列号已存在*/ /**序列号已存在*/
public static final int SERIAL_NUMBERE_ALREADY_EXISTS_CODE = 10500000; public static final int SERIAL_NUMBERE_ALREADY_EXISTS_CODE = 10500000;
public static final String SERIAL_NUMBERE_ALREADY_EXISTS_MSG = "序列号:%s已存在"; public static final String SERIAL_NUMBERE_ALREADY_EXISTS_MSG = "序列号:%s已存在";
/**序列号不能为为空*/ /**序列号不存在或者已经出库*/
public static final int SERIAL_NUMBERE_NOT_BE_EMPTY_CODE = 10500001; public static final int SERIAL_NUMBERE_NOT_EXISTS_CODE = 10500001;
public static final String SERIAL_NUMBERE_NOT_BE_EMPTY_MSG = "序列号不能为为空"; public static final String SERIAL_NUMBERE_NOT_EXISTS_MSG = "序列号:%s不存在或者已经出库";
/**商品%s下序列号不充足请补充后重试*/
public static final int MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE = 10500002;
public static final String MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG = "商品:%s下序列号不充足请补充后重试";
/**删序列号信息失败*/
public static final int SERIAL_NUMBERE_DELETE_FAILED_CODE = 10500003;
public static final String SERIAL_NUMBERE_DELETE_FAILED_MSG = "删序列号信息失败";
/** /**
* 机构信息 * 机构信息
* type = 110 * type = 110

View File

@@ -54,4 +54,8 @@ public interface SerialNumberMapperEx {
@Param("name") String name, @Param("name") String name,
@Param("depotId") Long depotId, @Param("depotId") Long depotId,
@Param("barCode") String barCode); @Param("barCode") String barCode);
int getIsNotSellCountByParam(
@Param("materialId") Long materialId,
@Param("serialNumber") String serialNumber);
} }

View File

@@ -7,8 +7,6 @@ import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.*; import com.jsh.erp.datasource.mappers.*;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException; import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.depotHead.DepotHeadService;
import com.jsh.erp.service.depotItem.DepotItemService;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.material.MaterialService; import com.jsh.erp.service.material.MaterialService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
@@ -26,12 +24,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/**
* Description
*
* @Author: cjl
* @Date: 2019/1/21 16:33
*/
@Service @Service
public class SerialNumberService { public class SerialNumberService {
private Logger logger = LoggerFactory.getLogger(SerialNumberService.class); private Logger logger = LoggerFactory.getLogger(SerialNumberService.class);
@@ -150,7 +142,6 @@ public class SerialNumberService {
} }
/** /**
* create by: qiankunpingtai
* 逻辑删除序列号信息 * 逻辑删除序列号信息
* create time: 2019/3/27 17:43 * create time: 2019/3/27 17:43
* @Param: ids * @Param: ids
@@ -188,11 +179,9 @@ public class SerialNumberService {
} }
return list==null?0:list.size(); return list==null?0:list.size();
} }
/** /**
* create by: cjl
* description:
* 根据商品名称判断商品名称是否有效 * 根据商品名称判断商品名称是否有效
* create time: 2019/1/23 17:04
* @Param: materialName * @Param: materialName
* @return Long 满足使用条件的商品的id * @return Long 满足使用条件的商品的id
*/ */
@@ -225,17 +214,13 @@ public class SerialNumberService {
} }
return null; return null;
} }
/** /**
* create by: cjl
* description:
* 根据商品名称判断给商品添加序列号是否可行 * 根据商品名称判断给商品添加序列号是否可行
* 1、根据商品名称必须查询到唯一的商品 * 1、根据商品名称必须查询到唯一的商品
* 2、该商品必须已经启用序列号 * 2、该商品必须已经启用序列号
* 3、该商品已绑定序列号数量小于商品现有库存 * 3、该商品已绑定序列号数量小于商品现有库存
* 2019-02-01
* 用商品的库存去限制序列号的添加有点不合乎道理,去掉此限制 * 用商品的库存去限制序列号的添加有点不合乎道理,去掉此限制
* create time: 2019/1/23 17:04
* @Param: materialName
* @return Long 满足使用条件的商品的id * @return Long 满足使用条件的商品的id
*/ */
public Long getSerialNumberMaterialIdByBarCode(String materialCode)throws Exception{ public Long getSerialNumberMaterialIdByBarCode(String materialCode)throws Exception{
@@ -254,58 +239,40 @@ public class SerialNumberService {
} }
/** /**
* create by: cjl
* description:
* 出库时判断序列号库存是否足够, * 出库时判断序列号库存是否足够,
* 同时将对应的序列号绑定单据 * 同时将对应的序列号绑定单据
* create time: 2019/1/24 16:24
* @Param: List<DepotItem>
* @return void
*/ */
public void checkAndUpdateSerialNumber(DepotItem depotItem, String outBillNo,User userInfo, String snList) throws Exception{ public void checkAndUpdateSerialNumber(DepotItem depotItem, String outBillNo,User userInfo, String snList) throws Exception{
if(depotItem!=null){ if(depotItem!=null){
sellSerialNumber(depotItem.getMaterialId(), outBillNo, snList,userInfo); sellSerialNumber(depotItem.getMaterialId(), outBillNo, snList,userInfo);
} }
} }
/** /**
* * 出售序列号
*
* */
/**
* create by: cjl
* description:
* 卖出序列号
* create time: 2019/1/25 9:17
* @Param: materialId
* @Param: depotheadId
* @Param: isSell 卖出'1'
* @Param: Count 卖出或者赎回的数量
* @return com.jsh.erp.datasource.entities.SerialNumberEx
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int sellSerialNumber(Long materialId, String outBillNo, String snList, User user) throws Exception{ public void sellSerialNumber(Long materialId, String outBillNo, String snList, User user) throws Exception{
int result=0; //将中文的逗号批量替换为英文逗号
try{ snList = snList.replaceAll("",",");
//将中文的逗号批量替换为英文逗号 String [] snArray=snList.split(",");
snList = snList.replaceAll("",","); for (String sn : snArray) {
String [] snArray=snList.split(","); int isNotSellCount = serialNumberMapperEx.getIsNotSellCountByParam(materialId, sn);
result = serialNumberMapperEx.sellSerialNumber(materialId, outBillNo, snArray, new Date(),user==null?null:user.getId()); if (isNotSellCount == 0) {
}catch(Exception e){ //如果序列号不存在或者已售出则进行提示,不再进行后续的出售操作
JshException.writeFail(logger, e); throw new BusinessRunTimeException(ExceptionConstants.SERIAL_NUMBERE_NOT_EXISTS_CODE,
String.format(ExceptionConstants.SERIAL_NUMBERE_NOT_EXISTS_MSG, sn));
}
} }
return result; serialNumberMapperEx.sellSerialNumber(materialId, outBillNo, snArray, new Date(), user == null ? null : user.getId());
} }
/** /**
* create by: cjl
* description:
* 赎回序列号 * 赎回序列号
* create time: 2019/1/25 9:17
* @Param: materialId * @Param: materialId
 * @Param: depotheadId * @Param: depotheadId
 * @Param: isSell 赎回'0' * @Param: isSell 赎回'0'
 * @Param: Count 卖出或者赎回的数量 * @Param: Count 卖出或者赎回的数量
* @return com.jsh.erp.datasource.entities.SerialNumberEx
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int cancelSerialNumber(Long materialId, String outBillNo,int count,User user) throws Exception{ public int cancelSerialNumber(Long materialId, String outBillNo,int count,User user) throws Exception{
@@ -319,15 +286,7 @@ public class SerialNumberService {
} }
/** /**
* create by: cjl * 批量添加序列号最多500个
* description:
*批量添加序列号最多500个
* create time: 2019/1/29 15:11
* @Param: materialName
* @Param: serialNumberPrefix
* @Param: batAddTotal
* @Param: remark
* @return java.lang.Object
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batAddSerialNumber(String materialCode, String serialNumberPrefix, Integer batAddTotal, String remark)throws Exception { public int batAddSerialNumber(String materialCode, String serialNumberPrefix, Integer batAddTotal, String remark)throws Exception {
@@ -394,7 +353,7 @@ public class SerialNumberService {
} }
public void addSerialNumberByBill(String type, String subType, String inBillNo, Long materialId, Long depotId, String snList) throws Exception { public void addSerialNumberByBill(String type, String subType, String inBillNo, Long materialId, Long depotId, String snList) throws Exception {
//录入序列号的时候不能重复 //录入序列号的时候不能和库里面的重复-入库
if ((BusinessConstants.SUB_TYPE_PURCHASE.equals(subType) || if ((BusinessConstants.SUB_TYPE_PURCHASE.equals(subType) ||
BusinessConstants.SUB_TYPE_OTHER.equals(subType) || BusinessConstants.SUB_TYPE_OTHER.equals(subType) ||
BusinessConstants.SUB_TYPE_SALES_RETURN.equals(subType)|| BusinessConstants.SUB_TYPE_SALES_RETURN.equals(subType)||

View File

@@ -210,4 +210,12 @@
) )
and ifnull(ser.delete_flag,'0') !='1' and ifnull(ser.delete_flag,'0') !='1'
</select> </select>
<select id="getIsNotSellCountByParam" resultType="java.lang.Integer">
select count(1) from jsh_serial_number
where material_id = #{materialId}
and serial_number = #{serialNumber}
and is_sell = '0'
and ifnull(delete_flag,'0') !='1'
</select>
</mapper> </mapper>