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
5ee37924
Commit
5ee37924
authored
Dec 15, 2020
by
季圣华
Browse files
给商品选择接口增加商品类别的查询条件
parent
0388b8fa
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/controller/MaterialController.java
View file @
5ee37924
...
...
@@ -152,7 +152,8 @@ public class MaterialController {
* @return
*/
@GetMapping
(
value
=
"/findBySelect"
)
public
JSONObject
findBySelect
(
@RequestParam
(
value
=
"q"
,
required
=
false
)
String
q
,
public
JSONObject
findBySelect
(
@RequestParam
(
value
=
"categoryId"
,
required
=
false
)
Long
categoryId
,
@RequestParam
(
value
=
"q"
,
required
=
false
)
String
q
,
@RequestParam
(
"mpList"
)
String
mpList
,
@RequestParam
(
value
=
"depotId"
,
required
=
false
)
Long
depotId
,
@RequestParam
(
"page"
)
Integer
currentPage
,
...
...
@@ -161,9 +162,9 @@ public class MaterialController {
JSONObject
object
=
new
JSONObject
();
try
{
Long
tenantId
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"tenantId"
).
toString
());
List
<
MaterialVo4Unit
>
dataList
=
materialService
.
findBySelectWithBarCode
(
q
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
List
<
MaterialVo4Unit
>
dataList
=
materialService
.
findBySelectWithBarCode
(
categoryId
,
q
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
String
[]
mpArr
=
mpList
.
split
(
","
);
int
total
=
materialService
.
findBySelectWithBarCodeCount
(
q
);
int
total
=
materialService
.
findBySelectWithBarCodeCount
(
categoryId
,
q
);
object
.
put
(
"total"
,
total
);
JSONArray
dataArray
=
new
JSONArray
();
//存放数据json数组
...
...
src/main/java/com/jsh/erp/datasource/mappers/MaterialCategoryMapperEx.java
View file @
5ee37924
...
...
@@ -37,4 +37,6 @@ public interface MaterialCategoryMapperEx {
List
<
MaterialCategory
>
getMaterialCategoryBySerialNo
(
@Param
(
"serialNo"
)
String
serialNo
,
@Param
(
"id"
)
Long
id
);
List
<
MaterialCategory
>
getMaterialCategoryListByCategoryIds
(
@Param
(
"parentIds"
)
String
[]
categoryIds
);
List
<
MaterialCategory
>
getListByParentId
(
Long
parentId
);
}
src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java
View file @
5ee37924
...
...
@@ -41,11 +41,13 @@ public interface MaterialMapperEx {
List
<
MaterialVo4Unit
>
findByIdWithBarCode
(
@Param
(
"meId"
)
Long
meId
);
List
<
MaterialVo4Unit
>
findBySelectWithBarCode
(
@Param
(
"q"
)
String
q
,
List
<
MaterialVo4Unit
>
findBySelectWithBarCode
(
@Param
(
"idList"
)
List
<
Long
>
idList
,
@Param
(
"q"
)
String
q
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"rows"
)
Integer
rows
);
int
findBySelectWithBarCodeCount
(
@Param
(
"q"
)
String
q
);
int
findBySelectWithBarCodeCount
(
@Param
(
"idList"
)
List
<
Long
>
idList
,
@Param
(
"q"
)
String
q
);
List
<
MaterialVo4Unit
>
findByAll
(
@Param
(
"name"
)
String
name
,
...
...
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
5ee37924
...
...
@@ -46,6 +46,8 @@ public class MaterialService {
@Resource
private
MaterialExtendMapperEx
materialExtendMapperEx
;
@Resource
private
MaterialCategoryMapperEx
materialCategoryMapperEx
;
@Resource
private
LogService
logService
;
@Resource
private
UserService
userService
;
...
...
@@ -338,26 +340,57 @@ public class MaterialService {
return
list
;
}
public
List
<
MaterialVo4Unit
>
findBySelectWithBarCode
(
String
q
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
public
List
<
Long
>
getListByParentId
(
Long
parentId
)
{
List
<
Long
>
idList
=
new
ArrayList
<
Long
>();
List
<
MaterialCategory
>
list
=
materialCategoryMapperEx
.
getListByParentId
(
parentId
);
idList
.
add
(
parentId
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
getIdListByParentId
(
idList
,
parentId
);
}
return
idList
;
}
public
List
<
Long
>
getIdListByParentId
(
List
<
Long
>
idList
,
Long
parentId
){
List
<
MaterialCategory
>
list
=
materialCategoryMapperEx
.
getListByParentId
(
parentId
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
for
(
MaterialCategory
mc
:
list
){
idList
.
add
(
mc
.
getId
());
getIdListByParentId
(
idList
,
mc
.
getId
());
}
}
return
idList
;
}
public
List
<
MaterialVo4Unit
>
findBySelectWithBarCode
(
Long
categoryId
,
String
q
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
List
<
Long
>
idList
=
new
ArrayList
<>();
if
(
categoryId
!=
null
){
Long
parentId
=
categoryId
;
idList
=
getListByParentId
(
parentId
);
}
if
(
StringUtil
.
isNotEmpty
(
q
))
{
q
=
q
.
replace
(
"'"
,
""
);
}
list
=
materialMapperEx
.
findBySelectWithBarCode
(
q
,
offset
,
rows
);
list
=
materialMapperEx
.
findBySelectWithBarCode
(
idList
,
q
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
int
findBySelectWithBarCodeCount
(
String
q
)
throws
Exception
{
public
int
findBySelectWithBarCodeCount
(
Long
categoryId
,
String
q
)
throws
Exception
{
int
result
=
0
;
try
{
List
<
Long
>
idList
=
new
ArrayList
<>();
if
(
categoryId
!=
null
){
Long
parentId
=
categoryId
;
idList
=
getListByParentId
(
parentId
);
}
if
(
StringUtil
.
isNotEmpty
(
q
))
{
q
=
q
.
replace
(
"'"
,
""
);
}
result
=
materialMapperEx
.
findBySelectWithBarCodeCount
(
q
);
result
=
materialMapperEx
.
findBySelectWithBarCodeCount
(
idList
,
q
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
...
...
src/main/resources/mapper_xml/MaterialCategoryMapperEx.xml
View file @
5ee37924
...
...
@@ -46,6 +46,10 @@
ofType=
"com.jsh.erp.datasource.vo.TreeNode"
select=
"getNextNodeTree"
/>
</resultMap>
<resultMap
id=
"ResultCategoryMapList"
type=
"com.jsh.erp.datasource.entities.MaterialCategory"
>
<result
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, name
</sql>
...
...
@@ -123,4 +127,12 @@
and ifnull(status,'0') !='2'
</select>
<select
id=
"getListByParentId"
resultMap=
"ResultCategoryMapList"
>
SELECT id FROM jsh_material_category
where 1=1
<if
test=
"parentId != null and parentId !=''"
>
and parent_id = #{parentId}
</if>
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper_xml/MaterialMapperEx.xml
View file @
5ee37924
...
...
@@ -106,6 +106,12 @@
<if
test=
"q != null"
>
and (m.name like '%${q}%' or me.bar_code like '%${q}%')
</if>
<if
test=
"idList.size()>0"
>
and m.category_id in
<foreach
collection=
"idList"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</if>
and ifnull(m.delete_flag,'0') !='1'
ORDER BY id desc
<if
test=
"offset != null and rows != null"
>
...
...
@@ -121,6 +127,12 @@
<if
test=
"q != null"
>
and (m.name like '%${q}%' or me.bar_code like '%${q}%')
</if>
<if
test=
"idList.size()>0"
>
and m.category_id in
<foreach
collection=
"idList"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</if>
and ifnull(m.delete_flag,'0') !='1'
</select>
...
...
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