Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dc-cost-system
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
dc-cost-system
Commits
15ab7751
Commit
15ab7751
authored
Aug 20, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
费用系统的批量搜索
parent
09950487
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
26 deletions
+86
-26
pom.xml
cost-core/pom.xml
+15
-0
CostListSearchController.java
...other/other_cost/controller/CostListSearchController.java
+3
-5
CostListSearchDao.java
.../java/com/blt/other/other_cost/dao/CostListSearchDao.java
+2
-2
CostListSearchService.java
...m/blt/other/other_cost/service/CostListSearchService.java
+1
-1
CostListSearchServiceImpl.java
...er/other_cost/service/impl/CostListSearchServiceImpl.java
+6
-6
CostListSearchMapper.xml
cost-core/src/main/resources/mapper/CostListSearchMapper.xml
+26
-12
CostListSearchServiceTest.java
...t/other/other_cost/service/CostListSearchServiceTest.java
+33
-0
No files found.
cost-core/pom.xml
View file @
15ab7751
...
...
@@ -36,6 +36,7 @@
<org.apache.poi>
3.9
</org.apache.poi>
<commons.fileupload>
1.3.1
</commons.fileupload>
<commons.io>
2.4
</commons.io>
<commons-lang3.verson>
3.10
</commons-lang3.verson>
</properties>
<dependencies>
...
...
@@ -172,6 +173,20 @@
<artifactId>
commons-io
</artifactId>
<version>
${commons.io}
</version>
</dependency>
<!--apache lang 工具包-->
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
${commons-lang3.verson}
</version>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
20.0
</version>
</dependency>
<!-- POI end-->
<dependency>
...
...
cost-core/src/main/java/com/blt/other/other_cost/controller/CostListSearchController.java
View file @
15ab7751
...
...
@@ -3,7 +3,6 @@ package com.blt.other.other_cost.controller;
import
com.blt.other.other_commons.utils.AxiosUtil
;
import
com.blt.other.other_commons.utils.MyMapperUtil
;
import
com.blt.other.other_cost.service.CostListSearchService
;
import
com.blt.other.other_cost.service.CostService
;
import
com.blt.other.other_cost.vo.CostListSearchKeysVo
;
import
com.blt.other.other_database.model.CostDomain
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -12,13 +11,11 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
@RestController
...
...
@@ -29,14 +26,15 @@ public class CostListSearchController {
private
CostListSearchService
costListSearchService
;
@PostMapping
(
"/search/key"
)
public
Map
<
String
,
Object
>
getByKey
(
HttpServletResponse
response
,
HttpServletRequest
request
){
public
Map
<
String
,
Object
>
getByKey
(
HttpServletResponse
response
,
HttpServletRequest
request
){
AxiosUtil
.
setCors
(
response
,
request
);
String
key
=
request
.
getParameter
(
"key"
);
String
pageNumStr
=
request
.
getParameter
(
"pageNum"
);
String
pageSizeStr
=
request
.
getParameter
(
"pageSize"
);
Map
<
String
,
Object
>
map
=
costListSearchService
.
seachByKey
(
key
,
Integer
.
parseInt
(
pageNumStr
),
Integer
.
parseInt
(
pageSizeStr
));
Map
<
String
,
Object
>
map
=
costListSearchService
.
sea
r
chByKey
(
key
,
Integer
.
parseInt
(
pageNumStr
),
Integer
.
parseInt
(
pageSizeStr
));
map
.
put
(
"success"
,
true
);
return
map
;
}
...
...
cost-core/src/main/java/com/blt/other/other_cost/dao/CostListSearchDao.java
View file @
15ab7751
...
...
@@ -15,10 +15,10 @@ public interface CostListSearchDao {
/**
* 通过关键字模糊查询
* @param key
* @param key
s
* @return
*/
List
<
CostDomain
>
selectByKey
(
@Param
(
"key
"
)
String
key
);
List
<
CostDomain
>
selectByKey
(
@Param
(
"key
s"
)
List
<
String
>
keys
);
List
<
CostDomain
>
selectByKeys
(
CostListSearchKeysVo
searchKeysVo
);
...
...
cost-core/src/main/java/com/blt/other/other_cost/service/CostListSearchService.java
View file @
15ab7751
...
...
@@ -14,7 +14,7 @@ public interface CostListSearchService {
* @param key
* @return
*/
Map
<
String
,
Object
>
sea
chByKey
(
String
key
,
int
pageNum
,
int
pageSize
);
Map
<
String
,
Object
>
sea
rchByKey
(
String
key
,
int
pageNum
,
int
pageSize
);
List
<
CostDto
>
domainListToDto
(
List
<
CostDomain
>
domains
);
...
...
cost-core/src/main/java/com/blt/other/other_cost/service/impl/CostListSearchServiceImpl.java
View file @
15ab7751
...
...
@@ -10,15 +10,15 @@ import com.blt.other.other_database.mapper.StatusMapper;
import
com.blt.other.other_database.model.CostDomain
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.collections.ListUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
CostListSearchServiceImpl
implements
CostListSearchService
{
...
...
@@ -31,10 +31,10 @@ public class CostListSearchServiceImpl implements CostListSearchService {
private
CostService
costService
;
@Override
public
Map
<
String
,
Object
>
sea
chByKey
(
String
key
,
int
pageNum
,
int
pageSize
)
{
public
Map
<
String
,
Object
>
sea
rchByKey
(
String
key
,
int
pageNum
,
int
pageSize
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
PageHelper
.
startPage
(
pageNum
,
pageSize
);
List
<
CostDomain
>
costDomains
=
costListSearchDao
.
selectByKey
(
key
);
List
<
CostDomain
>
costDomains
=
costListSearchDao
.
selectByKey
(
Lists
.
newArrayList
(
key
.
split
(
","
)).
stream
().
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
())
);
List
<
CostDto
>
dtos
=
domainListToDto
(
costDomains
);
PageInfo
<
CostDomain
>
pageInfo
=
new
PageInfo
<>(
costDomains
);
result
.
put
(
"costs"
,
dtos
);
...
...
cost-core/src/main/resources/mapper/CostListSearchMapper.xml
View file @
15ab7751
...
...
@@ -7,18 +7,32 @@
*
FROM
cost
WHERE
cost_plan_no = #{key}
OR
cost_no LIKE CONCAT('%',#{key},'%')
OR
create_username LIKE CONCAT('%',#{key},'%')
OR
type_name LIKE CONCAT('%',#{key},'%')
OR
kind_name LIKE CONCAT('%',#{key},'%')
OR
company_name LIKE CONCAT('%',#{key},'%')
WHERE false
<foreach
collection=
"keys"
item=
"key"
index=
"index"
>
<if
test=
"key != null and key != '' "
>
or cost_plan_no = #{key}
</if>
</foreach>
<foreach
collection=
"keys"
item=
"key"
index=
"index"
>
<if
test=
"key != null and key != '' "
>
or cost_no LIKE CONCAT('%',#{key},'%')
</if>
</foreach>
<foreach
collection=
"keys"
item=
"key"
index=
"index"
>
<if
test=
"key != null and key != '' "
>
or type_name LIKE CONCAT('%',#{key},'%')
</if>
</foreach>
<foreach
collection=
"keys"
item=
"key"
index=
"index"
>
<if
test=
"key != null and key != '' "
>
or kind_name LIKE CONCAT('%',#{key},'%')
</if>
</foreach>
<foreach
collection=
"keys"
item=
"key"
index=
"index"
>
<if
test=
"key != null and key != '' "
>
or company_name LIKE CONCAT('%',#{key},'%')
</if>
</foreach>
</select>
<select
id=
"selectByKeys"
resultType=
"com.blt.other.other_database.model.CostDomain"
>
...
...
cost-core/src/test/java/com/blt/other/other_cost/service/CostListSearchServiceTest.java
0 → 100644
View file @
15ab7751
package
com
.
blt
.
other
.
other_cost
.
service
;
import
com.alibaba.fastjson.JSON
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.annotation.Resource
;
import
java.util.Map
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/8/20 4:33 下午
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
CostListSearchServiceTest
{
@Resource
CostListSearchService
costListSearchService
;
@Test
public
void
searchByKey
()
{
Map
<
String
,
Object
>
result
=
costListSearchService
.
searchByKey
(
"F024926,F024927,F024928"
,
1
,
100
);
System
.
out
.
println
(
JSON
.
toJSONString
(
result
));
}
}
Write
Preview
Markdown
is supported
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