Commit 67032e95 by wnb0128

车家智能数据服务开发 万能遥控器情况处理--think.wang

2 parents c5ee3633 dace1fa3
...@@ -12,7 +12,6 @@ import com.glsx.smart.dao.entity.SmartUserRelation; ...@@ -12,7 +12,6 @@ import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.service.SmartProductService; import com.glsx.smart.service.SmartProductService;
import com.glsx.smart.service.SmartProductTypeService; import com.glsx.smart.service.SmartProductTypeService;
import com.glsx.smart.service.SmartUserRelationService; import com.glsx.smart.service.SmartUserRelationService;
import com.glsx.smart.utils.HttpUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -20,9 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,9 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
...@@ -38,9 +35,6 @@ public class RemoteProductController { ...@@ -38,9 +35,6 @@ public class RemoteProductController {
@Value("${device_remote_url}") @Value("${device_remote_url}")
private String remoteUrl; private String remoteUrl;
@Value("${findRemotesUrl}")
private String findRemotesUrl;
@Autowired @Autowired
private SmartProductService productService; private SmartProductService productService;
...@@ -50,6 +44,9 @@ public class RemoteProductController { ...@@ -50,6 +44,9 @@ public class RemoteProductController {
@Autowired @Autowired
private SmartUserRelationService userRelationService; private SmartUserRelationService userRelationService;
@Autowired
private SmartProductTypeService smartProductTypeService;
/** /**
* 用户获取远程产品列表数据 * 用户获取远程产品列表数据
* *
...@@ -161,16 +158,7 @@ public class RemoteProductController { ...@@ -161,16 +158,7 @@ public class RemoteProductController {
@RequestMapping(value = "/findRemotes", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/findRemotes", method = {RequestMethod.GET, RequestMethod.POST})
@ApiOperation(value = "查询红外设备下的遥控器") @ApiOperation(value = "查询红外设备下的遥控器")
public String findRemotes(@RequestParam String infrared_id) { public String findRemotes(@RequestParam String infrared_id) {
return findRemotesById(infrared_id); return smartProductTypeService.findRemotesById(infrared_id);
} }
private String findRemotesById(String infrared_id) {
String responseResult=null;
try {
responseResult = HttpUtil.sendGet(findRemotesUrl.replace("{infrared_id}", infrared_id), null, new HashMap<>());
} catch (IOException e) {
e.printStackTrace();
}
return responseResult;
}
} }
...@@ -27,4 +27,6 @@ public interface SmartProductTypeService { ...@@ -27,4 +27,6 @@ public interface SmartProductTypeService {
List<SmartProductType> getListAndContent(List<Long> list); List<SmartProductType> getListAndContent(List<Long> list);
List<SmartProductType> getListAndCondition(List<Long> list); List<SmartProductType> getListAndCondition(List<Long> list);
String findRemotesById(String infrared_id);
} }
package com.glsx.smart.service.impl; package com.glsx.smart.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.smart.dao.entity.SmartProductType; import com.glsx.smart.dao.entity.SmartProductType;
import com.glsx.smart.dao.mapper.SmartProductTypeMapper; import com.glsx.smart.dao.mapper.SmartProductTypeMapper;
...@@ -7,12 +10,16 @@ import com.glsx.smart.exception.BusinessException; ...@@ -7,12 +10,16 @@ import com.glsx.smart.exception.BusinessException;
import com.glsx.smart.exception.ResultEnum; import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.service.BaseService; import com.glsx.smart.service.BaseService;
import com.glsx.smart.service.SmartProductTypeService; import com.glsx.smart.service.SmartProductTypeService;
import com.glsx.smart.utils.HttpUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
...@@ -25,9 +32,13 @@ import java.util.List; ...@@ -25,9 +32,13 @@ import java.util.List;
@Slf4j @Slf4j
@Service @Service
public class SmartProductTypeServiceImpl extends BaseService implements SmartProductTypeService { public class SmartProductTypeServiceImpl extends BaseService implements SmartProductTypeService {
@Resource @Resource
private SmartProductTypeMapper productTypeMapper; private SmartProductTypeMapper productTypeMapper;
@Value("${findRemotesUrl}")
private String findRemotesUrl;
/** /**
* 分页获取产品类型列表。 * 分页获取产品类型列表。
* *
...@@ -114,4 +125,31 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro ...@@ -114,4 +125,31 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
public List<SmartProductType> getListAndCondition(List<Long> list) { public List<SmartProductType> getListAndCondition(List<Long> list) {
return productTypeMapper.getListAndCondition(list); return productTypeMapper.getListAndCondition(list);
} }
@Override
public String findRemotesById(String infrared_id) {
String responseResult = null;
JSONObject json = null;
try {
responseResult = HttpUtil.sendGet(findRemotesUrl.replace("{infrared_id}", infrared_id), null, new HashMap<>());
json = JSON.parseObject(responseResult);
if (json.getInteger("code").equals(200)) {
JSONArray newArray = new JSONArray();
JSONArray array = json.getJSONArray("message");
int len = array.size();
for (int i = 0; i < len; i++) {
JSONObject object = array.getJSONObject(i);
JSONObject val = new JSONObject();
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);
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!