Commit 689f918a by 111-PC\111

[+]红外修改

1 parent c41a05dc
......@@ -111,7 +111,7 @@ public class RemoteProductController {
* @return 结果
*/
@ResponseBody
@RequestMapping(value = "/findRemotes", method = {RequestMethod.GET, RequestMethod.POST})
@RequestMapping(value = "/findRemotes", method = {RequestMethod.GET})
@ApiOperation(value = "查询红外设备下的遥控器")
public String findRemotes(@RequestParam String infrared_id) {
return productTypeService.findRemotesById(infrared_id);
......
......@@ -88,4 +88,7 @@ public class SmartUserDevice {
*/
@Column(name = "update_time")
private Date updateTime;
@Transient
private String typeId;
}
......@@ -19,4 +19,6 @@ public interface SmartUserDeviceMapper extends tk.mybatis.mapper.common.Mapper<S
SmartUserDevice getByDeviceId(SmartUserDevice req);
int deleteDevice(SmartUserDevice req);
List<SmartUserDevice> findByParentId(String infrared_id);
}
......@@ -10,6 +10,7 @@ import com.glsx.smart.dao.entity.SmartProductType;
import com.glsx.smart.dao.entity.SmartUserDevice;
import com.glsx.smart.dao.mapper.SmartProductMapper;
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.ResultEnum;
import com.glsx.smart.pojo.response.RemoteDeviceResp;
......@@ -44,6 +45,9 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@Resource
private SmartProductMapper productMapper;
@Resource
private SmartUserDeviceMapper smartUserDeviceMapper;
@Value("${findRemotesUrl}")
private String findRemotesUrl;
......@@ -136,28 +140,15 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@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);
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);
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());
hash.put("remote_id", index.getDeviceId());
hash.put("typeId", index.getTypeId());
return hash;
}).collect(Collectors.toList());
return JSONObject.toJSONString(collect);
}
/**
......
......@@ -15,6 +15,7 @@
<result column="platform_product_id" jdbcType="VARCHAR" property="platformProductId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="type_id" jdbcType="VARCHAR" property="typeId"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated generated on Fri Apr 23 15:24:29 CST 2021.-->
......@@ -50,6 +51,12 @@
</where>
limit 1
</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 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!