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
61b40f47
Commit
61b40f47
authored
Nov 25, 2021
by
季圣华
Browse files
优化商品库存查询接口
parent
de53f2eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java
View file @
61b40f47
...
...
@@ -592,7 +592,7 @@ public class MaterialController {
* 商品库存查询
* @param currentPage
* @param pageSize
* @param depotId
* @param depotId
s
* @param categoryId
* @param materialParam
* @param mpList
...
...
@@ -606,7 +606,7 @@ public class MaterialController {
@ApiOperation
(
value
=
"商品库存查询"
)
public
BaseResponseInfo
getListWithStock
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
value
=
"depotId"
,
required
=
false
)
Lo
ng
depotId
,
@RequestParam
(
value
=
"depotId
s
"
,
required
=
false
)
Stri
ng
depotId
s
,
@RequestParam
(
value
=
"categoryId"
,
required
=
false
)
Long
categoryId
,
@RequestParam
(
"materialParam"
)
String
materialParam
,
@RequestParam
(
"zeroStock"
)
Integer
zeroStock
,
...
...
@@ -618,13 +618,24 @@ public class MaterialController {
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
try
{
List
<
Long
>
idList
=
new
ArrayList
<>();
List
<
Long
>
depotList
=
new
ArrayList
<>();
if
(
categoryId
!=
null
){
idList
=
materialService
.
getListByParentId
(
categoryId
);
}
List
<
MaterialVo4Unit
>
dataList
=
materialService
.
getListWithStock
(
depotId
,
idList
,
StringUtil
.
toNull
(
materialParam
),
zeroStock
,
if
(
StringUtil
.
isNotEmpty
(
depotIds
))
{
depotList
=
StringUtil
.
strToLongList
(
depotIds
);
}
else
{
//未选择仓库时默认为当前用户有权限的仓库
JSONArray
depotArr
=
depotService
.
findDepotByCurrentUser
();
for
(
Object
obj:
depotArr
)
{
JSONObject
object
=
JSONObject
.
parseObject
(
obj
.
toString
());
depotList
.
add
(
object
.
getLong
(
"id"
));
}
}
List
<
MaterialVo4Unit
>
dataList
=
materialService
.
getListWithStock
(
depotList
,
idList
,
StringUtil
.
toNull
(
materialParam
),
zeroStock
,
StringUtil
.
safeSqlParse
(
column
),
StringUtil
.
safeSqlParse
(
order
),
(
currentPage
-
1
)*
pageSize
,
pageSize
);
int
total
=
materialService
.
getListWithStockCount
(
depot
Id
,
idList
,
StringUtil
.
toNull
(
materialParam
),
zeroStock
);
MaterialVo4Unit
materialVo4Unit
=
materialService
.
getTotalStockAndPrice
(
depot
Id
,
idList
,
StringUtil
.
toNull
(
materialParam
));
int
total
=
materialService
.
getListWithStockCount
(
depot
List
,
idList
,
StringUtil
.
toNull
(
materialParam
),
zeroStock
);
MaterialVo4Unit
materialVo4Unit
=
materialService
.
getTotalStockAndPrice
(
depot
List
,
idList
,
StringUtil
.
toNull
(
materialParam
));
map
.
put
(
"total"
,
total
);
map
.
put
(
"currentStock"
,
materialVo4Unit
.
getCurrentStock
());
map
.
put
(
"currentStockPrice"
,
materialVo4Unit
.
getCurrentStockPrice
());
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java
View file @
61b40f47
...
...
@@ -89,7 +89,7 @@ public interface MaterialMapperEx {
List
<
MaterialVo4Unit
>
getMaterialByBarCode
(
@Param
(
"barCodeArray"
)
String
[]
barCodeArray
);
List
<
MaterialVo4Unit
>
getListWithStock
(
@Param
(
"depot
Id"
)
Long
depot
Id
,
@Param
(
"depot
List"
)
List
<
Long
>
depot
List
,
@Param
(
"idList"
)
List
<
Long
>
idList
,
@Param
(
"materialParam"
)
String
materialParam
,
@Param
(
"zeroStock"
)
Integer
zeroStock
,
...
...
@@ -99,13 +99,13 @@ public interface MaterialMapperEx {
@Param
(
"rows"
)
Integer
rows
);
int
getListWithStockCount
(
@Param
(
"depot
Id"
)
Long
depot
Id
,
@Param
(
"depot
List"
)
List
<
Long
>
depot
List
,
@Param
(
"idList"
)
List
<
Long
>
idList
,
@Param
(
"materialParam"
)
String
materialParam
,
@Param
(
"zeroStock"
)
Integer
zeroStock
);
MaterialVo4Unit
getTotalStockAndPrice
(
@Param
(
"depot
Id"
)
Long
depot
Id
,
@Param
(
"depot
List"
)
List
<
Long
>
depot
List
,
@Param
(
"idList"
)
List
<
Long
>
idList
,
@Param
(
"materialParam"
)
String
materialParam
);
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
61b40f47
...
...
@@ -872,17 +872,17 @@ public class MaterialService {
return
materialMapperEx
.
getMaterialByBarCode
(
barCodeArray
);
}
public
List
<
MaterialVo4Unit
>
getListWithStock
(
Long
depot
Id
,
List
<
Long
>
idList
,
String
materialParam
,
Integer
zeroStock
,
public
List
<
MaterialVo4Unit
>
getListWithStock
(
List
<
Long
>
depot
List
,
List
<
Long
>
idList
,
String
materialParam
,
Integer
zeroStock
,
String
column
,
String
order
,
Integer
offset
,
Integer
rows
)
{
return
materialMapperEx
.
getListWithStock
(
depot
Id
,
idList
,
materialParam
,
zeroStock
,
column
,
order
,
offset
,
rows
);
return
materialMapperEx
.
getListWithStock
(
depot
List
,
idList
,
materialParam
,
zeroStock
,
column
,
order
,
offset
,
rows
);
}
public
int
getListWithStockCount
(
Long
depot
Id
,
List
<
Long
>
idList
,
String
materialParam
,
Integer
zeroStock
)
{
return
materialMapperEx
.
getListWithStockCount
(
depot
Id
,
idList
,
materialParam
,
zeroStock
);
public
int
getListWithStockCount
(
List
<
Long
>
depot
List
,
List
<
Long
>
idList
,
String
materialParam
,
Integer
zeroStock
)
{
return
materialMapperEx
.
getListWithStockCount
(
depot
List
,
idList
,
materialParam
,
zeroStock
);
}
public
MaterialVo4Unit
getTotalStockAndPrice
(
Long
depot
Id
,
List
<
Long
>
idList
,
String
materialParam
)
{
return
materialMapperEx
.
getTotalStockAndPrice
(
depot
Id
,
idList
,
materialParam
);
public
MaterialVo4Unit
getTotalStockAndPrice
(
List
<
Long
>
depot
List
,
List
<
Long
>
idList
,
String
materialParam
)
{
return
materialMapperEx
.
getTotalStockAndPrice
(
depot
List
,
idList
,
materialParam
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
...
...
jshERP-boot/src/main/resources/mapper_xml/MaterialMapperEx.xml
View file @
61b40f47
...
...
@@ -339,8 +339,11 @@
select m.*, me.commodity_unit unitName, mc.name categoryName, me.bar_code,
ifnull(me.purchase_decimal,0) purchase_decimal,
(select ifnull(sum(mis.number),0) from jsh_material_initial_stock mis where mis.material_id = m.id
<if
test=
"depotId != null"
>
and mis.depot_id = #{depotId}
<if
test=
"depotList.size()>0"
>
and mis.depot_id in
<foreach
collection=
"depotList"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</if>
) initialStock,
ifnull(sum(mcs.current_number),0) currentStock,
...
...
@@ -352,8 +355,11 @@
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
where 1=1
and me.default_flag=1
<if
test=
"depotId != null"
>
and mcs.depot_id = #{depotId}
<if
test=
"depotList.size()>0"
>
and mcs.depot_id in
<foreach
collection=
"depotList"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</if>
<if
test=
"idList.size()>0"
>
and m.category_id in
...
...
@@ -390,8 +396,11 @@
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
where 1=1
and me.default_flag=1
<if
test=
"depotId != null"
>
and mcs.depot_id = #{depotId}
<if
test=
"depotList.size()>0"
>
and mcs.depot_id in
<foreach
collection=
"depotList"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</if>
<if
test=
"idList.size()>0"
>
and m.category_id in
...
...
@@ -422,8 +431,11 @@
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
where 1=1
and me.default_flag=1
<if
test=
"depotId != null"
>
and mcs.depot_id = #{depotId}
<if
test=
"depotList.size()>0"
>
and mcs.depot_id in
<foreach
collection=
"depotList"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</if>
<if
test=
"idList.size()>0"
>
and m.category_id in
...
...
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