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 e49fe677
authored
May 13, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
60d57085
8d8f43eb
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
99 additions
and
262 deletions
glsx-rest-admin-job/src/main/java/cn/com/glsx/kafka/config/KafkaProductorConfig.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/kafka/config/MqConfig.java → glsx-rest-admin-job/src/main/java/cn/com/glsx/kafka/config/MqProperties.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/kafka/producer/ScenseProducer.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/Common/Constants.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/component/CheckDayComponent.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/factory/strategy/AllMatchStrategy.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/factory/strategy/AnyMatchStrategy.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/job/TimerTriggerAllJob.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/job/TimerTriggerAnyJob.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/job/WorkOrHoliDayJob.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/service/Impl/CheckDayService.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/service/Impl/SceneService.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/kafka/config/KafkaProductorConfig.java
View file @
e49fe67
...
...
@@ -21,7 +21,7 @@ import java.util.Properties;
public
class
KafkaProductorConfig
{
@Autowired
private
Mq
Config
mqConfig
;
private
Mq
Properties
mqConfig
;
@Bean
(
"productor"
)
public
Producer
getProducer
()
{
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/kafka/config/Mq
Config
.java
→
glsx-rest-admin-job/src/main/java/cn/com/glsx/kafka/config/Mq
Properties
.java
View file @
e49fe67
...
...
@@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties
(
"mq.kafka"
)
public
class
Mq
Config
{
public
class
Mq
Properties
{
/**
* kafka 生产者服务端地址
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/kafka/producer/ScenseProducer.java
View file @
e49fe67
package
cn
.
com
.
glsx
.
kafka
.
producer
;
import
cn.com.glsx.kafka.config.Mq
Config
;
import
cn.com.glsx.kafka.config.Mq
Properties
;
import
cn.com.glsx.modules.model.param.SceneReq
;
import
com.alibaba.fastjson.JSON
;
import
kafka.javaapi.producer.Producer
;
...
...
@@ -18,7 +18,7 @@ public class ScenseProducer {
private
Producer
productor
;
@Autowired
private
Mq
Config
mqConfig
;
private
Mq
Properties
mqConfig
;
/**
* 公共的消息发送
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/Common/Constants.java
View file @
e49fe67
...
...
@@ -6,15 +6,25 @@ package cn.com.glsx.smartdevice.Common;
*/
public
class
Constants
{
// 涂鸦立牌rediskey
/**
* 涂鸦立牌rediskey
*/
public
static
final
String
ACCESSTOKEN_REDISKEY
=
"accessToken_redisKey"
;
//设备状态触发条件key
/**
* 设备状态触发条件key
*/
public
static
final
String
CONDITION_STATUS
=
"scene_condition_status"
;
//时间触发条件key
/**
* 时间触发条件key
*/
public
static
final
String
CONDITION_TIME
=
"scene_condition_time"
;
//手动触发条件key
/**
* 手动触发条件key
*/
public
static
final
String
CONDITION_CLICK
=
"scene_condition_click"
;
public
static
final
String
SCENE_STATUS
=
"scene_status"
;
}
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/component/CheckDayComponent.java
deleted
100644 → 0
View file @
60d5708
package
cn
.
com
.
glsx
.
smartdevice
.
component
;
import
cn.com.glsx.smartdevice.Common.EMonth
;
import
cn.com.glsx.smartdevice.utils.HttpUtil
;
import
cn.com.glsx.vasp.modules.entity.DayInfo
;
import
cn.com.glsx.vasp.modules.mapper.DayInfoMapper
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Slf4j
@Component
public
class
CheckDayComponent
{
//天行数据平台key(节假日接口)
@Value
(
"${tianapi.url}"
)
private
String
url
;
//天行数据平台key(节假日接口)
@Value
(
"${tianapi.key}"
)
private
String
key
;
@Autowired
private
DayInfoMapper
dayInfoMapper
;
//1.查询节假日接口(参数为当前时间转化的年月,如2021-03,type为月份)
public
JSONObject
sendCheckDayRequestGet
(
String
date
)
{
JSONObject
response
=
null
;
try
{
Map
<
String
,
String
>
reqParams
=
new
HashMap
<>();
reqParams
.
put
(
"key"
,
key
);
reqParams
.
put
(
"type"
,
"2"
);
reqParams
.
put
(
"date"
,
date
);
response
=
HttpUtil
.
sendGet
(
url
,
reqParams
,
new
HashMap
<>());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
info
(
"请求节假日接口异常,异常信息{}"
,
e
);
}
return
response
;
}
//每天100次免费调用,每次使用12次(查12个月)
public
void
searchAndInsertMonth
()
{
//全年数据
List
<
DayInfo
>
daysYear
=
new
ArrayList
<>();
Calendar
cal
=
Calendar
.
getInstance
();
int
year
=
cal
.
get
(
Calendar
.
YEAR
);
long
start
=
System
.
currentTimeMillis
();
//全年12个月遍历
Arrays
.
stream
(
EMonth
.
values
()).
forEach
(
m
->
{
//月份
String
monthStr
=
m
.
getValue
();
//查询年月,返回当月每天总数据,如2021-01,每次查一个月所有天数据(每天可判断节假日,工作日,双休日,调休日)
JSONObject
response
=
sendCheckDayRequestGet
(
year
+
"-"
+
monthStr
);
if
(
null
!=
response
&&
response
.
getInteger
(
"code"
)
==
200
)
{
//请求成功
JSONArray
newslist
=
response
.
getJSONArray
(
"newslist"
);
//当月数据
List
<
DayInfo
>
daysMonth
=
newslist
.
stream
().
map
(
j
->
{
JSONObject
jsonObject
=
(
JSONObject
)
j
;
DayInfo
day
=
new
DayInfo
();
//当前阳历日期,如:2019-10-01
String
date
=
jsonObject
.
getString
(
"date"
);
day
.
setDate
(
date
);
//日期类型,为0表示工作日、为1节假日、为2双休日、3为调休日(上班)
int
daycode
=
jsonObject
.
getIntValue
(
"daycode"
);
day
.
setDaycode
(
daycode
);
//节假日名称,如:国庆节
String
name
=
jsonObject
.
getString
(
"name"
);
day
.
setName
(
name
);
//放假提示,如:10月1日至7日放假调休,共7天......
String
tip
=
jsonObject
.
getString
(
"tip"
);
day
.
setTip
(
tip
);
return
day
;
}).
collect
(
Collectors
.
toList
());
//添加数据
daysYear
.
addAll
(
daysMonth
);
}
});
long
end1
=
System
.
currentTimeMillis
();
log
.
info
(
"全年数据请求时长====="
+
(
end1
-
start
));
/*daysYear.stream().forEach(day->{
log.info("WorkOrHoliDayJob==date:"+day.getDate()+"==daycode:"+day.getDaycode()+"==name:"+day.getName()+"==tip:"+day.getTip());
});*/
//全年每天的数据入库
if
(
null
!=
daysYear
&&
!
daysYear
.
isEmpty
())
{
int
res
=
dayInfoMapper
.
updateDayInsert
(
daysYear
);
long
end2
=
System
.
currentTimeMillis
();
log
.
info
(
"全年数据入库时长=====code:"
+
res
+
"======time:"
+
(
end2
-
start
));
}
}
//测试
public
void
searchAndInsertMonth2
()
{
//全年数据
List
<
DayInfo
>
daysYear
=
new
ArrayList
<>();
long
start
=
System
.
currentTimeMillis
();
//全年12个月遍历
for
(
int
i
=
0
;
i
<
31
;
i
++){
DayInfo
day
=
new
DayInfo
();
//当前阳历日期,如:2019-10-01
String
date
=
"datefz"
+
i
;
day
.
setDate
(
date
);
//日期类型,为0表示工作日、为1节假日、为2双休日、3为调休日(上班)
int
daycode
=
0
;
day
.
setDaycode
(
daycode
);
//节假日名称,如:国庆节
String
name
=
"name"
;
day
.
setName
(
name
);
//放假提示,如:10月1日至7日放假调休,共7天......
String
tip
=
"tip"
;
day
.
setTip
(
tip
);
//添加数据
daysYear
.
add
(
day
);
}
long
end1
=
System
.
currentTimeMillis
();
log
.
info
(
"全年数据请求时长====="
+
(
end1
-
start
));
/*daysYear.stream().forEach(day->{
log.info("WorkOrHoliDayJob==date:"+day.getDate()+"==daycode:"+day.getDaycode()+"==name:"+day.getName()+"==tip:"+day.getTip());
});*/
//全年每天的数据入库
if
(
null
!=
daysYear
&&
!
daysYear
.
isEmpty
())
{
int
res
=
dayInfoMapper
.
updateDayInsert
(
daysYear
);
long
end2
=
System
.
currentTimeMillis
();
log
.
info
(
"全年数据入库时长=====code:"
+
res
+
"======time:"
+
(
end2
-
start
));
}
}
}
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/factory/strategy/AllMatchStrategy.java
View file @
e49fe67
...
...
@@ -13,7 +13,9 @@ import org.springframework.stereotype.Component;
import
java.util.List
;
import
java.util.function.Predicate
;
//全部满足触发条件策略
/**
* 全部满足触发条件策略
*/
@Slf4j
@Component
public
class
AllMatchStrategy
implements
ConditionStrategy
{
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/factory/strategy/AnyMatchStrategy.java
View file @
e49fe67
...
...
@@ -11,7 +11,9 @@ import org.springframework.stereotype.Component;
import
java.util.List
;
import
java.util.function.Predicate
;
//任意满足触发条件策略
/**
* 任意满足触发条件策略
*/
@Slf4j
@Component
public
class
AnyMatchStrategy
implements
ConditionStrategy
{
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/job/TimerTriggerAllJob.java
View file @
e49fe67
...
...
@@ -24,7 +24,7 @@ public class TimerTriggerAllJob implements SimpleJob {
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
//
log.info("Jobname==="+shardingContext.getJobName());
log
.
info
(
"Jobname==="
+
shardingContext
.
getJobName
());
//定时每10秒执行
sceneComponent
.
execute
(
Condition
.
ALL_MATCH
.
getCode
());
}
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/job/TimerTriggerAnyJob.java
View file @
e49fe67
...
...
@@ -22,8 +22,8 @@ public class TimerTriggerAnyJob implements SimpleJob {
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
//
log.info("Jobname===" + shardingContext.getJobName());
//定时每
1
0秒执行
log
.
info
(
"Jobname==="
+
shardingContext
.
getJobName
());
//定时每
6
0秒执行
sceneComponent
.
execute
(
Condition
.
ANY_MATCH
.
getCode
());
}
}
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/job/WorkOrHoliDayJob.java
View file @
e49fe67
...
...
@@ -16,13 +16,14 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@ElasticSimpleJob
(
jobName
=
"WorkOrHoliDayJob"
,
cron
=
"0 0 0 1 * ?"
)
//定时每月1号0点
public
class
WorkOrHoliDayJob
implements
SimpleJob
{
@Autowired
private
CheckDayService
checkDayComponent
;
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
//定时每月1号0点
log
.
info
(
"Jobname==="
+
shardingContext
.
getJobName
());
checkDayComponent
.
searchAndInsertMonth
();
}
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/service/Impl/CheckDayService.java
View file @
e49fe67
...
...
@@ -28,7 +28,9 @@ public class CheckDayService {
@Autowired
private
DayInfoMapper
dayInfoMapper
;
//1.查询节假日接口(参数为当前时间转化的年月,如2021-03,type为月份)
/**
* 查询节假日接口(参数为当前时间转化的年月,如2021-03,type为月份)
*/
public
JSONObject
sendCheckDayRequestGet
(
String
date
)
{
JSONObject
response
=
null
;
try
{
...
...
@@ -88,47 +90,7 @@ public class CheckDayService {
log
.
info
(
"全年数据请求时长====="
+
(
end1
-
start
));
//全年每天的数据入库
if
(
null
!=
daysYear
&&
!
daysYear
.
isEmpty
())
{
int
res
=
dayInfoMapper
.
updateDayInsert
(
daysYear
);
long
end2
=
System
.
currentTimeMillis
();
log
.
info
(
"全年数据入库时长=====code:"
+
res
+
"======time:"
+
(
end2
-
start
));
}
}
//测试
public
void
searchAndInsertMonth2
()
{
//全年数据
List
<
DayInfo
>
daysYear
=
new
ArrayList
<>();
long
start
=
System
.
currentTimeMillis
();
//全年12个月遍历
for
(
int
i
=
0
;
i
<
31
;
i
++){
DayInfo
day
=
new
DayInfo
();
//当前阳历日期,如:2019-10-01
String
date
=
"datefz"
+
i
;
day
.
setDate
(
date
);
//日期类型,为0表示工作日、为1节假日、为2双休日、3为调休日(上班)
int
daycode
=
0
;
day
.
setDaycode
(
daycode
);
//节假日名称,如:国庆节
String
name
=
"name"
;
day
.
setName
(
name
);
//放假提示,如:10月1日至7日放假调休,共7天......
String
tip
=
"tip"
;
day
.
setTip
(
tip
);
//添加数据
daysYear
.
add
(
day
);
}
long
end1
=
System
.
currentTimeMillis
();
log
.
info
(
"全年数据请求时长====="
+
(
end1
-
start
));
/*daysYear.stream().forEach(day->{
log.info("WorkOrHoliDayJob==date:"+day.getDate()+"==daycode:"+day.getDaycode()+"==name:"+day.getName()+"==tip:"+day.getTip());
});*/
//全年每天的数据入库
if
(
null
!=
daysYear
&&
!
daysYear
.
isEmpty
())
{
if
(!
daysYear
.
isEmpty
())
{
int
res
=
dayInfoMapper
.
updateDayInsert
(
daysYear
);
long
end2
=
System
.
currentTimeMillis
();
log
.
info
(
"全年数据入库时长=====code:"
+
res
+
"======time:"
+
(
end2
-
start
));
...
...
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/service/Impl/SceneService.java
View file @
e49fe67
package
cn
.
com
.
glsx
.
smartdevice
.
service
.
Impl
;
import
cn.com.glsx.kafka.config.MqConfig
;
import
cn.com.glsx.kafka.producer.ScenseProducer
;
import
cn.com.glsx.modules.model.param.SceneReq
;
import
cn.com.glsx.smartdevice.Common.Constants
;
...
...
@@ -53,12 +52,11 @@ public class SceneService {
private
ScenseProducer
scenseProducer
;
@Autowired
private
MqConfig
config
;
@Autowired
private
RedisService
redisService
;
//执行定时任务
/**
* 执行定时任务
*/
public
void
execute
(
Integer
conditionType
)
{
//获取对应策略,1:任意触发条件满足 2:全部触发条件满足
ConditionStrategy
conditionStrategy
=
null
;
...
...
@@ -69,67 +67,66 @@ public class SceneService {
}
if
(
null
!=
conditionStrategy
)
{
//获取当前时间
long
rangeBegintTime
=
System
.
currentTimeMillis
();
//判断当前日期,转为周期类型
Integer
executeCycle
=
getExecuteCycle
();
if
(
null
==
executeCycle
)
{
log
.
info
(
"查询周期失败,无法获取对应的周期"
);
return
;
}
//获取符合周期类型且满足判断策略(任意满足,全部满足触发)的触发条件
List
<
ScenseData
>
dataAnyCondition
=
conditionStrategy
.
getScenseData
(
executeCycle
);
log
.
error
(
"策略不能为空"
);
return
;
}
//获取当前时间
long
rangeBegintTime
=
System
.
currentTimeMillis
();
//判断当前日期,转为周期类型
Integer
executeCycle
=
getExecuteCycle
();
if
(
null
==
executeCycle
)
{
log
.
error
(
"查询周期失败,无法获取对应的周期"
);
return
;
}
//获取符合周期类型且满足判断策略(任意满足,全部满足触发)的触发条件
List
<
ScenseData
>
dataAnyCondition
=
conditionStrategy
.
getScenseData
(
executeCycle
);
if
(
CollectionUtils
.
isEmpty
(
dataAnyCondition
))
{
log
.
info
(
"无触发条件:"
+
executeCycle
);
return
;
}
if
(
CollectionUtils
.
isEmpty
(
dataAnyCondition
))
{
log
.
info
(
"无触发条件:"
+
executeCycle
);
return
;
}
//将集合按key:场景id,val:场景触发条件集合转为map,
Map
<
Long
,
List
<
ScenseData
>>
scenseDataMap
=
listToMap
(
dataAnyCondition
);
ConditionStrategy
finalConditionStrategy
=
conditionStrategy
;
scenseDataMap
.
entrySet
().
stream
().
forEach
(
entry
->
{
//遍历场景,按每个场景处理对应的触发条件判断
long
scenseId
=
entry
.
getKey
();
List
<
ScenseData
>
dataList
=
entry
.
getValue
();
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
//判断当前场景的触发情况(时间符合或者设备状态符合)
String
key
=
scenseId
+
"_"
+
Constants
.
SCENE_STATUS
;
boolean
isTrigger
=
finalConditionStrategy
.
isTrigger
(
dataList
,
rangeBegintTime
,
(
ScenseData
condition
)
->
getTriggerResult
(
rangeBegintTime
,
condition
,
conditionType
));
// 时间控制一次
Object
o
=
redisService
.
get
(
key
);
if
(
isTrigger
)
{
if
(
o
==
null
)
{
redisService
.
set
(
key
,
key
);
}
else
{
log
.
info
(
"场景id{}已经触发过一次"
,
scenseId
);
return
;
}
}
else
{
redisService
.
delete
(
key
);
}
if
(
isTrigger
)
{
//将集合按key:场景id,val:场景触发条件集合转为map,
Map
<
Long
,
List
<
ScenseData
>>
scenseDataMap
=
listToMap
(
dataAnyCondition
);
ConditionStrategy
finalConditionStrategy
=
conditionStrategy
;
scenseDataMap
.
forEach
((
key1
,
dataList
)
->
{
//遍历场景,按每个场景处理对应的触发条件判断
long
scenseId
=
key1
;
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
//判断当前场景的触发情况(时间符合或者设备状态符合)
String
key
=
scenseId
+
"_"
+
Constants
.
SCENE_STATUS
;
boolean
isTrigger
=
finalConditionStrategy
.
isTrigger
(
dataList
,
rangeBegintTime
,
(
ScenseData
condition
)
->
getTriggerResult
(
rangeBegintTime
,
condition
,
conditionType
));
// 时间控制一次
Object
o
=
redisService
.
get
(
key
);
if
(
isTrigger
)
{
if
(
o
==
null
)
{
redisService
.
set
(
key
,
key
);
//如果符合触发场景,推送kafka
SceneReq
scene
=
new
SceneReq
();
scene
.
setScenseId
(
scenseId
);
scene
.
setType
(
conditionType
);
scenseProducer
.
sendKafkaMessage
(
scene
);
}
else
{
log
.
info
(
"场景id{}已经触发过一次"
,
scenseId
);
return
;
}
}
else
{
redisService
.
delete
(
key
);
}
});
//todo 如果耗时过长,计划采用分片
//打印耗时
long
time
=
System
.
currentTimeMillis
()
-
rangeBegintTime
;
log
.
info
(
"execute====time:"
+
time
+
"====conditionType:"
+
conditionType
);
}
}
});
//打印耗时
long
time
=
System
.
currentTimeMillis
()
-
rangeBegintTime
;
log
.
info
(
"execute====time:"
+
time
+
"====conditionType:"
+
conditionType
);
}
//根据当前时间对应的执行周期类型
/**
* 根据当前时间对应的执行周期类型
*/
private
Integer
getExecuteCycle
()
{
//判断当天的日类型
String
date
=
DateUtils
.
getDate
();
...
...
@@ -140,13 +137,15 @@ public class SceneService {
return
EDay
.
getValueByCode
(
null
==
dayInfo
?
-
1
:
dayInfo
.
getDaycode
());
}
//将场景触发条件转为map,key为场景id,val为触发条件集合
/**
* 将场景触发条件转为map,key为场景id,val为触发条件集合
*/
public
Map
<
Long
,
List
<
ScenseData
>>
listToMap
(
List
<
ScenseData
>
dataAnyCondition
)
{
//a.2 根据场景id分类
Map
<
Long
,
List
<
ScenseData
>>
scenseDataMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
dataAnyCondition
))
{
dataAnyCondition
.
stream
().
forEach
(
data
->
{
List
<
ScenseData
>
scenseDataList
=
null
;
dataAnyCondition
.
forEach
(
data
->
{
List
<
ScenseData
>
scenseDataList
;
long
scenseId
=
data
.
getSceneId
();
if
(
scenseDataMap
.
containsKey
(
scenseId
))
{
...
...
@@ -155,15 +154,19 @@ public class SceneService {
scenseDataList
=
new
ArrayList
<>();
}
if
(!
Constants
.
CONDITION_CLICK
.
equals
(
data
.
getParamKey
()))
if
(!
Constants
.
CONDITION_CLICK
.
equals
(
data
.
getParamKey
()))
{
scenseDataList
.
add
(
data
);
}
scenseDataMap
.
put
(
scenseId
,
scenseDataList
);
});
}
return
scenseDataMap
;
}
//触发条件判断
/**
* 触发条件判断
*/
private
boolean
getTriggerResult
(
long
rangeBegintTime
,
ScenseData
condition
,
int
conditionType
)
{
String
key
=
condition
.
getParamKey
();
String
value
=
condition
.
getParamValue
();
...
...
@@ -174,7 +177,7 @@ public class SceneService {
return
false
;
}
ScenseParamValue
paramValue
=
null
;
ScenseParamValue
paramValue
;
try
{
paramValue
=
JSON
.
parseObject
(
JSON
.
parse
(
value
).
toString
(),
ScenseParamValue
.
class
);
}
catch
(
Exception
e
)
{
...
...
@@ -210,7 +213,6 @@ public class SceneService {
}
//根据logic逻辑码,判断触发条件与数据库中实际的值,判断是否满足
//log.info("fz===scenseId:"+condition.getSceneId()+"===condition_val:"+Value+"====realval:"+status.getDeviceOrderValue()+"===logic:"+logic);
return
ELogic
.
getValueByCode
(
logic
,
Value
,
status
.
getDeviceOrderValue
());
}
...
...
@@ -225,7 +227,7 @@ public class SceneService {
String
select
=
paramValue
.
getSelect
();
if
(
StringUtils
.
isBlank
(
select
))
{
log
.
info
(
"时间条件select不能为空===conditionType:"
+
conditionType
+
"===ID:"
+
condition
.
getId
());
log
.
info
(
"时间条件select不能为空===conditionType:"
+
conditionType
+
"===ID:"
+
condition
.
getId
());
return
false
;
}
...
...
@@ -237,13 +239,11 @@ public class SceneService {
try
{
long
dateConditionlong
=
df
.
parse
(
dateCondition
).
getTime
();
long
datenowlong
=
df
.
parse
(
datenow
).
getTime
();
boolean
time_result
=
ELogic
.
getDateByCode
(
Integer
.
valueOf
(
select
),
dateConditionlong
,
datenowlong
);
return
time_result
;
return
ELogic
.
getDateByCode
(
Integer
.
valueOf
(
select
),
dateConditionlong
,
datenowlong
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
log
.
info
(
"时间解析异常===key:"
+
key
+
"===value:"
+
value
+
"===conditionType:"
+
conditionType
+
"===id:"
+
condition
.
getId
());
log
.
info
(
"时间解析异常===key:"
+
key
+
"===value:"
+
value
+
"===conditionType:"
+
conditionType
+
"===id:"
+
condition
.
getId
());
return
false
;
}
}
return
false
;
...
...
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