Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhny
Project
Project
Details
Activity
Releases
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
王夏晖
zhny
Commits
5ad2eca4
Commit
5ad2eca4
authored
May 24, 2018
by
jichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
系统拓扑图 接口
parent
7b57ca45
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
205 additions
and
1 deletion
+205
-1
BusDeviceRepository.java
...isoft/business/device/assets/dao/BusDeviceRepository.java
+14
-0
BusDevice.java
.../org/rcisoft/business/device/assets/entity/BusDevice.java
+2
-0
SystemController.java
.../rcisoft/business/system/controller/SystemController.java
+38
-0
DeviceParamRepository.java
...rg/rcisoft/business/system/dao/DeviceParamRepository.java
+33
-0
DeviceParam.java
.../java/org/rcisoft/business/system/entity/DeviceParam.java
+28
-0
SystemService.java
...va/org/rcisoft/business/system/service/SystemService.java
+30
-0
SystemServiceImpl.java
...isoft/business/system/service/impl/SystemServiceImpl.java
+40
-0
MqttClient.java
src/main/java/org/rcisoft/mqttclient/MqttClient.java
+2
-1
deviceMapper.xml
src/main/resources/mapper/sys/device/assets/deviceMapper.xml
+3
-0
DeviceParamMapper.xml
src/main/resources/mapper/sys/system/DeviceParamMapper.xml
+15
-0
No files found.
src/main/java/org/rcisoft/business/device/assets/dao/BusDeviceRepository.java
View file @
5ad2eca4
...
...
@@ -76,9 +76,23 @@ public interface BusDeviceRepository extends BaseMapper<BusDevice> {
"group by d.DEV_ID,d.SHUT_POWER,d.RUN_TM</script>"
)
List
<
Map
<
String
,
Object
>>
addRunTime
(
@Param
(
"time"
)
String
time
);
/**
* 批量更新设备的运行时长
* @param list
* @return
*/
@Update
(
"<script><foreach collection=\"list\" item=\"item\" separator=\";\">"
+
"update bus_device set RUN_TM=#{item.runTm} where DEV_ID=#{item.devId}"
+
"</foreach></script>"
)
Integer
batchUpdateRunTm
(
List
<
BusDevice
>
list
);
/**
* 查询该项目下所有设备的故障数量和运行时长
* @param proId
* @return
*/
@Select
(
"<script>select DEV_NM,RUN_TM,ERROR_NUM from bus_device where PRO_ID=#{proId}</script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
List
<
BusDevice
>
selectErrorandRuntime
(
@Param
(
"proId"
)
String
proId
);
}
src/main/java/org/rcisoft/business/device/assets/entity/BusDevice.java
View file @
5ad2eca4
...
...
@@ -47,5 +47,7 @@ public class BusDevice implements Serializable{
private
BigDecimal
runTm
;
private
Integer
errorNum
;
}
src/main/java/org/rcisoft/business/system/controller/SystemController.java
View file @
5ad2eca4
package
org
.
rcisoft
.
business
.
system
.
controller
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
* Created by JiChao on 2018/5/2.
* 系统模块
*/
@Api
(
tags
=
"系统检测"
)
@RestController
@RequestMapping
(
"system"
)
public
class
SystemController
{
...
...
@@ -47,4 +49,40 @@ public class SystemController {
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
systemServiceImpl
.
burdenHour
(
proId
));
}
@ApiOperation
(
value
=
"故障报修 and 运行时长"
,
notes
=
"根据项目id查询所有设备的错误数量和运行时长,10分钟查询一次"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目主键"
,
required
=
true
,
dataType
=
"字符串"
)
})
@RequestMapping
(
"/selectErrorandRuntime"
)
public
Result
selectErrorandRuntime
(
@RequestParam
String
proId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
systemServiceImpl
.
selectErrorandRuntime
(
proId
));
}
@ApiOperation
(
value
=
"查询参数列表"
,
notes
=
"根据设备num查询所有参数"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"devNum"
,
value
=
"设备num"
,
required
=
true
,
dataType
=
"字符串"
)
})
@RequestMapping
(
"/selectDeviceParamList"
)
public
Result
selectDeviceParamList
(
@RequestParam
String
devNum
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
systemServiceImpl
.
selectDeviceParamList
(
devNum
));
}
@ApiOperation
(
value
=
"查询参数数据"
,
notes
=
"查询缓存中的数据,10秒钟查询1次"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目主键"
,
required
=
true
,
dataType
=
"字符串"
)
})
@RequestMapping
(
"/selectDataByCache"
)
public
Result
selectDataByCache
(
@RequestParam
String
proId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
systemServiceImpl
.
selectDataByCache
(
proId
));
}
@ApiOperation
(
value
=
"查询传感器code"
,
notes
=
"查询传感器code"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目主键"
,
required
=
true
,
dataType
=
"字符串"
)
})
@RequestMapping
(
"/selectSensorCode"
)
public
Result
selectSensorCode
(
@RequestParam
String
proId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
systemServiceImpl
.
selectSensorCode
(
proId
));
}
}
src/main/java/org/rcisoft/business/system/dao/DeviceParamRepository.java
0 → 100644
View file @
5ad2eca4
package
org
.
rcisoft
.
business
.
system
.
dao
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.ResultMap
;
import
org.apache.ibatis.annotations.ResultType
;
import
org.apache.ibatis.annotations.Select
;
import
org.rcisoft.business.system.entity.DeviceParam
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
* Created by JiChao on 2018/5/24.
*/
@Repository
public
interface
DeviceParamRepository
{
/**
* 查询参数列表
* @param devNum
* @return
*/
@Select
(
"<script>select d.PARAM,p.PARAM_NM,p.P_SOURCE,p.P_MIN,p.P_MAX,p.SYMBOL,p.FLAG,p.PARAM_UNIT "
+
"from bus_device_param d,bus_devicetp_param p "
+
"where d.PARAM_CODE=p.PARAM_CODE and d.DEV_NUM=#{devNum}</script>"
)
@ResultMap
(
"BaseResultMap"
)
List
<
DeviceParam
>
selectDeviceParamList
(
@Param
(
"devNum"
)
String
devNum
);
@Select
(
"<script>select OTHER_PARAM from bus_param_refer where PRO_ID=#{proId} and OWN_PARAM='sensor'</script>"
)
@ResultType
(
String
.
class
)
String
selectSensorCode
(
@Param
(
"proId"
)
String
proId
);
}
src/main/java/org/rcisoft/business/system/entity/DeviceParam.java
0 → 100644
View file @
5ad2eca4
package
org
.
rcisoft
.
business
.
system
.
entity
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Entity
;
import
java.math.BigDecimal
;
/**
* Created by JiChao on 2018/5/24.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
DeviceParam
{
private
String
param
;
private
String
paramNm
;
private
String
source
;
private
BigDecimal
min
;
private
BigDecimal
max
;
private
String
symbol
;
private
String
flag
;
private
String
paramUnit
;
}
src/main/java/org/rcisoft/business/system/service/SystemService.java
View file @
5ad2eca4
package
org
.
rcisoft
.
business
.
system
.
service
;
import
org.rcisoft.business.device.assets.entity.BusDevice
;
import
org.rcisoft.business.system.entity.DeviceParam
;
import
org.rcisoft.business.system.vo.ClimateStatistics
;
import
java.util.List
;
...
...
@@ -30,4 +32,32 @@ public interface SystemService {
*/
List
<
Object
>
burdenHour
(
String
proId
);
/**
* 查询该项目下所有设备的故障数量和运行时长
* @param proId
* @return
*/
List
<
BusDevice
>
selectErrorandRuntime
(
String
proId
);
/**
* 根据devNum查询参数列表
* @param devNum
* @return
*/
List
<
DeviceParam
>
selectDeviceParamList
(
String
devNum
);
/**
* 查询传感器code
* @param proId
* @return
*/
String
selectSensorCode
(
String
proId
);
/**
* 查询缓存中的数据,10秒钟查询1次
* @param proId
* @return
*/
String
selectDataByCache
(
String
proId
);
}
src/main/java/org/rcisoft/business/system/service/impl/SystemServiceImpl.java
View file @
5ad2eca4
...
...
@@ -2,6 +2,8 @@ package org.rcisoft.business.system.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
import
org.rcisoft.business.device.assets.dao.BusDeviceRepository
;
import
org.rcisoft.business.device.assets.entity.BusDevice
;
import
org.rcisoft.business.mainte.adaptive.dao.BusParamReferRepository
;
import
org.rcisoft.business.mainte.adaptive.dao.BusTemperatureRepository
;
import
org.rcisoft.business.mainte.adaptive.dao.TotalSensorRepository
;
...
...
@@ -15,8 +17,11 @@ import org.rcisoft.business.overview.dao.BusProjectRepository;
import
org.rcisoft.business.overview.dao.EnergyCountMRepository
;
import
org.rcisoft.business.overview.entity.BusProject
;
import
org.rcisoft.business.overview.vo.EnergyCountMVo
;
import
org.rcisoft.business.system.dao.DeviceParamRepository
;
import
org.rcisoft.business.system.entity.DeviceParam
;
import
org.rcisoft.business.system.service.SystemService
;
import
org.rcisoft.business.system.vo.ClimateStatistics
;
import
org.rcisoft.core.service.RcRedisService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -42,6 +47,12 @@ public class SystemServiceImpl implements SystemService {
private
EnergyCountMRepository
energyCountMRepository
;
@Autowired
private
AdaptiveService
adaptiveServiceImpl
;
@Autowired
private
BusDeviceRepository
busDeviceRepository
;
@Autowired
private
DeviceParamRepository
deviceParamRepository
;
@Autowired
private
RcRedisService
redisServiceImpl
;
private
String
getCode
(
String
proId
)
{
BusProject
b
=
new
BusProject
();
...
...
@@ -119,4 +130,33 @@ public class SystemServiceImpl implements SystemService {
Params
params
=
new
Params
(
proId
,
time
,
this
.
getCode
(
proId
));
return
adaptiveServiceImpl
.
buildingList
(
params
);
}
@Override
public
List
<
BusDevice
>
selectErrorandRuntime
(
String
proId
)
{
List
<
BusDevice
>
list
=
busDeviceRepository
.
selectErrorandRuntime
(
proId
);
list
.
forEach
(
busDevice
->
{
BigDecimal
runTm
=
busDevice
.
getRunTm
();
runTm
=
runTm
==
null
?
new
BigDecimal
(
0
)
:
runTm
;
Integer
errorNum
=
busDevice
.
getErrorNum
();
errorNum
=
errorNum
==
null
?
0
:
errorNum
;
busDevice
.
setRunTm
(
runTm
);
busDevice
.
setErrorNum
(
errorNum
);
});
return
list
;
}
@Override
public
List
<
DeviceParam
>
selectDeviceParamList
(
String
devNum
)
{
return
deviceParamRepository
.
selectDeviceParamList
(
devNum
);
}
@Override
public
String
selectSensorCode
(
String
proId
)
{
return
deviceParamRepository
.
selectSensorCode
(
proId
);
}
@Override
public
String
selectDataByCache
(
String
proId
)
{
return
redisServiceImpl
.
get
(
proId
);
}
}
src/main/java/org/rcisoft/mqttclient/MqttClient.java
View file @
5ad2eca4
...
...
@@ -43,6 +43,7 @@ public class MqttClient {
referMap
=
totalService
.
queryBusParamRefer
(
map
);
devStr
=
totalService
.
queryDevByPro
(
jwnum
);
String
time
=
jb
.
getString
(
"TIME"
);
//时间
JSONObject
jbody
=
jb
.
getJSONObject
(
"body"
);
//数据体
//String time = DateUtil.getSimepleDate("yyyyMMddHHmmss",new Date());
if
(
DateUtil
.
getParseDate
(
"yyyyMMddhhmmss"
,
time
)!=
null
){
//时间格式正常
String
minute
=
time
.
substring
(
10
,
12
);
...
...
@@ -52,13 +53,13 @@ public class MqttClient {
* 用作拓扑图点击设备查看实时参数及10秒级的能耗
*/
if
(
Integer
.
parseInt
(
sec
)%
10
==
0
){
rcRedisService
.
set
(
jwnum
,
jbody
.
toJSONString
());
//rcRedisService.set("old","old"+new Date() + rcRedisService.get("new"));
//rcRedisService.set("new","new"+new Date() + content);
}
System
.
out
.
println
(
"++++++++++++++++++++++++++++++++++"
+
minute
+
"-----"
+
sec
);
if
(
Integer
.
parseInt
(
minute
)%
10
==
0
&&
sec
.
equalsIgnoreCase
(
"00"
)){
//10分钟级的数据,进行存储
List
<
String
>
list
=
new
ArrayList
<
String
>();
JSONObject
jbody
=
jb
.
getJSONObject
(
"body"
);
//数据体
List
<
TotalOriginal
>
originalList
=
new
ArrayList
<>();
List
<
TotalSensor
>
sensorList
=
new
ArrayList
<>();
//遍历数据体内对象
...
...
src/main/resources/mapper/sys/device/assets/deviceMapper.xml
View file @
5ad2eca4
...
...
@@ -14,6 +14,9 @@
<result
column=
"PRO_ID"
jdbcType=
"VARCHAR"
property=
"proId"
/>
<result
column=
"SYS_ID"
jdbcType=
"VARCHAR"
property=
"sysId"
/>
<result
column=
"OWN_ID"
jdbcType=
"VARCHAR"
property=
"ownId"
/>
<result
column=
"SHUT_POWER"
jdbcType=
"DECIMAL"
property=
"shutPower"
/>
<result
column=
"RUN_TM"
jdbcType=
"DECIMAL"
property=
"runTm"
/>
<result
column=
"ERROR_NUM"
jdbcType=
"INTEGER"
property=
"errorNum"
/>
</resultMap>
<resultMap
id=
"DeviceAssetStatistics"
type=
"org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo"
>
<result
column=
"DEV_NM"
jdbcType=
"VARCHAR"
property=
"devNm"
></result>
...
...
src/main/resources/mapper/sys/system/DeviceParamMapper.xml
0 → 100644
View file @
5ad2eca4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"org.rcisoft.business.system.dao.DeviceParamRepository"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.business.system.entity.DeviceParam"
>
<result
column=
"PARAM"
jdbcType=
"VARCHAR"
property=
"param"
/>
<result
column=
"DEV_NUM"
jdbcType=
"VARCHAR"
property=
"paramNm"
/>
<result
column=
"P_SOURCE"
jdbcType=
"VARCHAR"
property=
"source"
/>
<result
column=
"P_MIN"
jdbcType=
"DECIMAL"
property=
"min"
/>
<result
column=
"P_MAX"
jdbcType=
"DECIMAL"
property=
"max"
/>
<result
column=
"SYMBOL"
jdbcType=
"VARCHAR"
property=
"symbol"
/>
<result
column=
"FLAG"
jdbcType=
"VARCHAR"
property=
"flag"
/>
<result
column=
"PARAM_UNIT"
jdbcType=
"VARCHAR"
property=
"paramUnit"
/>
</resultMap>
</mapper>
\ No newline at end of file
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