Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
b55e9d15
Commit
b55e9d15
authored
Jan 24, 2019
by
乾坤平台
Committed by
季圣华
Jan 24, 2019
Browse files
!21 序列号功能更新
Merge pull request !21 from 乾坤平台/master
parents
69bd3567
9b3ec7f4
Changes
9
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/serialNumber.html
View file @
b55e9d15
...
@@ -364,12 +364,20 @@
...
@@ -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
()
{
...
...
sql/jsh_erp.sql
View file @
b55e9d15
...
@@ -5179,6 +5179,12 @@ INSERT INTO `jsh_userbusiness` VALUES ('24', 'UserDepot', '65', '[1]', null);
...
@@ -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` (
...
@@ -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', '电脑版', '');
sql/华夏ERP数据库设计汇总.xlsx
View file @
b55e9d15
No preview for this file type
src/main/java/com/jsh/erp/constants/BusinessConstants.java
View file @
b55e9d15
...
@@ -21,6 +21,20 @@ public class BusinessConstants {
...
@@ -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
=
"出库"
;
...
...
src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
b55e9d15
...
@@ -43,10 +43,16 @@ public class ExceptionConstants {
...
@@ -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
=
"该商品已绑定序列号数量大于等于商品现有库存"
;
/**
/**
* 标准正常返回/操作成功返回
* 标准正常返回/操作成功返回
...
...
src/main/java/com/jsh/erp/datasource/mappers/SerialNumberMapperEx.java
View file @
b55e9d15
...
@@ -37,4 +37,9 @@ public interface SerialNumberMapperEx {
...
@@ -37,4 +37,9 @@ public interface SerialNumberMapperEx {
* 修改序列号信息
* 修改序列号信息
* */
* */
int
updateSerialNumber
(
SerialNumberEx
serialNumberEx
);
int
updateSerialNumber
(
SerialNumberEx
serialNumberEx
);
/**
* 查询指定商品下有效的序列号数量
* 未删除为卖出的视为有效
* */
int
findSerialNumberByMaterialId
(
@Param
(
"materialId"
)
Long
materialId
);
}
}
src/main/java/com/jsh/erp/service/serialNumber/SerialNumberService.java
View file @
b55e9d15
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.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
/**
/**
* Description
* Description
...
@@ -39,6 +38,10 @@ public class SerialNumberService {
...
@@ -39,6 +38,10 @@ public class SerialNumberService {
private
SerialNumberMapperEx
serialNumberMapperEx
;
private
SerialNumberMapperEx
serialNumberMapperEx
;
@Resource
@Resource
private
MaterialMapperEx
materialMapperEx
;
private
MaterialMapperEx
materialMapperEx
;
@Resource
private
DepotItemService
depotItemService
;
@Resource
private
UserService
userService
;
public
SerialNumber
getSerialNumber
(
long
id
)
{
public
SerialNumber
getSerialNumber
(
long
id
)
{
...
@@ -121,11 +124,11 @@ public class SerialNumberService {
...
@@ -121,11 +124,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 +170,7 @@ public class SerialNumberService {
...
@@ -167,21 +170,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
);
...
@@ -190,8 +179,7 @@ public class SerialNumberService {
...
@@ -190,8 +179,7 @@ public class SerialNumberService {
Date
date
=
new
Date
();
Date
date
=
new
Date
();
serialNumberEx
.
setCreateTime
(
date
);
serialNumberEx
.
setCreateTime
(
date
);
serialNumberEx
.
setUpdateTime
(
date
);
serialNumberEx
.
setUpdateTime
(
date
);
HttpServletRequest
request
=
((
ServletRequestAttributes
)
Objects
.
requireNonNull
(
RequestContextHolder
.
getRequestAttributes
())).
getRequest
();
User
userInfo
=
userService
.
getCurrentUser
();
User
userInfo
=(
User
)
request
.
getSession
().
getAttribute
(
"user"
);
serialNumberEx
.
setCreator
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
serialNumberEx
.
setCreator
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
serialNumberEx
.
setUpdater
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
serialNumberEx
.
setUpdater
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
int
result
=
serialNumberMapperEx
.
addSerialNumber
(
serialNumberEx
);
int
result
=
serialNumberMapperEx
.
addSerialNumber
(
serialNumberEx
);
...
@@ -206,30 +194,64 @@ public class SerialNumberService {
...
@@ -206,30 +194,64 @@ 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
());
Date
date
=
new
Date
();
serialNumberEx
.
setUpdateTime
(
date
);
User
userInfo
=
userService
.
getCurrentUser
();
serialNumberEx
.
setUpdater
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
int
result
=
serialNumberMapperEx
.
updateSerialNumber
(
serialNumberEx
);
if
(
result
==
1
){
return
serialNumberEx
;
}
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
){
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
){
}
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
);
}
else
{
serialNumberEx
.
setMaterialId
(
mlist
.
get
(
0
).
getId
());
}
}
}
//获得唯一商品
Date
date
=
new
Date
();
if
(
BusinessConstants
.
MATERIAL_NOT_ENABLE_SERIAL_NUMBER
==
mlist
.
get
(
0
).
getEnableSerialNumber
()){
serialNumberEx
.
setUpdateTime
(
date
);
//商品未开启序列号
HttpServletRequest
request
=
((
ServletRequestAttributes
)
Objects
.
requireNonNull
(
RequestContextHolder
.
getRequestAttributes
())).
getRequest
();
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_NOT_ENABLE_SERIAL_NUMBER_CODE
,
User
userInfo
=(
User
)
request
.
getSession
().
getAttribute
(
"user"
);
ExceptionConstants
.
MATERIAL_NOT_ENABLE_SERIAL_NUMBER_MSG
);
serialNumberEx
.
setUpdater
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
}
int
result
=
serialNumberMapperEx
.
updateSerialNumber
(
serialNumberEx
);
//计算商品库存和目前占用的可用序列号数量关系
if
(
result
==
1
){
//库存=入库-出库
return
serialNumberEx
;
//入库数量
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
;
return
null
;
}
}
}
}
src/main/java/com/jsh/erp/service/user/UserService.java
View file @
b55e9d15
...
@@ -10,12 +10,15 @@ import org.slf4j.Logger;
...
@@ -10,12 +10,15 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
@Service
@Service
public
class
UserService
{
public
class
UserService
{
...
@@ -168,4 +171,16 @@ public class UserService {
...
@@ -168,4 +171,16 @@ public class UserService {
List
<
User
>
list
=
userMapper
.
selectByExample
(
example
);
List
<
User
>
list
=
userMapper
.
selectByExample
(
example
);
return
list
.
size
();
return
list
.
size
();
}
}
/**
* create by: cjl
* description:
* 获取当前用户信息
* create time: 2019/1/24 10:01
* @Param:
* @return com.jsh.erp.datasource.entities.User
*/
public
User
getCurrentUser
(){
HttpServletRequest
request
=
((
ServletRequestAttributes
)
Objects
.
requireNonNull
(
RequestContextHolder
.
getRequestAttributes
())).
getRequest
();
return
(
User
)
request
.
getSession
().
getAttribute
(
"user"
);
}
}
}
src/main/resources/mapper_xml/SerialNumberMapperEx.xml
View file @
b55e9d15
...
@@ -113,4 +113,16 @@
...
@@ -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>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment