Commit 3fab142b by 111-PC\111

[+]kafka消费数据修改

1 parent e350e028
...@@ -3,8 +3,8 @@ package cn.com.glsx.smart.entity; ...@@ -3,8 +3,8 @@ package cn.com.glsx.smart.entity;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.*; import javax.persistence.*;
@Table(name = "smart_template_param") @Table(name = "smart_scene_data")
public class SmartTemplateParam implements Serializable { public class SmartSceneData implements Serializable {
/** /**
* 标识ID * 标识ID
*/ */
...@@ -12,10 +12,10 @@ public class SmartTemplateParam implements Serializable { ...@@ -12,10 +12,10 @@ public class SmartTemplateParam implements Serializable {
private Long id; private Long id;
/** /**
* 模板ID 关联smart_scene_template中id * 场景ID 关联smart_scene中id
*/ */
@Column(name = "template_id") @Column(name = "scene_id")
private Long templateId; private Long sceneId;
/** /**
* 类型 1触发条件 2执行内容 * 类型 1触发条件 2执行内容
...@@ -34,7 +34,7 @@ public class SmartTemplateParam implements Serializable { ...@@ -34,7 +34,7 @@ public class SmartTemplateParam implements Serializable {
private String paramKey; private String paramKey;
/** /**
* 模板值 数组对象 * 参数值 数组对象
*/ */
@Column(name = "param_value") @Column(name = "param_value")
private String paramValue; private String paramValue;
...@@ -60,21 +60,21 @@ public class SmartTemplateParam implements Serializable { ...@@ -60,21 +60,21 @@ public class SmartTemplateParam implements Serializable {
} }
/** /**
* 获取模板ID 关联smart_scene_template中id * 获取场景ID 关联smart_scene中id
* *
* @return template_id - 模板ID 关联smart_scene_template中id * @return scene_id - 场景ID 关联smart_scene中id
*/ */
public Long getTemplateId() { public Long getSceneId() {
return templateId; return sceneId;
} }
/** /**
* 设置模板ID 关联smart_scene_template中id * 设置场景ID 关联smart_scene中id
* *
* @param templateId 模板ID 关联smart_scene_template中id * @param sceneId 场景ID 关联smart_scene中id
*/ */
public void setTemplateId(Long templateId) { public void setSceneId(Long sceneId) {
this.templateId = templateId; this.sceneId = sceneId;
} }
/** /**
...@@ -132,18 +132,18 @@ public class SmartTemplateParam implements Serializable { ...@@ -132,18 +132,18 @@ public class SmartTemplateParam implements Serializable {
} }
/** /**
* 获取模板值 数组对象 * 获取参数值 数组对象
* *
* @return param_value - 模板值 数组对象 * @return param_value - 参数值 数组对象
*/ */
public String getParamValue() { public String getParamValue() {
return paramValue; return paramValue;
} }
/** /**
* 设置模板值 数组对象 * 设置参数值 数组对象
* *
* @param paramValue 模板值 数组对象 * @param paramValue 参数值 数组对象
*/ */
public void setParamValue(String paramValue) { public void setParamValue(String paramValue) {
this.paramValue = paramValue == null ? null : paramValue.trim(); this.paramValue = paramValue == null ? null : paramValue.trim();
...@@ -156,7 +156,7 @@ public class SmartTemplateParam implements Serializable { ...@@ -156,7 +156,7 @@ public class SmartTemplateParam implements Serializable {
sb.append(" ["); sb.append(" [");
sb.append("Hash = ").append(hashCode()); sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", templateId=").append(templateId); sb.append(", sceneId=").append(sceneId);
sb.append(", type=").append(type); sb.append(", type=").append(type);
sb.append(", sort=").append(sort); sb.append(", sort=").append(sort);
sb.append(", paramKey=").append(paramKey); sb.append(", paramKey=").append(paramKey);
......
package cn.com.glsx.smart.mapper; package cn.com.glsx.smart.mapper;
import cn.com.glsx.smart.entity.SmartTemplateParam; import cn.com.glsx.smart.entity.SmartSceneData;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
public interface SmartTemplateParamMapper extends CommonBaseMapper<SmartTemplateParam> { public interface SmartSceneDataMapper extends CommonBaseMapper<SmartSceneData> {
List<SmartTemplateParam> findByTemplateId(@Param("templateId") int templateId);
List<SmartSceneData> findByTemplateId(@Param("templateId") int templateId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -4,10 +4,9 @@ import cn.com.glsx.smart.commons.Constants; ...@@ -4,10 +4,9 @@ import cn.com.glsx.smart.commons.Constants;
import cn.com.glsx.smart.entity.ExecuteTaskVo; import cn.com.glsx.smart.entity.ExecuteTaskVo;
import cn.com.glsx.smart.entity.MessageVo; import cn.com.glsx.smart.entity.MessageVo;
import cn.com.glsx.smart.entity.ResponseVo; import cn.com.glsx.smart.entity.ResponseVo;
import cn.com.glsx.smart.entity.SmartTemplateParam; import cn.com.glsx.smart.entity.SmartSceneData;
import cn.com.glsx.smart.mapper.SmartTemplateParamMapper; import cn.com.glsx.smart.mapper.SmartSceneDataMapper;
import cn.com.glsx.smart.utils.HttpUtil; import cn.com.glsx.smart.utils.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -32,11 +31,14 @@ import java.util.stream.Collectors; ...@@ -32,11 +31,14 @@ import java.util.stream.Collectors;
public class OrderIssueService { public class OrderIssueService {
@Autowired @Autowired
private SmartTemplateParamMapper smartTemplateParamMapper; private SmartSceneDataMapper smartSceneDataMapper;
@Value("${orderIssueurl}") @Value("${orderIssueurl}")
private String orderIssueurl; private String orderIssueurl;
@Value("${instructionInfIssue}")
private String instructionInfIssue;
/** /**
* 处理消息 * 处理消息
* *
...@@ -48,13 +50,13 @@ public class OrderIssueService { ...@@ -48,13 +50,13 @@ public class OrderIssueService {
log.info("数据异常"); log.info("数据异常");
return; return;
} }
List<SmartTemplateParam> smartTemplateParamList = smartTemplateParamMapper.findByTemplateId(Integer.parseInt(messageVo.getScenseId())); List<SmartSceneData> smartTemplateParamList = smartSceneDataMapper.findByTemplateId(Integer.parseInt(messageVo.getScenseId()));
if (CollectionUtils.isEmpty(smartTemplateParamList)) { if (CollectionUtils.isEmpty(smartTemplateParamList)) {
log.info("未查到该场景id的条件{}", messageVo.getScenseId()); log.info("未查到该场景id的条件{}", messageVo.getScenseId());
return; return;
} }
// 下发指令 // 下发指令
List<SmartTemplateParam> orders = smartTemplateParamList.stream().filter(index -> index.getParamKey().equals(Constants.Order_Issue)).collect(Collectors.toList()); List<SmartSceneData> orders = smartTemplateParamList.stream().filter(index -> index.getParamKey().equals(Constants.Order_Issue)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(orders)) { if (CollectionUtils.isEmpty(orders)) {
log.info("未查到该场景id的指令{}", messageVo.getScenseId()); log.info("未查到该场景id的指令{}", messageVo.getScenseId());
return; return;
...@@ -89,7 +91,7 @@ public class OrderIssueService { ...@@ -89,7 +91,7 @@ public class OrderIssueService {
} else { } else {
ordermap.put("key", executeTaskVo.getOrderCode()); ordermap.put("key", executeTaskVo.getOrderCode());
// 下发红外遥控指令 // 下发红外遥控指令
jsonObject = HttpUtil.sendPost(orderIssueurl.replace("{remote_id}", remoteId).replace("{infrared_id}", devideId), JSONObject.toJSONString(ordermap), new HashMap<>()); jsonObject = HttpUtil.sendPost(instructionInfIssue.replace("{remote_id}", remoteId).replace("{infrared_id}", devideId), JSONObject.toJSONString(ordermap), new HashMap<>());
} }
if(jsonObject!=null){ if(jsonObject!=null){
ResponseVo responseVo = JSONObject.toJavaObject(jsonObject, ResponseVo.class); ResponseVo responseVo = JSONObject.toJavaObject(jsonObject, ResponseVo.class);
...@@ -104,7 +106,7 @@ public class OrderIssueService { ...@@ -104,7 +106,7 @@ public class OrderIssueService {
} }
}); });
// 推送消息开始 ----- TODO // 推送消息开始 ----- TODO
List<SmartTemplateParam> messageOrders = smartTemplateParamList.stream().filter(index -> index.getParamKey().equals(Constants.MESSAGE_NOTI)).collect(Collectors.toList()); List<SmartSceneData> messageOrders = smartTemplateParamList.stream().filter(index -> index.getParamKey().equals(Constants.MESSAGE_NOTI)).collect(Collectors.toList());
// 推送消息结束 -----TODO // 推送消息结束 -----TODO
} }
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
</javaClientGenerator> </javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 --> <!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<table tableName="smart_template_param" domainObjectName="SmartTemplateParam" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" <table tableName="smart_scene_data" domainObjectName="SmartSceneData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false"/> enableSelectByExample="false" selectByExampleQueryId="false"/>
</context> </context>
</generatorConfiguration> </generatorConfiguration>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.smart.mapper.SmartTemplateParamMapper"> <mapper namespace="cn.com.glsx.smart.mapper.SmartSceneDataMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.smart.entity.SmartTemplateParam"> <resultMap id="BaseResultMap" type="cn.com.glsx.smart.entity.SmartSceneData">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="template_id" jdbcType="BIGINT" property="templateId" /> <result column="scene_id" jdbcType="BIGINT" property="sceneId" />
<result column="type" jdbcType="TINYINT" property="type" /> <result column="type" jdbcType="TINYINT" property="type" />
<result column="sort" jdbcType="TINYINT" property="sort" /> <result column="sort" jdbcType="TINYINT" property="sort" />
<result column="param_key" jdbcType="VARCHAR" property="paramKey" /> <result column="param_key" jdbcType="VARCHAR" property="paramKey" />
...@@ -16,11 +16,10 @@ ...@@ -16,11 +16,10 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
id, template_id, `type`, sort, param_key, param_value id, scene_id, `type`, sort, param_key, param_value
</sql> </sql>
<select id="findByTemplateId" resultMap="BaseResultMap"> <select id="findByTemplateId" resultMap="BaseResultMap">
select * select *
from smart_template_param where template_id=#{templateId} and type=2 from smart_scene_data where scene_id=#{templateId} and type=2
</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!