Commit 689f918a by 111-PC\111

[+]红外修改

1 parent c41a05dc
...@@ -111,7 +111,7 @@ public class RemoteProductController { ...@@ -111,7 +111,7 @@ public class RemoteProductController {
* @return 结果 * @return 结果
*/ */
@ResponseBody @ResponseBody
@RequestMapping(value = "/findRemotes", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/findRemotes", method = {RequestMethod.GET})
@ApiOperation(value = "查询红外设备下的遥控器") @ApiOperation(value = "查询红外设备下的遥控器")
public String findRemotes(@RequestParam String infrared_id) { public String findRemotes(@RequestParam String infrared_id) {
return productTypeService.findRemotesById(infrared_id); return productTypeService.findRemotesById(infrared_id);
......
...@@ -88,4 +88,7 @@ public class SmartUserDevice { ...@@ -88,4 +88,7 @@ public class SmartUserDevice {
*/ */
@Column(name = "update_time") @Column(name = "update_time")
private Date updateTime; private Date updateTime;
@Transient
private String typeId;
} }
...@@ -19,4 +19,6 @@ public interface SmartUserDeviceMapper extends tk.mybatis.mapper.common.Mapper<S ...@@ -19,4 +19,6 @@ public interface SmartUserDeviceMapper extends tk.mybatis.mapper.common.Mapper<S
SmartUserDevice getByDeviceId(SmartUserDevice req); SmartUserDevice getByDeviceId(SmartUserDevice req);
int deleteDevice(SmartUserDevice req); int deleteDevice(SmartUserDevice req);
List<SmartUserDevice> findByParentId(String infrared_id);
} }
...@@ -10,6 +10,7 @@ import com.glsx.smart.dao.entity.SmartProductType; ...@@ -10,6 +10,7 @@ import com.glsx.smart.dao.entity.SmartProductType;
import com.glsx.smart.dao.entity.SmartUserDevice; import com.glsx.smart.dao.entity.SmartUserDevice;
import com.glsx.smart.dao.mapper.SmartProductMapper; import com.glsx.smart.dao.mapper.SmartProductMapper;
import com.glsx.smart.dao.mapper.SmartProductTypeMapper; import com.glsx.smart.dao.mapper.SmartProductTypeMapper;
import com.glsx.smart.dao.mapper.SmartUserDeviceMapper;
import com.glsx.smart.exception.BusinessException; import com.glsx.smart.exception.BusinessException;
import com.glsx.smart.exception.ResultEnum; import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.pojo.response.RemoteDeviceResp; import com.glsx.smart.pojo.response.RemoteDeviceResp;
...@@ -44,6 +45,9 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro ...@@ -44,6 +45,9 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@Resource @Resource
private SmartProductMapper productMapper; private SmartProductMapper productMapper;
@Resource
private SmartUserDeviceMapper smartUserDeviceMapper;
@Value("${findRemotesUrl}") @Value("${findRemotesUrl}")
private String findRemotesUrl; private String findRemotesUrl;
...@@ -136,28 +140,15 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro ...@@ -136,28 +140,15 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@Override @Override
public String findRemotesById(String infrared_id) { public String findRemotesById(String infrared_id) {
String responseResult = null; List<SmartUserDevice> smartUserDeviceList=smartUserDeviceMapper.findByParentId(infrared_id);
JSONObject json = null; List<Map<String, String>> collect = smartUserDeviceList.stream().map(index -> {
try { Map<String, String> hash = new HashMap<>();
responseResult = HttpUtil.sendGet(findRemotesUrl.replace("{infrared_id}", infrared_id), null, new HashMap<>()); hash.put("remote_name", index.getDeviceName());
json = JSON.parseObject(responseResult); hash.put("remote_id", index.getDeviceId());
if (json.getInteger("code").equals(200)) { hash.put("typeId", index.getTypeId());
JSONArray newArray = new JSONArray(); return hash;
JSONArray array = json.getJSONArray("message"); }).collect(Collectors.toList());
int len = array.size(); return JSONObject.toJSONString(collect);
for (int i = 0; i < len; i++) {
JSONObject object = array.getJSONObject(i);
int category_id = object.getInteger("category_id");
SmartProductType productType = productTypeMapper.getByCategoryId(category_id);
object.put("typeId", productType.getId());
newArray.add(object);
}
json.put("message", newArray);
}
} catch (IOException e) {
e.printStackTrace();
}
return JSONObject.toJSONString(json);
} }
/** /**
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<result column="platform_product_id" jdbcType="VARCHAR" property="platformProductId"/> <result column="platform_product_id" jdbcType="VARCHAR" property="platformProductId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="type_id" jdbcType="VARCHAR" property="typeId"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated generated on Fri Apr 23 15:24:29 CST 2021.--> <!--@mbg.generated generated on Fri Apr 23 15:24:29 CST 2021.-->
...@@ -50,6 +51,12 @@ ...@@ -50,6 +51,12 @@
</where> </where>
limit 1 limit 1
</select> </select>
<select id="findByParentId" resultMap="BaseResultMap">
select s1.device_name,s1.device_id,s2.type_id as type_id from smart_user_device s1
left join smart_product s2 on s1.platform_product_id= s2.platform_product_id
where type=2 and
parent_id=#{infrared_id}
</select>
<delete id="deleteDevice"> <delete id="deleteDevice">
delete from smart_user_device delete from smart_user_device
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!