Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
pseer
gxpt_ht
Commits
86ba4804
Commit
86ba4804
authored
Nov 11, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改房间分页,因排序和LIMIT冲突导致数据异常
parent
990b5277
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
20 deletions
+62
-20
SRoomController.java
...ain/java/share/web/controller/system/SRoomController.java
+8
-17
ISRoomService.java
...tem/src/main/java/share/system/service/ISRoomService.java
+3
-0
SRoomServiceImpl.java
...main/java/share/system/service/impl/SRoomServiceImpl.java
+51
-3
No files found.
share-admin/src/main/java/share/web/controller/system/SRoomController.java
View file @
86ba4804
package
share
.
web
.
controller
.
system
;
package
share
.
web
.
controller
.
system
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
share.common.annotation.Log
;
import
share.common.annotation.Log
;
import
share.common.core.controller.BaseController
;
import
share.common.core.controller.BaseController
;
import
share.common.core.domain.AjaxResult
;
import
share.common.core.domain.AjaxResult
;
import
share.common.core.page.TableDataInfo
;
import
share.common.enums.BusinessType
;
import
share.common.enums.BusinessType
;
import
share.common.utils.poi.ExcelUtil
;
import
share.system.domain.Device
;
import
share.system.domain.Device
;
import
share.system.domain.SRoom
;
import
share.system.domain.SRoom
;
import
share.system.domain.vo.SRoomVo
;
import
share.system.service.ISRoomService
;
import
share.system.service.ISRoomService
;
import
share.common.utils.poi.ExcelUtil
;
import
share.common.core.page.TableDataInfo
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
/**
/**
* 房间Controller
* 房间Controller
...
@@ -43,9 +36,7 @@ public class SRoomController extends BaseController
...
@@ -43,9 +36,7 @@ public class SRoomController extends BaseController
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
SRoom
sRoom
)
public
TableDataInfo
list
(
SRoom
sRoom
)
{
{
startPage
();
return
sRoomService
.
pageList
(
sRoom
);
List
<
SRoom
>
list
=
sRoomService
.
selectSRoomList
(
sRoom
);
return
getDataTable
(
list
);
}
}
/**
/**
...
...
share-system/src/main/java/share/system/service/ISRoomService.java
View file @
86ba4804
package
share
.
system
.
service
;
package
share
.
system
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
share.common.core.page.TableDataInfo
;
import
share.system.domain.Device
;
import
share.system.domain.Device
;
import
share.system.domain.SPack
;
import
share.system.domain.SPack
;
import
share.system.domain.SRoom
;
import
share.system.domain.SRoom
;
...
@@ -110,4 +111,6 @@ public interface ISRoomService extends IService<SRoom>
...
@@ -110,4 +111,6 @@ public interface ISRoomService extends IService<SRoom>
List
<
SRoomVo
>
convertDoListToVoList
(
List
<
SRoom
>
roomList
);
List
<
SRoomVo
>
convertDoListToVoList
(
List
<
SRoom
>
roomList
);
List
<
SRoom
>
roomNameByIds
(
List
<
Long
>
longs
);
List
<
SRoom
>
roomNameByIds
(
List
<
Long
>
longs
);
TableDataInfo
pageList
(
SRoom
sRoom
);
}
}
share-system/src/main/java/share/system/service/impl/SRoomServiceImpl.java
View file @
86ba4804
...
@@ -7,6 +7,9 @@ import org.apache.commons.collections4.CollectionUtils;
...
@@ -7,6 +7,9 @@ import org.apache.commons.collections4.CollectionUtils;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
share.common.core.page.PageDomain
;
import
share.common.core.page.TableDataInfo
;
import
share.common.core.page.TableSupport
;
import
share.common.enums.*
;
import
share.common.enums.*
;
import
share.common.exception.base.BaseException
;
import
share.common.exception.base.BaseException
;
import
share.common.utils.DateUtils
;
import
share.common.utils.DateUtils
;
...
@@ -81,11 +84,19 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
...
@@ -81,11 +84,19 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
return
new
ArrayList
<>();
return
new
ArrayList
<>();
}
}
List
<
Long
>
storeIds
=
roomList
.
stream
().
map
(
SRoom:
:
getStoreId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
storeIds
=
roomList
.
stream
().
map
(
SRoom:
:
getStoreId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
roomIds
=
roomList
.
stream
().
map
(
SRoom:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Map
>
storeList
=
sStoreService
.
optionList
(
storeIds
);
List
<
Map
>
storeList
=
sStoreService
.
optionList
(
storeIds
);
List
<
SRoomPack
>
list
=
roomPackService
.
list
(
new
LambdaQueryWrapper
<
SRoomPack
>().
in
(
SRoomPack:
:
getRoomId
,
roomIds
));
Map
<
Long
,
List
<
Long
>>
listMap
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
SRoomPack:
:
getRoomId
,
Collectors
.
mapping
(
SRoomPack:
:
getPackId
,
Collectors
.
toList
())));
List
<
SPack
>
packList
=
packService
.
list
(
new
LambdaQueryWrapper
<
SPack
>().
eq
(
SPack:
:
getType
,
YesNoEnum
.
yes
.
getIndex
()));
Map
<
Long
,
List
<
SPack
>>
packMap
=
new
HashMap
<>();
//循环listMap
for
(
Map
.
Entry
<
Long
,
List
<
Long
>>
entry
:
listMap
.
entrySet
())
{
packMap
.
put
(
entry
.
getKey
(),
packList
.
stream
().
filter
(
o
->
entry
.
getValue
().
contains
(
o
.
getId
())).
collect
(
Collectors
.
toList
()));
}
roomList
.
forEach
(
o
->
{
roomList
.
forEach
(
o
->
{
List
<
Long
>
roomId
=
roomPackService
.
selectPackListByRoomId
(
o
.
getId
());
o
.
setPackIds
(
CollectionUtils
.
isNotEmpty
(
listMap
.
get
(
o
.
getId
()))
?
listMap
.
get
(
o
.
getId
()).
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
","
))
:
""
);
o
.
setPackIds
(
roomId
.
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
","
)));
o
.
setPackList
(
CollectionUtils
.
isNotEmpty
(
packMap
.
get
(
o
.
getId
()))
?
packMap
.
get
(
o
.
getId
())
:
new
ArrayList
<>());
o
.
setPackList
(
packService
.
selectPackListByIds
(
roomId
));
storeList
.
stream
().
forEach
(
store
->
{
storeList
.
stream
().
forEach
(
store
->
{
if
(
o
.
getStoreId
().
compareTo
(
Long
.
parseLong
(
store
.
get
(
"id"
).
toString
()))
==
0
)
{
if
(
o
.
getStoreId
().
compareTo
(
Long
.
parseLong
(
store
.
get
(
"id"
).
toString
()))
==
0
)
{
o
.
setStoreName
(
store
.
getOrDefault
(
"name"
,
""
).
toString
());
o
.
setStoreName
(
store
.
getOrDefault
(
"name"
,
""
).
toString
());
...
@@ -485,4 +496,41 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
...
@@ -485,4 +496,41 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
return
this
.
list
(
queryWrapper
);
return
this
.
list
(
queryWrapper
);
}
}
@Override
public
TableDataInfo
pageList
(
SRoom
sRoom
)
{
List
<
SRoom
>
roomList
=
baseMapper
.
selectSRoomList
(
sRoom
);
TableDataInfo
tableDataInfo
=
new
TableDataInfo
();
tableDataInfo
.
setTotal
(
roomList
.
size
());
PageDomain
pageDomain
=
TableSupport
.
buildPageRequest
();
Integer
pageNum
=
pageDomain
.
getPageNum
();
Integer
pageSize
=
pageDomain
.
getPageSize
();
int
start
=
(
pageNum
-
1
)
*
pageSize
;
int
end
=
Math
.
min
(
start
+
pageSize
,
roomList
.
size
());
List
<
SRoom
>
pagedList
=
roomList
.
subList
(
start
,
end
);
List
<
Long
>
storeIds
=
pagedList
.
stream
().
map
(
SRoom:
:
getStoreId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
roomIds
=
pagedList
.
stream
().
map
(
SRoom:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Map
>
storeList
=
sStoreService
.
optionList
(
storeIds
);
List
<
SRoomPack
>
list
=
roomPackService
.
list
(
new
LambdaQueryWrapper
<
SRoomPack
>().
in
(
SRoomPack:
:
getRoomId
,
roomIds
));
Map
<
Long
,
List
<
Long
>>
listMap
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
SRoomPack:
:
getRoomId
,
Collectors
.
mapping
(
SRoomPack:
:
getPackId
,
Collectors
.
toList
())));
List
<
SPack
>
packList
=
packService
.
list
(
new
LambdaQueryWrapper
<
SPack
>().
eq
(
SPack:
:
getType
,
YesNoEnum
.
yes
.
getIndex
()));
Map
<
Long
,
List
<
SPack
>>
packMap
=
new
HashMap
<>();
//循环listMap
for
(
Map
.
Entry
<
Long
,
List
<
Long
>>
entry
:
listMap
.
entrySet
())
{
packMap
.
put
(
entry
.
getKey
(),
packList
.
stream
().
filter
(
o
->
entry
.
getValue
().
contains
(
o
.
getId
())).
collect
(
Collectors
.
toList
()));
}
roomList
.
forEach
(
o
->
{
o
.
setPackIds
(
CollectionUtils
.
isNotEmpty
(
listMap
.
get
(
o
.
getId
()))
?
listMap
.
get
(
o
.
getId
()).
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
","
))
:
""
);
o
.
setPackList
(
CollectionUtils
.
isNotEmpty
(
packMap
.
get
(
o
.
getId
()))
?
packMap
.
get
(
o
.
getId
())
:
new
ArrayList
<>());
storeList
.
stream
().
forEach
(
store
->
{
if
(
o
.
getStoreId
().
compareTo
(
Long
.
parseLong
(
store
.
get
(
"id"
).
toString
()))
==
0
)
{
o
.
setStoreName
(
store
.
getOrDefault
(
"name"
,
""
).
toString
());
}
});
});
tableDataInfo
.
setRows
(
pagedList
);
tableDataInfo
.
setCode
(
200
);
tableDataInfo
.
setMsg
(
"查询成功"
);
return
tableDataInfo
;
}
}
}
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