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
ca1be886
Commit
ca1be886
authored
Jan 29, 2019
by
cjl
Browse files
批量添加序列号
parent
b08d349b
Changes
8
Hide whitespace changes
Inline
Side-by-side
erp_web/js/easyui-1.3.5/themes/icon.css
View file @
ca1be886
.icon-blank
{
background
:
url('icons/blank.gif')
no-repeat
center
center
;
}
.icon-add
{
background
:
url('icons/edit_add.png')
no-repeat
center
center
;
}
.icon-edit
{
background
:
url('icons/pencil.png')
no-repeat
center
center
;
}
.icon-remove
{
background
:
url('icons/edit_remove.png')
no-repeat
center
center
;
}
.icon-save
{
background
:
url('icons/filesave.png')
no-repeat
center
center
;
}
.icon-cut
{
background
:
url('icons/cut.png')
no-repeat
center
center
;
}
.icon-ok
{
background
:
url('icons/ok.png')
no-repeat
center
center
;
}
.icon-no
{
background
:
url('icons/no.png')
no-repeat
center
center
;
}
.icon-cancel
{
background
:
url('icons/cancel.png')
no-repeat
center
center
;
}
.icon-reload
{
background
:
url('icons/reload.png')
no-repeat
center
center
;
}
.icon-search
{
background
:
url('icons/049.png')
no-repeat
center
center
;
}
.icon-print
{
background
:
url('icons/print.png')
no-repeat
center
center
;
}
.icon-help
{
background
:
url('icons/help.png')
no-repeat
center
center
;
}
.icon-undo
{
background
:
url('icons/undo.png')
no-repeat
center
center
;
}
.icon-redo
{
background
:
url('icons/redo.png')
no-repeat
center
center
;
}
.icon-back
{
background
:
url('icons/back.png')
no-repeat
center
center
;
}
.icon-sum
{
background
:
url('icons/sum.png')
no-repeat
center
center
;
}
.icon-tip
{
background
:
url('icons/tip.png')
no-repeat
center
center
;
}
.icon-filter
{
background
:
url('icons/filter.png')
no-repeat
center
center
;
}
.icon-mini-add
{
background
:
url('icons/mini_add.png')
no-repeat
center
center
;
}
.icon-mini-edit
{
background
:
url('icons/mini_edit.png')
no-repeat
center
center
;
}
.icon-mini-refresh
{
background
:
url('icons/mini_refresh.png')
no-repeat
center
center
;
}
.icon-list
{
background
:
url('icons/list.png')
no-repeat
center
center
;
}
.icon-chart-column
{
background
:
url('icons/chart_bar.png')
no-repeat
center
center
;
}
.icon-chart-zonghe
{
background
:
url('icons/zonghe.png')
no-repeat
center
center
;
}
.icon-chart-pie
{
background
:
url('icons/pie.png')
no-repeat
center
center
;
}
.icon-chart-statistics
{
background
:
url('icons/statistics.png')
no-repeat
center
center
;
}
.icon-chart-polygram
{
background
:
url('icons/polygram.png')
no-repeat
center
center
;
}
.icon-unlock
{
background
:
url('icons/lock_unlock.png')
no-repeat
center
center
;
}
.icon-comment
{
background
:
url('icons/comment.png')
no-repeat
center
center
;
}
.icon-excel
{
background
:
url('icons/receipt-excel.png')
no-repeat
center
center
;
}
.icon-excel-new
{
background
:
url('icons/excel1.png')
no-repeat
center
center
;
}
.icon-page-excel
{
background
:
url('icons/page_excel.png')
no-repeat
center
center
;
.icon-blank
{
background
:
url('icons/blank.gif')
no-repeat
center
center
;
}
.icon-add
{
background
:
url('icons/edit_add.png')
no-repeat
center
center
;
}
.icon-edit
{
background
:
url('icons/pencil.png')
no-repeat
center
center
;
}
.icon-remove
{
background
:
url('icons/edit_remove.png')
no-repeat
center
center
;
}
.icon-save
{
background
:
url('icons/filesave.png')
no-repeat
center
center
;
}
.icon-cut
{
background
:
url('icons/cut.png')
no-repeat
center
center
;
}
.icon-ok
{
background
:
url('icons/ok.png')
no-repeat
center
center
;
}
.icon-no
{
background
:
url('icons/no.png')
no-repeat
center
center
;
}
.icon-cancel
{
background
:
url('icons/cancel.png')
no-repeat
center
center
;
}
.icon-reload
{
background
:
url('icons/reload.png')
no-repeat
center
center
;
}
.icon-search
{
background
:
url('icons/049.png')
no-repeat
center
center
;
}
.icon-print
{
background
:
url('icons/print.png')
no-repeat
center
center
;
}
.icon-help
{
background
:
url('icons/help.png')
no-repeat
center
center
;
}
.icon-undo
{
background
:
url('icons/undo.png')
no-repeat
center
center
;
}
.icon-redo
{
background
:
url('icons/redo.png')
no-repeat
center
center
;
}
.icon-back
{
background
:
url('icons/back.png')
no-repeat
center
center
;
}
.icon-sum
{
background
:
url('icons/sum.png')
no-repeat
center
center
;
}
.icon-tip
{
background
:
url('icons/tip.png')
no-repeat
center
center
;
}
.icon-filter
{
background
:
url('icons/filter.png')
no-repeat
center
center
;
}
.icon-mini-add
{
background
:
url('icons/mini_add.png')
no-repeat
center
center
;
}
.icon-mini-edit
{
background
:
url('icons/mini_edit.png')
no-repeat
center
center
;
}
.icon-mini-refresh
{
background
:
url('icons/mini_refresh.png')
no-repeat
center
center
;
}
.icon-list
{
background
:
url('icons/list.png')
no-repeat
center
center
;
}
.icon-chart-column
{
background
:
url('icons/chart_bar.png')
no-repeat
center
center
;
}
.icon-chart-zonghe
{
background
:
url('icons/zonghe.png')
no-repeat
center
center
;
}
.icon-chart-pie
{
background
:
url('icons/pie.png')
no-repeat
center
center
;
}
.icon-chart-statistics
{
background
:
url('icons/statistics.png')
no-repeat
center
center
;
}
.icon-chart-polygram
{
background
:
url('icons/polygram.png')
no-repeat
center
center
;
}
.icon-unlock
{
background
:
url('icons/lock_unlock.png')
no-repeat
center
center
;
}
.icon-comment
{
background
:
url('icons/comment.png')
no-repeat
center
center
;
}
.icon-excel
{
background
:
url('icons/receipt-excel.png')
no-repeat
center
center
;
}
.icon-excel-new
{
background
:
url('icons/excel1.png')
no-repeat
center
center
;
}
.icon-page-excel
{
background
:
url('icons/page_excel.png')
no-repeat
center
center
;
}
.icon-basket_add
{
background
:
url('icons/basket_add.png')
no-repeat
center
center
;
}
\ No newline at end of file
erp_web/js/easyui-1.3.5/themes/icons/basket_add.png
0 → 100644
View file @
ca1be886
752 Bytes
erp_web/pages/manage/serialNumber.html
View file @
ca1be886
...
...
@@ -87,12 +87,59 @@
</div>
</form>
</div>
<div
id=
"dlg-buttons"
>
<a
href=
"javascript:void(0)"
id=
"saveSerialNumber"
class=
"easyui-linkbutton"
iconCls=
"icon-ok"
>
保存
</a>
<a
href=
"javascript:void(0)"
id=
"cancelSerialNumber"
class=
"easyui-linkbutton"
iconCls=
"icon-cancel"
onclick=
"javascript:$('#serialNumberDlg').dialog('close')"
>
取消
</a>
</div>
<div
id=
"batAddSerialNumberDlg"
class=
"easyui-dialog"
style=
"width:860px;height:420px;padding:10px 20px"
closed=
"true"
buttons=
"#bat-dlg-buttons"
modal=
"true"
collapsible=
"false"
closable=
"true"
>
<form
id=
"batAddserialNumberFM"
method=
"post"
novalidate
>
<div
id=
"batAddtt"
class=
"easyui-tabs"
style=
"width:800px;height:320px;"
>
<div
title=
"批量自定义序列号"
style=
"padding:20px;"
>
<table>
<tr>
<td
style=
"width:60px; height:30px;"
>
商品名称
</td>
<td
style=
"padding:5px;width:180px;"
>
<input
name=
"materialName"
id=
"batAddMaterialName"
class=
"easyui-validatebox"
data-options=
"required:true,validType:'length[2,30]'"
style=
"width: 180px;height: 20px"
/>
</td>
<td
style=
"width:80px;"
>
序列号前缀
</td>
<td
style=
"padding:5px;width:180px;"
>
<input
name=
"serialNumber"
id=
"batAddSerialNumberInput"
class=
"easyui-validatebox"
data-options=
"required:true,validType:'length[1,30]'"
style=
"width: 180px;height: 20px"
/>
</td>
<td
style=
"width:200px;"
></td>
</tr>
<tr>
<td
style=
"width:80px;"
>
序列号数量
</td>
<td
style=
"padding:5px;width:180px;"
>
<input
name=
"batAddTotal"
id=
"batAddTotal"
class=
"easyui-numberbox"
data-options=
"min:0,max:10000"
style=
"width: 180px;height: 20px"
/>
</td>
<td></td>
</tr>
<tr>
<td
style=
"height:30px;"
>
备注
</td>
<td
style=
"padding:5px"
colspan=
"3"
>
<textarea
name=
"remark"
id=
"batAddremark"
rows=
"2"
cols=
"2"
placeholder=
"暂无备注信息"
style=
"width: 468px; height:40px;"
></textarea>
</td>
<td></td>
</tr>
</table>
</div>
</div>
</form>
</div>
<div
id=
"bat-dlg-buttons"
>
<a
href=
"javascript:void(0)"
id=
"batAddSerialNumberBtn"
class=
"easyui-linkbutton"
iconCls=
"icon-ok"
>
保存
</a>
<a
href=
"javascript:void(0)"
id=
"batCancelSerialNumberBtn"
class=
"easyui-linkbutton"
iconCls=
"icon-cancel"
onclick=
"javascript:$('#batAddSerialNumberDlg').dialog('close')"
>
取消
</a>
</div>
<script
type=
"text/javascript"
>
...
...
@@ -153,8 +200,8 @@
}
},
{
title
:
'
商品名称
'
,
field
:
'
materialName
'
,
width
:
100
},
{
title
:
'
序列号
'
,
field
:
'
serialNumber
'
,
width
:
8
0
},
{
title
:
'
已卖出
'
,
field
:
'
isSell
'
,
width
:
15
0
,
formatter
:
function
(
value
)
{
{
title
:
'
序列号
'
,
field
:
'
serialNumber
'
,
width
:
20
0
},
{
title
:
'
已卖出
'
,
field
:
'
isSell
'
,
width
:
6
0
,
formatter
:
function
(
value
)
{
return
value
==
'
1
'
?
"
是
"
:
"
否
"
;
}
},
...
...
@@ -184,6 +231,15 @@
batDeleteSerialNumber
();
}
},
'
-
'
,
{
id
:
'
batAddSerialNumber
'
,
text
:
'
批量添加
'
,
iconCls
:
'
icon-basket_add
'
,
handler
:
function
()
{
batAddSerialNumber
();
}
},
],
onLoadError
:
function
()
{
$
.
messager
.
alert
(
'
页面加载提示
'
,
'
页面加载异常,请稍后再试!
'
,
'
error
'
);
...
...
@@ -489,6 +545,70 @@
return
dt
.
format
(
"
yyyy-MM-dd hh:mm:ss
"
);
//扩展的Date的format方法(上述插件实现)
}
/**
* 批量添加序列号
* */
function
batAddSerialNumber
(){
$
(
'
#batAddSerialNumberDlg
'
).
dialog
(
'
open
'
).
dialog
(
'
setTitle
'
,
'
<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/> 批量添加序列号信息
'
);
$
(
"
.window-mask
"
).
css
({
width
:
webW
,
height
:
webH
});
$
(
'
#batAddMaterialName
'
).
val
(
''
);
$
(
'
#batAddSerialNumberInput
'
).
val
(
''
);
$
(
'
#batAddTotal
'
).
val
(
'
100
'
);
$
(
'
#batAddremark
'
).
val
(
''
);
url
=
'
/serialNumber/batAddSerialNumber
'
;
}
//保存信息
$
(
"
#batAddSerialNumberBtn
"
).
off
(
"
click
"
).
on
(
"
click
"
,
function
()
{
if
(
!
$
(
'
#batAddMaterialName
'
).
val
())
{
$
.
messager
.
alert
(
'
提示
'
,
'
商品名称不能为空!
'
,
'
warning
'
);
return
;
}
if
(
!
$
(
'
#batAddSerialNumberInput
'
).
val
())
{
$
.
messager
.
alert
(
'
提示
'
,
'
序列号前缀不能为空!
'
,
'
warning
'
);
return
;
}
if
(
!
$
(
'
#batAddTotal
'
).
val
())
{
$
.
messager
.
alert
(
'
提示
'
,
'
序列号数量不能为空!
'
,
'
warning
'
);
return
;
}
var
materialName
=
$
(
'
#batAddMaterialName
'
).
val
();
var
serialNumberPrefix
=
$
(
'
#batAddSerialNumberInput
'
).
val
();
var
batAddTotal
=
$
(
'
#batAddTotal
'
).
val
();
var
remark
=
$
(
'
#batAddremark
'
).
val
();
$
.
ajax
({
type
:
"
post
"
,
url
:
url
,
dataType
:
"
json
"
,
async
:
false
,
data
:
({
materialName
:
materialName
,
serialNumberPrefix
:
serialNumberPrefix
,
batAddTotal
:
batAddTotal
,
remark
:
remark
}),
success
:
function
(
res
)
{
if
(
res
){
if
(
res
.
code
!=
200
){
$
.
messager
.
alert
(
'
提示
'
,
res
.
msg
,
'
error
'
);
return
;
}
if
(
res
.
code
===
200
)
{
$
(
'
#batAddSerialNumberDlg
'
).
dialog
(
'
close
'
);
//加载完以后重新初始化
var
opts
=
$
(
"
#tableData
"
).
datagrid
(
'
options
'
);
showSerialNumberDetails
(
opts
.
pageNumber
,
opts
.
pageSize
);
}
}
},
//此处添加错误处理
error
:
function
()
{
$
.
messager
.
alert
(
'
提示
'
,
'
保存序列化信息异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
});
</script>
</body>
...
...
src/main/java/com/jsh/erp/constants/BusinessConstants.java
View file @
ca1be886
...
...
@@ -57,6 +57,10 @@ public class BusinessConstants {
public
static
final
String
SUB_TYPE_RETAIL
=
"零售"
;
public
static
final
String
SUB_TYPE_SALES
=
"销售"
;
public
static
final
String
SUB_TYPE_TRANSFER
=
"调拨"
;
/**
* 批量插入sql时最大的数据条数
* */
public
static
final
int
BATCH_INSERT_MAX_NUMBER
=
500
;
...
...
src/main/java/com/jsh/erp/controller/SerialNumberController.java
View file @
ca1be886
...
...
@@ -88,6 +88,27 @@ public class SerialNumberController {
return
result
;
}
/**
* create by: cjl
* description:
*批量添加序列号
* create time: 2019/1/29 15:11
* @Param: materialName
* @Param: serialNumberPrefix
* @Param: batAddTotal
* @Param: remark
* @return java.lang.Object
*/
@PostMapping
(
"/serialNumber/batAddSerialNumber"
)
@ResponseBody
public
Object
batAddSerialNumber
(
@RequestParam
(
"materialName"
)
String
materialName
,
@RequestParam
(
"serialNumberPrefix"
)
String
serialNumberPrefix
,
@RequestParam
(
"batAddTotal"
)
Integer
batAddTotal
,
@RequestParam
(
"remark"
)
String
remark
){
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
serialNumberService
.
batAddSerialNumber
(
materialName
,
serialNumberPrefix
,
batAddTotal
,
remark
);
return
result
;
}
...
...
src/main/java/com/jsh/erp/datasource/mappers/SerialNumberMapperEx.java
View file @
ca1be886
...
...
@@ -56,5 +56,8 @@ public interface SerialNumberMapperEx {
* and depothead_Id='depotheadId' and is_Sell !='0' and delete_Flag !='1' {limit 0,count}
* */
int
cancelSerialNumber
(
@Param
(
"materialId"
)
Long
materialId
,
@Param
(
"depotheadId"
)
Long
depotheadId
,
@Param
(
"count"
)
Integer
count
,
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
);
/**
* 批量添加序列号
* */
int
batAddSerialNumber
(
@Param
(
"list"
)
List
<
SerialNumberEx
>
list
);
}
src/main/java/com/jsh/erp/service/serialNumber/SerialNumberService.java
View file @
ca1be886
...
...
@@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -210,38 +211,52 @@ public class SerialNumberService {
/**
* create by: cjl
* description:
* 根据商品名称判断给商品添加序列号是否可行
* 1、根据商品名称必须查询到唯一的商品
* 2、该商品必须已经启用序列号
* 3、该商品已绑定序列号数量小于商品现有库存
* 根据商品名称判断商品名称是否有效
* create time: 2019/1/23 17:04
* @Param: materialName
* @return Long 满足使用条件的商品的id
*/
public
Long
getSerialNumberMaterialIdBy
MaterialName
(
String
materialName
){
if
(
StringUtil
.
isNotEmpty
(
materialName
)){
public
Long
check
MaterialName
(
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
,
ExceptionConstants
.
MATERIAL_NOT_EXISTS_MSG
);
}
if
(
mlist
.
size
()
>
1
){
if
(
mlist
.
size
()
>
1
)
{
//商品信息不唯一
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_NOT_ONLY_CODE
,
ExceptionConstants
.
MATERIAL_NOT_ONLY_MSG
);
}
//获得唯一商品
if
(
BusinessConstants
.
ENABLE_SERIAL_NUMBER_NOT_ENABLED
.
equals
(
mlist
.
get
(
0
).
getEnableSerialNumber
())){
if
(
BusinessConstants
.
ENABLE_SERIAL_NUMBER_NOT_ENABLED
.
equals
(
mlist
.
get
(
0
).
getEnableSerialNumber
()))
{
//商品未开启序列号
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_NOT_ENABLE_SERIAL_NUMBER_CODE
,
ExceptionConstants
.
MATERIAL_NOT_ENABLE_SERIAL_NUMBER_MSG
);
}
return
mlist
.
get
(
0
).
getId
();
}
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
)){
//计算商品库存和目前占用的可用序列号数量关系
//库存=入库-出库
//入库数量
Long
materialId
=
mlist
.
get
(
0
).
getId
(
);
Long
materialId
=
checkMaterialName
(
materialName
);
int
inSum
=
depotItemService
.
findByTypeAndMaterialId
(
BusinessConstants
.
DEPOTHEAD_TYPE_STORAGE
,
materialId
);
//出库数量
int
outSum
=
depotItemService
.
findByTypeAndMaterialId
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
,
materialId
);
...
...
@@ -316,6 +331,47 @@ public class SerialNumberService {
return
serialNumberMapperEx
.
cancelSerialNumber
(
materialId
,
depotheadId
,
count
,
new
Date
(),
user
==
null
?
null
:
user
.
getId
());
}
/**
* create by: cjl
* description:
*批量添加序列号
* create time: 2019/1/29 15:11
* @Param: materialName
* @Param: serialNumberPrefix
* @Param: batAddTotal
* @Param: remark
* @return java.lang.Object
*/
public
void
batAddSerialNumber
(
String
materialName
,
String
serialNumberPrefix
,
Integer
batAddTotal
,
String
remark
)
{
if
(
StringUtil
.
isNotEmpty
(
materialName
)){
//查询商品id
Long
materialId
=
checkMaterialName
(
materialName
);
List
<
SerialNumberEx
>
list
=
null
;
//当前用户
User
userInfo
=
userService
.
getCurrentUser
();
Long
userId
=
userInfo
==
null
?
null
:
userInfo
.
getId
();
Date
date
=
new
Date
();
Long
million
=
date
.
getTime
();
int
insertNum
=
0
;
StringBuffer
prefixBuf
=
new
StringBuffer
(
serialNumberPrefix
).
append
(
million
);
do
{
list
=
new
ArrayList
<
SerialNumberEx
>();
int
forNum
=
BusinessConstants
.
BATCH_INSERT_MAX_NUMBER
>=
batAddTotal
?
batAddTotal:
BusinessConstants
.
BATCH_INSERT_MAX_NUMBER
;
for
(
int
i
=
0
;
i
<
forNum
;
i
++){
insertNum
++;
SerialNumberEx
each
=
new
SerialNumberEx
();
each
.
setMaterialId
(
materialId
);
each
.
setCreator
(
userId
);
each
.
setCreateTime
(
date
);
each
.
setUpdater
(
userId
);
each
.
setUpdateTime
(
date
);
each
.
setRemark
(
remark
);
each
.
setSerialNumber
(
new
StringBuffer
(
prefixBuf
.
toString
()).
append
(
insertNum
).
toString
());
list
.
add
(
each
);
}
serialNumberMapperEx
.
batAddSerialNumber
(
list
);
batAddTotal
-=
BusinessConstants
.
BATCH_INSERT_MAX_NUMBER
;
}
while
(
batAddTotal
>
0
);
}
}
}
src/main/resources/mapper_xml/SerialNumberMapperEx.xml
View file @
ca1be886
...
...
@@ -204,6 +204,18 @@
)
</if>
</update>
<insert
id=
"batAddSerialNumber"
useGeneratedKeys=
"true"
keyProperty=
"id"
keyColumn=
"id"
>
insert into jsh_serial_number
(material_Id, serial_Number, is_Sell, remark,delete_Flag,
create_Time, creator,update_Time, updater)
values
<foreach
collection=
'list'
item=
'each'
separator=
','
>
(#{each.materialId},#{each.serialNumber},'0',#{each.remark},'0',
#{each.createTime},#{each.creator},#{each.updateTime},#{each.updater}
)
</foreach>
</insert>
...
...
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