| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.usky.cdi.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.usky.cdi.service.impl.IotDataTransferService;
- import com.usky.cdi.service.vo.base.*;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- /**
- *
- * @author fyc
- * @email yuchuan.fu@chinausky.com
- * @date 2025/11/20
- */
- @Slf4j
- @RestController
- @RequestMapping("/api/iotInfo")
- @ConditionalOnProperty(prefix = "mqtt", value = {"enabled"}, havingValue = "true")
- public class IotDataController {
- @Autowired
- private IotDataTransferService iotDataTransferService;
- /**
- * 上报水浸状态
- */
- @PostMapping("/flooded")
- public String sendWaterLeak(@RequestBody JSONObject jsonObject) {
- boolean success = iotDataTransferService.sendWaterLeak(jsonObject);
- return success ? "上报成功" : "上报失败";
- }
- /**
- * 上报温度、湿度、氧气、一氧化碳、二氧化碳
- */
- @PostMapping("/envData")
- public String sendEnvData(@RequestBody JSONObject jsonObject) {
- boolean success = iotDataTransferService.sendEnvData(jsonObject);
- return success ? "上报成功" : "上报失败";
- }
- /**
- * 上报人员闯入
- */
- @PostMapping("/personPresence")
- public String sendPerson(@RequestBody JSONObject jsonObject) {
- boolean success = iotDataTransferService.sendPersonPresence(jsonObject);
- return success ? "上报成功" : "上报失败";
- }
- /**
- * 上报用电负荷
- */
- @PostMapping("/electricityLoad")
- public String sendElectricityLoad(@RequestBody JSONObject jsonObject) {
- boolean success = iotDataTransferService.sendElectricityLoad(jsonObject);
- return success ? "上报成功" : "上报失败";
- }
- }
|