Commit 1a03e9d3 by 111-PC\111

[+]红外修改

1 parent 689f918a
......@@ -140,7 +140,8 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@Override
public String findRemotesById(String infrared_id) {
List<SmartUserDevice> smartUserDeviceList=smartUserDeviceMapper.findByParentId(infrared_id);
Map<String, Object> objectMap = new HashMap<>();
List<SmartUserDevice> smartUserDeviceList = smartUserDeviceMapper.findByParentId(infrared_id);
List<Map<String, String>> collect = smartUserDeviceList.stream().map(index -> {
Map<String, String> hash = new HashMap<>();
hash.put("remote_name", index.getDeviceName());
......@@ -148,7 +149,9 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
hash.put("typeId", index.getTypeId());
return hash;
}).collect(Collectors.toList());
return JSONObject.toJSONString(collect);
objectMap.put("code", 200);
objectMap.put("message", collect);
return JSONObject.toJSONString(objectMap);
}
/**
......@@ -168,7 +171,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
prodIdList.add(array.getJSONObject(i).getString("product_id"));
}
List<SmartProduct> productList = productMapper.getByPlatProductIdList(prodIdList);
if(CollectionUtils.isEmpty(productList)){
if (CollectionUtils.isEmpty(productList)) {
return deviceRespList;
}
Map<Long, SmartProductType> typeMap = this.getProductTypeMap(status, productList);
......@@ -177,11 +180,11 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
JSONObject object = array.getJSONObject(i);
String productId = object.getString("product_id");
SmartProduct product = this.compareProductId(productList, productId);
if(product == null){
if (product == null) {
continue;
}
SmartProductType productType = typeMap.get(product.getTypeId());
if(productType != null){
if (productType != null) {
RemoteDeviceResp resp = new RemoteDeviceResp();
resp.setProductId(productId);
resp.setUuid(object.getString("id"));
......@@ -199,7 +202,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
* 获取用户家设备
*
* @param deviceList
* @param status 1触发条件 2执行内容 -1 全部
* @param status 1触发条件 2执行内容 -1 全部
* @return
*/
@Override
......@@ -209,16 +212,16 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
List<String> prodIdList = new ArrayList<>(deviceList.size());
deviceList.forEach(index -> prodIdList.add(index.getPlatformProductId()));
List<SmartProduct> productList = productMapper.getByPlatProductIdList(prodIdList);
if(CollectionUtils.isEmpty(productList)){
if (CollectionUtils.isEmpty(productList)) {
return deviceRespList;
}
Map<Long, SmartProductType> typeMap = this.getProductTypeMap(status, productList);
//用户设备数据封装
deviceList.forEach(index ->{
deviceList.forEach(index -> {
SmartProduct product = this.compareProductId(productList, index.getPlatformProductId());
if(product != null){
if (product != null) {
SmartProductType productType = typeMap.get(product.getTypeId());
if(productType != null){
if (productType != null) {
RemoteDeviceResp resp = new RemoteDeviceResp();
resp.setProductId(index.getPlatformProductId());
resp.setUuid(index.getDeviceId());
......@@ -242,12 +245,12 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
* @param productList
* @return
*/
private Map<Long, SmartProductType> getProductTypeMap(Byte status, List<SmartProduct> productList){
private Map<Long, SmartProductType> getProductTypeMap(Byte status, List<SmartProduct> productList) {
//获取设备类型列表
List<SmartProductType> list;
if(status == 1){
if (status == 1) {
list = productTypeMapper.getAllConditionList();
} else if(status == 2){
} else if (status == 2) {
list = productTypeMapper.getAllContentList();
} else {
//获取平台产品类型id列表
......@@ -258,21 +261,22 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
list = productTypeMapper.getByIdList(typeIdList);
}
Map<Long, SmartProductType> typeMap = new HashMap<>(list.size());
list.stream().forEach(index ->typeMap.put(index.getId(), index));
list.stream().forEach(index -> typeMap.put(index.getId(), index));
return typeMap;
}
/**
* 比较获取产品
*
* @param list
* @param productId
* @return
*/
private SmartProduct compareProductId(List<SmartProduct> list, String productId){
private SmartProduct compareProductId(List<SmartProduct> list, String productId) {
int len = list.size();
for (int i = 0; i < len; i++) {
SmartProduct product = list.get(i);
if(productId.equals(product.getPlatformProductId())){
if (productId.equals(product.getPlatformProductId())) {
return product;
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!