Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-standard-interfaces
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 775d8f39
authored
Jun 13, 2022
by
向延琳
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
根据sn查询增加批量查询
1 parent
0a8dbe47
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
0 deletions
src/main/java/cn/com/glsx/stdinterface/modules/controller/BatteryController.java
src/main/java/cn/com/glsx/stdinterface/modules/mapper/DevicePowerMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/service/BatteryService.java
src/main/resources/mapper/DevicePowerMapper.xml
src/main/java/cn/com/glsx/stdinterface/modules/controller/BatteryController.java
View file @
775d8f3
...
...
@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.Collection
;
import
java.util.List
;
/**
* @author xiangyanlin
...
...
@@ -42,4 +44,10 @@ public class BatteryController implements BatteryClient {
public
R
<
DevicePowerDTO
>
getDevicePowerBySn
(
@RequestParam
(
"sn"
)
String
sn
)
{
return
R
.
ok
().
data
(
batteryService
.
getDevicePowerBySn
(
sn
));
}
@GetMapping
(
"/queryListBySn"
)
@Override
public
R
<
List
<
DevicePowerDTO
>>
getDevicePowerListBySn
(
Collection
<
String
>
sn
)
{
return
R
.
ok
().
data
(
batteryService
.
getDevicePowerListBySn
(
sn
));
}
}
src/main/java/cn/com/glsx/stdinterface/modules/mapper/DevicePowerMapper.java
View file @
775d8f3
...
...
@@ -5,6 +5,7 @@ import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -19,6 +20,13 @@ public interface DevicePowerMapper extends CommonBaseMapper<DevicePower> {
DevicePower
selectBySn
(
@Param
(
"sn"
)
String
sn
,
@Param
(
"vdId"
)
Long
vdId
);
/**
* 根据设备号获取
* @param sn 设备号集合
* @return 集合
*/
List
<
DevicePower
>
listBySn
(
@Param
(
"sn"
)
Collection
<
String
>
sn
);
/**
* 批量插入或修改
* @param entities
* @return
...
...
src/main/java/cn/com/glsx/stdinterface/modules/service/BatteryService.java
View file @
775d8f3
...
...
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
...
...
@@ -69,6 +70,7 @@ public class BatteryService {
DevicePower
devicePower
=
convert
(
devicePowerDTO
,
createdBy
,
updatedBy
,
vdId
);
DevicePower
devicePowerOld
=
devicePowerMapper
.
selectBySn
(
devicePowerDTO
.
getSn
(),
vdId
);
//TODO 失效过期的绑定关系 @xiangyanlin
if
(
Objects
.
isNull
(
devicePowerOld
))
{
devicePowerMapper
.
insert
(
devicePower
);
return
;
...
...
@@ -186,4 +188,18 @@ public class BatteryService {
return
DevicePowerConverter
.
INSTANCE
.
convertTo
(
devicePower
);
}
/**
* 根据sn获取
*/
public
List
<
DevicePowerDTO
>
getDevicePowerListBySn
(
Collection
<
String
>
sn
)
{
if
(
CollectionUtils
.
isEmpty
(
sn
))
{
return
Lists
.
newArrayList
();
}
List
<
DevicePower
>
devicePowers
=
devicePowerMapper
.
listBySn
(
sn
);
if
(
CollectionUtils
.
isEmpty
(
devicePowers
))
{
return
Lists
.
newArrayList
();
}
return
DevicePowerConverter
.
INSTANCE
.
convertTo
(
devicePowers
);
}
}
src/main/resources/mapper/DevicePowerMapper.xml
View file @
775d8f3
...
...
@@ -39,6 +39,15 @@
limit 1
</select>
<select
id=
"listBySn"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device_power
<foreach
collection=
"sn"
item=
"sn"
index=
"index"
open=
"("
close=
")"
separator=
","
>
#{sn}
</foreach>
</select>
<insert
id=
"insertOrUpdateBatch"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into t_device_power(sn, vd_id, alarm_time, soc, del_flag, created_date, created_by, updated_date, updated_by)
values
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment