Commit b2454cd6 by 111-PC\111

[+]kafka消费数据修改

1 parent 0443188f
...@@ -84,7 +84,7 @@ public class SceneService { ...@@ -84,7 +84,7 @@ public class SceneService {
//触发条件判断 //触发条件判断
private boolean getTriggerResult(SmartSceneData condition) { private boolean getTriggerResult(SmartSceneData condition) {
if (!getExecuteCycle().equals(condition.getExecuteCycle())) { if (condition.getExecuteCycle()!=1&&!getExecuteCycle().equals(condition.getExecuteCycle())) {
log.info("当前时间不是触发周期:" + condition.getId()); log.info("当前时间不是触发周期:" + condition.getId());
return false; return false;
} }
...@@ -121,7 +121,7 @@ public class SceneService { ...@@ -121,7 +121,7 @@ public class SceneService {
} }
} }
//根据logic逻辑码,判断触发条件与数据库中实际的值,判断是否满足 //根据logic逻辑码,判断触发条件与数据库中实际的值,判断是否满足
return ELogic.getValueByCode(logic, Value, smartDevideStatus.getDeviceOrderValue()); return ELogic.getValueByCode(logic, Value, smartDevideStatus.getDeviceOrderValue()==null?"":smartDevideStatus.getDeviceOrderValue());
} }
//根据当前时间对应的执行周期类型 //根据当前时间对应的执行周期类型
......
...@@ -23,20 +23,20 @@ public class SmartDeviceStatusService { ...@@ -23,20 +23,20 @@ public class SmartDeviceStatusService {
private SceneService sceneService; private SceneService sceneService;
public void saveEvent(Event event) { public void saveEvent(Event event) {
String sn=event.getSn(); SmartDevideStatus smartDevideStatus=smartDevideStatusMapper.findDevStatusByIdAndCode(event.getSn(), Constants.MACHINE_STATUS_ORDER);
String deviceId=smartDevideStatusMapper.findDeviceId(sn);
SmartDevideStatus smartDevideStatus=smartDevideStatusMapper.findDevStatusByIdAndCode(deviceId, Constants.MACHINE_STATUS_ORDER);
if(smartDevideStatus==null){ if(smartDevideStatus==null){
smartDevideStatus=new SmartDevideStatus(); smartDevideStatus=new SmartDevideStatus();
smartDevideStatus.setDeviceOrderCode(event.getDeviceType()); smartDevideStatus.setDeviceOrderCode(event.getDeviceType());
smartDevideStatus.setDeviceId(deviceId); smartDevideStatus.setDeviceId(event.getSn());
smartDevideStatus.setCreatetime(event.getTime());
} }
smartDevideStatus.setDeviceOrderValue(event.getValue()); smartDevideStatus.setDeviceOrderValue(event.getValue());
smartDevideStatus.setUpdatetime(event.getTime());
if(smartDevideStatus.getId()==null){ if(smartDevideStatus.getId()==null){
smartDevideStatusMapper.insert(smartDevideStatus); smartDevideStatusMapper.insert(smartDevideStatus);
}else{ }else{
smartDevideStatusMapper.updateByPrimaryKeySelective(smartDevideStatus); smartDevideStatusMapper.updateByPrimaryKeySelective(smartDevideStatus);
} }
sceneService.triggerScene(deviceId); sceneService.triggerScene(event.getSn());
} }
} }
...@@ -38,6 +38,7 @@ public class ProtobufConvert { ...@@ -38,6 +38,7 @@ public class ProtobufConvert {
} }
Event event = new Event(); Event event = new Event();
event.setSn(String.valueOf(protobufIgnition.getDevicesn().trim())); event.setSn(String.valueOf(protobufIgnition.getDevicesn().trim()));
event.setTime(DateUtils.parseDate(DateUtils.parseTimeStampDate(protobufIgnition.getGpstime())));
event.setDeviceType(Constants.MACHINE_STATUS_ORDER); event.setDeviceType(Constants.MACHINE_STATUS_ORDER);
event.setValue("true"); event.setValue("true");
return event; return event;
...@@ -57,6 +58,7 @@ public class ProtobufConvert { ...@@ -57,6 +58,7 @@ public class ProtobufConvert {
} }
Event event = new Event(); Event event = new Event();
event.setSn(String.valueOf(protobufFlameOut.getDevicesn().trim())); event.setSn(String.valueOf(protobufFlameOut.getDevicesn().trim()));
event.setTime(DateUtils.parseDate(DateUtils.parseTimeStampDate(protobufFlameOut.getGpstime())));
event.setDeviceType(Constants.MACHINE_STATUS_ORDER); event.setDeviceType(Constants.MACHINE_STATUS_ORDER);
event.setValue("false"); event.setValue("false");
return event; return event;
...@@ -78,6 +80,7 @@ public class ProtobufConvert { ...@@ -78,6 +80,7 @@ public class ProtobufConvert {
Event event = new Event(); Event event = new Event();
event.setSn(String.valueOf(protobufFlameOut.getSn())); event.setSn(String.valueOf(protobufFlameOut.getSn()));
event.setDeviceType(Constants.MACHINE_LEAVE_ORDER); event.setDeviceType(Constants.MACHINE_LEAVE_ORDER);
event.setTime(DateUtils.parseDate(DateUtils.parseTimeStampDate(protobufFlameOut.getTriggerTime())));
if((protobufFlameOut.getStatus()+"").equals("1")) { if((protobufFlameOut.getStatus()+"").equals("1")) {
event.setValue("true"); event.setValue("true");
}else{ }else{
......
package cn.com.glsx.smart.vo; package cn.com.glsx.smart.vo;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* 发动机事件 * 发动机事件
...@@ -17,7 +18,7 @@ public class Event implements Serializable{ ...@@ -17,7 +18,7 @@ public class Event implements Serializable{
private String userId; private String userId;
private String sn; private String sn;
private String type; // 类型:10点火事件,11熄火事件 private String type; // 类型:10点火事件,11熄火事件
private String time; // 终端报警时上带的GPS时间 (服务器 + 8 小时),格式 yyyy-MM-dd HH:mm:ss private Date time; // 终端报警时上带的GPS时间 (服务器 + 8 小时),格式 yyyy-MM-dd HH:mm:ss
private String deviceType;// private String deviceType;//
private String accessTime; private String accessTime;
...@@ -28,10 +29,9 @@ public class Event implements Serializable{ ...@@ -28,10 +29,9 @@ public class Event implements Serializable{
public Event() { public Event() {
} }
public Event(String sn, String type, String time) { public Event(String sn, String type) {
this.sn = sn; this.sn = sn;
this.type = type; this.type = type;
this.time = time;
} }
public String getSn() { public String getSn() {
...@@ -50,11 +50,11 @@ public class Event implements Serializable{ ...@@ -50,11 +50,11 @@ public class Event implements Serializable{
this.type = type; this.type = type;
} }
public String getTime() { public Date getTime() {
return time; return time;
} }
public void setTime(String time) { public void setTime(Date time) {
this.time = time; this.time = time;
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
--> -->
id, device_id, device_order_code, device_order_value, createtime, updatetime, product_key id, device_id, device_order_code, device_order_value, createtime, updatetime, product_key
</sql> </sql>
<select id="findDevStatusByIdAndCode" resultType="cn.com.glsx.smart.entity.SmartDevideStatus"> <select id="findDevStatusByIdAndCode" resultMap="BaseResultMap">
select * from smart_device_status select * from smart_device_status
where device_order_code=#{code} and device_id=#{devId} where device_order_code=#{code} and device_id=#{devId}
</select> </select>
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
select t1.*,t2.condition_rule,t2.execute_cycle from smart_scene_data t1 left join smart_scene t2 on t1.scene_id=t2.id select t1.*,t2.condition_rule,t2.execute_cycle from smart_scene_data t1 left join smart_scene t2 on t1.scene_id=t2.id
where device_id=#{deviceId} and param_key='scene_condition_status' where device_id=#{deviceId} and param_key='scene_condition_status'
</select> </select>
<select id="findBySceneId" resultType="cn.com.glsx.smart.entity.SmartSceneData"> <select id="findBySceneId" resultMap="BaseResultMap">
select * from smart_scene_data select t1.*,t2.condition_rule,t2.execute_cycle from smart_scene_data t1 left join smart_scene t2 on t1.scene_id=t2.id
where scene_id=#{sceneId} and (param_key='scene_condition_status' or param_key='scene_condition_time') where scene_id=#{sceneId} and (param_key='scene_condition_status' or param_key='scene_condition_time')
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!