NoticeController.java
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package cn.com.glsx.consumer.controller;
import cn.com.glsx.consumer.common.Contants;
import cn.com.glsx.consumer.entity.AqaraEvent;
import cn.com.glsx.consumer.service.DeviceEventService;
import cn.com.glsx.consumer.service.InfoService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author zhouhaibao
* @date 2021/4/18 10:39
*/
@Controller
@RequestMapping("/notice")
@Slf4j
public class NoticeController {
@Autowired
private InfoService infoService;
@Autowired
private DeviceEventService deviceEventService;
@RequestMapping("/deviceinfo")
public String deviceStatusInfo(@RequestBody String requestBody){
// 解密请求体信息
try {
log.info("消息内容{}",requestBody);
// 解密传过来的状态值
AqaraEvent aqaraEvent = JSONObject.parseObject(requestBody, AqaraEvent.class);
if(Contants.MSG_TYPE_RESOURCE.equals(aqaraEvent.getMsgType())){
deviceEventService.processResMessage(aqaraEvent);
}else if(Contants.MSG_TYPE_DEIVCE.equals(aqaraEvent.getMsgType())){
deviceEventService.processDevMessage(aqaraEvent);
}
return "glsxtest";
}catch (Exception e){
e.printStackTrace();
return null;
}
}
}