Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
rpc-openplatform
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 1494d65d
authored
Dec 19, 2020
by
fz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.添加获取私钥接口
2.添加获取客户信息接口 3.添加获取设备列表接口 4.添加注释,代码优化
1 parent
dede0bef
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
9 deletions
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/service/IceOpenApiService.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformDeviceMapper.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformUserMapper.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/service/IceOpenApiServiceImpl.java
rpc-openplatform-container/src/main/resources/META-INF/orm/PlatformDeviceMapper.xml
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/service/IceOpenApiService.java
View file @
1494d65
package
cn
.
com
.
glsx
.
openplatform
.
service
;
package
cn
.
com
.
glsx
.
openplatform
.
service
;
import
cn.hutool.db.Page
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.Map
;
public
interface
IceOpenApiService
{
public
interface
IceOpenApiService
{
Map
<
String
,
Integer
>
getDataView
(
int
customerId
,
int
deviceType
);
Map
<
String
,
Integer
>
getDataView
(
int
customerId
,
int
deviceType
);
String
getPrivateSecret
(
int
appId
);
Map
<
String
,
Object
>
getCustomerInfo
(
int
appId
);
Map
<
String
,
Object
>
getDeviceList
(
Integer
appid
,
Page
page
,
Date
start_time
,
Date
end_time
);
}
}
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformDeviceMapper.java
View file @
1494d65
...
@@ -2,10 +2,10 @@ package cn.com.glsx.openplatform.mapper;
...
@@ -2,10 +2,10 @@ package cn.com.glsx.openplatform.mapper;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
cn.com.glsx.openplatform.vo.DeviceVo
;
import
cn.com.glsx.openplatform.vo.DeviceVo
;
import
com.github.pagehelper.Page
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -34,6 +34,8 @@ public interface PlatformDeviceMapper extends OreMapper<PlatformDevice> {
...
@@ -34,6 +34,8 @@ public interface PlatformDeviceMapper extends OreMapper<PlatformDevice> {
List
<
Map
<
String
,
Object
>>
getDeviceActivationStatistic
(
@Param
(
"startTime"
)
Date
startTime
,
@Param
(
"endTime"
)
Date
endTime
,
@Param
(
"customerName"
)
String
customerName
);
List
<
Map
<
String
,
Object
>>
getDeviceActivationStatistic
(
@Param
(
"startTime"
)
Date
startTime
,
@Param
(
"endTime"
)
Date
endTime
,
@Param
(
"customerName"
)
String
customerName
);
List
<
Map
<
String
,
Object
>>
getDeviceByTimeRangeAndCustID
(
@Param
(
"startTime"
)
Date
startTime
,
@Param
(
"endTime"
)
Date
endTime
,
@Param
(
"customerID"
)
String
customerID
);
int
getDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
int
getDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
int
getacticveDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
int
getacticveDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
...
...
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformUserMapper.java
View file @
1494d65
...
@@ -4,6 +4,7 @@ import cn.com.glsx.openplatform.model.PlatformUser;
...
@@ -4,6 +4,7 @@ import cn.com.glsx.openplatform.model.PlatformUser;
import
cn.com.glsx.openplatform.vo.UserVo
;
import
cn.com.glsx.openplatform.vo.UserVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.Date
;
import
java.util.Date
;
...
...
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/service/IceOpenApiServiceImpl.java
View file @
1494d65
package
cn
.
com
.
glsx
.
openplatform
.
service
;
package
cn
.
com
.
glsx
.
openplatform
.
service
;
import
cn.com.glsx.openplatform.mapper.PlatformCustomerMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformDeviceMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformDeviceMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformUserMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformUserMapper
;
import
cn.com.glsx.openplatform.model.PlatformCustomer
;
import
cn.hutool.db.Page
;
import
com.alibaba.dubbo.config.annotation.Service
;
import
com.alibaba.dubbo.config.annotation.Service
;
import
org.slf4j.Logger
;
import
com.github.pagehelper.PageHelper
;
import
org.slf4j.LoggerFactory
;
import
com.github.pagehelper.PageInfo
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
* 开放平台对外接口API相关服务
*/
@Service
@Service
@Data
@Slf4j
public
class
IceOpenApiServiceImpl
implements
IceOpenApiService
{
public
class
IceOpenApiServiceImpl
implements
IceOpenApiService
{
/**
* 日志
*/
private
final
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
IceOpenApiServiceImpl
.
class
);
@Resource
@Resource
private
PlatformDeviceMapper
deviceMapper
;
private
PlatformDeviceMapper
deviceMapper
;
@Resource
@Resource
private
PlatformUserMapper
userMapper
;
private
PlatformUserMapper
userMapper
;
@Resource
private
PlatformCustomerMapper
customerMapper
;
/**
* 获取商户下的数据概况信息
* @param customerId 客户id
* @return Map 数据信息
*/
@Override
@Override
public
Map
<
String
,
Integer
>
getDataView
(
int
customerId
,
int
deviceType
)
{
public
Map
<
String
,
Integer
>
getDataView
(
int
customerId
,
int
deviceType
)
{
HashMap
<
String
,
Integer
>
hashMap
=
new
HashMap
<>();
HashMap
<
String
,
Integer
>
hashMap
=
new
HashMap
<>();
...
@@ -51,4 +65,78 @@ public class IceOpenApiServiceImpl implements IceOpenApiService {
...
@@ -51,4 +65,78 @@ public class IceOpenApiServiceImpl implements IceOpenApiService {
hashMap
.
put
(
"onlinedevices"
,
acticveDeviceCount
);
hashMap
.
put
(
"onlinedevices"
,
acticveDeviceCount
);
return
hashMap
;
return
hashMap
;
}
}
/**
* 获取私钥
* @param appId 用户id
* @return String 私钥
*/
@Override
public
String
getPrivateSecret
(
int
appId
)
{
log
.
info
(
"rpc==getPrivateSecret开始==appid:"
+
appId
);
//查询客户信息
PlatformCustomer
platformCustomer
=
getPlatformCustomer
(
appId
);
//返回客户私钥
String
privateKey
=
platformCustomer
.
getPrivateKey
();
log
.
info
(
"rpc==getPrivateSecret开始==appid:"
+
privateKey
);
return
privateKey
;
}
/**
* 查询客户信息
* @param appId 客户id
* @return PlatformCustomer 客户信息实体类
*/
private
PlatformCustomer
getPlatformCustomer
(
int
appId
)
{
PlatformCustomer
req
=
new
PlatformCustomer
();
req
.
setId
(
appId
);
return
customerMapper
.
selectOne
(
req
);
}
/**
* 获取客户数据概况信息
* @param appId 用户id
* @return Map 用户信息
*/
@Override
public
Map
<
String
,
Object
>
getCustomerInfo
(
int
appId
)
{
log
.
info
(
"rpc==getCustomerInfo开始==appid:"
+
appId
);
//查询客户信息
PlatformCustomer
platformCustomer
=
getPlatformCustomer
(
appId
);
//封装返回数据
Map
<
String
,
Object
>
res
=
new
HashMap
<>();
//客户ID
res
.
put
(
"appid"
,
appId
);
//客户名称
res
.
put
(
"customer_name"
,
platformCustomer
.
getCustomerName
());
//联系电话
res
.
put
(
"contact_number"
,
platformCustomer
.
getContactNumber
());
//渠道号
res
.
put
(
"channel_number"
,
platformCustomer
.
getChannelNumber
());
log
.
info
(
"rpc==getCustomerInfo结果==appid:"
+
res
);
return
res
;
}
@Override
public
Map
<
String
,
Object
>
getDeviceList
(
Integer
appid
,
Page
page
,
Date
start_time
,
Date
end_time
)
{
log
.
info
(
"rpc==getDeviceList开始==appid:"
+
appid
,
"==page:"
+
page
+
"==start_time:"
+
start_time
,
"==end_time:"
+
start_time
);
//分页查询
PageHelper
.
startPage
(
page
.
getPageNumber
(),
page
.
getPageSize
(),
true
);
List
<
Map
<
String
,
Object
>>
deviceList
=
deviceMapper
.
getDeviceByTimeRangeAndCustID
(
start_time
,
end_time
,
appid
+
""
);
//分页结果
PageInfo
pageInfo
=
new
PageInfo
<>(
deviceList
);
//封装返回结果
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<>();
//是否有更多用户数据
boolean
hasMore
=
page
.
getPageNumber
()
<
pageInfo
.
getPages
();
hashMap
.
put
(
"has_more"
,
hasMore
);
//显示该appid下所有的用户数
int
total
=
userMapper
.
getUserCountByCustomerId
(
appid
);
hashMap
.
put
(
"total"
,
total
);
//设备数据
hashMap
.
put
(
"list"
,
pageInfo
.
getList
());
log
.
info
(
"rpc==getDeviceList结果=="
+
hashMap
);
return
hashMap
;
}
}
}
rpc-openplatform-container/src/main/resources/META-INF/orm/PlatformDeviceMapper.xml
View file @
1494d65
...
@@ -126,4 +126,13 @@
...
@@ -126,4 +126,13 @@
and device_type = #{deviceTypeStr,jdbcType=VARCHAR}
and device_type = #{deviceTypeStr,jdbcType=VARCHAR}
</if>
</if>
</select>
</select>
<select
id=
"getDeviceByTimeRangeAndCustID"
resultType=
"java.util.Map"
>
select tpd.device_sn as sn,tpu.nickname as username,tpu.contact_number as mobile from t_platform_device tpd inner join t_platform_user tpu
on tpd.user_id = tpu.id
where tpd.activat_time >= #{startTime,jdbcType=TIMESTAMP}
and tpd.activat_time
<
#{endTime,jdbcType=TIMESTAMP}
and tpd.customer_id = #{customerID}
order by tpd.activat_time desc
</select>
</mapper>
</mapper>
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