Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAMOSIotRoot
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
iot
YeeAMOSIotRoot
Commits
5984c540
Commit
5984c540
authored
Nov 30, 2020
by
高东东
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-)删除多余文件
parent
230257be
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
5 additions
and
3259 deletions
+5
-3259
.gitignore
.gitignore
+2
-0
IDataGroupDao.java
...ejoin/amos/iot/business/dao/repository/IDataGroupDao.java
+0
-6
IDataModeDao.java
...eejoin/amos/iot/business/dao/repository/IDataModeDao.java
+0
-20
IDataModelItemDao.java
...n/amos/iot/business/dao/repository/IDataModelItemDao.java
+0
-11
IEqpTmplCpblDao.java
...oin/amos/iot/business/dao/repository/IEqpTmplCpblDao.java
+0
-8
IEqpTmplDataDao.java
...oin/amos/iot/business/dao/repository/IEqpTmplDataDao.java
+0
-7
DataGroup.java
.../java/com/yeejoin/amos/iot/business/entity/DataGroup.java
+0
-55
DataModel.java
.../java/com/yeejoin/amos/iot/business/entity/DataModel.java
+0
-227
DataModelItem.java
...a/com/yeejoin/amos/iot/business/entity/DataModelItem.java
+0
-112
EqpTmplCpbl.java
...ava/com/yeejoin/amos/iot/business/entity/EqpTmplCpbl.java
+0
-207
EqpTmplData.java
...ava/com/yeejoin/amos/iot/business/entity/EqpTmplData.java
+0
-118
EqpTmplDataAttr.java
...com/yeejoin/amos/iot/business/entity/EqpTmplDataAttr.java
+0
-191
IntfcDefaultAttribute.java
...ejoin/amos/iot/business/entity/IntfcDefaultAttribute.java
+0
-67
CapacityVo.java
...ain/java/com/yeejoin/amos/iot/business/vo/CapacityVo.java
+0
-63
RedisConfig.java
...n/java/com/yeejoin/amos/iot/core/adapter/RedisConfig.java
+0
-100
ThreadTaskHelper.java
...om/yeejoin/amos/iot/core/threadpool/ThreadTaskHelper.java
+0
-16
ChannelCache.java
.../java/com/yeejoin/amos/iot/netty/common/ChannelCache.java
+0
-180
CommonChannelHandler.java
...m/yeejoin/amos/iot/netty/common/CommonChannelHandler.java
+0
-35
CommonDataCache.java
...va/com/yeejoin/amos/iot/netty/common/CommonDataCache.java
+0
-11
CommonDecoder.java
...java/com/yeejoin/amos/iot/netty/common/CommonDecoder.java
+0
-36
CommonEncoder.java
...java/com/yeejoin/amos/iot/netty/common/CommonEncoder.java
+0
-17
CommonStart.java
...n/java/com/yeejoin/amos/iot/netty/common/CommonStart.java
+0
-52
CommonTcpCache.java
...ava/com/yeejoin/amos/iot/netty/common/CommonTcpCache.java
+0
-141
CommonThread.java
.../java/com/yeejoin/amos/iot/netty/common/CommonThread.java
+0
-36
ConsumerThead.java
...java/com/yeejoin/amos/iot/netty/common/ConsumerThead.java
+0
-8
DataConsumer.java
.../java/com/yeejoin/amos/iot/netty/common/DataConsumer.java
+0
-35
DataProcessThreadPool.java
.../yeejoin/amos/iot/netty/common/DataProcessThreadPool.java
+0
-69
FrameConsumer.java
...java/com/yeejoin/amos/iot/netty/common/FrameConsumer.java
+0
-0
JSONConsumer.java
.../java/com/yeejoin/amos/iot/netty/common/JSONConsumer.java
+0
-0
NettyService.java
.../java/com/yeejoin/amos/iot/netty/common/NettyService.java
+0
-101
StartHttpThread.java
...va/com/yeejoin/amos/iot/netty/common/StartHttpThread.java
+0
-55
StartMqttThread.java
...va/com/yeejoin/amos/iot/netty/common/StartMqttThread.java
+0
-57
StartTcpThread.java
...ava/com/yeejoin/amos/iot/netty/common/StartTcpThread.java
+0
-61
StopTcpThread.java
...java/com/yeejoin/amos/iot/netty/common/StopTcpThread.java
+0
-22
XMLConsumer.java
...n/java/com/yeejoin/amos/iot/netty/common/XMLConsumer.java
+0
-201
CpblDataModel.java
...m/yeejoin/amos/iot/netty/common/entity/CpblDataModel.java
+0
-70
EquipTmplData.java
...m/yeejoin/amos/iot/netty/common/entity/EquipTmplData.java
+0
-67
EquipTmplDataAttr.java
...ejoin/amos/iot/netty/common/entity/EquipTmplDataAttr.java
+0
-134
EquipmentVo.java
...com/yeejoin/amos/iot/netty/common/entity/EquipmentVo.java
+0
-31
InterfaceFrame.java
.../yeejoin/amos/iot/netty/common/entity/InterfaceFrame.java
+0
-134
ByteConvert.java
.../com/yeejoin/amos/iot/netty/common/utils/ByteConvert.java
+0
-352
ChangeUtils.java
.../com/yeejoin/amos/iot/netty/common/utils/ChangeUtils.java
+0
-85
ToolUtil.java
...ava/com/yeejoin/amos/iot/netty/common/utils/ToolUtil.java
+0
-58
pom.xml
YeeAMOSIotStart/pom.xml
+1
-1
application-prod.properties
...OSIotStart/src/main/resources/application-prod.properties
+2
-2
iot-4.0.0.sql
...MOSIotStart/src/main/resources/db/changelog/iot-4.0.0.sql
+0
-0
No files found.
.gitignore
View file @
5984c540
...
...
@@ -3,6 +3,8 @@
# Log file
*.log
logs/
.vs
# BlueJ files
*.ctxt
...
...
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/dao/repository/IDataGroupDao.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
dao
.
repository
;
import
com.yeejoin.amos.iot.business.entity.DataGroup
;
public
interface
IDataGroupDao
extends
BaseDao
<
DataGroup
,
Long
>{
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/dao/repository/IDataModeDao.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
dao
.
repository
;
import
com.yeejoin.amos.iot.business.entity.DataModel
;
import
java.util.List
;
public
interface
IDataModeDao
extends
BaseDao
<
DataModel
,
Long
>{
List
<
DataModel
>
findAllByOrgCodeAndVisibility
(
String
orgCode
,
int
visibility
);
List
<
DataModel
>
findAllByVisibility
(
int
visibility
);
List
<
DataModel
>
findAllByNameAndVisibility
(
String
name
,
Integer
visibility
);
List
<
DataModel
>
findAllByVisibility
(
Integer
visibility
);
List
<
DataModel
>
findAllByVisibilityAndIsBlock
(
int
i
,
boolean
b
);
List
<
DataModel
>
findAllByOrgCodeAndVisibilityAndIsBlock
(
String
orgCode
,
int
i
,
boolean
b
);
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/dao/repository/IDataModelItemDao.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
dao
.
repository
;
import
com.yeejoin.amos.iot.business.entity.DataModelItem
;
import
java.util.List
;
public
interface
IDataModelItemDao
extends
BaseDao
<
DataModelItem
,
Long
>{
List
<
DataModelItem
>
findAllByDataModelId
(
long
id
);
List
<
DataModelItem
>
findAllByDataModelIdAndParentId
(
Long
id
,
long
parentId
);
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/dao/repository/IEqpTmplCpblDao.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
dao
.
repository
;
import
com.yeejoin.amos.iot.business.entity.EqpTmplCpbl
;
public
interface
IEqpTmplCpblDao
extends
BaseDao
<
EqpTmplCpbl
,
Long
>{
void
deleteByEquipmentDataId
(
long
id
);
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/dao/repository/IEqpTmplDataDao.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
dao
.
repository
;
import
com.yeejoin.amos.iot.business.entity.EqpTmplData
;
public
interface
IEqpTmplDataDao
extends
BaseDao
<
EqpTmplData
,
Long
>{
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/entity/DataGroup.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
entity
;
import
com.yeejoin.amos.op.core.entity.Resource
;
import
javax.persistence.*
;
import
java.io.Serializable
;
@Entity
@Inheritance
@Table
(
name
=
"t_data_group"
)
public
class
DataGroup
extends
Resource
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
,
nullable
=
false
,
unique
=
true
)
private
long
id
;
private
String
name
;
private
String
code
;
private
String
type
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/entity/DataModel.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
entity
;
import
com.yeejoin.amos.op.core.entity.Resource
;
import
io.netty.handler.codec.ByteToMessageDecoder
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.List
;
@Entity
@Inheritance
@Table
(
name
=
"t_interface_data_model"
)
public
class
DataModel
extends
Resource
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* ID
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
,
nullable
=
false
,
unique
=
true
)
private
Long
id
;
private
String
name
;
int
maxFrameLength
;
int
lengthFieldOffset
;
int
lengthFieldLength
;
int
lengthAdjustment
;
int
initialBytesToStrip
;
boolean
failFast
;
private
String
checkFun
;
private
int
checkLength
;
private
int
checkEndLengthOffset
;
private
String
orgCode
;
private
int
visibility
;
private
String
version
;
private
String
descr
;
private
String
type
;
private
String
byteOrder
;
private
boolean
isBlock
;
public
boolean
getIsBlock
()
{
return
isBlock
;
}
public
void
setIsBlock
(
boolean
block
)
{
isBlock
=
block
;
}
@Transient
@OneToMany
(
mappedBy
=
"dataModelId"
,
fetch
=
FetchType
.
LAZY
,
cascade
=
{
CascadeType
.
ALL
})
@Where
(
clause
=
"is_delete=0"
)
//表示未删除的数据
private
List
<
DataModelItem
>
items
;
@Transient
private
List
<
DataModelItem
>
deleteData
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
int
getMaxFrameLength
()
{
return
maxFrameLength
;
}
public
void
setMaxFrameLength
(
int
maxFrameLength
)
{
this
.
maxFrameLength
=
maxFrameLength
;
}
public
int
getLengthFieldOffset
()
{
return
lengthFieldOffset
;
}
public
void
setLengthFieldOffset
(
int
lengthFieldOffset
)
{
this
.
lengthFieldOffset
=
lengthFieldOffset
;
}
public
int
getLengthFieldLength
()
{
return
lengthFieldLength
;
}
public
void
setLengthFieldLength
(
int
lengthFieldLength
)
{
this
.
lengthFieldLength
=
lengthFieldLength
;
}
public
int
getLengthAdjustment
()
{
return
lengthAdjustment
;
}
public
void
setLengthAdjustment
(
int
lengthAdjustment
)
{
this
.
lengthAdjustment
=
lengthAdjustment
;
}
public
int
getInitialBytesToStrip
()
{
return
initialBytesToStrip
;
}
public
void
setInitialBytesToStrip
(
int
initialBytesToStrip
)
{
this
.
initialBytesToStrip
=
initialBytesToStrip
;
}
public
boolean
getIsFailFast
()
{
return
failFast
;
}
public
void
setIsFailFast
(
boolean
failFast
)
{
this
.
failFast
=
failFast
;
}
public
String
getCheckFun
()
{
return
checkFun
;
}
public
void
setCheckFun
(
String
checkFun
)
{
this
.
checkFun
=
checkFun
;
}
public
int
getCheckLength
()
{
return
checkLength
;
}
public
void
setCheckLength
(
int
checkLength
)
{
this
.
checkLength
=
checkLength
;
}
public
int
getCheckEndLengthOffset
()
{
return
checkEndLengthOffset
;
}
public
void
setCheckEndLengthOffset
(
int
checkEndLengthOffset
)
{
this
.
checkEndLengthOffset
=
checkEndLengthOffset
;
}
public
String
getOrgCode
()
{
return
orgCode
;
}
public
void
setOrgCode
(
String
orgCode
)
{
this
.
orgCode
=
orgCode
;
}
public
int
getVisibility
()
{
return
visibility
;
}
public
void
setVisibility
(
int
visibility
)
{
this
.
visibility
=
visibility
;
}
public
String
getDescr
()
{
return
descr
;
}
public
void
setDescr
(
String
descr
)
{
this
.
descr
=
descr
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getByteOrder
()
{
return
byteOrder
;
}
public
void
setByteOrder
(
String
byteOrder
)
{
this
.
byteOrder
=
byteOrder
;
}
public
List
<
DataModelItem
>
getItems
()
{
return
items
;
}
public
void
setItems
(
List
<
DataModelItem
>
items
)
{
this
.
items
=
items
;
}
public
List
<
DataModelItem
>
getDeleteData
()
{
return
deleteData
;
}
public
void
setDeleteData
(
List
<
DataModelItem
>
deleteData
)
{
this
.
deleteData
=
deleteData
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/entity/DataModelItem.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
entity
;
import
com.yeejoin.amos.op.core.entity.Resource
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.List
;
@Entity
@Inheritance
@Table
(
name
=
"t_interface_data_model_item"
)
public
class
DataModelItem
extends
Resource
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
,
nullable
=
false
,
unique
=
true
)
private
long
id
;
private
long
groupId
;
private
long
length
;
private
Boolean
isDelete
;
private
String
name
;
private
long
serialNumber
;
private
long
dataModelId
;
private
String
displayName
;
private
long
parentId
;
@OneToMany
(
mappedBy
=
"parentId"
,
fetch
=
FetchType
.
LAZY
,
cascade
=
CascadeType
.
REMOVE
)
private
List
<
DataModelItem
>
children
;
public
List
<
DataModelItem
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
DataModelItem
>
children
)
{
this
.
children
=
children
;
}
public
long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
long
groupId
)
{
this
.
groupId
=
groupId
;
}
public
long
getLength
()
{
return
length
;
}
public
void
setLength
(
long
length
)
{
this
.
length
=
length
;
}
public
Boolean
getIsDelete
()
{
return
isDelete
;
}
public
void
setIsDelete
(
Boolean
delete
)
{
isDelete
=
delete
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
long
getSerialNumber
()
{
return
serialNumber
;
}
public
void
setSerialNumber
(
long
serialNumber
)
{
this
.
serialNumber
=
serialNumber
;
}
public
long
getDataModelId
()
{
return
dataModelId
;
}
public
void
setDataModelId
(
long
dataModelId
)
{
this
.
dataModelId
=
dataModelId
;
}
public
String
getDisplayName
()
{
return
displayName
;
}
public
void
setDisplayName
(
String
displayName
)
{
this
.
displayName
=
displayName
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/entity/EqpTmplCpbl.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.yeejoin.amos.op.core.entity.Resource
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.*
;
import
java.io.Serializable
;
@Entity
@Table
(
name
=
"t_equipment_templ_cpbl"
)
public
class
EqpTmplCpbl
extends
Resource
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
,
nullable
=
false
,
unique
=
true
)
private
long
id
;
private
long
intfcId
;
private
String
dataType
;
@Column
(
name
=
"code"
)
private
String
name
;
@Column
(
name
=
"name"
)
private
String
displayName
;
private
String
strValue
;
private
String
maxValue
;
private
String
minValue
;
private
String
enumTypes
;
private
String
type
;
private
long
equipmentDataId
;
private
long
intfcDataModelItem
;
private
long
serialNumber
;
private
String
endian
;
private
long
length
;
private
long
objectId
;
private
long
parentId
;
private
boolean
isArray
;
private
long
arrayLength
;
private
boolean
isControl
;
private
long
accuracy
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getIntfcId
()
{
return
intfcId
;
}
public
void
setIntfcId
(
long
intfcId
)
{
this
.
intfcId
=
intfcId
;
}
public
String
getDataType
()
{
return
dataType
;
}
public
void
setDataType
(
String
dataType
)
{
this
.
dataType
=
dataType
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDisplayName
()
{
return
displayName
;
}
public
void
setDisplayName
(
String
displayName
)
{
this
.
displayName
=
displayName
;
}
public
String
getStrValue
()
{
return
strValue
;
}
public
void
setStrValue
(
String
strValue
)
{
this
.
strValue
=
strValue
;
}
public
String
getMaxValue
()
{
return
maxValue
;
}
public
void
setMaxValue
(
String
maxValue
)
{
this
.
maxValue
=
maxValue
;
}
public
String
getMinValue
()
{
return
minValue
;
}
public
void
setMinValue
(
String
minValue
)
{
this
.
minValue
=
minValue
;
}
public
String
getEnumTypes
()
{
return
enumTypes
;
}
public
void
setEnumTypes
(
String
enumTypes
)
{
this
.
enumTypes
=
enumTypes
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
long
getEquipmentDataId
()
{
return
equipmentDataId
;
}
public
void
setEquipmentDataId
(
long
equipmentDataId
)
{
this
.
equipmentDataId
=
equipmentDataId
;
}
public
long
getIntfcDataModelItem
()
{
return
intfcDataModelItem
;
}
public
void
setIntfcDataModelItem
(
long
intfcDataModelItem
)
{
this
.
intfcDataModelItem
=
intfcDataModelItem
;
}
public
long
getSerialNumber
()
{
return
serialNumber
;
}
public
void
setSerialNumber
(
long
serialNumber
)
{
this
.
serialNumber
=
serialNumber
;
}
public
String
getEndian
()
{
return
endian
;
}
public
void
setEndian
(
String
endian
)
{
this
.
endian
=
endian
;
}
public
long
getLength
()
{
return
length
;
}
public
void
setLength
(
long
length
)
{
this
.
length
=
length
;
}
public
long
getObjectId
()
{
return
objectId
;
}
public
void
setObjectId
(
long
objectId
)
{
this
.
objectId
=
objectId
;
}
public
long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
boolean
getIsArray
()
{
return
isArray
;
}
public
void
setIsArray
(
boolean
array
)
{
isArray
=
array
;
}
public
long
getArrayLength
()
{
return
arrayLength
;
}
public
void
setArrayLength
(
long
arrayLength
)
{
this
.
arrayLength
=
arrayLength
;
}
public
boolean
getIsControl
()
{
return
isControl
;
}
public
void
setIsControl
(
boolean
control
)
{
isControl
=
control
;
}
public
long
getAccuracy
()
{
return
accuracy
;
}
public
void
setAccuracy
(
long
accuracy
)
{
this
.
accuracy
=
accuracy
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/entity/EqpTmplData.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.yeejoin.amos.op.core.entity.Resource
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.*
;
import
java.io.Serializable
;
@Entity
@Table
(
name
=
"t_equipment_templ_data"
)
@Where
(
clause
=
"is_delete=0"
)
//表示未删除的数据
public
class
EqpTmplData
extends
Resource
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
,
nullable
=
false
,
unique
=
true
)
private
long
id
;
private
long
intfcId
;
private
long
intfcDataModelId
;
private
boolean
isDelete
;
private
long
equipmentTemplId
;
private
long
eqpTmplIntfcId
;
private
String
name
;
private
String
control
;
private
boolean
isArray
;
private
long
cpblId
;
private
long
dataModelItemId
;
public
long
getDataModelItemId
()
{
return
dataModelItemId
;
}
public
void
setDataModelItemId
(
long
dataModelItemId
)
{
this
.
dataModelItemId
=
dataModelItemId
;
}
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getIntfcId
()
{
return
intfcId
;
}
public
void
setIntfcId
(
long
intfcId
)
{
this
.
intfcId
=
intfcId
;
}
public
long
getIntfcDataModelId
()
{
return
intfcDataModelId
;
}
public
void
setIntfcDataModelId
(
long
intfcDataModelId
)
{
this
.
intfcDataModelId
=
intfcDataModelId
;
}
public
boolean
isDelete
()
{
return
isDelete
;
}
public
void
setDelete
(
boolean
delete
)
{
isDelete
=
delete
;
}
public
long
getEquipmentTemplId
()
{
return
equipmentTemplId
;
}
public
void
setEquipmentTemplId
(
long
equipmentTemplId
)
{
this
.
equipmentTemplId
=
equipmentTemplId
;
}
public
long
getEqpTmplIntfcId
()
{
return
eqpTmplIntfcId
;
}
public
void
setEqpTmplIntfcId
(
long
eqpTmplIntfcId
)
{
this
.
eqpTmplIntfcId
=
eqpTmplIntfcId
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getControl
()
{
return
control
;
}
public
void
setControl
(
String
control
)
{
this
.
control
=
control
;
}
public
boolean
isArray
()
{
return
isArray
;
}
public
void
setArray
(
boolean
array
)
{
isArray
=
array
;
}
public
long
getCpblId
()
{
return
cpblId
;
}
public
void
setCpblId
(
long
cpblId
)
{
this
.
cpblId
=
cpblId
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/entity/EqpTmplDataAttr.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
entity
;
import
com.yeejoin.amos.op.core.entity.Resource
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.*
;
import
java.io.Serializable
;
@Entity
@Table
(
name
=
"t_equipment_templ_cpbl"
)
@Where
(
clause
=
"is_delete=0"
)
//表示未删除的数据
public
class
EqpTmplDataAttr
extends
Resource
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
,
nullable
=
false
,
unique
=
true
)
private
long
id
;
private
String
dataType
;
private
String
name
;
private
String
code
;
private
String
strValue
;
private
String
maxValue
;
private
String
minValue
;
private
String
enumTypes
;
private
String
type
;
private
long
equipmentDataId
;
private
long
intfcDataModelItem
;
private
long
serialNumber
;
private
String
endian
;
private
long
length
;
private
long
parentId
;
private
boolean
isArray
;
private
long
arrayLength
;
private
boolean
isControl
;
private
long
accuracy
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getDataType
()
{
return
dataType
;
}
public
void
setDataType
(
String
dataType
)
{
this
.
dataType
=
dataType
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getStrValue
()
{
return
strValue
;
}
public
void
setStrValue
(
String
strValue
)
{
this
.
strValue
=
strValue
;
}
public
String
getMaxValue
()
{
return
maxValue
;
}
public
void
setMaxValue
(
String
maxValue
)
{
this
.
maxValue
=
maxValue
;
}
public
String
getMinValue
()
{
return
minValue
;
}
public
void
setMinValue
(
String
minValue
)
{
this
.
minValue
=
minValue
;
}
public
String
getEnumTypes
()
{
return
enumTypes
;
}
public
void
setEnumTypes
(
String
enumTypes
)
{
this
.
enumTypes
=
enumTypes
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
long
getEquipmentDataId
()
{
return
equipmentDataId
;
}
public
void
setEquipmentDataId
(
long
equipmentDataId
)
{
this
.
equipmentDataId
=
equipmentDataId
;
}
public
long
getIntfcDataModelItem
()
{
return
intfcDataModelItem
;
}
public
void
setIntfcDataModelItem
(
long
intfcDataModelItem
)
{
this
.
intfcDataModelItem
=
intfcDataModelItem
;
}
public
long
getSerialNumber
()
{
return
serialNumber
;
}
public
void
setSerialNumber
(
long
serialNumber
)
{
this
.
serialNumber
=
serialNumber
;
}
public
String
getEndian
()
{
return
endian
;
}
public
void
setEndian
(
String
endian
)
{
this
.
endian
=
endian
;
}
public
long
getLength
()
{
return
length
;
}
public
void
setLength
(
long
length
)
{
this
.
length
=
length
;
}
public
boolean
getIsArray
()
{
return
isArray
;
}
public
void
setIsArray
(
boolean
array
)
{
isArray
=
array
;
}
public
boolean
getIsControl
()
{
return
isControl
;
}
public
void
setIsControl
(
boolean
control
)
{
isControl
=
control
;
}
public
long
getAccuracy
()
{
return
accuracy
;
}
public
void
setAccuracy
(
long
accuracy
)
{
this
.
accuracy
=
accuracy
;
}
public
long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
long
getArrayLength
()
{
return
arrayLength
;
}
public
void
setArrayLength
(
long
arrayLength
)
{
this
.
arrayLength
=
arrayLength
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/entity/IntfcDefaultAttribute.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
entity
;
import
org.apache.log4j.Logger
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
@Entity
@Table
(
name
=
"t_intfc_default_attr"
)
@Where
(
clause
=
"is_delete=0"
)
//表示未删除的数据
public
class
IntfcDefaultAttribute
extends
BasicAttribute
implements
Serializable
,
Cloneable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
6818794079648782928L
;
/**
* 日志记录器
*/
private
static
final
Logger
logger
=
Logger
.
getLogger
(
IntfcDefaultAttribute
.
class
);
/**
* 是否必填
*/
private
Boolean
isRequired
;
@Column
(
name
=
"is_required"
,
columnDefinition
=
"bit"
)
public
Boolean
getIsRequired
()
{
return
isRequired
;
}
public
void
setIsRequired
(
Boolean
isRequired
)
{
this
.
isRequired
=
isRequired
;
}
/**
* 接口外键ID
*/
private
Long
dicId
;
@Column
(
name
=
"dicId"
)
public
Long
getDicId
()
{
return
dicId
;
}
public
void
setDicId
(
Long
dicId
)
{
this
.
dicId
=
dicId
;
}
@Override
public
Object
clone
()
{
IntfcDefaultAttribute
newObj
=
null
;
try
{
newObj
=
(
IntfcDefaultAttribute
)
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
logger
.
error
(
e
);
}
return
newObj
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/business/vo/CapacityVo.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
business
.
vo
;
import
com.yeejoin.amos.iot.business.entity.EqpTmplData
;
import
java.util.List
;
public
class
CapacityVo
{
private
long
id
;
private
String
name
;
private
String
control
;
private
long
dataModelId
;
private
List
<
EqpTmplData
>
cpblTmplData
;
private
String
type
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getControl
()
{
return
control
;
}
public
void
setControl
(
String
control
)
{
this
.
control
=
control
;
}
public
long
getDataModelId
()
{
return
dataModelId
;
}
public
void
setDataModelId
(
long
dataModelId
)
{
this
.
dataModelId
=
dataModelId
;
}
public
List
<
EqpTmplData
>
getCpblTmplData
()
{
return
cpblTmplData
;
}
public
void
setCpblTmplData
(
List
<
EqpTmplData
>
cpblTmplData
)
{
this
.
cpblTmplData
=
cpblTmplData
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/core/adapter/RedisConfig.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
core
.
adapter
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheConfiguration
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.cache.RedisCacheWriter
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.connection.RedisPassword
;
import
org.springframework.data.redis.connection.RedisStandaloneConfiguration
;
import
org.springframework.data.redis.connection.jedis.JedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.RedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
java.time.Duration
;
import
java.util.HashMap
;
import
java.util.Map
;
@Configuration
@EnableCaching
public
class
RedisConfig
{
@Value
(
"${spring.redis.host}"
)
private
String
redisHost
;
@Value
(
"${spring.redis.port}"
)
private
String
redisPort
;
@Value
(
"${spring.redis.password}"
)
private
String
redisPasswd
;
@Value
(
"${spring.redis.database}"
)
private
String
database
;
private
int
timeOut
=
2000
;
private
int
redirects
=
8
;
@Bean
// redis连接
public
RedisConnectionFactory
redisConnectionFactory
()
{
JedisConnectionFactory
cf
=
null
;
RedisStandaloneConfiguration
redisStandaloneConfiguration
=
new
RedisStandaloneConfiguration
();
redisStandaloneConfiguration
.
setHostName
(
redisHost
);
redisStandaloneConfiguration
.
setPort
(
Integer
.
parseInt
(
redisPort
));
redisStandaloneConfiguration
.
setPassword
(
RedisPassword
.
of
(
redisPasswd
));
redisStandaloneConfiguration
.
setDatabase
(
Integer
.
parseInt
(
database
));
cf
=
new
JedisConnectionFactory
(
redisStandaloneConfiguration
);
cf
.
afterPropertiesSet
();
return
cf
;
}
@Bean
// 实际使用的redisTemplate,可以直接注入到代码中,直接操作redis
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
factory
)
{
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<
String
,
Object
>();
template
.
setConnectionFactory
(
factory
);
Jackson2JsonRedisSerializer
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
jackson2JsonRedisSerializer
.
setObjectMapper
(
om
);
StringRedisSerializer
stringRedisSerializer
=
new
StringRedisSerializer
();
// key采用String的序列化方式
template
.
setKeySerializer
(
stringRedisSerializer
);
// hash的key也采用String的序列化方式
template
.
setHashKeySerializer
(
stringRedisSerializer
);
// value序列化方式采用jackson
template
.
setValueSerializer
(
jackson2JsonRedisSerializer
);
// hash的value序列化方式采用jackson
template
.
setHashValueSerializer
(
jackson2JsonRedisSerializer
);
template
.
afterPropertiesSet
();
return
template
;
}
@Bean
// 关联redis到注解
CacheManager
cacheManager
(
RedisConnectionFactory
redisConnectionFactory
)
{
RedisCacheWriter
redisCacheWriter
=
RedisCacheWriter
.
nonLockingRedisCacheWriter
(
redisConnectionFactory
);
// 默认配置,过期时间指定是30分钟
RedisCacheConfiguration
defaultCacheConfig
=
RedisCacheConfiguration
.
defaultCacheConfig
();
defaultCacheConfig
.
entryTtl
(
Duration
.
ofMinutes
(
30
));
// redisExpire1h cache配置,过期时间指定是1小时,缓存key的前缀指定成prefixaaa_(存到redis的key会自动添加这个前缀)
RedisCacheConfiguration
userCacheConfiguration
=
RedisCacheConfiguration
.
defaultCacheConfig
().
entryTtl
(
Duration
.
ofHours
(
1
)).
prefixKeysWith
(
"prefixaaa_"
);
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
=
new
HashMap
<>();
redisCacheConfigurationMap
.
put
(
"redisExpire1h"
,
userCacheConfiguration
);
RedisCacheManager
cacheManager
=
new
RedisCacheManager
(
redisCacheWriter
,
defaultCacheConfig
,
redisCacheConfigurationMap
);
return
cacheManager
;
}
}
\ No newline at end of file
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/core/threadpool/ThreadTaskHelper.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
core
.
threadpool
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
/**
* Created by jiang on 2017/3/6.
*/
public
class
ThreadTaskHelper
{
private
static
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
20
);
public
static
void
run
(
Runnable
runnable
){
executorService
.
execute
(
runnable
);
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/ChannelCache.java
deleted
100644 → 0
View file @
230257be
/**
*
*/
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.constants.IotConstant
;
import
com.yeejoin.amos.iot.business.queue.AlarmDataObj
;
import
com.yeejoin.amos.iot.business.queue.AlarmDataQueue
;
import
com.yeejoin.amos.iot.business.queue.ChannelAlarmData
;
import
com.yeejoin.amos.iot.netty.vehicle.entity.VehicleDevice
;
import
io.netty.channel.Channel
;
import
org.apache.log4j.Logger
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* 通道缓存
*
* @author as-youjun
*
*/
public
class
ChannelCache
{
/**
* 单例
*/
private
static
ChannelCache
instance
;
/**
* 记录通道和sid:<通道,sid>
*/
private
ConcurrentHashMap
<
Channel
,
String
>
channelSidMap
=
new
ConcurrentHashMap
<>();
/**
* 记录消防物联网设备标识、时间和连接状况数据:<sid,VehicleDevice>
*/
private
ConcurrentHashMap
<
String
,
VehicleDevice
>
vehicleDeviceMap
=
new
ConcurrentHashMap
<>();
/**
* 构造方法
*/
private
ChannelCache
()
{
Logger
.
getLogger
(
ChannelCache
.
class
).
debug
(
IotConstant
.
CONSTRUCTOR
);
}
/**
* 获取单例
*
* @return
*/
public
static
ChannelCache
getInstance
()
{
if
(
instance
==
null
)
{
synchronized
(
ChannelCache
.
class
)
{
if
(
instance
==
null
)
{
instance
=
new
ChannelCache
();
}
}
}
return
instance
;
}
public
void
channelRegister
(
Channel
channel
,
String
sId
)
{
String
str
=
channelSidMap
.
get
(
channel
);
if
(
null
==
str
){
//缓存新的通道
channelSidMap
.
put
(
channel
,
sId
);
ChannelAlarmData
channelAlarmData
=
new
ChannelAlarmData
();
channelAlarmData
.
setsId
(
sId
);
channelAlarmData
.
setType
(
IotConstant
.
REGISTER
);
AlarmDataObj
alarmDataObj
=
new
AlarmDataObj
(
channelAlarmData
);
alarmDataObj
.
setType
(
IotConstant
.
CHANNEL
);
//设备通道建立清除告警
AlarmDataQueue
.
getInstance
().
add
(
alarmDataObj
);
}
else
{
Logger
.
getLogger
(
ChannelCache
.
class
).
info
(
"register sId:"
+
sId
);
}
}
public
void
channelUnregister
(
Channel
channel
){
String
sId
=
channelSidMap
.
get
(
channel
);
if
(
null
!=
sId
){
ChannelAlarmData
channelAlarmData
=
new
ChannelAlarmData
();
channelAlarmData
.
setsId
(
sId
);
channelAlarmData
.
setType
(
IotConstant
.
UNREGISTER
);
AlarmDataObj
alarmDataObj
=
new
AlarmDataObj
(
channelAlarmData
);
alarmDataObj
.
setType
(
IotConstant
.
CHANNEL
);
AlarmDataQueue
.
getInstance
().
add
(
alarmDataObj
);
//清除旧的通道
channelSidMap
.
remove
(
channel
);
}
else
{
Logger
.
getLogger
(
ChannelCache
.
class
).
info
(
"unregister sId:"
+
sId
);
}
}
/**
* 添加通道
*
* @param channel
* @param sid
*/
public
void
addChannel
(
Channel
channel
,
String
sid
)
{
// 1.获取与关闭旧连接
Channel
oldChannel
=
getChannel
(
sid
);
try
{
channelSidMap
.
remove
(
oldChannel
);
oldChannel
.
closeFuture
().
sync
();
}
catch
(
Exception
e
)
{
Logger
.
getLogger
(
this
.
getClass
()).
error
(
e
);
}
// 2.添加通道
channelSidMap
.
put
(
channel
,
sid
);
}
/**
* 获取通道
*
* @param sid
* @return
*/
public
Channel
getChannel
(
String
sid
)
{
Channel
channel
=
null
;
Set
<
Entry
<
Channel
,
String
>>
channels
=
channelSidMap
.
entrySet
();
for
(
Entry
<
Channel
,
String
>
entry
:
channels
)
{
if
(
entry
.
getValue
().
equals
(
sid
))
{
channel
=
entry
.
getKey
();
break
;
}
}
return
channel
;
}
/**
* 获取sid
*
* @param channel
* @return
*/
public
String
getSid
(
Channel
channel
)
{
return
channelSidMap
.
get
(
channel
);
}
/**
* 移除通道
*
* @param channel
*/
public
void
removeChannel
(
Channel
channel
)
{
channelSidMap
.
remove
(
channel
);
}
/**
* 移除通道
*
* @param sid
*/
public
void
removeChannel
(
String
sid
)
{
Channel
channel
=
getChannel
(
sid
);
if
(
channel
!=
null
)
{
channelSidMap
.
remove
(
channel
);
}
}
/**
* 缓存中添加消防物联网设备
*
* @param vehicleDevice
*/
public
void
addVehicleDevice
(
VehicleDevice
vehicleDevice
)
{
vehicleDeviceMap
.
put
(
vehicleDevice
.
getSourceId
(),
vehicleDevice
);
}
/**
* 缓存中移除消防物联网设备
*
* @param sid
*/
public
void
removeVehicleDevice
(
String
sid
)
{
vehicleDeviceMap
.
remove
(
sid
);
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/CommonChannelHandler.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.ChannelInboundHandlerAdapter
;
import
io.netty.channel.SimpleChannelInboundHandler
;
public
class
CommonChannelHandler
extends
ChannelInboundHandlerAdapter
{
private
long
intfcId
;
public
CommonChannelHandler
(
long
intfcId
)
{
this
.
intfcId
=
intfcId
;
}
// @Override
// protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf o) throws Exception {
// DataProcessThreadPool.getInstance().publish(channelHandlerContext, this.intfcId,o);
// }
@Override
public
void
channelRead
(
ChannelHandlerContext
ctx
,
Object
msg
)
throws
Exception
{
DataProcessThreadPool
.
getInstance
().
publish
(
ctx
,
this
.
intfcId
,
(
ByteBuf
)
msg
);
}
@Override
public
void
channelActive
(
ChannelHandlerContext
ctx
)
throws
Exception
{
super
.
channelActive
(
ctx
);
}
@Override
public
void
channelInactive
(
ChannelHandlerContext
ctx
)
throws
Exception
{
super
.
channelInactive
(
ctx
);
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/CommonDataCache.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.Intfc
;
import
net.sf.json.JSONArray
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
public
class
CommonDataCache
{
private
static
final
BlockingQueue
<
JSONArray
>
startBlockingQueue
=
new
LinkedBlockingQueue
<
JSONArray
>();
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/CommonDecoder.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.dao.mapper.IntfcMapper
;
import
com.yeejoin.amos.iot.business.entity.DataModel
;
import
com.yeejoin.amos.iot.context.IotContext
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.buffer.Unpooled
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.handler.codec.ByteToMessageDecoder
;
import
io.netty.handler.codec.LengthFieldBasedFrameDecoder
;
import
javax.script.Invocable
;
import
javax.script.ScriptException
;
import
java.util.List
;
public
class
CommonDecoder
extends
LengthFieldBasedFrameDecoder
{
private
IntfcMapper
intfcMapper
;
private
Invocable
invocable
=
null
;
private
String
DECODE_DATA_METHOD_NAME
=
"decode"
;
private
int
HEADER_SIZE
=
1
;
public
CommonDecoder
(
int
maxFrameLength
,
int
lengthFieldOffset
,
int
lengthFieldLength
,
int
lengthAdjustment
,
int
initialBytesToStrip
,
boolean
failFast
)
{
super
(
maxFrameLength
,
lengthFieldOffset
,
lengthFieldLength
,
lengthAdjustment
,
initialBytesToStrip
,
failFast
);
}
@Override
public
ByteBuf
decode
(
ChannelHandlerContext
ctx
,
ByteBuf
in
)
throws
Exception
{
ByteBuf
buf
=
Unpooled
.
buffer
(
in
.
readableBytes
());
buf
.
writeBytes
(
in
);
if
(
buf
==
null
){
return
null
;
}
return
buf
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/CommonEncoder.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.handler.codec.MessageToByteEncoder
;
public
class
CommonEncoder
extends
MessageToByteEncoder
{
public
CommonEncoder
(
long
intfcId
)
{
}
@Override
protected
void
encode
(
ChannelHandlerContext
channelHandlerContext
,
Object
o
,
ByteBuf
byteBuf
)
throws
Exception
{
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/CommonStart.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.Intfc
;
import
com.yeejoin.amos.iot.business.service.intfc.IIntfcService
;
import
com.yeejoin.amos.op.core.util.ApplicationConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.util.ObjectUtils
;
import
javax.annotation.PostConstruct
;
import
java.util.List
;
@Configuration
public
class
CommonStart
{
@Autowired
private
IIntfcService
intfcService
;
@Autowired
ApplicationConfig
applicationConfig
;
@PostConstruct
public
void
start
()
{
initTcpQueue
();
new
ConsumerThead
().
run
();
new
StartTcpThread
(
applicationConfig
).
start
();
new
StartMqttThread
(
applicationConfig
).
start
();
new
StartHttpThread
(
applicationConfig
).
start
();
new
StopTcpThread
().
start
();
}
private
void
initTcpQueue
()
{
List
<
Intfc
>
intfcs
=
intfcService
.
findALLByCommunityProtocolName
(
"TCP"
);
if
(!
ObjectUtils
.
isEmpty
(
intfcs
))
{
CommonTcpCache
.
getInstance
().
addAll
(
intfcs
);
}
List
<
Intfc
>
mqttIntfcs
=
intfcService
.
findALLByCommunityProtocolName
(
"MQTT"
);
if
(!
ObjectUtils
.
isEmpty
(
mqttIntfcs
))
{
CommonTcpCache
.
getInstance
().
addAllMqtt
(
mqttIntfcs
);
}
List
<
Intfc
>
httpIntfcs
=
intfcService
.
findALLByCommunityProtocolName
(
"HTTP"
);
if
(!
ObjectUtils
.
isEmpty
(
httpIntfcs
))
{
CommonTcpCache
.
getInstance
().
addAllHttp
(
httpIntfcs
);
}
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/CommonTcpCache.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.Intfc
;
import
io.netty.channel.ChannelHandlerContext
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.LinkedBlockingQueue
;
public
class
CommonTcpCache
{
// 启动TCP服务队列
private
static
final
BlockingQueue
<
Intfc
>
startBlockingQueue
=
new
LinkedBlockingQueue
<
Intfc
>();
// 停止TCP服务队列
private
static
final
BlockingQueue
<
Intfc
>
stopBlockingQueue
=
new
LinkedBlockingQueue
<
Intfc
>();
// 启动mqtt服务队列
private
static
final
BlockingQueue
<
Intfc
>
startMqttBlockingQueue
=
new
LinkedBlockingQueue
<
Intfc
>();
// 停止mqtt服务队列
private
static
final
BlockingQueue
<
Intfc
>
stopMqttBlockingQueue
=
new
LinkedBlockingQueue
<
Intfc
>();
// 启动mqtt服务队列
private
static
final
BlockingQueue
<
Intfc
>
startHttpBlockingQueue
=
new
LinkedBlockingQueue
<
Intfc
>();
// 停止mqtt服务队列
private
static
final
BlockingQueue
<
Intfc
>
stopHttpBlockingQueue
=
new
LinkedBlockingQueue
<
Intfc
>();
private
static
final
Map
<
String
,
Thread
>
runnableHashMap
=
new
ConcurrentHashMap
<
String
,
Thread
>();
/**
* 单例
*/
private
static
CommonTcpCache
instance
;
/**
* 获取单例
*
* @return
*/
public
static
CommonTcpCache
getInstance
()
{
if
(
instance
==
null
)
{
synchronized
(
CommonTcpCache
.
class
)
{
if
(
instance
==
null
)
{
instance
=
new
CommonTcpCache
();
}
}
}
return
instance
;
}
public
BlockingQueue
<
Intfc
>
getStartBlockingQueue
()
{
return
startBlockingQueue
;
}
public
static
BlockingQueue
<
Intfc
>
getStopBlockingQueue
()
{
return
stopBlockingQueue
;
}
public
void
add
(
Intfc
obj
)
{
startBlockingQueue
.
add
(
obj
);
}
public
void
addAll
(
List
<
Intfc
>
objs
)
{
startBlockingQueue
.
addAll
(
objs
);
}
public
void
remove
(
Intfc
obj
)
{
stopBlockingQueue
.
add
(
obj
);
}
public
void
removeAll
(
List
<
Intfc
>
objs
)
{
stopBlockingQueue
.
addAll
(
objs
);
}
public
void
addMqtt
(
Intfc
obj
)
{
startMqttBlockingQueue
.
add
(
obj
);
}
public
void
addAllMqtt
(
List
<
Intfc
>
objs
)
{
startMqttBlockingQueue
.
addAll
(
objs
);
}
public
void
removeMqtt
(
Intfc
obj
)
{
stopMqttBlockingQueue
.
add
(
obj
);
}
public
void
removeAllMqtt
(
List
<
Intfc
>
objs
)
{
stopMqttBlockingQueue
.
addAll
(
objs
);
}
public
Map
<
String
,
Thread
>
getRunnableHashMap
()
{
return
runnableHashMap
;
}
public
Thread
getRunnable
(
String
key
)
{
return
runnableHashMap
.
get
(
key
);
}
public
void
removeRunnable
(
String
key
)
{
runnableHashMap
.
remove
(
key
);
}
public
void
addRunnable
(
String
key
,
Thread
nettyService
)
{
runnableHashMap
.
put
(
key
,
nettyService
);
}
public
BlockingQueue
<
Intfc
>
getStartMqttBlockingQueue
()
{
return
startMqttBlockingQueue
;
}
public
void
addHttp
(
Intfc
obj
)
{
startHttpBlockingQueue
.
add
(
obj
);
}
public
void
addAllHttp
(
List
<
Intfc
>
objs
)
{
startHttpBlockingQueue
.
addAll
(
objs
);
}
public
void
removeHttp
(
Intfc
obj
)
{
stopHttpBlockingQueue
.
add
(
obj
);
}
public
void
removeAllHttp
(
List
<
Intfc
>
objs
)
{
stopHttpBlockingQueue
.
addAll
(
objs
);
}
public
static
BlockingQueue
<
Intfc
>
getStopMqttBlockingQueue
()
{
return
stopMqttBlockingQueue
;
}
public
static
BlockingQueue
<
Intfc
>
getStartHttpBlockingQueue
()
{
return
startHttpBlockingQueue
;
}
public
static
BlockingQueue
<
Intfc
>
getStopHttpBlockingQueue
()
{
return
stopHttpBlockingQueue
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/CommonThread.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
io.netty.channel.ChannelFuture
;
import
io.netty.channel.EventLoopGroup
;
import
org.apache.log4j.Logger
;
public
abstract
class
CommonThread
extends
Thread
{
/**
* boss线程池
*/
public
EventLoopGroup
bossLoopGroup
;
/**
* worker线程池
*/
public
EventLoopGroup
workLoogGroup
;
/**
* ChannelFuture
*/
public
ChannelFuture
channelFuture
;
/**
* 停止mqtt服务
*/
public
void
stopService
()
{
System
.
out
.
println
(
"mqtt server stopped."
);
try
{
channelFuture
.
channel
().
closeFuture
().
sync
();
}
catch
(
Exception
e
)
{
Logger
.
getLogger
(
this
.
getClass
()).
error
(
e
);
}
finally
{
bossLoopGroup
.
shutdownGracefully
();
workLoogGroup
.
shutdownGracefully
();
}
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/ConsumerThead.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
public
class
ConsumerThead
implements
Runnable
{
@Override
public
void
run
()
{
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/DataConsumer.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.dao.mapper.DeviceMapper
;
import
com.yeejoin.amos.iot.business.dao.repository.IEquipmentDao
;
import
com.yeejoin.amos.iot.business.entity.MetricData
;
import
com.yeejoin.amos.iot.context.IotContext
;
import
net.sf.json.JSONArray
;
public
class
DataConsumer
implements
Runnable
{
private
DeviceMapper
deviceMapper
;
private
IEquipmentDao
equipmentDao
;
public
DataConsumer
(
MetricData
metricData
)
{
this
.
deviceMapper
=
(
DeviceMapper
)
IotContext
.
getInstance
().
getBean
(
DeviceMapper
.
class
);
this
.
equipmentDao
=
(
IEquipmentDao
)
IotContext
.
getInstance
().
getBean
(
IEquipmentDao
.
class
);
}
@Override
public
void
run
()
{
// 获取设备信息
// this.deviceMapper.findEqpBySourceId(templateId, sourceId);
// 跟新数据库实时数据
// 保存数据到mongodb
// 产生告警
// 消息推送
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/DataProcessThreadPool.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.DataModel
;
import
com.yeejoin.amos.iot.business.entity.MetricData
;
import
com.yeejoin.amos.iot.business.service.impl.IntfcServiceImpl
;
import
com.yeejoin.amos.iot.business.service.intfc.IIntfcService
;
import
com.yeejoin.amos.iot.context.IotContext
;
import
com.yeejoin.amos.iot.netty.common.entity.InterfaceFrame
;
import
com.yeejoin.amos.iot.netty.mqtt.MqttFrameQueue
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.ChannelHandlerContext
;
import
net.sf.json.JSONArray
;
import
java.util.List
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
public
class
DataProcessThreadPool
{
private
ExecutorService
executorService
;
private
ExecutorService
executorDataService
;
private
IIntfcService
intfcService
;
private
static
DataProcessThreadPool
instance
;
private
DataProcessThreadPool
()
{
executorService
=
Executors
.
newFixedThreadPool
(
20
);
executorDataService
=
Executors
.
newFixedThreadPool
(
20
);
this
.
intfcService
=
(
IIntfcService
)
IotContext
.
getInstance
().
getBean
((
IIntfcService
.
class
));
};
/**
* 获取单例
*
* @return
*/
public
static
DataProcessThreadPool
getInstance
()
{
if
(
instance
==
null
)
{
synchronized
(
DataProcessThreadPool
.
class
)
{
if
(
instance
==
null
)
{
instance
=
new
DataProcessThreadPool
();
}
}
}
return
instance
;
}
public
void
publish
(
ChannelHandlerContext
channelHandlerContext
,
long
intfcId
,
ByteBuf
byteBuf
)
{
DataModel
dataModel
=
intfcService
.
findOneDataModelByIntfcId
(
intfcId
);
Runnable
runnable
=
null
;
if
(
dataModel
!=
null
)
{
if
(
"json"
.
equals
(
dataModel
.
getType
()))
{
runnable
=
new
JSONConsumer
(
intfcService
,
byteBuf
,
intfcId
,
channelHandlerContext
,
dataModel
);
}
else
if
(
"hex"
.
equals
(
dataModel
.
getType
()))
{
runnable
=
new
FrameConsumer
(
intfcService
,
byteBuf
,
intfcId
,
channelHandlerContext
,
dataModel
);
}
else
if
(
"xml"
.
equals
(
dataModel
.
getType
()))
{
runnable
=
new
XMLConsumer
(
intfcService
,
byteBuf
,
intfcId
,
channelHandlerContext
,
dataModel
);
}
if
(
runnable
!=
null
)
{
executorService
.
execute
(
runnable
);
}
}
}
public
void
publish
(
MetricData
metricData
)
{
executorDataService
.
submit
(
new
DataConsumer
(
metricData
));
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/FrameConsumer.java
deleted
100644 → 0
View file @
230257be
This diff is collapsed.
Click to expand it.
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/JSONConsumer.java
deleted
100644 → 0
View file @
230257be
This diff is collapsed.
Click to expand it.
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/NettyService.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.DataModel
;
import
com.yeejoin.amos.iot.business.service.intfc.IInterfacePropertyService
;
import
com.yeejoin.amos.iot.business.service.intfc.IIntfcService
;
import
com.yeejoin.amos.iot.context.IotContext
;
import
com.yeejoin.amos.op.core.util.ApplicationConfig
;
import
io.netty.bootstrap.ServerBootstrap
;
import
io.netty.channel.*
;
import
io.netty.channel.nio.NioEventLoopGroup
;
import
io.netty.channel.socket.SocketChannel
;
import
io.netty.channel.socket.nio.NioServerSocketChannel
;
import
org.apache.log4j.Logger
;
import
java.net.InetSocketAddress
;
public
class
NettyService
extends
CommonThread
{
/**
* 端口号
*/
int
port
;
/**
* server配置
*/
private
ApplicationConfig
applicationConfig
;
private
long
intfcId
;
private
IIntfcService
intfcService
;
private
DataModel
dataModel
;
public
NettyService
(
long
intfcId
,
int
port
,
ApplicationConfig
applicationConfig
)
{
this
.
intfcId
=
intfcId
;
this
.
port
=
port
;
this
.
applicationConfig
=
applicationConfig
;
this
.
intfcService
=
(
IIntfcService
)
IotContext
.
getInstance
().
getBean
(
IIntfcService
.
class
);
this
.
dataModel
=
intfcService
.
findOneDataModelByIntfcId
(
intfcId
);
}
@Override
public
void
run
()
{
// 创建一个serverbootstrap实例
ServerBootstrap
serverBootstrap
=
new
ServerBootstrap
();
// BOSS线程池
bossLoopGroup
=
new
NioEventLoopGroup
(
1
);
// CPU个数
int
processorsNumber
=
Runtime
.
getRuntime
().
availableProcessors
();
// worker线程池
workLoogGroup
=
new
NioEventLoopGroup
(
processorsNumber
*
2
);
// 指定 boss线程池、worker线程池
serverBootstrap
.
group
(
bossLoopGroup
,
workLoogGroup
);
// 指定使用NIO传输Channel
serverBootstrap
.
channel
(
NioServerSocketChannel
.
class
);
// 设置option
/***
* BACKLOG用于构造服务端套接字ServerSocket对象,标识当服务器请求处理线程全满时,用于临时存放已完成三次握手的请求的队列的最大长度。
* 如果未设置或所设置的值小于1,Java将使用默认值50。
*/
String
backlog
=
applicationConfig
.
getParamValueStr
(
"so.backlog"
);
serverBootstrap
.
option
(
ChannelOption
.
SO_BACKLOG
,
Integer
.
valueOf
(
backlog
));
serverBootstrap
.
childOption
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
// 设置连接超时时间30秒
serverBootstrap
.
option
(
ChannelOption
.
CONNECT_TIMEOUT_MILLIS
,
30000
);
// 设置ChannelHandler
serverBootstrap
.
childHandler
(
new
ChannelInitializer
<
SocketChannel
>()
{
@Override
protected
void
initChannel
(
SocketChannel
channel
)
throws
Exception
{
InetSocketAddress
s
=
channel
.
remoteAddress
();
Logger
.
getLogger
(
this
.
getClass
()).
debug
(
"client channel:"
+
s
.
toString
());
channel
.
pipeline
().
addLast
(
new
CommonDecoder
(
dataModel
.
getMaxFrameLength
(),
dataModel
.
getLengthFieldOffset
(),
dataModel
.
getLengthFieldLength
(),
dataModel
.
getLengthAdjustment
(),
dataModel
.
getInitialBytesToStrip
(),
dataModel
.
getIsFailFast
()));
channel
.
pipeline
().
addLast
(
new
CommonChannelHandler
(
intfcId
));
}
});
// 异步的绑定服务器,sync()一直等到绑定完成:绑定端口
try
{
channelFuture
=
serverBootstrap
.
bind
(
this
.
port
).
sync
();
Logger
.
getLogger
(
this
.
getClass
())
.
debug
(
"netty server started and listen on '"
+
channelFuture
.
channel
().
localAddress
());
}
catch
(
InterruptedException
e
)
{
Logger
.
getLogger
(
StartTcpThread
.
class
).
error
(
e
.
getMessage
());
}
}
public
void
stopService
()
{
channelFuture
.
addListener
(
ChannelFutureListener
.
CLOSE
);
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/StartHttpThread.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.Intfc
;
import
com.yeejoin.amos.iot.business.entity.IntfcAttribute
;
import
com.yeejoin.amos.iot.business.service.intfc.IInterfacePropertyService
;
import
com.yeejoin.amos.iot.context.IotContext
;
import
com.yeejoin.amos.iot.netty.common.utils.ToolUtil
;
import
com.yeejoin.amos.iot.netty.http.HttpServer
;
import
com.yeejoin.amos.op.core.util.ApplicationConfig
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
public
class
StartHttpThread
extends
Thread
{
private
ApplicationConfig
applicationConfig
;
private
IInterfacePropertyService
intfcAttributeService
;
public
StartHttpThread
(
ApplicationConfig
applicationConfig
)
{
this
.
applicationConfig
=
applicationConfig
;
this
.
intfcAttributeService
=
(
IInterfacePropertyService
)
IotContext
.
getInstance
().
getBean
(
IInterfacePropertyService
.
class
);
}
@Override
public
void
run
()
{
do
{
while
(
true
)
{
try
{
Intfc
param
=
CommonTcpCache
.
getInstance
().
getStartHttpBlockingQueue
().
take
();
List
<
IntfcAttribute
>
intfcAttrs
=
intfcAttributeService
.
getPropertysById
(
param
.
getId
());
int
port
=
0
;
for
(
IntfcAttribute
attr
:
intfcAttrs
)
{
if
(!
ObjectUtils
.
isEmpty
(
attr
.
getName
())
&&
"port"
.
equals
(
attr
.
getName
()))
{
port
=
Integer
.
parseInt
(
attr
.
getValueStr
());
break
;
}
}
if
(
ToolUtil
.
isLocalPortUsing
(
port
))
{
/**
* TODO 端口被占用 异常消息提示
*/
break
;
}
if
(
port
>
0
)
{
HttpServer
httpServer
=
new
HttpServer
(
applicationConfig
,
port
,
param
.
getId
());
httpServer
.
start
();
CommonTcpCache
.
getInstance
().
addRunnable
(
param
.
getId
()+
""
,
httpServer
);
}
}
catch
(
Exception
e
)
{
break
;
}
}
}
while
(
true
);
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/StartMqttThread.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.Intfc
;
import
com.yeejoin.amos.iot.business.entity.IntfcAttribute
;
import
com.yeejoin.amos.iot.business.service.impl.InterfacePropertyServiceImpl
;
import
com.yeejoin.amos.iot.business.service.intfc.IInterfacePropertyService
;
import
com.yeejoin.amos.iot.context.IotContext
;
import
com.yeejoin.amos.iot.netty.common.utils.ToolUtil
;
import
com.yeejoin.amos.iot.netty.mqtt.server.MqttServer
;
import
com.yeejoin.amos.op.core.util.ApplicationConfig
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
public
class
StartMqttThread
extends
Thread
{
private
ApplicationConfig
applicationConfig
;
private
IInterfacePropertyService
intfcAttributeService
;
public
StartMqttThread
(
ApplicationConfig
applicationConfig
)
{
this
.
applicationConfig
=
applicationConfig
;
this
.
intfcAttributeService
=
(
IInterfacePropertyService
)
IotContext
.
getInstance
().
getBean
(
IInterfacePropertyService
.
class
);
}
@Override
public
void
run
()
{
do
{
while
(
true
)
{
try
{
Intfc
param
=
CommonTcpCache
.
getInstance
().
getStartMqttBlockingQueue
().
take
();
List
<
IntfcAttribute
>
intfcAttrs
=
intfcAttributeService
.
getPropertysById
(
param
.
getId
());
int
port
=
0
;
for
(
IntfcAttribute
attr
:
intfcAttrs
)
{
if
(!
ObjectUtils
.
isEmpty
(
attr
.
getName
())
&&
"port"
.
equals
(
attr
.
getName
()))
{
port
=
Integer
.
parseInt
(
attr
.
getValueStr
());
break
;
}
}
if
(
ToolUtil
.
isLocalPortUsing
(
port
))
{
/**
* TODO 端口被占用 异常消息提示
*/
break
;
}
if
(
port
>
0
)
{
MqttServer
nettyService
=
new
MqttServer
(
applicationConfig
,
port
,
param
.
getId
());
nettyService
.
start
();
CommonTcpCache
.
getInstance
().
addRunnable
(
param
.
getId
()+
""
,
nettyService
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
break
;
}
}
}
while
(
true
);
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/StartTcpThread.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.Intfc
;
import
com.yeejoin.amos.iot.business.entity.IntfcAttribute
;
import
com.yeejoin.amos.iot.business.service.impl.InterfacePropertyServiceImpl
;
import
com.yeejoin.amos.iot.business.service.intfc.IInterfacePropertyService
;
import
com.yeejoin.amos.iot.context.IotContext
;
import
com.yeejoin.amos.iot.netty.common.utils.ToolUtil
;
import
com.yeejoin.amos.op.core.util.ApplicationConfig
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
public
class
StartTcpThread
extends
Thread
{
private
ApplicationConfig
applicationConfig
;
private
IInterfacePropertyService
intfcAttributeService
;
public
StartTcpThread
(
ApplicationConfig
applicationConfig
)
{
this
.
applicationConfig
=
applicationConfig
;
this
.
intfcAttributeService
=
(
IInterfacePropertyService
)
IotContext
.
getInstance
().
getBean
(
IInterfacePropertyService
.
class
);
}
@Override
public
void
run
()
{
do
{
while
(
true
)
{
try
{
Intfc
param
=
CommonTcpCache
.
getInstance
().
getStartBlockingQueue
().
take
();
List
<
IntfcAttribute
>
intfcAttrs
=
intfcAttributeService
.
getPropertysById
(
param
.
getId
());
int
port
=
0
;
for
(
IntfcAttribute
attr
:
intfcAttrs
)
{
if
(!
ObjectUtils
.
isEmpty
(
attr
.
getName
())
&&
"port"
.
equals
(
attr
.
getName
()))
{
port
=
Integer
.
parseInt
(
attr
.
getValueStr
());
break
;
}
}
if
(
ToolUtil
.
isLocalPortUsing
(
port
))
{
/**
* TODO 端口被占用 异常消息提示
*/
break
;
}
if
(
port
>
0
)
{
NettyService
nettyService
=
new
NettyService
(
param
.
getId
(),
port
,
applicationConfig
);
nettyService
.
start
();
CommonTcpCache
.
getInstance
().
addRunnable
(
param
.
getId
()+
""
,
nettyService
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
break
;
}
}
}
while
(
true
);
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/StopTcpThread.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.Intfc
;
import
java.util.Map
;
public
class
StopTcpThread
extends
Thread
{
@Override
public
void
run
()
{
while
(
true
)
{
try
{
Intfc
param
=
CommonTcpCache
.
getInstance
().
getStopBlockingQueue
().
take
();
String
intfcId
=
param
.
getId
().
toString
();
CommonThread
nettyService
=
(
CommonThread
)
CommonTcpCache
.
getInstance
().
getRunnable
(
intfcId
);
nettyService
.
stopService
();
}
catch
(
Exception
e
)
{
}
}
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/XMLConsumer.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
;
import
com.yeejoin.amos.iot.business.entity.DataModel
;
import
com.yeejoin.amos.iot.business.service.intfc.IIntfcService
;
import
com.yeejoin.amos.iot.netty.common.entity.EquipTmplData
;
import
com.yeejoin.amos.iot.netty.common.entity.EquipTmplDataAttr
;
import
com.yeejoin.amos.iot.netty.common.entity.InterfaceFrame
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.ChannelHandlerContext
;
import
net.sf.json.JSONArray
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.Element
;
import
org.dom4j.io.SAXReader
;
import
java.io.ByteArrayInputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
XMLConsumer
implements
Runnable
{
private
ChannelHandlerContext
channelHandlerContext
;
private
ByteBuf
byteBuf
;
private
IIntfcService
intfcService
;
private
List
<
InterfaceFrame
>
interfaceFrameList
;
private
long
intfcId
;
private
DataModel
dataModel
;
public
XMLConsumer
(
IIntfcService
intfcService
,
ByteBuf
o
,
long
intfcId
,
ChannelHandlerContext
ctx
,
DataModel
dataModel
)
{
this
.
byteBuf
=
o
;
this
.
intfcService
=
intfcService
;
this
.
dataModel
=
dataModel
;
this
.
interfaceFrameList
=
intfcService
.
findAllInterfaceAttrNodesById
(
dataModel
.
getId
());;
this
.
intfcId
=
intfcId
;
this
.
channelHandlerContext
=
ctx
;
}
@Override
public
void
run
()
{
do
{
HashMap
<
String
,
Object
>
interfaceData
=
new
HashMap
<>();
String
control
=
null
;
String
json
=
new
String
(
byteBuf
.
array
());
Map
<
String
,
Object
>
valueMap
=
null
;
String
sourceId
=
null
;
try
{
valueMap
=
parseXml
(
json
);
}
catch
(
DocumentException
e
)
{
e
.
printStackTrace
();
break
;
}
int
totalUnit
=
interfaceFrameList
.
size
();
Object
data
=
new
HashMap
<>();
for
(
InterfaceFrame
unit
:
interfaceFrameList
)
{
interfaceData
.
put
(
unit
.
getPropertyName
(),
valueMap
.
get
(
unit
.
getPropertyName
()));
if
(
"CONTROL"
.
equals
(
unit
.
getGroupType
()))
{
control
=
valueMap
.
get
(
unit
.
getPropertyName
()).
toString
();
}
if
(
"DATA"
.
equals
(
unit
.
getGroupType
()))
{
data
=
valueMap
.
get
(
unit
.
getPropertyName
());
}
if
(
unit
.
getIsEquipmentId
())
{
sourceId
=
interfaceData
.
get
(
unit
.
getPropertyName
()).
toString
();
ChannelCache
.
getInstance
().
channelRegister
(
channelHandlerContext
.
channel
(),
sourceId
);
}
}
if
(
interfaceData
.
size
()
<=
0
)
{
break
;
}
// 根据control域数据处理帧数据
List
<
EquipTmplData
>
list
=
null
;
if
(
control
==
null
)
{
list
=
intfcService
.
findAllTmplDataByInterfaceId
(
intfcId
);
}
else
{
list
=
intfcService
.
findAllTmplDataByInterfaceIdAndControl
(
intfcId
,
control
);
}
try
{
List
<
HashMap
<
String
,
Object
>>
resultList
=
new
ArrayList
();
for
(
EquipTmplData
d
:
list
)
{
List
<
EquipTmplDataAttr
>
attr
=
intfcService
.
findAllByEqpTmplDataId
(
d
.
getId
());
List
<
HashMap
<
String
,
Object
>>
dataResult
=
analysis
(
attr
,
data
,
d
.
getIsArray
());
if
(
dataResult
.
size
()
<=
0
)
{
continue
;
}
for
(
HashMap
<
String
,
Object
>
m:
dataResult
)
{
m
.
put
(
"equipmentTmplId"
,
d
.
getEquipmentTemplId
());
m
.
putAll
(
interfaceData
);
}
resultList
.
addAll
(
dataResult
);
}
JSONArray
jsonArr
=
JSONArray
.
fromObject
(
resultList
);
System
.
out
.
println
(
jsonArr
.
toString
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
break
;
}
break
;
}
while
(
true
);
byteBuf
.
release
();
}
private
List
<
HashMap
<
String
,
Object
>>
analysis
(
List
<
EquipTmplDataAttr
>
attrs
,
Object
data
,
boolean
isArray
)
throws
Exception
{
List
<
HashMap
<
String
,
Object
>>
resultList
=
new
ArrayList
<>();
if
(
isArray
)
{
List
<
HashMap
<
String
,
Object
>>
dataList
=
(
List
<
HashMap
<
String
,
Object
>>)
data
;
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
for
(
EquipTmplDataAttr
attr
:
attrs
)
{
if
(
"property"
.
equals
(
attr
.
getType
()))
{
map
.
put
(
attr
.
getCode
(),
dataList
.
get
(
i
).
get
(
attr
.
getCode
()));
}
else
if
(
"node"
.
equals
(
attr
.
getType
())
||
"object"
.
equals
(
attr
.
getType
()))
{
List
<
EquipTmplDataAttr
>
sonAttr
=
intfcService
.
findAllTmplDataByParentId
(
attr
.
getId
());
map
.
put
(
attr
.
getCode
(),
analysis
(
sonAttr
,
dataList
.
get
(
i
).
get
(
attr
.
getCode
()),
attr
.
isArray
()));
}
}
resultList
.
add
(
map
);
}
}
else
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
dataObject
=
(
HashMap
<
String
,
Object
>)
data
;
for
(
EquipTmplDataAttr
attr
:
attrs
)
{
if
(
"property"
.
equals
(
attr
.
getType
()))
{
map
.
put
(
attr
.
getCode
(),
dataObject
.
get
(
attr
.
getCode
()));
}
else
if
(
"node"
.
equals
(
attr
.
getType
())
||
"object"
.
equals
(
attr
.
getType
()))
{
List
<
EquipTmplDataAttr
>
sonAttr
=
intfcService
.
findAllTmplDataByParentId
(
attr
.
getId
());
map
.
put
(
attr
.
getCode
(),
analysis
(
sonAttr
,
dataObject
.
get
(
attr
.
getCode
()),
attr
.
isArray
()));
}
}
resultList
.
add
(
map
);
}
return
resultList
;
}
/**
* xml转为map,map中有list(节点相同时候),list中有map
* @param xml
* @return
* @throws DocumentException
*/
public
Map
<
String
,
Object
>
parseXml
(
String
xml
)
throws
DocumentException
{
Map
map
=
new
HashMap
();
try
{
SAXReader
saxReader
=
new
SAXReader
();
Document
document
=
saxReader
.
read
(
new
ByteArrayInputStream
(
xml
.
getBytes
(
"UTF-8"
)));
//xml串第一行不能有空格,否则报错
Element
root
=
document
.
getRootElement
();
//得到xml文档根节点元素,即最上层的"<xml>"
elementTomap
(
root
,
map
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
map
;
}
@SuppressWarnings
(
"unchecked"
)
public
Map
<
String
,
Object
>
elementTomap
(
Element
outele
,
Map
<
String
,
Object
>
outmap
)
{
List
<
Element
>
list
=
outele
.
elements
();
int
size
=
list
.
size
();
if
(
size
==
0
)
{
outmap
.
put
(
outele
.
getName
(),
outele
.
getTextTrim
());
}
else
{
Map
<
String
,
Object
>
innermap
=
new
HashMap
<
String
,
Object
>();
int
i
=
1
;
for
(
Element
ele1
:
list
)
{
String
eleName
=
ele1
.
getName
();
String
value
=
ele1
.
getText
();
Object
obj
=
innermap
.
get
(
eleName
);
if
(
obj
==
null
)
{
elementTomap
(
ele1
,
innermap
);
}
else
{
if
(
obj
instanceof
java
.
util
.
Map
)
{
List
<
Map
<
String
,
Object
>>
list1
=
new
ArrayList
<
Map
<
String
,
Object
>>();
list1
.
add
((
Map
<
String
,
Object
>)
innermap
.
remove
(
eleName
));
elementTomap
(
ele1
,
innermap
);
list1
.
add
((
Map
<
String
,
Object
>)
innermap
.
remove
(
eleName
));
innermap
.
put
(
eleName
,
list1
);
}
else
if
(
obj
instanceof
String
)
{
innermap
.
put
(
eleName
+
i
,
value
);
i
++;
}
else
{
elementTomap
(
ele1
,
innermap
);
Map
<
String
,
Object
>
listValue
=
(
Map
<
String
,
Object
>)
innermap
.
get
(
eleName
);
((
List
<
Map
<
String
,
Object
>>)
obj
).
add
(
listValue
);
innermap
.
put
(
eleName
,
obj
);
}
}
}
outmap
.
put
(
outele
.
getName
(),
innermap
);
}
return
outmap
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/entity/CpblDataModel.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
.
entity
;
import
java.util.List
;
public
class
CpblDataModel
{
private
long
id
;
private
long
length
;
private
String
name
;
private
String
type
;
private
long
parentId
;
private
String
byteOrder
;
List
<
CpblDataModel
>
children
;
public
List
<
CpblDataModel
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
CpblDataModel
>
children
)
{
this
.
children
=
children
;
}
public
long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getLength
()
{
return
length
;
}
public
void
setLength
(
long
length
)
{
this
.
length
=
length
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getByteOrder
()
{
return
byteOrder
;
}
public
void
setByteOrder
(
String
byteOrder
)
{
this
.
byteOrder
=
byteOrder
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/entity/EquipTmplData.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
.
entity
;
public
class
EquipTmplData
{
private
Long
id
;
private
Long
intfcId
;
private
Long
intfcDataModelId
;
private
Long
equipmentTemplId
;
private
String
name
;
private
String
control
;
private
boolean
isArray
;
public
boolean
getIsArray
()
{
return
isArray
;
}
public
void
setIsArray
(
boolean
isArray
)
{
this
.
isArray
=
isArray
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
void
setIntfcId
(
Long
intfcId
)
{
this
.
intfcId
=
intfcId
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setControl
(
String
control
)
{
this
.
control
=
control
;
}
public
long
getId
()
{
return
id
;
}
public
Long
getIntfcId
()
{
return
intfcId
;
}
public
Long
getIntfcDataModelId
()
{
return
intfcDataModelId
;
}
public
Long
getEquipmentTemplId
()
{
return
equipmentTemplId
;
}
public
String
getName
()
{
return
name
;
}
public
String
getControl
()
{
return
control
;
}
public
void
setIntfcDataModelId
(
Long
intfcDataModelId
)
{
this
.
intfcDataModelId
=
intfcDataModelId
;
}
public
void
setEquipmentTemplId
(
Long
equipmentTemplId
)
{
this
.
equipmentTemplId
=
equipmentTemplId
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/entity/EquipTmplDataAttr.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
.
entity
;
import
java.util.List
;
public
class
EquipTmplDataAttr
{
private
long
id
;
private
String
dataType
;
private
String
name
;
private
String
code
;
private
String
enumType
;
private
String
type
;
private
String
serialNumber
;
private
String
endian
;
private
Integer
length
;
private
boolean
control
;
private
boolean
array
;
private
String
decimal
;
private
long
parentId
;
List
<
EquipTmplDataAttr
>
children
;
public
long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
List
<
EquipTmplDataAttr
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
EquipTmplDataAttr
>
children
)
{
this
.
children
=
children
;
}
public
String
getDecimal
()
{
return
decimal
;
}
public
void
setDecimal
(
String
decimal
)
{
this
.
decimal
=
decimal
;
}
public
void
setControl
(
boolean
control
)
{
this
.
control
=
control
;
}
public
void
setArray
(
boolean
array
)
{
this
.
array
=
array
;
}
public
boolean
isControl
()
{
return
control
;
}
public
boolean
isArray
()
{
return
array
;
}
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getDataType
()
{
return
dataType
;
}
public
String
getName
()
{
return
name
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getEnumType
()
{
return
enumType
;
}
public
String
getType
()
{
return
type
;
}
public
String
getSerialNumber
()
{
return
serialNumber
;
}
public
String
getEndian
()
{
return
endian
;
}
public
Integer
getLength
()
{
return
length
;
}
public
void
setDataType
(
String
dataType
)
{
this
.
dataType
=
dataType
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
void
setEnumType
(
String
enumType
)
{
this
.
enumType
=
enumType
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
void
setSerialNumber
(
String
serialNumber
)
{
this
.
serialNumber
=
serialNumber
;
}
public
void
setEndian
(
String
endian
)
{
this
.
endian
=
endian
;
}
public
void
setLength
(
Integer
length
)
{
this
.
length
=
length
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/entity/EquipmentVo.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
.
entity
;
public
class
EquipmentVo
{
private
long
id
;
private
long
eqpTmplId
;
private
long
subgraphId
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getEqpTmplId
()
{
return
eqpTmplId
;
}
public
void
setEqpTmplId
(
long
eqpTmplId
)
{
this
.
eqpTmplId
=
eqpTmplId
;
}
public
long
getSubgraphId
()
{
return
subgraphId
;
}
public
void
setSubgraphId
(
long
subgraphId
)
{
this
.
subgraphId
=
subgraphId
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/entity/InterfaceFrame.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
.
entity
;
import
java.util.List
;
public
class
InterfaceFrame
{
private
long
id
;
private
int
index
;
private
String
groupType
;
private
String
groupName
;
private
String
propertyName
;
private
String
dataType
;
private
String
defaultValue
;
private
Integer
propertyLength
;
private
Integer
decimal
;
private
String
modelDataType
;
private
Boolean
isEquipmentId
;
private
String
byteOrder
;
private
long
parentId
;
private
List
<
InterfaceFrame
>
children
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
List
<
InterfaceFrame
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
InterfaceFrame
>
children
)
{
this
.
children
=
children
;
}
public
void
setIsEquipmentId
(
Boolean
equipmentId
)
{
isEquipmentId
=
equipmentId
;
}
public
Boolean
getIsEquipmentId
()
{
return
isEquipmentId
;
}
public
void
setModelDataType
(
String
modelDataType
)
{
this
.
modelDataType
=
modelDataType
;
}
public
String
getModelDataType
()
{
return
modelDataType
;
}
public
Integer
getDecimal
()
{
return
decimal
;
}
public
void
setDecimal
(
Integer
decimal
)
{
this
.
decimal
=
decimal
;
}
public
int
getIndex
()
{
return
index
;
}
public
String
getGroupType
()
{
return
groupType
;
}
public
String
getGroupName
()
{
return
groupName
;
}
public
String
getPropertyName
()
{
return
propertyName
;
}
public
String
getDataType
()
{
return
dataType
;
}
public
String
getDefaultValue
()
{
return
defaultValue
;
}
public
Integer
getPropertyLength
()
{
return
propertyLength
;
}
public
void
setIndex
(
int
index
)
{
this
.
index
=
index
;
}
public
void
setGroupType
(
String
groupType
)
{
this
.
groupType
=
groupType
;
}
public
void
setGroupName
(
String
groupName
)
{
this
.
groupName
=
groupName
;
}
public
void
setPropertyName
(
String
propertyName
)
{
this
.
propertyName
=
propertyName
;
}
public
void
setDataType
(
String
dataType
)
{
this
.
dataType
=
dataType
;
}
public
void
setDefaultValue
(
String
defaultValue
)
{
this
.
defaultValue
=
defaultValue
;
}
public
void
setPropertyLength
(
Integer
propertyLength
)
{
this
.
propertyLength
=
propertyLength
;
}
public
String
getByteOrder
()
{
return
byteOrder
;
}
public
void
setByteOrder
(
String
byteOrder
)
{
this
.
byteOrder
=
byteOrder
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/utils/ByteConvert.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
.
utils
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
public
class
ByteConvert
{
// public static void main(String[] argv) {
// byte[] b = new byte[]{0x00, 0x01};
// Object o = null;
// try {
// o = parse(b, "big", "short");
// } catch (Exception e) {
// e.printStackTrace();
// }
// System.out.println(o);
// }
public
static
Object
parse
(
byte
[]
b
,
String
endian
,
String
dataType
)
throws
Exception
{
Class
classZ
=
new
ByteConvert
().
getClass
();
String
methodName
=
""
;
if
(
"little"
.
equals
(
endian
))
{
methodName
=
methodName
+
"l"
;
}
else
{
methodName
=
methodName
+
"h"
;
}
String
str1
=
dataType
.
substring
(
0
,
1
).
toUpperCase
();
//A:截取0~1之间的字符,并转为大写
String
str2
=
dataType
.
substring
(
1
).
toLowerCase
();
//把1之后包括1之后的字母转为小写
String
str3
=
str1
+
str2
;
//链接
methodName
=
methodName
+
"BytesTo"
+
str3
;
Method
method
=
classZ
.
getMethod
(
methodName
,
byte
[].
class
);
return
method
.
invoke
(
null
,
b
);
}
/**
* 将int转为低字节在前,高字节在后的byte数组
* @param n int
* @return byte[]
*/
public
static
byte
[]
toLH
(
int
n
)
{
byte
[]
b
=
new
byte
[
4
];
b
[
0
]
=
(
byte
)
(
n
&
0xff
);
b
[
1
]
=
(
byte
)
(
n
>>
8
&
0xff
);
b
[
2
]
=
(
byte
)
(
n
>>
16
&
0xff
);
b
[
3
]
=
(
byte
)
(
n
>>
24
&
0xff
);
return
b
;
}
/**
* 将int转为高字节在前,低字节在后的byte数组
* @param n int
* @return byte[]
*/
public
static
byte
[]
toHH
(
int
n
)
{
byte
[]
b
=
new
byte
[
4
];
b
[
3
]
=
(
byte
)
(
n
&
0xff
);
b
[
2
]
=
(
byte
)
(
n
>>
8
&
0xff
);
b
[
1
]
=
(
byte
)
(
n
>>
16
&
0xff
);
b
[
0
]
=
(
byte
)
(
n
>>
24
&
0xff
);
return
b
;
}
/**
* 将short转为低字节在前,高字节在后的byte数组
* @param n short
* @return byte[]
*/
public
static
byte
[]
toLH
(
short
n
)
{
byte
[]
b
=
new
byte
[
2
];
b
[
0
]
=
(
byte
)
(
n
&
0xff
);
b
[
1
]
=
(
byte
)
(
n
>>
8
&
0xff
);
return
b
;
}
/**
* 将short转为高字节在前,低字节在后的byte数组
* @param n short
* @return byte[]
*/
public
static
byte
[]
toHH
(
short
n
)
{
byte
[]
b
=
new
byte
[
2
];
b
[
1
]
=
(
byte
)
(
n
&
0xff
);
b
[
0
]
=
(
byte
)
(
n
>>
8
&
0xff
);
return
b
;
}
/**
* 将将int转为高字节在前,低字节在后的byte数组
public static byte[] toHH(int number) {
int temp = number;
byte[] b = new byte[4];
for (int i = b.length - 1; i > -1; i--) {
b = new Integer(temp & 0xff).byteValue();
temp = temp >> 8;
}
return b;
}
public static byte[] IntToByteArray(int i) {
byte[] abyte0 = new byte[4];
abyte0[3] = (byte) (0xff & i);
abyte0[2] = (byte) ((0xff00 & i) >> 8);
abyte0[1] = (byte) ((0xff0000 & i) >> 16);
abyte0[0] = (byte) ((0xff000000 & i) >> 24);
return abyte0;
}
*/
/**
* 将float转为低字节在前,高字节在后的byte数组
*/
public
static
byte
[]
toLH
(
float
f
)
{
return
toLH
(
Float
.
floatToRawIntBits
(
f
));
}
/**
* 将float转为高字节在前,低字节在后的byte数组
*/
public
static
byte
[]
toHH
(
float
f
)
{
return
toHH
(
Float
.
floatToRawIntBits
(
f
));
}
/**
* 将String转为byte数组
*/
public
static
byte
[]
stringToBytes
(
String
s
,
int
length
)
{
while
(
s
.
getBytes
().
length
<
length
)
{
s
+=
" "
;
}
return
s
.
getBytes
();
}
/**
* 将字节数组转换为String
* @param b byte[]
* @return String
*/
public
static
String
bytesToString
(
byte
[]
b
)
{
if
(
b
==
null
)
{
return
null
;
}
StringBuffer
result
=
new
StringBuffer
(
""
);
int
length
=
b
.
length
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
result
.
append
((
char
)(
b
[
i
]
&
0xff
));
}
return
result
.
toString
();
}
/**
* 将字符串转换为byte数组
* @param s String
* @return byte[]
*/
public
static
byte
[]
stringToBytes
(
String
s
)
{
return
s
.
getBytes
();
}
/**
* 将高字节数组转换为int
* @param b byte[]
* @return int
*/
public
static
Integer
hBytesToInt
(
byte
[]
b
)
{
int
s
=
0
;
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
if
(
b
[
i
]
>=
0
)
{
s
=
s
+
b
[
i
];
}
else
{
s
=
s
+
256
+
b
[
i
];
}
s
=
s
*
256
;
}
if
(
b
[
3
]
>=
0
)
{
s
=
s
+
b
[
3
];
}
else
{
s
=
s
+
256
+
b
[
3
];
}
return
s
;
}
/**
* 将低字节数组转换为int
* @param b byte[]
* @return int
*/
public
static
Integer
lBytesToInt
(
byte
[]
b
)
{
int
s
=
0
;
int
total
=
b
.
length
-
1
;
for
(
int
i
=
0
;
i
<
total
;
i
++)
{
if
(
b
[
total
-
i
]
>=
0
)
{
s
=
s
+
b
[
total
-
i
];
}
else
{
s
=
s
+
256
+
b
[
total
-
i
];
}
s
=
s
*
256
;
}
if
(
b
[
0
]
>=
0
)
{
s
=
s
+
b
[
0
];
}
else
{
s
=
s
+
256
+
b
[
0
];
}
return
s
;
}
/**
* 高字节数组到short的转换
* @param b byte[]
* @return short
*/
public
static
Short
hBytesToShort
(
byte
[]
b
)
{
int
s
=
0
;
if
(
b
[
0
]
>=
0
)
{
s
=
s
+
b
[
0
];
}
else
{
s
=
s
+
256
+
b
[
0
];
}
s
=
s
*
256
;
if
(
b
[
1
]
>=
0
)
{
s
=
s
+
b
[
1
];
}
else
{
s
=
s
+
256
+
b
[
1
];
}
short
result
=
(
short
)
s
;
return
result
;
}
/**
* 低字节数组到short的转换
* @param b byte[]
* @return short
*/
public
static
Short
lBytesToShort
(
byte
[]
b
)
{
int
s
=
0
;
if
(
b
[
1
]
>=
0
)
{
s
=
s
+
b
[
1
];
}
else
{
s
=
s
+
256
+
b
[
1
];
}
s
=
s
*
256
;
if
(
b
[
0
]
>=
0
)
{
s
=
s
+
b
[
0
];
}
else
{
s
=
s
+
256
+
b
[
0
];
}
short
result
=
(
short
)
s
;
return
result
;
}
/**
* 高字节数组转换为float
* @param b byte[]
* @return float
*/
public
static
Float
hBytesToFloat
(
byte
[]
b
)
{
int
i
=
0
;
Float
F
=
new
Float
(
0.0
);
i
=
((((
b
[
0
]&
0xff
)<<
8
|
(
b
[
1
]&
0xff
))<<
8
)
|
(
b
[
2
]&
0xff
))<<
8
|
(
b
[
3
]&
0xff
);
return
F
.
intBitsToFloat
(
i
);
}
/**
* 低字节数组转换为float
* @param b byte[]
* @return float
*/
public
static
Float
lBytesToFloat
(
byte
[]
b
)
{
int
i
=
0
;
Float
F
=
new
Float
(
0.0
);
i
=
((((
b
[
3
]&
0xff
)<<
8
|
(
b
[
2
]&
0xff
))<<
8
)
|
(
b
[
1
]&
0xff
))<<
8
|
(
b
[
0
]&
0xff
);
return
F
.
intBitsToFloat
(
i
);
}
/**
* 将byte数组中的元素倒序排列
*/
public
static
byte
[]
bytesReverseOrder
(
byte
[]
b
)
{
int
length
=
b
.
length
;
byte
[]
result
=
new
byte
[
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
result
[
length
-
i
-
1
]
=
b
[
i
];
}
return
result
;
}
/**
* 打印byte数组
*/
public
static
void
printBytes
(
byte
[]
bb
)
{
int
length
=
bb
.
length
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
System
.
out
.
print
(
bb
+
" "
);
}
System
.
out
.
println
(
""
);
}
public
static
void
logBytes
(
byte
[]
bb
)
{
int
length
=
bb
.
length
;
String
out
=
""
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
out
=
out
+
bb
+
" "
;
}
}
/**
* 将int类型的值转换为字节序颠倒过来对应的int值
* @param i int
* @return int
*/
public
static
int
reverseInt
(
int
i
)
{
int
result
=
ByteConvert
.
hBytesToInt
(
ByteConvert
.
toLH
(
i
));
return
result
;
}
/**
* 将short类型的值转换为字节序颠倒过来对应的short值
* @param s short
* @return short
*/
public
static
short
reverseShort
(
short
s
)
{
short
result
=
ByteConvert
.
hBytesToShort
(
ByteConvert
.
toLH
(
s
));
return
result
;
}
/**
* 将float类型的值转换为字节序颠倒过来对应的float值
* @param f float
* @return float
*/
public
static
float
reverseFloat
(
float
f
)
{
float
result
=
ByteConvert
.
hBytesToFloat
(
ByteConvert
.
toLH
(
f
));
return
result
;
}
//byte[]转hex字符串
public
static
String
bytes2HexString
(
byte
[]
array
)
{
StringBuilder
builder
=
new
StringBuilder
();
for
(
byte
b
:
array
)
{
String
hex
=
Integer
.
toHexString
(
b
&
0xFF
);
if
(
hex
.
length
()
==
1
)
{
hex
=
'0'
+
hex
;
}
builder
.
append
(
hex
);
}
return
builder
.
toString
().
toUpperCase
();
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/utils/ChangeUtils.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
.
utils
;
public
class
ChangeUtils
{
private
static
final
char
[]
HEX_CHAR_TABLE
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
public
static
String
toHexString
(
Byte
[]
data
){
byte
[]
resultBytes
=
new
byte
[
data
.
length
];
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++){
resultBytes
[
i
]
=
data
[
i
];
}
return
toHexString
(
resultBytes
);
}
public
static
String
toHexString
(
byte
[]
data
){
if
(
data
==
null
||
data
.
length
==
0
)
return
null
;
byte
[]
hex
=
new
byte
[
data
.
length
*
2
];
int
index
=
0
;
for
(
byte
b
:
data
){
int
v
=
b
&
0xFF
;
hex
[
index
++]
=
(
byte
)
HEX_CHAR_TABLE
[
v
>>>
4
];
hex
[
index
++]
=
(
byte
)
HEX_CHAR_TABLE
[
v
&
0xF
];
}
return
new
String
(
hex
);
}
public
static
byte
[]
hexStringToBytes
(
String
data
){
if
(
data
==
null
||
""
.
equals
(
data
))
return
null
;
data
=
data
.
toUpperCase
();
int
length
=
data
.
length
()/
2
;
char
[]
dataChars
=
data
.
toCharArray
();
byte
[]
byteData
=
new
byte
[
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++){
int
pos
=
i
*
2
;
byteData
[
i
]
=
(
byte
)(
charToByte
(
dataChars
[
pos
])
<<
4
|
charToByte
(
dataChars
[
pos
+
1
]));
}
return
byteData
;
}
public
static
byte
charToByte
(
char
c
){
return
(
byte
)
"0123456789ABCDEF"
.
indexOf
(
c
);
}
public
static
String
byteAppend
(
byte
[]
bytes
){
StringBuffer
stringBuffer
=
new
StringBuffer
();
for
(
int
i
=
bytes
.
length
-
1
;
i
>=
0
;
i
--){
stringBuffer
.
append
(
String
.
format
(
"%02d"
,
bytes
[
i
]));
}
return
stringBuffer
.
toString
();
}
public
static
byte
[]
float2byte
(
float
f
)
{
// 把float转换为byte[]
int
fbit
=
Float
.
floatToIntBits
(
f
);
byte
[]
b
=
new
byte
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
b
[
i
]
=
(
byte
)
(
fbit
>>
(
24
-
i
*
8
));
}
// 翻转数组
int
len
=
b
.
length
;
// 建立一个与源数组元素类型相同的数组
byte
[]
dest
=
new
byte
[
len
];
// 为了防止修改源数组,将源数组拷贝一份副本
System
.
arraycopy
(
b
,
0
,
dest
,
0
,
len
);
byte
temp
;
// 将顺位第i个与倒数第i个交换
for
(
int
i
=
0
;
i
<
len
/
2
;
++
i
)
{
temp
=
dest
[
i
];
dest
[
i
]
=
dest
[
len
-
i
-
1
];
dest
[
len
-
i
-
1
]
=
temp
;
}
return
dest
;
}
}
YeeAMOSIotServer/src/main/java/com/yeejoin/amos/iot/netty/common/utils/ToolUtil.java
deleted
100644 → 0
View file @
230257be
package
com
.
yeejoin
.
amos
.
iot
.
netty
.
common
.
utils
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.Socket
;
import
java.net.UnknownHostException
;
public
class
ToolUtil
{
//start--end是所要检测的端口范围
static
int
start
=
0
;
static
int
end
=
65535
;
/**
* 测试本机端口是否被使用
* @param port
* @return
*/
public
static
boolean
isLocalPortUsing
(
int
port
){
boolean
flag
=
true
;
try
{
//如果该端口还在使用则返回true,否则返回false,127.0.0.1代表本机
flag
=
isPortUsing
(
"127.0.0.1"
,
port
);
}
catch
(
Exception
e
)
{
}
return
flag
;
}
/***
* 测试主机Host的port端口是否被使用
* @param host
* @param port
* @throws UnknownHostException
*/
public
static
boolean
isPortUsing
(
String
host
,
int
port
)
throws
UnknownHostException
{
boolean
flag
=
false
;
InetAddress
Address
=
InetAddress
.
getByName
(
host
);
try
{
Socket
socket
=
new
Socket
(
Address
,
port
);
//建立一个Socket连接
flag
=
true
;
}
catch
(
IOException
e
)
{
}
return
flag
;
}
public
static
String
bytes2HexString
(
byte
[]
b
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++)
{
sb
.
append
(
String
.
format
(
"%02x"
,
b
[
i
]));
}
return
sb
.
toString
();
}
public
static
Object
parseBytes
(
byte
[]
b
,
String
endian
,
String
dataType
)
{
return
null
;
}
}
YeeAMOSIotStart/pom.xml
View file @
5984c540
...
...
@@ -8,7 +8,7 @@
<parent>
<groupId>
com.yeejoin.amos
</groupId>
<artifactId>
YeeAMOSIotRoot
</artifactId>
<version>
4.0.0
</version>
<version>
3.1.22
</version>
</parent>
<dependencies>
...
...
YeeAMOSIotStart/src/main/resources/application-prod.properties
View file @
5984c540
...
...
@@ -109,13 +109,13 @@ params.xssSecurity = false
spring.redis.database
=
3
#redis ip
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.port
=
6379
#redis password (default is empty)
spring.redis.password
=
1234560
#max connect number
spring.redis.jedis.pool.max-active
=
200
# redis max wait time ( -1 is not limit)
spring.redis.jedis.pool.max-idle
=
10
spring.rabbitmq.connection-timeout
=
1000
spring.rabbitmq.connection-timeout
=
1000
spring.redis.jedis.pool.min-idle
=
0
spring.redis.jedis.pool.max-wait
=
-1
YeeAMOSIotStart/src/main/resources/db/changelog/iot-4.0.0.sql
deleted
100644 → 0
View file @
230257be
This diff is collapsed.
Click to expand it.
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