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
81465e5d
Commit
81465e5d
authored
Aug 20, 2021
by
季圣华
Browse files
优化商品导入功能
parent
d7ade048
Changes
3
Show whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
81465e5d
...
@@ -287,6 +287,9 @@ public class ExceptionConstants {
...
@@ -287,6 +287,9 @@ public class ExceptionConstants {
//商品条码重复
//商品条码重复
public
static
final
int
MATERIAL_BARCODE_EXISTS_CODE
=
8000005
;
public
static
final
int
MATERIAL_BARCODE_EXISTS_CODE
=
8000005
;
public
static
final
String
MATERIAL_BARCODE_EXISTS_MSG
=
"商品条码:%s重复"
;
public
static
final
String
MATERIAL_BARCODE_EXISTS_MSG
=
"商品条码:%s重复"
;
//商品-单位匹配不上
public
static
final
int
MATERIAL_UNIT_MATE_CODE
=
8000006
;
public
static
final
String
MATERIAL_UNIT_MATE_MSG
=
"抱歉,单位匹配不上,请完善计量单位信息!"
;
/**
/**
* 单据信息
* 单据信息
* type = 85
* type = 85
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
81465e5d
...
@@ -441,6 +441,8 @@ public class MaterialService {
...
@@ -441,6 +441,8 @@ public class MaterialService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
BaseResponseInfo
importExcel
(
Sheet
src
,
HttpServletRequest
request
)
throws
Exception
{
public
BaseResponseInfo
importExcel
(
Sheet
src
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
info
=
new
BaseResponseInfo
();
try
{
List
<
Depot
>
depotList
=
depotService
.
getDepot
();
List
<
Depot
>
depotList
=
depotService
.
getDepot
();
int
depotCount
=
depotList
.
size
();
int
depotCount
=
depotList
.
size
();
List
<
MaterialWithInitStock
>
mList
=
new
ArrayList
<>();
List
<
MaterialWithInitStock
>
mList
=
new
ArrayList
<>();
...
@@ -484,7 +486,12 @@ public class MaterialService {
...
@@ -484,7 +486,12 @@ public class MaterialService {
if
(
StringUtil
.
isNotEmpty
(
manyUnit
.
trim
())){
//多单位
if
(
StringUtil
.
isNotEmpty
(
manyUnit
.
trim
())){
//多单位
String
manyUnitAll
=
unit
+
","
+
manyUnit
+
"(1:"
+
ratio
+
")"
;
String
manyUnitAll
=
unit
+
","
+
manyUnit
+
"(1:"
+
ratio
+
")"
;
Long
unitId
=
unitService
.
getUnitIdByName
(
manyUnitAll
);
Long
unitId
=
unitService
.
getUnitIdByName
(
manyUnitAll
);
if
(
unitId
!=
null
)
{
m
.
setUnitId
(
unitId
);
m
.
setUnitId
(
unitId
);
}
else
{
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_UNIT_MATE_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_UNIT_MATE_MSG
));
}
JSONObject
otherObj
=
new
JSONObject
();
JSONObject
otherObj
=
new
JSONObject
();
otherObj
.
put
(
"barCode"
,
manyBarCode
);
otherObj
.
put
(
"barCode"
,
manyBarCode
);
otherObj
.
put
(
"commodityUnit"
,
manyUnit
);
otherObj
.
put
(
"commodityUnit"
,
manyUnit
);
...
@@ -521,8 +528,6 @@ public class MaterialService {
...
@@ -521,8 +528,6 @@ public class MaterialService {
logService
.
insertLog
(
"商品"
,
logService
.
insertLog
(
"商品"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_IMPORT
).
append
(
mList
.
size
()).
append
(
BusinessConstants
.
LOG_DATA_UNIT
).
toString
(),
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_IMPORT
).
append
(
mList
.
size
()).
append
(
BusinessConstants
.
LOG_DATA_UNIT
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
BaseResponseInfo
info
=
new
BaseResponseInfo
();
try
{
Long
mId
=
0L
;
Long
mId
=
0L
;
for
(
MaterialWithInitStock
m:
mList
)
{
for
(
MaterialWithInitStock
m:
mList
)
{
//判断该商品是否存在,如果不存在就新增,如果存在就更新
//判断该商品是否存在,如果不存在就新增,如果存在就更新
...
@@ -598,6 +603,9 @@ public class MaterialService {
...
@@ -598,6 +603,9 @@ public class MaterialService {
}
}
info
.
code
=
200
;
info
.
code
=
200
;
info
.
data
=
"导入成功"
;
info
.
data
=
"导入成功"
;
}
catch
(
BusinessRunTimeException
e
)
{
info
.
code
=
e
.
getCode
();
info
.
data
=
e
.
getData
().
get
(
"message"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
info
.
code
=
500
;
info
.
code
=
500
;
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/unit/UnitService.java
View file @
81465e5d
...
@@ -190,7 +190,7 @@ public class UnitService {
...
@@ -190,7 +190,7 @@ public class UnitService {
* @param name
* @param name
*/
*/
public
Long
getUnitIdByName
(
String
name
){
public
Long
getUnitIdByName
(
String
name
){
Long
unitId
=
0L
;
Long
unitId
=
null
;
UnitExample
example
=
new
UnitExample
();
UnitExample
example
=
new
UnitExample
();
example
.
createCriteria
().
andNameEqualTo
(
name
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
example
.
createCriteria
().
andNameEqualTo
(
name
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Unit
>
list
=
unitMapper
.
selectByExample
(
example
);
List
<
Unit
>
list
=
unitMapper
.
selectByExample
(
example
);
...
...
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