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
c6a5689f
Commit
c6a5689f
authored
Aug 06, 2021
by
季圣华
Browse files
优化商品条码查询接口,支持选择多商品
parent
3269b487
Changes
5
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java
View file @
c6a5689f
...
...
@@ -7,6 +7,7 @@ import com.jsh.erp.constants.BusinessConstants;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.depot.DepotService
;
import
com.jsh.erp.service.depotItem.DepotItemService
;
import
com.jsh.erp.service.material.MaterialService
;
import
com.jsh.erp.service.redis.RedisService
;
...
...
@@ -45,6 +46,9 @@ public class MaterialController {
@Resource
private
UnitService
unitService
;
@Resource
private
DepotService
depotService
;
@Resource
private
RedisService
redisService
;
...
...
@@ -445,40 +449,63 @@ public class MaterialController {
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
String
[]
mpArr
=
mpList
.
split
(
","
);
MaterialVo4Unit
mu
=
new
MaterialVo4Unit
();
List
<
MaterialVo4Unit
>
list
=
materialService
.
getMaterialByBarCode
(
barCode
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
mu
=
list
.
get
(
0
);
String
expand
=
""
;
//扩展信息
for
(
int
i
=
0
;
i
<
mpArr
.
length
;
i
++)
{
if
(
mpArr
[
i
].
equals
(
"制造商"
))
{
expand
=
expand
+
((
mu
.
getMfrs
()
==
null
||
mu
.
getMfrs
().
equals
(
""
))
?
""
:
"("
+
mu
.
getMfrs
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"自定义1"
))
{
expand
=
expand
+
((
mu
.
getOtherField1
()
==
null
||
mu
.
getOtherField1
().
equals
(
""
))
?
""
:
"("
+
mu
.
getOtherField1
()
+
")"
);
for
(
MaterialVo4Unit
mvo:
list
)
{
String
expand
=
""
;
//扩展信息
for
(
int
i
=
0
;
i
<
mpArr
.
length
;
i
++)
{
if
(
mpArr
[
i
].
equals
(
"制造商"
))
{
expand
=
expand
+
((
mvo
.
getMfrs
()
==
null
||
mvo
.
getMfrs
().
equals
(
""
))
?
""
:
"("
+
mvo
.
getMfrs
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"自定义1"
))
{
expand
=
expand
+
((
mvo
.
getOtherField1
()
==
null
||
mvo
.
getOtherField1
().
equals
(
""
))
?
""
:
"("
+
mvo
.
getOtherField1
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"自定义2"
))
{
expand
=
expand
+
((
mvo
.
getOtherField2
()
==
null
||
mvo
.
getOtherField2
().
equals
(
""
))
?
""
:
"("
+
mvo
.
getOtherField2
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"自定义3"
))
{
expand
=
expand
+
((
mvo
.
getOtherField3
()
==
null
||
mvo
.
getOtherField3
().
equals
(
""
))
?
""
:
"("
+
mvo
.
getOtherField3
()
+
")"
);
}
}
if
(
mpArr
[
i
].
equals
(
"自定义2"
))
{
expand
=
expand
+
((
mu
.
getOtherField2
()
==
null
||
mu
.
getOtherField2
().
equals
(
""
))
?
""
:
"("
+
mu
.
getOtherField2
()
+
")"
);
mvo
.
setMaterialOther
(
expand
);
if
(
"LSCK"
.
equals
(
prefixNo
)
||
"LSTH"
.
equals
(
prefixNo
))
{
//零售价
mvo
.
setBillPrice
(
mvo
.
getCommodityDecimal
());
}
else
if
(
"CGDD"
.
equals
(
prefixNo
)
||
"CGRK"
.
equals
(
prefixNo
)
||
"CGTH"
.
equals
(
prefixNo
)
||
"QTRK"
.
equals
(
prefixNo
)
||
"DBCK"
.
equals
(
prefixNo
)
||
"ZZD"
.
equals
(
prefixNo
)
||
"CXD"
.
equals
(
prefixNo
)
)
{
//采购价
mvo
.
setBillPrice
(
mvo
.
getPurchaseDecimal
());
}
else
if
(
"XSDD"
.
equals
(
prefixNo
)
||
"XSCK"
.
equals
(
prefixNo
)
||
"XSTH"
.
equals
(
prefixNo
)
||
"QTCK"
.
equals
(
prefixNo
))
{
//销售价
mvo
.
setBillPrice
(
mvo
.
getWholesaleDecimal
());
}
if
(
mpArr
[
i
].
equals
(
"自定义3"
))
{
expand
=
expand
+
((
mu
.
getOtherField3
()
==
null
||
mu
.
getOtherField3
().
equals
(
""
))
?
""
:
"("
+
mu
.
getOtherField3
()
+
")"
);
//仓库id
JSONArray
depotArr
=
depotService
.
findDepotByCurrentUser
();
for
(
Object
obj:
depotArr
){
JSONObject
depotObj
=
JSONObject
.
parseObject
(
obj
.
toString
());
if
(
depotObj
.
get
(
"isDefault"
)!=
null
)
{
Boolean
isDefault
=
depotObj
.
getBoolean
(
"isDefault"
);
if
(
isDefault
)
{
Long
depotId
=
depotObj
.
getLong
(
"id"
);
mvo
.
setDepotId
(
depotId
);
//库存
BigDecimal
stock
=
depotItemService
.
getStockByParam
(
depotId
,
mvo
.
getId
(),
null
,
null
);
if
(
mvo
.
getUnitId
()!=
null
){
Unit
unit
=
unitService
.
getUnit
(
mvo
.
getUnitId
());
if
(
mvo
.
getCommodityUnit
().
equals
(
unit
.
getOtherUnit
()))
{
if
(
unit
.
getRatio
()!=
0
)
{
stock
=
stock
.
divide
(
BigDecimal
.
valueOf
(
unit
.
getRatio
()),
2
,
BigDecimal
.
ROUND_HALF_UP
);
}
}
}
mvo
.
setStock
(
stock
);
}
}
}
}
mu
.
setMaterialOther
(
expand
);
if
(
"LSCK"
.
equals
(
prefixNo
)
||
"LSTH"
.
equals
(
prefixNo
))
{
//零售价
mu
.
setBillPrice
(
mu
.
getCommodityDecimal
());
}
else
if
(
"CGDD"
.
equals
(
prefixNo
)
||
"CGRK"
.
equals
(
prefixNo
)
||
"CGTH"
.
equals
(
prefixNo
)
||
"QTRK"
.
equals
(
prefixNo
)
||
"DBCK"
.
equals
(
prefixNo
)
||
"ZZD"
.
equals
(
prefixNo
)
||
"CXD"
.
equals
(
prefixNo
)
)
{
//采购价
mu
.
setBillPrice
(
mu
.
getPurchaseDecimal
());
}
else
if
(
"XSDD"
.
equals
(
prefixNo
)
||
"XSCK"
.
equals
(
prefixNo
)
||
"XSTH"
.
equals
(
prefixNo
)
||
"QTCK"
.
equals
(
prefixNo
))
{
//销售价
mu
.
setBillPrice
(
mu
.
getWholesaleDecimal
());
}
}
res
.
code
=
200
;
res
.
data
=
mu
;
res
.
data
=
list
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
res
.
code
=
500
;
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialVo4Unit.java
View file @
c6a5689f
...
...
@@ -36,6 +36,8 @@ public class MaterialVo4Unit extends Material{
private
String
sku
;
private
Long
depotId
;
public
String
getUnitName
()
{
return
unitName
;
}
...
...
@@ -163,4 +165,12 @@ public class MaterialVo4Unit extends Material{
public
void
setSku
(
String
sku
)
{
this
.
sku
=
sku
;
}
public
Long
getDepotId
()
{
return
depotId
;
}
public
void
setDepotId
(
Long
depotId
)
{
this
.
depotId
=
depotId
;
}
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java
View file @
c6a5689f
...
...
@@ -84,7 +84,7 @@ public interface MaterialMapperEx {
int
setUnitIdToNull
(
@Param
(
"id"
)
Long
id
);
List
<
MaterialVo4Unit
>
getMaterialByBarCode
(
@Param
(
"barCode"
)
String
barCode
);
List
<
MaterialVo4Unit
>
getMaterialByBarCode
(
@Param
(
"barCode
Array
"
)
String
[]
barCode
Array
);
List
<
MaterialVo4Unit
>
getListWithStock
(
@Param
(
"depotId"
)
Long
depotId
,
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
c6a5689f
...
...
@@ -803,7 +803,8 @@ public class MaterialService {
}
public
List
<
MaterialVo4Unit
>
getMaterialByBarCode
(
String
barCode
)
{
return
materialMapperEx
.
getMaterialByBarCode
(
barCode
);
String
[]
barCodeArray
=
barCode
.
split
(
","
);
return
materialMapperEx
.
getMaterialByBarCode
(
barCodeArray
);
}
public
List
<
MaterialVo4Unit
>
getListWithStock
(
Long
depotId
,
List
<
Long
>
idList
,
String
materialParam
,
Integer
offset
,
Integer
rows
)
{
...
...
jshERP-boot/src/main/resources/mapper_xml/MaterialMapperEx.xml
View file @
c6a5689f
...
...
@@ -307,8 +307,14 @@
from jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
where me.bar_code = #{barCode}
where
me.bar_code in (
<foreach
collection=
"barCodeArray"
item=
"barCode"
separator=
","
>
#{barCode}
</foreach>
)
and ifnull(m.delete_flag,'0') !='1'
order by me.id desc
</select>
<update
id=
"setUnitIdToNull"
>
...
...
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