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
3e2bbd0a
Commit
3e2bbd0a
authored
Dec 03, 2021
by
季圣华
Browse files
解决多单位商品导入的bug
parent
4bb91404
Changes
7
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/docs/jsh_erp.sql
View file @
3e2bbd0a
...
...
@@ -879,10 +879,10 @@ CREATE TABLE `jsh_unit` (
-- ----------------------------
-- Records of jsh_unit
-- ----------------------------
INSERT
INTO
`jsh_unit`
VALUES
(
'15'
,
'个
,箱(1:
12)'
,
'个'
,
'箱'
,
null
,
null
,
'12'
,
null
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_unit`
VALUES
(
'19'
,
'个
,盒(1:
15)'
,
'个'
,
'盒'
,
null
,
null
,
'15'
,
null
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_unit`
VALUES
(
'20'
,
'盒
,箱(1:8
)'
,
'盒'
,
'箱'
,
null
,
null
,
'8'
,
null
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_unit`
VALUES
(
'21'
,
'瓶
,箱(1:
12)'
,
'瓶'
,
'箱'
,
null
,
null
,
'12'
,
null
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_unit`
VALUES
(
'15'
,
'个
/(箱=
12
个
)'
,
'个'
,
'箱'
,
null
,
null
,
'12'
,
null
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_unit`
VALUES
(
'19'
,
'个
/(盒=
15
个
)'
,
'个'
,
'盒'
,
null
,
null
,
'15'
,
null
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_unit`
VALUES
(
'20'
,
'盒
/(箱=8盒
)'
,
'盒'
,
'箱'
,
null
,
null
,
'8'
,
null
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_unit`
VALUES
(
'21'
,
'瓶
/(箱=
12
瓶
)'
,
'瓶'
,
'箱'
,
null
,
null
,
'12'
,
null
,
null
,
'63'
,
'0'
);
-- ----------------------------
-- Table structure for jsh_user
...
...
jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
3e2bbd0a
...
...
@@ -295,7 +295,7 @@ public class ExceptionConstants {
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
=
"抱歉,单位匹配不上,请完善计量单位信息!"
;
public
static
final
String
MATERIAL_UNIT_MATE_MSG
=
"抱歉,
商品条码:%s的
单位匹配不上,请完善计量单位信息!"
;
/**
* 单据信息
* type = 85
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
3e2bbd0a
...
...
@@ -382,7 +382,7 @@ public class DepotItemService {
Unit
unitInfo
=
materialService
.
findUnit
(
materialExtend
.
getMaterialId
());
//查询计量单位信息
if
(
StringUtil
.
isNotEmpty
(
unitInfo
.
getName
()))
{
String
basicUnit
=
unitInfo
.
getBasicUnit
();
//基本单位
if
(
unit
.
equals
(
basicUnit
))
{
//如果等于基
础
单位
if
(
unit
.
equals
(
basicUnit
))
{
//如果等于基
本
单位
depotItem
.
setBasicNumber
(
oNumber
);
//数量一致
}
else
if
(
unit
.
equals
(
unitInfo
.
getOtherUnit
()))
{
//如果等于副单位
depotItem
.
setBasicNumber
(
oNumber
.
multiply
(
new
BigDecimal
(
unitInfo
.
getRatio
()))
);
//数量乘以比例
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
3e2bbd0a
...
...
@@ -472,7 +472,7 @@ public class MaterialService {
String
color
=
ExcelUtils
.
getContent
(
src
,
i
,
3
);
//颜色
String
categoryName
=
ExcelUtils
.
getContent
(
src
,
i
,
4
);
//类别
String
expiryNum
=
ExcelUtils
.
getContent
(
src
,
i
,
5
);
//保质期
String
unit
=
ExcelUtils
.
getContent
(
src
,
i
,
6
);
//基
础
单位
String
unit
=
ExcelUtils
.
getContent
(
src
,
i
,
6
);
//基
本
单位
//校验名称、单位是否为空
if
(
StringUtil
.
isNotEmpty
(
name
)
&&
StringUtil
.
isNotEmpty
(
unit
))
{
MaterialWithInitStock
m
=
new
MaterialWithInitStock
();
...
...
@@ -516,14 +516,13 @@ public class MaterialService {
basicObj
.
put
(
"wholesaleDecimal"
,
wholesaleDecimal
);
basicObj
.
put
(
"lowDecimal"
,
lowDecimal
);
materialExObj
.
put
(
"basic"
,
basicObj
);
if
(
StringUtil
.
isNotEmpty
(
manyUnit
.
trim
())){
//多单位
String
manyUnitAll
=
unit
+
","
+
manyUnit
+
"(1:"
+
ratio
+
")"
;
Long
unitId
=
unitService
.
getUnitIdByName
(
manyUnitAll
);
if
(
StringUtil
.
isNotEmpty
(
manyUnit
)
&&
StringUtil
.
isNotEmpty
(
ratio
)){
//多单位
Long
unitId
=
unitService
.
getUnitIdByParam
(
unit
,
manyUnit
,
Integer
.
parseInt
(
ratio
.
trim
()));
if
(
unitId
!=
null
)
{
m
.
setUnitId
(
unitId
);
}
else
{
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_UNIT_MATE_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_UNIT_MATE_MSG
));
String
.
format
(
ExceptionConstants
.
MATERIAL_UNIT_MATE_MSG
,
manyBarCode
));
}
JSONObject
otherObj
=
new
JSONObject
();
otherObj
.
put
(
"barCode"
,
manyBarCode
);
...
...
@@ -544,11 +543,13 @@ public class MaterialService {
int
col
=
15
+
j
;
if
(
col
<
src
.
getColumns
()){
String
depotName
=
ExcelUtils
.
getContent
(
src
,
1
,
col
);
//获取仓库名称
Long
depotId
=
depotService
.
getIdByName
(
depotName
);
if
(
depotId
!=
0L
){
String
stockStr
=
ExcelUtils
.
getContent
(
src
,
i
,
col
);
if
(
StringUtil
.
isNotEmpty
(
stockStr
))
{
stockMap
.
put
(
depotId
,
parseBigDecimalEx
(
stockStr
));
if
(
StringUtil
.
isNotEmpty
(
depotName
))
{
Long
depotId
=
depotService
.
getIdByName
(
depotName
);
if
(
depotId
!=
0L
){
String
stockStr
=
ExcelUtils
.
getContent
(
src
,
i
,
col
);
if
(
StringUtil
.
isNotEmpty
(
stockStr
))
{
stockMap
.
put
(
depotId
,
parseBigDecimalEx
(
stockStr
));
}
}
}
}
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendService.java
View file @
3e2bbd0a
...
...
@@ -192,7 +192,7 @@ public class MaterialExtendService {
this
.
updateMaterialExtend
(
materialExtend
);
}
}
//处理条码的排序,基
础
单位排第一个
//处理条码的排序,基
本
单位排第一个
if
(
null
!=
sortJson
&&
sortJson
.
size
()>
0
)
{
//此处为更新的逻辑
for
(
int
i
=
0
;
i
<
sortJson
.
size
();
i
++)
{
...
...
@@ -207,7 +207,7 @@ public class MaterialExtendService {
this
.
updateMaterialExtend
(
materialExtend
);
}
}
else
{
//新增的时候将第一条记录设置为默认基
础
单位
//新增的时候将第一条记录设置为默认基
本
单位
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialExtend
>
meList
=
materialExtendMapper
.
selectByExample
(
example
);
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/unit/UnitService.java
View file @
3e2bbd0a
...
...
@@ -208,13 +208,17 @@ public class UnitService {
}
/**
* 根据名称获取类型
* @param name
* 根据条件查询单位id
* @param basicUnit
* @param otherUnit
* @param ratio
* @return
*/
public
Long
getUnitIdBy
N
am
e
(
String
name
){
public
Long
getUnitIdBy
Par
am
(
String
basicUnit
,
String
otherUnit
,
Integer
ratio
){
Long
unitId
=
null
;
UnitExample
example
=
new
UnitExample
();
example
.
createCriteria
().
andNameEqualTo
(
name
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
example
.
createCriteria
().
andBasicUnitEqualTo
(
basicUnit
).
andOtherUnitEqualTo
(
otherUnit
).
andRatioEqualTo
(
ratio
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Unit
>
list
=
unitMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
unitId
=
list
.
get
(
0
).
getId
();
...
...
jshERP-boot/src/main/java/com/jsh/erp/utils/ExcelUtils.java
View file @
3e2bbd0a
...
...
@@ -204,7 +204,11 @@ public class ExcelUtils {
public
static
String
getContent
(
Sheet
src
,
int
rowNum
,
int
colNum
)
{
return
src
.
getRow
(
rowNum
)[
colNum
].
getContents
().
trim
();
if
(
colNum
<
src
.
getRow
(
rowNum
).
length
)
{
return
src
.
getRow
(
rowNum
)[
colNum
].
getContents
().
trim
();
}
else
{
return
null
;
}
}
/**
...
...
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