Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
glsx-rest-admin-job-archetype
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 6845a6d1
authored
Mar 19, 2021
by
fengzhi
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.设备状态数值判断精度double
2.数据库实体对应字段修改 3.注释提示添加
1 parent
774018b4
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
29 additions
and
133 deletions
glsx-rest-admin-job-dao/src/main/java/cn/com/glsx/vasp/modules/entity/DayInfo.java
glsx-rest-admin-job-dao/src/main/java/cn/com/glsx/vasp/modules/entity/ScenseData.java
glsx-rest-admin-job-dao/src/main/java/cn/com/glsx/vasp/modules/mapper/DayInfoMapper.java
glsx-rest-admin-job-dao/src/main/resources/mapper/DayInfoMapper.xml
glsx-rest-admin-job-dao/src/main/resources/mapper/ScenseDataMapper.xml
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/Common/EDay.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/Common/ELogic.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/service/SceneService.java
glsx-rest-admin-job/target/classes/cn/com/glsx/smartdevice/job/WorkOrHoliDayJob.class
glsx-rest-admin-job-dao/src/main/java/cn/com/glsx/vasp/modules/entity/DayInfo.java
View file @
6845a6d
...
...
@@ -42,6 +42,4 @@ public class DayInfo implements Serializable {
* 放假提示,如:10月1日至7日放假调休,共7天......
*/
private
String
tip
;
private
static
final
long
serialVersionUID
=
-
8402343759691572906L
;
}
\ No newline at end of file
glsx-rest-admin-job-dao/src/main/java/cn/com/glsx/vasp/modules/entity/ScenseData.java
View file @
6845a6d
...
...
@@ -26,18 +26,18 @@ public class ScenseData implements Serializable {
/**
* 场景ID 关联smart_scense中id
*/
@Column
(
name
=
"
templat
e_id"
)
private
Long
templat
eId
;
@Column
(
name
=
"
scen
e_id"
)
private
Long
scen
eId
;
/**
* 类型 1触发条件 2执行内容
*/
private
Byte
type
;
private
Integer
type
;
/**
* 排序
*/
private
Byte
sort
;
private
Integer
sort
;
/**
* 参数key
...
...
@@ -50,114 +50,4 @@ public class ScenseData implements Serializable {
*/
@Column
(
name
=
"param_value"
)
private
String
paramValue
;
private
static
final
long
serialVersionUID
=
1L
;
/**
* 获取标识ID
*
* @return id - 标识ID
*/
public
Long
getId
()
{
return
id
;
}
/**
* 设置标识ID
*
* @param id 标识ID
*/
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
/**
* 获取场景ID 关联smart_scense中id
*
* @return template_id - 场景ID 关联smart_scense中id
*/
public
Long
getTemplateId
()
{
return
templateId
;
}
/**
* 设置场景ID 关联smart_scense中id
*
* @param templateId 场景ID 关联smart_scense中id
*/
public
void
setTemplateId
(
Long
templateId
)
{
this
.
templateId
=
templateId
;
}
/**
* 获取类型 1触发条件 2执行内容
*
* @return type - 类型 1触发条件 2执行内容
*/
public
Byte
getType
()
{
return
type
;
}
/**
* 设置类型 1触发条件 2执行内容
*
* @param type 类型 1触发条件 2执行内容
*/
public
void
setType
(
Byte
type
)
{
this
.
type
=
type
;
}
/**
* 获取排序
*
* @return sort - 排序
*/
public
Byte
getSort
()
{
return
sort
;
}
/**
* 设置排序
*
* @param sort 排序
*/
public
void
setSort
(
Byte
sort
)
{
this
.
sort
=
sort
;
}
/**
* 获取参数key
*
* @return param_key - 参数key
*/
public
String
getParamKey
()
{
return
paramKey
;
}
/**
* 设置参数key
*
* @param paramKey 参数key
*/
public
void
setParamKey
(
String
paramKey
)
{
this
.
paramKey
=
paramKey
==
null
?
null
:
paramKey
.
trim
();
}
/**
* 获取参数值 数组对象
*
* @return param_value - 参数值 数组对象
*/
public
String
getParamValue
()
{
return
paramValue
;
}
/**
* 设置参数值 数组对象
*
* @param paramValue 参数值 数组对象
*/
public
void
setParamValue
(
String
paramValue
)
{
this
.
paramValue
=
paramValue
==
null
?
null
:
paramValue
.
trim
();
}
}
\ No newline at end of file
glsx-rest-admin-job-dao/src/main/java/cn/com/glsx/vasp/modules/mapper/DayInfoMapper.java
View file @
6845a6d
...
...
@@ -11,5 +11,5 @@ import java.util.List;
public
interface
DayInfoMapper
extends
CommonBaseMapper
<
DayInfo
>
{
int
updateDayInsert
(
@Param
(
"daysYear"
)
List
<
DayInfo
>
daysYear
);
int
getDayCodeByDate
(
String
date
);
DayInfo
getDayCodeByDate
(
String
date
);
}
\ No newline at end of file
glsx-rest-admin-job-dao/src/main/resources/mapper/DayInfoMapper.xml
View file @
6845a6d
...
...
@@ -41,7 +41,7 @@
`tip` = values(`tip`)
</update>
<select
id=
"getDayCodeByDate"
result
Type=
"integer
"
>
<select
id=
"getDayCodeByDate"
result
Map=
"BaseResultMap
"
>
select `daycode` from smart_date where date = #{date}
</select>
...
...
glsx-rest-admin-job-dao/src/main/resources/mapper/ScenseDataMapper.xml
View file @
6845a6d
...
...
@@ -6,7 +6,7 @@
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"
template_id"
jdbcType=
"BIGINT"
property=
"templat
eId"
/>
<result
column=
"
scene_id"
jdbcType=
"BIGINT"
property=
"scen
eId"
/>
<result
column=
"type"
jdbcType=
"TINYINT"
property=
"type"
/>
<result
column=
"sort"
jdbcType=
"TINYINT"
property=
"sort"
/>
<result
column=
"param_key"
jdbcType=
"VARCHAR"
property=
"paramKey"
/>
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/Common/EDay.java
View file @
6845a6d
...
...
@@ -41,7 +41,7 @@ public enum EDay {
WEEKDAY
{
@Override
public
Integer
getCode
()
{
return
3
;
return
2
;
}
@Override
...
...
@@ -57,7 +57,7 @@ public enum EDay {
LEAVE_OFF_DAY
{
@Override
public
Integer
getCode
()
{
return
4
;
return
3
;
}
@Override
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/Common/ELogic.java
View file @
6845a6d
...
...
@@ -5,6 +5,7 @@ package cn.com.glsx.smartdevice.Common;
* @date 2021/3/19 17:40
* @description 枚举,触发条件的逻辑判断
*/
public
enum
ELogic
{
LESS_THAN
{
@Override
...
...
@@ -14,7 +15,7 @@ public enum ELogic {
@Override
public
boolean
getValue
(
String
deviceOrderValue
,
String
deviceOrderValueReal
)
{
return
Integer
.
parseInt
(
deviceOrderValueReal
)
<
Integer
.
parseInt
(
deviceOrderValue
);
return
Double
.
parseDouble
(
deviceOrderValueReal
)
<
Double
.
parseDouble
(
deviceOrderValue
);
}
@Override
...
...
@@ -30,7 +31,7 @@ public enum ELogic {
@Override
public
boolean
getValue
(
String
deviceOrderValue
,
String
deviceOrderValueReal
)
{
return
Integer
.
parseInt
(
deviceOrderValueReal
)
>
Integer
.
parseInt
(
deviceOrderValue
);
return
Double
.
parseDouble
(
deviceOrderValueReal
)
>
Double
.
parseDouble
(
deviceOrderValue
);
}
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/service/SceneService.java
View file @
6845a6d
...
...
@@ -9,6 +9,7 @@ import cn.com.glsx.smartdevice.Common.ELogic;
import
cn.com.glsx.smartdevice.factory.ConditionFactory
;
import
cn.com.glsx.smartdevice.factory.ConditionStrategy
;
import
cn.com.glsx.smartdevice.utils.DateUtils
;
import
cn.com.glsx.vasp.modules.entity.DayInfo
;
import
cn.com.glsx.vasp.modules.entity.DeviceStatus
;
import
cn.com.glsx.vasp.modules.entity.ScenseData
;
import
cn.com.glsx.vasp.modules.mapper.DayInfoMapper
;
...
...
@@ -63,7 +64,11 @@ public class SceneService {
//获取当前时间
long
rangeBegintTime
=
System
.
currentTimeMillis
();
//判断当前日期,转为周期类型
int
executeCycle
=
getExecuteCycle
();
Integer
executeCycle
=
getExecuteCycle
();
if
(
null
==
executeCycle
){
log
.
info
(
"查询周期失败,无法获取对应的周期"
);
return
;
}
//获取符合周期类型且满足判断策略(任意满足,全部满足触发)的触发条件
List
<
ScenseData
>
dataAnyCondition
=
conditionStrategy
.
getScenseData
(
executeCycle
);
//将集合按key:场景id,val:场景触发条件集合转为map,
...
...
@@ -75,12 +80,11 @@ public class SceneService {
//遍历场景,按每个场景处理对应的触发条件判断
long
scenseId
=
entry
.
getKey
();
List
<
ScenseData
>
dataList
=
entry
.
getValue
();
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
//判断当前场景的触发情况(时间符合或者设备状态符合)
boolean
isTrigger
=
finalConditionStrategy
.
isTrigger
(
dataList
,
rangeBegintTime
,
(
ScenseData
condition
)
->
getTriggerResult
(
rangeBegintTime
,
condition
));
(
ScenseData
condition
)
->
getTriggerResult
(
rangeBegintTime
,
condition
,
conditionType
));
if
(
isTrigger
)
{
//如果符合触发场景,推送kafka
...
...
@@ -100,13 +104,14 @@ public class SceneService {
}
//根据当前时间对应的执行周期类型
private
int
getExecuteCycle
()
{
private
Integer
getExecuteCycle
()
{
//判断当天的日类型
String
date
=
DateUtils
.
getDate
();
//0表示工作日、为1节假日、为2双休日、3为调休日(上班)
int
dayCode
=
dayInfoMapper
.
getDayCodeByDate
(
date
);
DayInfo
dayInfo
=
dayInfoMapper
.
getDayCodeByDate
(
date
);
//转换为对应的执行周期
return
EDay
.
getValueByCode
(
dayCode
);
return
EDay
.
getValueByCode
(
null
==
dayInfo
?
-
1
:
dayInfo
.
getDaycode
()
);
}
//将场景触发条件转为map,key为场景id,val为触发条件集合
...
...
@@ -116,7 +121,7 @@ public class SceneService {
if
(
CollectionUtils
.
isNotEmpty
(
dataAnyCondition
))
{
dataAnyCondition
.
stream
().
forEach
(
data
->
{
List
<
ScenseData
>
scenseDataList
=
null
;
long
scenseId
=
data
.
get
Templat
eId
();
long
scenseId
=
data
.
get
Scen
eId
();
if
(
scenseDataMap
.
containsKey
(
scenseId
))
{
scenseDataList
=
scenseDataMap
.
get
(
scenseId
);
...
...
@@ -132,17 +137,17 @@ public class SceneService {
}
//触发条件判断
private
boolean
getTriggerResult
(
long
rangeBegintTime
,
ScenseData
condition
)
{
private
boolean
getTriggerResult
(
long
rangeBegintTime
,
ScenseData
condition
,
int
conditionType
)
{
String
key
=
condition
.
getParamKey
();
String
value
=
condition
.
getParamValue
();
//log.info("fz====scenseId:"+condition.getSceneId()+"===key:"+key+"==VAL:"+value);
//scene_condition_status设备状态
if
(
Constants
.
CONDITION_STATUS
.
equals
(
key
))
{
//value为设备状态的条件数组
if
(
StringUtils
.
isEmpty
(
value
))
{
log
.
info
(
"设备状态触发条件的value不存在===id:"
+
condition
.
getId
());
return
false
;
}
log
.
info
(
"getParamValue=="
+
value
);
String
[]
vals
=
value
.
split
(
","
);
//参数一,设备id
String
deviceId
=
vals
[
0
];
...
...
@@ -160,6 +165,7 @@ public class SceneService {
}
//根据logic逻辑码,判断触发条件与数据库中实际的值,判断是否满足
//log.info("fz===scenseId:"+condition.getSceneId()+"===condition_val:"+deviceOrderValue+"====realval:"+status.getDeviceOrderValue() );
return
ELogic
.
getValueByCode
(
logic
,
deviceOrderValue
,
status
.
getDeviceOrderValue
());
}
...
...
@@ -167,6 +173,7 @@ public class SceneService {
if
(
Constants
.
CONDITION_TIME
.
equals
(
key
))
{
//value为时分
if
(
StringUtils
.
isEmpty
(
value
))
{
log
.
info
(
"时间触发条件的value不存在===id:"
+
condition
.
getId
());
return
false
;
}
...
...
glsx-rest-admin-job/target/classes/cn/com/glsx/smartdevice/job/WorkOrHoliDayJob.class
View file @
6845a6d
No preview for this file type
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