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 117ca1ca
authored
Dec 24, 2020
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
2 parents
b2800617
a4570217
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
241 additions
and
19 deletions
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/enums/MessageMethodEnum.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/Area.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/PlatformSubMessage.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/service/OpenApiService.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/util/FdfsUtils.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/util/RSAUtils.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/vo/OpenDeviceVo.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformCustomerMapper.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/PlatformMessageMapper.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/service/OpenApiServiceImpl.java
rpc-openplatform-container/src/main/resources/META-INF/orm/PlatformDeviceMapper.xml
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/enums/MessageMethodEnum.java
0 → 100644
View file @
117ca1c
package
cn
.
com
.
glsx
.
openplatform
.
enums
;
import
cn.com.glsx.openplatform.exception.BusinessException
;
/**
* <p>Description:
* <p>Project: open-platform-admin
*
* @author wbh
* @date 2020-12-16
*/
public
enum
MessageMethodEnum
{
ADD
(
1
,
"增加"
),
UPDATE
(
2
,
"修改"
),
DELETE
(
3
,
"删除"
);
private
final
Integer
code
;
private
final
String
msg
;
MessageMethodEnum
(
Integer
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
Integer
getCode
()
{
return
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
BusinessException
exception
()
{
return
new
BusinessException
(
this
.
code
,
this
.
msg
);
}
}
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/Area.java
View file @
117ca1c
package
cn
.
com
.
glsx
.
openplatform
.
model
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
/**
* <p>Description:
...
...
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/PlatformSubMessage.java
0 → 100644
View file @
117ca1c
package
cn
.
com
.
glsx
.
openplatform
.
model
;
import
cn.com.glsx.framework.core.beans.BaseModel
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Table
;
/**
* <p>Description:
* <p>Project: shop
*
* @author wbh
* @date 2020-12-15
*/
/**
* 设备管理表
*/
@Data
@Table
(
name
=
"t_platform_sub_message"
)
public
class
PlatformSubMessage
extends
BaseModel
{
/**
* 消息类型ID
*/
@Column
(
name
=
"msg_id"
)
private
Integer
msgID
;
/**
* 设备类型ID
*/
@Column
(
name
=
"device_type"
)
private
Integer
deviceType
;
/**
* 推送地址
*/
@Column
(
name
=
"push_url"
)
private
String
pushUrl
;
}
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/service/OpenApiService.java
View file @
117ca1c
...
...
@@ -38,7 +38,17 @@ public interface OpenApiService {
* @param page
* @param start_time
* @param end_time
* @return 结果集
*/
Map
<
String
,
Object
>
getDeviceList
(
int
appid
,
Page
page
,
Date
start_time
,
Date
end_time
);
/**
* 消息订阅
* @param msgID 消息类型ID
* @param deviceType 设备类型
* @param method
* @param pushUrl
* @return
*/
Map
<
String
,
Object
>
getDeviceList
(
Integer
appid
,
Page
page
,
Date
start_time
,
Date
end_time
);
Map
<
String
,
Object
>
subscribeMessage
(
int
msgID
,
int
deviceType
,
int
method
,
String
pushUrl
);
}
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/util/FdfsUtils.java
View file @
117ca1c
package
cn
.
com
.
glsx
.
openplatform
.
util
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
cn.com.glsx.openplatform.config.FdfsProperty
;
import
com.github.tobato.fastdfs.domain.fdfs.StorePath
;
import
com.github.tobato.fastdfs.service.FastFileStorageClient
;
...
...
@@ -14,6 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
* <p>Description: FastDFS 文件操作工具类
* <p>Project: shop
...
...
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/util/RSAUtils.java
View file @
117ca1c
package
cn
.
com
.
glsx
.
openplatform
.
util
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.Base64Utils
;
import
javax.crypto.Cipher
;
import
java.security.KeyFactory
;
import
java.security.KeyPair
;
import
java.security.KeyPairGenerator
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
java.security.*
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPublicKey
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.Base64Utils
;
/**
...
...
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/vo/OpenDeviceVo.java
0 → 100644
View file @
117ca1c
package
cn
.
com
.
glsx
.
openplatform
.
vo
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* <p>Description:
* <p>Project: shop
*
* @author fengzhi
* @date 2020-12-23
*/
/**
* 设备
*/
@Data
public
class
OpenDeviceVo
implements
Serializable
{
private
Integer
id
;
/**
* 设备号
*/
private
String
sn
;
/**
* 客户名称
*/
private
String
username
;
/**
* 手机号
*/
private
String
mobile
;
}
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformCustomerMapper.java
View file @
117ca1c
...
...
@@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Param;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.List
;
import
java.util.Map
;
/**
* <p>Description:
...
...
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformDeviceMapper.java
View file @
117ca1c
...
...
@@ -2,10 +2,11 @@ package cn.com.glsx.openplatform.mapper;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
cn.com.glsx.openplatform.vo.DeviceVo
;
import
c
om.github.pagehelper.Page
;
import
c
n.com.glsx.openplatform.vo.OpenDeviceVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -34,7 +35,9 @@ 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
>>
getDeviceByTimeRangeAndCustID
(
@Param
(
"startTime"
)
Date
startTime
,
@Param
(
"endTime"
)
Date
endTime
,
@Param
(
"customerID"
)
String
customerID
);
List
<
OpenDeviceVo
>
getDeviceByTimeRangeAndCustID
(
@Param
(
"startTime"
)
Date
startTime
,
@Param
(
"endTime"
)
Date
endTime
,
@Param
(
"customerID"
)
Integer
customerID
);
int
getCountDeviceByTimeRangeAndCustID
(
@Param
(
"startTime"
)
Date
startTime
,
@Param
(
"endTime"
)
Date
endTime
,
@Param
(
"customerID"
)
Integer
customerID
);
int
getDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
...
...
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformMessageMapper.java
0 → 100644
View file @
117ca1c
package
cn
.
com
.
glsx
.
openplatform
.
mapper
;
import
cn.com.glsx.openplatform.model.PlatformSubMessage
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
/**
* <p>Description:
* <p>Project: shop
*
* @author wbh
* @date 2020-12-15
*/
@Mapper
public
interface
PlatformMessageMapper
extends
OreMapper
<
PlatformSubMessage
>
{
}
\ No newline at end of file
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/service/OpenApiServiceImpl.java
View file @
117ca1c
package
cn
.
com
.
glsx
.
openplatform
.
service
;
import
cn.com.glsx.openplatform.enums.MessageMethodEnum
;
import
cn.com.glsx.openplatform.mapper.PlatformCustomerMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformDeviceMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformMessageMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformUserMapper
;
import
cn.com.glsx.openplatform.model.PlatformCustomer
;
import
cn.com.glsx.openplatform.model.PlatformSubMessage
;
import
cn.com.glsx.openplatform.vo.OpenDeviceVo
;
import
cn.hutool.db.Page
;
import
com.alibaba.dubbo.config.annotation.Service
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
tk.mybatis.mapper.entity.Example
;
import
javax.annotation.Resource
;
import
java.util.Date
;
...
...
@@ -31,6 +36,10 @@ public class OpenApiServiceImpl implements OpenApiService {
@Resource
private
PlatformCustomerMapper
customerMapper
;
@Resource
private
PlatformMessageMapper
messageMapper
;
/**
* 获取商户下的数据概况信息
*
...
...
@@ -117,11 +126,75 @@ public class OpenApiServiceImpl implements OpenApiService {
}
@Override
public
Map
<
String
,
Object
>
getDeviceList
(
Integer
appid
,
Page
page
,
Date
start_time
,
Date
end_time
)
{
public
Map
<
String
,
Object
>
subscribeMessage
(
int
msgID
,
int
deviceType
,
int
method
,
String
pushUrl
)
{
log
.
info
(
"rpc==subscribeMessage开始===msgID:"
+
msgID
+
",deviceType:"
+
deviceType
+
",method:"
+
method
+
",pushUrl:"
+
pushUrl
);
//封装返回数据
Map
<
String
,
Object
>
res
=
new
HashMap
<>();
try
{
//查询msgID是否存在
Example
example
=
new
Example
(
PlatformSubMessage
.
class
);
example
.
createCriteria
().
andEqualTo
(
"msg_id"
,
msgID
);
PlatformSubMessage
message
=
messageMapper
.
selectOneByExample
(
example
);
//新增
if
(
MessageMethodEnum
.
ADD
.
getCode
()==
method
){
if
(
null
!=
message
){
//msgID存在,返回失败信息
res
.
put
(
"success"
,
false
);
res
.
put
(
"msg"
,
"新增失败,msgID存在"
);
return
res
;
}
else
{
//新增订阅消息
message
=
new
PlatformSubMessage
();
message
.
setMsgID
(
msgID
);
message
.
setPushUrl
(
pushUrl
);
message
.
setDeviceType
(
deviceType
);
messageMapper
.
insert
(
message
);
}
}
//更新
if
(
MessageMethodEnum
.
UPDATE
.
getCode
()==
method
){
if
(
null
!=
message
){
//msgID存在,更新数据
message
.
setPushUrl
(
pushUrl
);
message
.
setDeviceType
(
deviceType
);
messageMapper
.
updateByPrimaryKey
(
message
);
}
else
{
//不存在,新增数据
message
=
new
PlatformSubMessage
();
message
.
setMsgID
(
msgID
);
message
.
setPushUrl
(
pushUrl
);
message
.
setDeviceType
(
deviceType
);
messageMapper
.
insert
(
message
);
}
}
//删除
if
(
MessageMethodEnum
.
DELETE
.
getCode
()==
method
){
if
(
null
!=
message
){
//msgID存在,逻辑删除数据
message
.
setDeletedFlag
(
"1"
);
messageMapper
.
updateByPrimaryKey
(
message
);
}
}
//执行成功
res
.
put
(
"success"
,
true
);
}
catch
(
Exception
e
){
res
.
put
(
"success"
,
false
);
res
.
put
(
"msg"
,
e
.
getMessage
());
return
res
;
}
log
.
info
(
"rpc==subscribeMessage结果=="
+
res
);
return
res
;
}
@Override
public
Map
<
String
,
Object
>
getDeviceList
(
int
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
+
""
);
List
<
OpenDeviceVo
>
deviceList
=
deviceMapper
.
getDeviceByTimeRangeAndCustID
(
start_time
,
end_time
,
appid
);
//分页结果
PageInfo
pageInfo
=
new
PageInfo
<>(
deviceList
);
...
...
rpc-openplatform-container/src/main/resources/META-INF/orm/PlatformDeviceMapper.xml
View file @
117ca1c
...
...
@@ -18,6 +18,7 @@
<result
column=
"update_by"
jdbcType=
"INTEGER"
property=
"updateBy"
/>
<result
column=
"remark"
jdbcType=
"VARCHAR"
property=
"remark"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated-->
id, device_sn, device_type, customer_id, activat_time, `status`, create_time, update_time,
...
...
@@ -127,12 +128,21 @@
</if>
</select>
<select
id=
"getDeviceByTimeRangeAndCustID"
resultType=
"
java.util.Map
"
>
<select
id=
"getDeviceByTimeRangeAndCustID"
resultType=
"
cn.com.glsx.openplatform.vo.OpenDeviceVo
"
>
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}
and tpd.customer_id = #{customerID,jdbcType=INTEGER}
order by tpd.activat_time desc
</select>
<select
id=
"getCountDeviceByTimeRangeAndCustID"
resultType=
"java.lang.Integer"
>
select count(1) 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,jdbcType=INTEGER}
order by tpd.activat_time desc
</select>
</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