添加序列号新增时验证条件
This commit is contained in:
@@ -364,12 +364,20 @@
|
|||||||
info: JSON.stringify(objInfo)
|
info: JSON.stringify(objInfo)
|
||||||
}),
|
}),
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
if(res && res.code === 200) {
|
if(res){
|
||||||
$('#serialNumberDlg').dialog('close');
|
if(res.code!=200){
|
||||||
//加载完以后重新初始化
|
$.messager.alert('提示', res.msg, 'error');
|
||||||
var opts = $("#tableData").datagrid('options');
|
return;
|
||||||
showSerialNumberDetails(opts.pageNumber, opts.pageSize);
|
}
|
||||||
|
if(res.code === 200) {
|
||||||
|
$('#serialNumberDlg').dialog('close');
|
||||||
|
//加载完以后重新初始化
|
||||||
|
var opts = $("#tableData").datagrid('options');
|
||||||
|
showSerialNumberDetails(opts.pageNumber, opts.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
//此处添加错误处理
|
//此处添加错误处理
|
||||||
error: function () {
|
error: function () {
|
||||||
|
|||||||
@@ -5179,6 +5179,12 @@ INSERT INTO `jsh_userbusiness` VALUES ('24', 'UserDepot', '65', '[1]', null);
|
|||||||
INSERT INTO `jsh_userbusiness` VALUES ('25', 'UserCustomer', '64', '[5][2]', null);
|
INSERT INTO `jsh_userbusiness` VALUES ('25', 'UserCustomer', '64', '[5][2]', null);
|
||||||
INSERT INTO `jsh_userbusiness` VALUES ('26', 'UserCustomer', '65', '[6]', null);
|
INSERT INTO `jsh_userbusiness` VALUES ('26', 'UserCustomer', '65', '[6]', null);
|
||||||
INSERT INTO `jsh_userbusiness` VALUES ('27', 'UserCustomer', '63', '[5][2]', null);
|
INSERT INTO `jsh_userbusiness` VALUES ('27', 'UserCustomer', '63', '[5][2]', null);
|
||||||
|
-- ----------------------------
|
||||||
|
-- 时间:2019年1月21日
|
||||||
|
-- version:1.0.0
|
||||||
|
-- 此次更新添加序列号功能
|
||||||
|
-- 特别提醒:之后的sql都是在之前基础上迭代,可以对已存在的系统进行数据保留更新
|
||||||
|
-- ----------------------------
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 添加序列号表
|
-- 添加序列号表
|
||||||
@@ -5202,4 +5208,16 @@ CREATE TABLE `jsh_serial_number` (
|
|||||||
-- 产品表新增字段是否启用序列号
|
-- 产品表新增字段是否启用序列号
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
alter table jsh_material add enableSerialNumber bit(1) DEFAULT 0 COMMENT '是否开启序列号,0否,1是';
|
alter table jsh_material add enableSerialNumber bit(1) DEFAULT 0 COMMENT '是否开启序列号,0否,1是';
|
||||||
|
-- ----------------------------
|
||||||
|
-- 时间:2019年1月24日
|
||||||
|
-- version:1.0.1
|
||||||
|
-- 此次更新添加序列号菜单
|
||||||
|
-- 特别提醒:之后的sql都是在之前基础上迭代,可以对已存在的系统进行数据保留更新
|
||||||
|
-- ----------------------------
|
||||||
|
-- ----------------------------
|
||||||
|
-- 添加序列号菜单
|
||||||
|
-- ----------------------------
|
||||||
|
delete from `jsh_functions` where Name='序列号';
|
||||||
|
INSERT INTO `jsh_functions`(`Number`, `Name`, `PNumber`, `URL`, `State`, `Sort`, `Enabled`, `Type`, `PushBtn`) VALUES ('010104', '序列号', '0101', '../manage/serialNumber.html', b'0', '0246', b'1', '电脑版', '');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -21,6 +21,20 @@ public class BusinessConstants {
|
|||||||
* 默认的分页页数
|
* 默认的分页页数
|
||||||
*/
|
*/
|
||||||
public static final String DEFAULT_PAGINATION_PAGE_SIZE = "10";
|
public static final String DEFAULT_PAGINATION_PAGE_SIZE = "10";
|
||||||
|
/**
|
||||||
|
* 商品是否开启序列号标识enableSerialNumber 0否false,1是true
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
public static final boolean MATERIAL_ENABLE_SERIAL_NUMBER = true;
|
||||||
|
public static final boolean MATERIAL_NOT_ENABLE_SERIAL_NUMBER = false;
|
||||||
|
/**
|
||||||
|
* 单据主表出入库类型 type 入库 出库
|
||||||
|
* depothead
|
||||||
|
* */
|
||||||
|
public static final String DEPOTHEAD_TYPE_STORAGE = "入库";
|
||||||
|
public static final String DEPOTHEAD_TYPE_OUT = "出库";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,16 @@ public class ExceptionConstants {
|
|||||||
* */
|
* */
|
||||||
//商品信息不存在
|
//商品信息不存在
|
||||||
public static final int MATERIAL_NOT_EXISTS_CODE = 8000000;
|
public static final int MATERIAL_NOT_EXISTS_CODE = 8000000;
|
||||||
public static final String MATERIAL_NOT_EXISTS__MSG = "商品信息不存在";
|
public static final String MATERIAL_NOT_EXISTS_MSG = "商品信息不存在";
|
||||||
//商品信息不唯一
|
//商品信息不唯一
|
||||||
public static final int MATERIAL_NOT_ONLY_CODE = 8000001;
|
public static final int MATERIAL_NOT_ONLY_CODE = 8000001;
|
||||||
public static final String MATERIAL_NOT_ONLY__MSG = "商品信息不唯一";
|
public static final String MATERIAL_NOT_ONLY_MSG = "商品信息不唯一";
|
||||||
|
//该商品未开启序列号
|
||||||
|
public static final int MATERIAL_NOT_ENABLE_SERIAL_NUMBER_CODE = 8000002;
|
||||||
|
public static final String MATERIAL_NOT_ENABLE_SERIAL_NUMBER_MSG = "该商品未开启序列号功能";
|
||||||
|
//该商品已绑定序列号数量小于等于商品现有库存
|
||||||
|
public static final int MATERIAL_SERIAL_NUMBERE_NOT_MORE_THAN_STORAGE_CODE = 8000003;
|
||||||
|
public static final String MATERIAL_SERIAL_NUMBERE_NOT_MORE_THAN_STORAGE_MSG = "该商品已绑定序列号数量大于等于商品现有库存";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标准正常返回/操作成功返回
|
* 标准正常返回/操作成功返回
|
||||||
|
|||||||
@@ -37,4 +37,9 @@ public interface SerialNumberMapperEx {
|
|||||||
* 修改序列号信息
|
* 修改序列号信息
|
||||||
* */
|
* */
|
||||||
int updateSerialNumber(SerialNumberEx serialNumberEx);
|
int updateSerialNumber(SerialNumberEx serialNumberEx);
|
||||||
|
/**
|
||||||
|
* 查询指定商品下有效的序列号数量
|
||||||
|
* 未删除为卖出的视为有效
|
||||||
|
* */
|
||||||
|
int findSerialNumberByMaterialId(@Param("materialId") Long materialId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package com.jsh.erp.service.serialNumber;
|
package com.jsh.erp.service.serialNumber;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.*;
|
import com.jsh.erp.datasource.entities.*;
|
||||||
import com.jsh.erp.datasource.mappers.MaterialMapperEx;
|
import com.jsh.erp.datasource.mappers.MaterialMapperEx;
|
||||||
import com.jsh.erp.datasource.mappers.SerialNumberMapper;
|
import com.jsh.erp.datasource.mappers.SerialNumberMapper;
|
||||||
import com.jsh.erp.datasource.mappers.SerialNumberMapperEx;
|
import com.jsh.erp.datasource.mappers.SerialNumberMapperEx;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
|
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||||
import com.jsh.erp.service.material.MaterialService;
|
import com.jsh.erp.service.material.MaterialService;
|
||||||
import com.jsh.erp.utils.StringUtil;
|
import com.jsh.erp.utils.StringUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -39,6 +41,8 @@ public class SerialNumberService {
|
|||||||
private SerialNumberMapperEx serialNumberMapperEx;
|
private SerialNumberMapperEx serialNumberMapperEx;
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialMapperEx materialMapperEx;
|
private MaterialMapperEx materialMapperEx;
|
||||||
|
@Resource
|
||||||
|
private DepotItemService depotItemService;
|
||||||
|
|
||||||
|
|
||||||
public SerialNumber getSerialNumber(long id) {
|
public SerialNumber getSerialNumber(long id) {
|
||||||
@@ -121,11 +125,11 @@ public class SerialNumberService {
|
|||||||
if(mlist==null||mlist.size()<1){
|
if(mlist==null||mlist.size()<1){
|
||||||
//商品名称不存在
|
//商品名称不存在
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
||||||
ExceptionConstants.MATERIAL_NOT_EXISTS__MSG);
|
ExceptionConstants.MATERIAL_NOT_EXISTS_MSG);
|
||||||
}else if(mlist.size()>1){
|
}else if(mlist.size()>1){
|
||||||
//商品信息不唯一
|
//商品信息不唯一
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_ONLY_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_ONLY_CODE,
|
||||||
ExceptionConstants.MATERIAL_NOT_ONLY__MSG);
|
ExceptionConstants.MATERIAL_NOT_ONLY_MSG);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,21 +171,7 @@ public class SerialNumberService {
|
|||||||
}
|
}
|
||||||
/**处理商品id*/
|
/**处理商品id*/
|
||||||
if(serialNumberEx.getMaterialId()==null){
|
if(serialNumberEx.getMaterialId()==null){
|
||||||
if(StringUtil.isNotEmpty(serialNumberEx.getMaterialName())){
|
serialNumberEx.setMaterialId(getSerialNumberMaterialIdByMaterialName(serialNumberEx.getMaterialName()));
|
||||||
List<Material> mlist = materialMapperEx.findByMaterialName(serialNumberEx.getMaterialName());
|
|
||||||
if(mlist==null||mlist.size()<1){
|
|
||||||
//商品名称不存在
|
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
|
||||||
ExceptionConstants.MATERIAL_NOT_EXISTS__MSG);
|
|
||||||
}else if(mlist.size()>1){
|
|
||||||
//商品信息不唯一
|
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_ONLY_CODE,
|
|
||||||
ExceptionConstants.MATERIAL_NOT_ONLY__MSG);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
serialNumberEx.setMaterialId(mlist.get(0).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//删除标记,默认未删除
|
//删除标记,默认未删除
|
||||||
serialNumberEx.setDeleteFlag(false);
|
serialNumberEx.setDeleteFlag(false);
|
||||||
@@ -206,21 +196,7 @@ public class SerialNumberService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/**处理商品id*/
|
/**处理商品id*/
|
||||||
if(StringUtil.isNotEmpty(serialNumberEx.getMaterialName())){
|
serialNumberEx.setMaterialId(getSerialNumberMaterialIdByMaterialName(serialNumberEx.getMaterialName()));
|
||||||
List<Material> mlist = materialMapperEx.findByMaterialName(serialNumberEx.getMaterialName());
|
|
||||||
if(mlist==null||mlist.size()<1){
|
|
||||||
//商品名称不存在
|
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
|
||||||
ExceptionConstants.MATERIAL_NOT_EXISTS__MSG);
|
|
||||||
}else if(mlist.size()>1){
|
|
||||||
//商品信息不唯一
|
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_ONLY_CODE,
|
|
||||||
ExceptionConstants.MATERIAL_NOT_ONLY__MSG);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
serialNumberEx.setMaterialId(mlist.get(0).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Date date=new Date();
|
Date date=new Date();
|
||||||
serialNumberEx.setUpdateTime(date);
|
serialNumberEx.setUpdateTime(date);
|
||||||
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||||
@@ -232,4 +208,53 @@ public class SerialNumberService {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* create by: cjl
|
||||||
|
* description:
|
||||||
|
* 根据商品名称判断给商品添加序列号是否可行
|
||||||
|
* 1、根据商品名称必须查询到唯一的商品
|
||||||
|
* 2、该商品必须已经启用序列号
|
||||||
|
* 3、该商品已绑定序列号数量小于商品现有库存
|
||||||
|
* create time: 2019/1/23 17:04
|
||||||
|
* @Param: materialName
|
||||||
|
* @return Long 满足使用条件的商品的id
|
||||||
|
*/
|
||||||
|
public Long getSerialNumberMaterialIdByMaterialName(String materialName){
|
||||||
|
if(StringUtil.isNotEmpty(materialName)){
|
||||||
|
List<Material> mlist = materialMapperEx.findByMaterialName(materialName);
|
||||||
|
if(mlist==null||mlist.size()<1){
|
||||||
|
//商品名称不存在
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
||||||
|
ExceptionConstants.MATERIAL_NOT_EXISTS_MSG);
|
||||||
|
}
|
||||||
|
if(mlist.size()>1){
|
||||||
|
//商品信息不唯一
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_ONLY_CODE,
|
||||||
|
ExceptionConstants.MATERIAL_NOT_ONLY_MSG);
|
||||||
|
|
||||||
|
}
|
||||||
|
//获得唯一商品
|
||||||
|
if(BusinessConstants.MATERIAL_NOT_ENABLE_SERIAL_NUMBER==mlist.get(0).getEnableSerialNumber()){
|
||||||
|
//商品未开启序列号
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_ENABLE_SERIAL_NUMBER_CODE,
|
||||||
|
ExceptionConstants.MATERIAL_NOT_ENABLE_SERIAL_NUMBER_MSG);
|
||||||
|
}
|
||||||
|
//计算商品库存和目前占用的可用序列号数量关系
|
||||||
|
//库存=入库-出库
|
||||||
|
//入库数量
|
||||||
|
Long materialId=mlist.get(0).getId();
|
||||||
|
int inSum = depotItemService.findByTypeAndMaterialId(BusinessConstants.DEPOTHEAD_TYPE_STORAGE, materialId);
|
||||||
|
//出库数量
|
||||||
|
int outSum = depotItemService.findByTypeAndMaterialId(BusinessConstants.DEPOTHEAD_TYPE_OUT, materialId);
|
||||||
|
//查询当前商品下有效的序列号
|
||||||
|
int serialNumberSum = serialNumberMapperEx.findSerialNumberByMaterialId(materialId);
|
||||||
|
if((inSum-outSum)<=serialNumberSum){
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_MORE_THAN_STORAGE_CODE,
|
||||||
|
ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_MORE_THAN_STORAGE_MSG);
|
||||||
|
}
|
||||||
|
return materialId;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,4 +113,16 @@
|
|||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=BIGINT}
|
where id = #{id,jdbcType=BIGINT}
|
||||||
</update>
|
</update>
|
||||||
|
<select id="findSerialNumberByMaterialId" resultType="java.lang.Integer">
|
||||||
|
SELECT
|
||||||
|
count(ser.id)
|
||||||
|
FROM jsh_serial_number ser
|
||||||
|
where 1=1
|
||||||
|
<if test="materialId != null">
|
||||||
|
and ser.material_Id=#{materialId}
|
||||||
|
</if>
|
||||||
|
and ser.delete_Flag !='1'
|
||||||
|
and ser.is_Sell !='1'
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user