Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-evbusiness-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 626f6f62
authored
Nov 17, 2023
by
林永健
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+] 新增根据设备号获取充电枪详情接口
1 parent
fe9b5b67
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
platform-evbusiness/src/main/java/cn/com/glsx/evbusiness/modules/controller/ChargingGunController.java
platform-evbusiness/src/main/java/cn/com/glsx/evbusiness/modules/service/ChargingGunService.java
platform-evbusiness/src/main/resources/mapper/ChargingGunMapper.xml
platform-evbusiness/src/main/java/cn/com/glsx/evbusiness/modules/controller/ChargingGunController.java
View file @
626f6f6
...
@@ -41,4 +41,10 @@ public class ChargingGunController {
...
@@ -41,4 +41,10 @@ public class ChargingGunController {
public
ChargingGunResponse
detail
(
@PathVariable
(
"id"
)
Long
id
)
{
public
ChargingGunResponse
detail
(
@PathVariable
(
"id"
)
Long
id
)
{
return
gunService
.
detail
(
id
);
return
gunService
.
detail
(
id
);
}
}
@Operation
(
summary
=
"根据设备号(桩号+枪号)查看详情"
,
description
=
"查询充电枪详情"
)
@GetMapping
(
"/getByDeviceNo/{deviceNo}"
)
public
ChargingGunResponse
getByDeviceNo
(
@PathVariable
(
"deviceNo"
)
String
deviceNo
)
{
return
gunService
.
getByDeviceNo
(
deviceNo
);
}
}
}
platform-evbusiness/src/main/java/cn/com/glsx/evbusiness/modules/service/ChargingGunService.java
View file @
626f6f6
...
@@ -69,6 +69,16 @@ public class ChargingGunService {
...
@@ -69,6 +69,16 @@ public class ChargingGunService {
return
res
;
return
res
;
}
}
public
ChargingGunResponse
getByDeviceNo
(
String
deviceNo
)
{
if
(!
StringUtils
.
hasLength
(
deviceNo
)
||
deviceNo
.
length
()
<
2
)
{
throw
new
RuntimeException
(
"设备不存在"
);
}
String
pileId
=
deviceNo
.
substring
(
0
,
deviceNo
.
length
()
-
2
);
String
gunNumber
=
deviceNo
.
substring
(
deviceNo
.
length
()
-
2
);
ChargingGun
res
=
gunMapper
.
findByPileIdAndNumber
(
pileId
,
Byte
.
parseByte
(
gunNumber
));
return
detail
(
res
);
}
/**
/**
* 同步上传数据到枪实体
* 同步上传数据到枪实体
*/
*/
...
@@ -94,7 +104,7 @@ public class ChargingGunService {
...
@@ -94,7 +104,7 @@ public class ChargingGunService {
public
void
saveOrUpdate
(
ChargingGun
entity
)
{
public
void
saveOrUpdate
(
ChargingGun
entity
)
{
// 来自设备端同步的设备,并无业务属性name,需要构建
// 来自设备端同步的设备,并无业务属性name,需要构建
entity
.
setName
(
StringUtils
.
hasLength
(
entity
.
getName
())
?
entity
.
getName
()
:
String
.
format
(
"%s-%d"
,
entity
.
getPileId
(),
entity
.
getGunNumber
()));
entity
.
setName
(
StringUtils
.
hasLength
(
entity
.
getName
())
?
entity
.
getName
()
:
String
.
format
(
"%s-%
02
d"
,
entity
.
getPileId
(),
entity
.
getGunNumber
()));
if
(
Objects
.
isNull
(
entity
.
getId
()))
{
if
(
Objects
.
isNull
(
entity
.
getId
()))
{
gunMapper
.
insert
(
entity
);
gunMapper
.
insert
(
entity
);
log
.
info
(
"新增充电枪数据, entity: {}"
,
entity
);
log
.
info
(
"新增充电枪数据, entity: {}"
,
entity
);
...
...
platform-evbusiness/src/main/resources/mapper/ChargingGunMapper.xml
View file @
626f6f6
...
@@ -36,6 +36,6 @@
...
@@ -36,6 +36,6 @@
</select>
</select>
<select
id=
"findByPileIdAndNumber"
resultMap=
"BaseResult"
>
<select
id=
"findByPileIdAndNumber"
resultMap=
"BaseResult"
>
select * from charging_gun where pile
I
d = #{pileId} and gun_number = #{gunNumber}
select * from charging_gun where pile
_i
d = #{pileId} and gun_number = #{gunNumber}
</select>
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
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