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
decf45cf
Commit
decf45cf
authored
May 28, 2022
by
季圣华
Browse files
优化商品库存流水记录的接口,增加仓库参数
parent
4557a13f
Changes
4
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
decf45cf
...
...
@@ -61,28 +61,21 @@ public class DepotItemController {
private
RedisService
redisService
;
/**
*
只
根据商品
id
查询单据列表
* 根据
仓库和
商品查询单据列表
* @param mId
* @param request
* @return
*/
@GetMapping
(
value
=
"/findDetailBy
Type
AndMaterialId"
)
@ApiOperation
(
value
=
"
只
根据商品
id
查询单据列表"
)
public
String
findDetailBy
Type
AndMaterialId
(
@GetMapping
(
value
=
"/findDetailBy
DepotIds
AndMaterialId"
)
@ApiOperation
(
value
=
"根据
仓库和
商品查询单据列表"
)
public
String
findDetailBy
DepotIds
AndMaterialId
(
@RequestParam
(
value
=
Constants
.
PAGE_SIZE
,
required
=
false
)
Integer
pageSize
,
@RequestParam
(
value
=
Constants
.
CURRENT_PAGE
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
"materialId"
)
String
mId
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
String
>
parameterMap
=
ParamUtils
.
requestToMap
(
request
);
parameterMap
.
put
(
"mId"
,
mId
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
if
(
pageSize
!=
null
&&
pageSize
<=
0
)
{
pageSize
=
10
;
}
String
offset
=
ParamUtils
.
getPageOffset
(
currentPage
,
pageSize
);
if
(
StringUtil
.
isNotEmpty
(
offset
))
{
parameterMap
.
put
(
Constants
.
OFFSET
,
offset
);
}
List
<
DepotItemVo4DetailByTypeAndMId
>
list
=
depotItemService
.
findDetailByTypeAndMaterialIdList
(
parameterMap
);
@RequestParam
(
value
=
"depotIds"
,
required
=
false
)
String
depotIds
,
@RequestParam
(
"materialId"
)
Long
mId
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
List
<
DepotItemVo4DetailByTypeAndMId
>
list
=
depotItemService
.
findDetailByDepotIdsAndMaterialIdList
(
depotIds
,
mId
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
JSONArray
dataArray
=
new
JSONArray
();
if
(
list
!=
null
)
{
for
(
DepotItemVo4DetailByTypeAndMId
d:
list
)
{
...
...
@@ -109,7 +102,7 @@ public class DepotItemController {
return
returnJson
(
objectMap
,
"查找不到数据"
,
ErpInfo
.
OK
.
code
);
}
objectMap
.
put
(
"rows"
,
dataArray
);
objectMap
.
put
(
"total"
,
depotItemService
.
findDetailBy
Type
AndMaterialIdCount
s
(
parameterMap
));
objectMap
.
put
(
"total"
,
depotItemService
.
findDetailBy
DepotIds
AndMaterialIdCount
(
depotIds
,
mId
));
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java
View file @
decf45cf
...
...
@@ -29,12 +29,14 @@ public interface DepotItemMapperEx {
@Param
(
"type"
)
Integer
type
,
@Param
(
"remark"
)
String
remark
);
List
<
DepotItemVo4DetailByTypeAndMId
>
findDetailByTypeAndMaterialIdList
(
List
<
DepotItemVo4DetailByTypeAndMId
>
findDetailByDepotIdsAndMaterialIdList
(
@Param
(
"depotIdArray"
)
String
[]
depotIdArray
,
@Param
(
"mId"
)
Long
mId
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"rows"
)
Integer
rows
);
Long
findDetailByTypeAndMaterialIdCounts
(
Long
findDetailByDepotIdsAndMaterialIdCount
(
@Param
(
"depotIdArray"
)
String
[]
depotIdArray
,
@Param
(
"mId"
)
Long
mId
);
List
<
DepotItemVo4WithInfoEx
>
getDetailList
(
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
decf45cf
...
...
@@ -168,30 +168,28 @@ public class DepotItemService {
return
list
==
null
?
0
:
list
.
size
();
}
public
List
<
DepotItemVo4DetailByTypeAndMId
>
findDetailByTypeAndMaterialIdList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
mIdStr
=
map
.
get
(
"mId"
);
Long
mId
=
null
;
if
(!
StringUtil
.
isEmpty
(
mIdStr
))
{
mId
=
Long
.
parseLong
(
mIdStr
);
public
List
<
DepotItemVo4DetailByTypeAndMId
>
findDetailByDepotIdsAndMaterialIdList
(
String
depotIds
,
Long
mId
,
int
offset
,
int
rows
)
throws
Exception
{
String
[]
depotIdArray
=
null
;
if
(
StringUtil
.
isNotEmpty
(
depotIds
))
{
depotIdArray
=
depotIds
.
split
(
","
);
}
List
<
DepotItemVo4DetailByTypeAndMId
>
list
=
null
;
try
{
list
=
depotItemMapperEx
.
findDetailBy
Type
AndMaterialIdList
(
mId
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
)
);
list
=
depotItemMapperEx
.
findDetailBy
DepotIds
AndMaterialIdList
(
depotIdArray
,
mId
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
Long
findDetailByTypeAndMaterialIdCounts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
mIdStr
=
map
.
get
(
"mId"
);
Long
mId
=
null
;
if
(!
StringUtil
.
isEmpty
(
mIdStr
))
{
mId
=
Long
.
parseLong
(
mIdStr
);
public
Long
findDetailByDepotIdsAndMaterialIdCount
(
String
depotIds
,
Long
mId
)
throws
Exception
{
String
[]
depotIdArray
=
null
;
if
(
StringUtil
.
isNotEmpty
(
depotIds
))
{
depotIdArray
=
depotIds
.
split
(
","
);
}
Long
result
=
null
;
try
{
result
=
depotItemMapperEx
.
findDetailBy
Type
AndMaterialIdCount
s
(
mId
);
result
=
depotItemMapperEx
.
findDetailBy
DepotIds
AndMaterialIdCount
(
depotIdArray
,
mId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
...
...
jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
decf45cf
...
...
@@ -136,8 +136,9 @@
and ifnull(delete_flag,'0') !='1'
</select>
<select
id=
"findDetailByTypeAndMaterialIdList"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"DetailByTypeAndMIdResultMap"
>
select dh.number,me.bar_code,m.name material_name,dh.type,dh.sub_type,
<select
id=
"findDetailByDepotIdsAndMaterialIdList"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"DetailByTypeAndMIdResultMap"
>
select tb.* from
(select dh.number,me.bar_code,m.name material_name,dh.type,dh.sub_type,
case
when type='入库' then ifnull(di.basic_number,0)
when type='出库' then 0-di.basic_number
...
...
@@ -155,28 +156,68 @@
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
where
(
(dh.type!='其它'
and dh.sub_type!='调拨')
where (dh.type!='其它'
or (dh.type='其它' and dh.sub_type='组装单')
or (dh.type='其它' and dh.sub_type='拆卸单')
or (dh.type='其它' and dh.sub_type='盘点复盘'))
<if
test=
"depotIdArray != null"
>
and di.depot_id in (
<foreach
collection=
"depotIdArray"
item=
"depotId"
separator=
","
>
#{depotId}
</foreach>
)
</if>
and di.material_id = #{mId}
and ifnull(dh.delete_flag,'0') !='1'
ORDER BY oTime desc
union all
--单独构造记录:调拨入库
select dh.number,me.bar_code,m.name material_name,dh.type,dh.sub_type,
ifnull(di.basic_number,0) as b_num,
(select concat(name,'[调入]') from jsh_depot d where d.id=di.another_depot_id and ifnull(d.delete_flag,'0') !='1') as depotName,
date_format(dh.oper_time,'%Y-%m-%d %H:%i:%S') as oTime
from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
where dh.type='出库' and dh.sub_type='调拨'
<if
test=
"depotIdArray != null"
>
and di.another_depot_id in (
<foreach
collection=
"depotIdArray"
item=
"depotId"
separator=
","
>
#{depotId}
</foreach>
)
</if>
and di.material_id = #{mId}
and ifnull(dh.delete_flag,'0') !='1') tb
order by tb.oTime desc
<if
test=
"offset != null and rows != null"
>
limit #{offset},#{rows}
</if>
</select>
<select
id=
"findDetailBy
Type
AndMaterialIdCount
s
"
resultType=
"java.lang.Long"
>
select count(
1)
from jsh_depot_head dh
<select
id=
"findDetailBy
DepotIds
AndMaterialIdCount"
resultType=
"java.lang.Long"
>
select count(
tb.number) from
(select dh.number
from jsh_depot_head dh
left JOIN jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where
(
(dh.type!='其它'
and dh.sub_type!='调拨')
where (dh.type!='其它'
or (dh.type='其它' and dh.sub_type='组装单')
or (dh.type='其它' and dh.sub_type='拆卸单')
or (dh.type='其它' and dh.sub_type='盘点复盘'))
<if
test=
"depotIdArray != null"
>
and di.depot_id in (
<foreach
collection=
"depotIdArray"
item=
"depotId"
separator=
","
>
#{depotId}
</foreach>
)
</if>
and di.material_id =#{mId}
and ifnull(dh.delete_flag,'0') !='1'
union all
--单独构造记录:调拨入库
select dh.number from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where dh.type='出库' and dh.sub_type='调拨'
<if
test=
"depotIdArray != null"
>
and di.another_depot_id in (
<foreach
collection=
"depotIdArray"
item=
"depotId"
separator=
","
>
#{depotId}
</foreach>
)
</if>
and di.material_id = #{mId}
and ifnull(dh.delete_flag,'0') !='1') tb
</select>
<select
id=
"getDetailList"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"ResultWithInfoExMap"
>
...
...
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