Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Z
zhmes-agecal
Project
Project
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
耿迪迪
zhmes-agecal
Commits
bffaa226
Commit
bffaa226
authored
Sep 16, 2025
by
wanghao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 给所有设备上电 断电
parent
2650274c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
207 additions
and
5 deletions
+207
-5
TStoreyInfoController.java
...ehong/web/controller/equipment/TStoreyInfoController.java
+16
-0
TStoreyInfoMapper.java
...main/java/com/zehong/system/mapper/TStoreyInfoMapper.java
+2
-0
ITStoreyInfoService.java
...n/java/com/zehong/system/service/ITStoreyInfoService.java
+4
-0
TStoreyInfoServiceImpl.java
...om/zehong/system/service/impl/TStoreyInfoServiceImpl.java
+120
-0
TStoreyInfoMapper.xml
...em/src/main/resources/mapper/system/TStoreyInfoMapper.xml
+8
-0
storey.js
zhmes-agecal-web/src/api/storey/storey.js
+14
-0
index.vue
zhmes-agecal-web/src/views/storey/index.vue
+43
-5
No files found.
zhmes-agecal-admin/src/main/java/com/zehong/web/controller/equipment/TStoreyInfoController.java
View file @
bffaa226
...
@@ -88,6 +88,22 @@ public class TStoreyInfoController extends BaseController
...
@@ -88,6 +88,22 @@ public class TStoreyInfoController extends BaseController
return
tStoreyInfoService
.
batchReadingCabinetStatus
(
fEquipmentCode
);
return
tStoreyInfoService
.
batchReadingCabinetStatus
(
fEquipmentCode
);
}
}
/**
* 给所有设备下电
*/
@GetMapping
(
value
=
"/powerOffAllStore"
)
public
AjaxResult
powerOffAllStore
()
{
return
tStoreyInfoService
.
powerOffAllStore
();
}
/**
* 给所有设备上电
*/
@GetMapping
(
value
=
"/powerOnAllStore"
)
public
AjaxResult
powerOnAllStore
()
{
return
tStoreyInfoService
.
powerOnAllStore
();
}
/**
/**
* 获取老化层信息详细信息
* 获取老化层信息详细信息
*/
*/
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/mapper/TStoreyInfoMapper.java
View file @
bffaa226
...
@@ -62,6 +62,8 @@ public interface TStoreyInfoMapper
...
@@ -62,6 +62,8 @@ public interface TStoreyInfoMapper
*/
*/
public
int
updateTStoreyInfo
(
TStoreyInfo
tStoreyInfo
);
public
int
updateTStoreyInfo
(
TStoreyInfo
tStoreyInfo
);
public
int
updateAllStatusAndAgingStartTime
(
TStoreyInfo
tStoreyInfo
);
public
int
updateBatch
(
@Param
(
"storeyInfos"
)
List
<
TStoreyInfo
>
storeyInfos
);
public
int
updateBatch
(
@Param
(
"storeyInfos"
)
List
<
TStoreyInfo
>
storeyInfos
);
/**
/**
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/service/ITStoreyInfoService.java
View file @
bffaa226
...
@@ -45,6 +45,10 @@ public interface ITStoreyInfoService
...
@@ -45,6 +45,10 @@ public interface ITStoreyInfoService
public
AjaxResult
batchReadingCabinetStatus
(
String
fEquipmentCode
);
public
AjaxResult
batchReadingCabinetStatus
(
String
fEquipmentCode
);
public
AjaxResult
powerOffAllStore
();
public
AjaxResult
powerOnAllStore
();
/**
/**
* 新增老化层信息
* 新增老化层信息
*
*
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/service/impl/TStoreyInfoServiceImpl.java
View file @
bffaa226
package
com
.
zehong
.
system
.
service
.
impl
;
package
com
.
zehong
.
system
.
service
.
impl
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
import
com.serotonin.modbus4j.ModbusMaster
;
import
com.serotonin.modbus4j.ModbusMaster
;
import
com.serotonin.modbus4j.exception.ErrorResponseException
;
import
com.serotonin.modbus4j.exception.ErrorResponseException
;
...
@@ -35,6 +39,8 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
...
@@ -35,6 +39,8 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
@Resource
@Resource
private
TEquipmentInfoMapper
equipmentInfoMapper
;
private
TEquipmentInfoMapper
equipmentInfoMapper
;
private
final
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
10
);
/**
/**
* 查询老化层信息
* 查询老化层信息
*
*
...
@@ -166,6 +172,120 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
...
@@ -166,6 +172,120 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return
tStoreyInfoMapper
.
queryByDepartmentId
(
fEquipmentId
);
return
tStoreyInfoMapper
.
queryByDepartmentId
(
fEquipmentId
);
}
}
public
AjaxResult
powerOffAllStore
()
{
List
<
String
>
types
=
Arrays
.
asList
(
"1"
,
"2"
);
List
<
TEquipmentInfo
>
equipmentInfos
=
equipmentInfoMapper
.
selectTEquipmentList
(
types
);
if
(
equipmentInfos
.
size
()
==
0
)
{
return
AjaxResult
.
error
(
"无设备信息!!!"
);
}
// 收集所有异步任务
List
<
CompletableFuture
<
TEquipmentInfo
>>
futures
=
equipmentInfos
.
stream
()
.
map
(
equipmentInfo
->
CompletableFuture
.
supplyAsync
(()
->
{
ModbusMaster
master
=
null
;
List
<
Integer
>
registerOffsets
=
Arrays
.
asList
(
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
);
try
{
master
=
Modbus4jUtils
.
getMaster
(
equipmentInfo
.
getfPowerOutageIp
(),
equipmentInfo
.
getfPowerOutagePort
());
for
(
Integer
registerOffset
:
registerOffsets
)
{
Boolean
aBoolean
=
Modbus4jUtils
.
readCoilStatus
(
master
,
1
,
registerOffset
);
if
(
aBoolean
)
{
Modbus4jUtils
.
writeCoil
(
master
,
1
,
registerOffset
,
false
);
}
}
}
catch
(
ModbusInitException
|
ModbusTransportException
|
ErrorResponseException
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
// 建议在这里关闭master连接,避免资源泄露
if
(
master
!=
null
)
{
try
{
master
.
destroy
();
}
catch
(
Exception
e
)
{
// 处理关闭异常
}
}
}
return
equipmentInfo
;
},
executorService
))
.
collect
(
Collectors
.
toList
());
// 等待所有异步任务完成
CompletableFuture
<
Void
>
allFutures
=
CompletableFuture
.
allOf
(
futures
.
toArray
(
new
CompletableFuture
[
0
])
);
// 所有任务完成后执行数据库更新
allFutures
.
thenRun
(()
->
{
TStoreyInfo
tStoreyInfo
=
new
TStoreyInfo
();
tStoreyInfo
.
setfStatus
(
"0"
);
tStoreyInfo
.
setfAgingStartTime
(
null
);
tStoreyInfoMapper
.
updateAllStatusAndAgingStartTime
(
tStoreyInfo
);
}).
join
();
// 阻塞等待所有操作完成
return
AjaxResult
.
success
();
}
/**
* 批量开灯
* @return r
*/
@Override
public
AjaxResult
powerOnAllStore
()
{
List
<
String
>
types
=
Arrays
.
asList
(
"1"
,
"2"
);
List
<
TEquipmentInfo
>
equipmentInfos
=
equipmentInfoMapper
.
selectTEquipmentList
(
types
);
if
(
equipmentInfos
.
size
()
==
0
)
{
return
AjaxResult
.
error
(
"无设备信息!!!"
);
}
// 收集所有异步任务
List
<
CompletableFuture
<
TEquipmentInfo
>>
futures
=
equipmentInfos
.
stream
()
.
map
(
equipmentInfo
->
CompletableFuture
.
supplyAsync
(()
->
{
ModbusMaster
master
=
null
;
List
<
Integer
>
registerOffsets
=
Arrays
.
asList
(
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
);
try
{
master
=
Modbus4jUtils
.
getMaster
(
equipmentInfo
.
getfPowerOutageIp
(),
equipmentInfo
.
getfPowerOutagePort
());
for
(
Integer
registerOffset
:
registerOffsets
)
{
Boolean
aBoolean
=
Modbus4jUtils
.
readCoilStatus
(
master
,
1
,
registerOffset
);
if
(!
aBoolean
)
{
Modbus4jUtils
.
writeCoil
(
master
,
1
,
registerOffset
,
true
);
}
}
}
catch
(
ModbusInitException
|
ModbusTransportException
|
ErrorResponseException
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
// 建议在这里关闭master连接,避免资源泄露
if
(
master
!=
null
)
{
try
{
master
.
destroy
();
}
catch
(
Exception
e
)
{
// 处理关闭异常
}
}
}
return
equipmentInfo
;
},
executorService
))
.
collect
(
Collectors
.
toList
());
// 等待所有异步任务完成
CompletableFuture
<
Void
>
allFutures
=
CompletableFuture
.
allOf
(
futures
.
toArray
(
new
CompletableFuture
[
0
])
);
// 所有任务完成后执行数据库更新
allFutures
.
thenRun
(()
->
{
TStoreyInfo
tStoreyInfo
=
new
TStoreyInfo
();
tStoreyInfo
.
setfStatus
(
"1"
);
tStoreyInfo
.
setfAgingStartTime
(
DateUtils
.
getNowDate
());
tStoreyInfoMapper
.
updateAllStatusAndAgingStartTime
(
tStoreyInfo
);
}).
join
();
// 阻塞等待所有操作完成
return
AjaxResult
.
success
();
}
/**
/**
* 批量读取设备状态
* 批量读取设备状态
* @param fEquipmentCode f
* @param fEquipmentCode f
...
...
zhmes-agecal-system/src/main/resources/mapper/system/TStoreyInfoMapper.xml
View file @
bffaa226
...
@@ -168,6 +168,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -168,6 +168,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</trim>
where f_storey_id = #{fStoreyId}
where f_storey_id = #{fStoreyId}
</update>
</update>
<update
id=
"updateAllStatusAndAgingStartTime"
parameterType=
"TStoreyInfo"
>
update t_storey_info
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"fStatus != null"
>
f_status = #{fStatus},
</if>
<if
test=
"fAgingStartTime != null"
>
f_aging_start_time = #{fAgingStartTime},
</if>
<if
test=
"fAgingStartTime == null"
>
f_aging_start_time = null,
</if>
</trim>
</update>
<update
id=
"unbindByCode"
parameterType=
"TStoreyInfo"
>
<update
id=
"unbindByCode"
parameterType=
"TStoreyInfo"
>
update t_storey_info
update t_storey_info
...
...
zhmes-agecal-web/src/api/storey/storey.js
View file @
bffaa226
...
@@ -83,3 +83,17 @@ export function batchReadingCabinetStatus(fEquipmentCode) {
...
@@ -83,3 +83,17 @@ export function batchReadingCabinetStatus(fEquipmentCode) {
method
:
'get'
method
:
'get'
})
})
}
}
export
function
powerOnAllStore
()
{
return
request
({
url
:
'/storey/powerOnAllStore'
,
method
:
'get'
})
}
export
function
powerOffAllStore
()
{
return
request
({
url
:
'/storey/powerOffAllStore'
,
method
:
'get'
})
}
zhmes-agecal-web/src/views/storey/index.vue
View file @
bffaa226
...
@@ -63,6 +63,24 @@
...
@@ -63,6 +63,24 @@
@
click=
"handleReading"
@
click=
"handleReading"
>
批量读取设备状态
</el-button>
>
批量读取设备状态
</el-button>
</el-col>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"warning"
plain
icon=
"el-icon-reading"
size=
"mini"
@
click=
"handleAllPowerOn"
>
所有设备上电
</el-button>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"warning"
plain
icon=
"el-icon-reading"
size=
"mini"
@
click=
"handleAllPowerOff"
>
所有设备断电
</el-button>
</el-col>
<right-toolbar
:showSearch
.
sync=
"showSearch"
@
queryTable=
"getList"
></right-toolbar>
<right-toolbar
:showSearch
.
sync=
"showSearch"
@
queryTable=
"getList"
></right-toolbar>
</el-row>
</el-row>
...
@@ -184,7 +202,7 @@
...
@@ -184,7 +202,7 @@
<
/template
>
<
/template
>
<
script
>
<
script
>
import
{
listStorey
,
getStorey
,
delStorey
,
addStorey
,
updateStorey
,
exportStorey
,
PowerOn
,
PowerOutage
,
batchReadingCabinetStatus
}
from
"@/api/storey/storey"
;
import
{
listStorey
,
getStorey
,
delStorey
,
addStorey
,
updateStorey
,
exportStorey
,
PowerOn
,
PowerOutage
,
batchReadingCabinetStatus
,
powerOnAllStore
,
powerOffAllStore
}
from
"@/api/storey/storey"
;
export
default
{
export
default
{
name
:
"Info"
,
name
:
"Info"
,
...
@@ -386,12 +404,32 @@ export default {
...
@@ -386,12 +404,32 @@ export default {
}
}
}
)
}
)
}
).
catch
(()
=>
{
}
).
catch
(()
=>
{
this
.
$message
({
type
:
'info'
,
message
:
'取消输入'
}
);
}
);
}
);
}
,
}
,
handleAllPowerOff
()
{
this
.
$confirm
(
'是否确认给所有设备断电?'
,
"警告"
,
{
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
}
).
then
(
function
()
{
return
powerOffAllStore
();
}
).
then
(()
=>
{
this
.
getList
();
this
.
msgSuccess
(
"断电成功"
);
}
).
catch
(()
=>
{
}
);
}
,
handleAllPowerOn
()
{
this
.
$confirm
(
'是否确认给所有设备上电?'
,
"警告"
,
{
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
}
).
then
(
function
()
{
return
powerOnAllStore
();
}
).
then
(()
=>
{
this
.
getList
();
this
.
msgSuccess
(
"上电成功"
);
}
).
catch
(()
=>
{
}
);
}
,
/** 导出按钮操作 */
/** 导出按钮操作 */
handleExport
()
{
handleExport
()
{
const
queryParams
=
this
.
queryParams
;
const
queryParams
=
this
.
queryParams
;
...
...
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