zhj преди 1 година
родител
ревизия
482f9bfd11

+ 167 - 0
src/main/java/com/welampiot/controller/MicrowaveController.java

@@ -0,0 +1,167 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dto.MicrowaveInfoDTO;
+import com.welampiot.service.MicrowaveInfoService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.EventVO;
+import com.welampiot.vo.InductionConfigVO;
+import com.welampiot.vo.MicrowaveInfoVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@CrossOrigin
+@RequestMapping("/microwave")
+public class MicrowaveController extends BaseController {
+    @Autowired
+    private MicrowaveInfoService microwaveInfoService;
+    @Autowired
+    private ToolUtils toolUtils;
+
+    /**
+     * 获取列表
+     */
+    @RequestMapping(value = "/getList", method = RequestMethod.POST)
+    private BaseResult<?> getList(MicrowaveInfoVO microwaveInfoVO) {
+        microwaveInfoVO.setSectionList(getSectionList(microwaveInfoVO.getUsername()));
+        microwaveInfoVO.setPageAndCount(microwaveInfoVO.getPage(), microwaveInfoVO.getCount());
+        List<MicrowaveInfoDTO> microList = microwaveInfoService.getMicrowaveListByMicrowaveInfoVO(microwaveInfoVO);
+        Integer total = microwaveInfoService.getMicrowaveTotalByMicrowaveInfoVO(microwaveInfoVO);
+        Integer onlineTotal = microwaveInfoService.getMicrowaveOnlineTotalByMicrowaveInfoVO(microwaveInfoVO);
+        MicrowaveInfoVO microwaveInfoVO1 = new MicrowaveInfoVO();
+        microwaveInfoVO1.setTotal(total);
+        microwaveInfoVO1.setOnlineTotal(onlineTotal);
+        microwaveInfoVO1.setList(microList);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, microwaveInfoVO.getVersion(), microwaveInfoVO1);
+    }
+
+    /**
+     * 删除设备
+     */
+    @RequestMapping(value = "/del", method = RequestMethod.POST)
+    private BaseResult<?> del(MicrowaveInfoVO microwaveInfoVO) {
+        Integer version = microwaveInfoVO.getVersion();
+        if (microwaveInfoVO.getId() == null || microwaveInfoVO.getId() == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        microwaveInfoService.deleteMicrowaveDataById(microwaveInfoVO.getId());
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version);
+    }
+
+    /**
+     * 保存设备
+     */
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    private BaseResult<?> save(MicrowaveInfoVO microwaveInfoVO) {
+        return microwaveInfoService.saveMicrowaveDataByMicrowaveVO(microwaveInfoVO);
+    }
+
+    /**
+     * 设置事件配置
+     */
+    @RequestMapping(value = "/setEventConfig", method = RequestMethod.POST)
+    private BaseResult<?> setEventConfig(EventVO eventVO) {
+        Integer version = eventVO.getVersion();
+        Integer id = eventVO.getId();
+        if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        MicrowaveInfoDTO microwaveInfoDTO = microwaveInfoService.getMicrowaveDetailsById(id);
+        if (microwaveInfoDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        boolean isSuccess = toolUtils.setEventData(
+                microwaveInfoDTO.getGateway(),
+                microwaveInfoDTO.getAddress(),
+                eventVO.getEventType(),
+                eventVO.getEventID(),
+                eventVO.getPerTimes(),
+                eventVO.getAddSpeed(),
+                eventVO.getGroupAddr());
+        if (!isSuccess) return toolUtils.response(InterfaceResultEnum.COMMAND_FAIL, version);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version);
+    }
+
+    /**
+     * 获取事件配置
+     */
+    @RequestMapping(value = "/getEventConfig", method = RequestMethod.POST)
+    private BaseResult<?> getEventConfig(EventVO eventVO) {
+        Integer version = eventVO.getVersion();
+        if (eventVO.getId() == null || eventVO.getId() == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        MicrowaveInfoDTO microwaveDetails = microwaveInfoService.getMicrowaveDetailsById(eventVO.getId());
+        if (microwaveDetails == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        EventVO eventData = toolUtils.getEventData(microwaveDetails.getGateway(), microwaveDetails.getAddress());
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, eventData);
+    }
+
+    /**
+     * 获取感应配置
+     */
+    @RequestMapping(value = "/getInductionConfig", method = RequestMethod.POST)
+    private BaseResult<?> getInductionConfig(InductionConfigVO inductionConfigVO) {
+        Integer version = inductionConfigVO.getVersion();
+        if (inductionConfigVO.getId() == null || inductionConfigVO.getId() == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        MicrowaveInfoDTO microwaveDetails = microwaveInfoService.getMicrowaveDetailsById(inductionConfigVO.getId());
+        if (microwaveDetails == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        InductionConfigVO inductionConfig = toolUtils.getInductionConfig(microwaveDetails.getGateway(), microwaveDetails.getAddress());
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, inductionConfig);
+    }
+
+    /**
+     * 设置感应配置
+     */
+    @RequestMapping(value = "/setInductionConfig", method = RequestMethod.POST)
+    private BaseResult<?> setInductionConfig(InductionConfigVO inductionConfigVO) {
+        Integer version = inductionConfigVO.getVersion();
+        Integer id = inductionConfigVO.getId();
+        if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        MicrowaveInfoDTO microwaveInfoDTO = microwaveInfoService.getMicrowaveDetailsById(id);
+        if (microwaveInfoDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        boolean isSuccess = toolUtils.setInductionConfig(
+                microwaveInfoDTO.getGateway(),
+                microwaveInfoDTO.getAddress(),
+                inductionConfigVO.getEnable(),
+                inductionConfigVO.getSensitivity(),
+                inductionConfigVO.getOnLight(),
+                inductionConfigVO.getOffLight());
+        if (!isSuccess) return toolUtils.response(InterfaceResultEnum.COMMAND_FAIL, version);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version);
+    }
+
+    /**
+     * 刷新数据
+     */
+    @RequestMapping(value = "/getLogInfo", method = RequestMethod.POST)
+    private BaseResult<?> getLogInfo(MicrowaveInfoVO microwaveInfoVO) {
+        Integer version = microwaveInfoVO.getVersion();
+        Integer id = microwaveInfoVO.getId();
+        if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        MicrowaveInfoDTO microwaveInfoDTO = microwaveInfoService.getMicrowaveDetailsById(id);
+        if (microwaveInfoDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        boolean isSuccess = toolUtils.refreshData(microwaveInfoDTO.getGateway(), microwaveInfoDTO.getAddress());
+        if (!isSuccess) return toolUtils.response(InterfaceResultEnum.COMMAND_FAIL, version);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version);
+    }
+
+    /**
+     * 获取光照度
+     */
+    @RequestMapping(value = "/getLight", method = RequestMethod.POST)
+    private BaseResult<?> getLight(MicrowaveInfoVO microwaveInfoVO) {
+        Integer version = microwaveInfoVO.getVersion();
+        Integer id = microwaveInfoVO.getId();
+        if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        MicrowaveInfoDTO microwaveInfoDTO = microwaveInfoService.getMicrowaveDetailsById(id);
+        if (microwaveInfoDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        Integer value = toolUtils.getIlluminanceValue(microwaveInfoDTO.getGateway(), microwaveInfoDTO.getAddress());
+        if (-1 == value) return toolUtils.response(InterfaceResultEnum.COMMAND_FAIL, version);
+        InductionConfigVO inductionConfigVO = new InductionConfigVO();
+        inductionConfigVO.setLight(value);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, inductionConfigVO);
+    }
+}

+ 18 - 0
src/main/java/com/welampiot/dao/MicrowaveInfoDao.java

@@ -0,0 +1,18 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.MicrowaveInfoDTO;
+import com.welampiot.vo.MicrowaveInfoVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface MicrowaveInfoDao {
+    List<MicrowaveInfoDTO> getMicrowaveListByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO);
+    Integer getMicrowaveTotalByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO);
+    Integer getMicrowaveOnlineTotalByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO);
+    void deleteMicrowaveDataById(@Param("id") Integer id);
+    Integer findMicrowaveCountByMicroDTO(MicrowaveInfoDTO microwaveInfoDTO);
+    void addMicrowaveData(MicrowaveInfoDTO microwaveInfoDTO);
+    void updateMicrowaveData(MicrowaveInfoDTO microwaveInfoDTO);
+    MicrowaveInfoDTO getMicrowaveDetailsById(@Param("id") Integer id);
+}

+ 26 - 0
src/main/java/com/welampiot/dto/MicrowaveInfoDTO.java

@@ -0,0 +1,26 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+@Data
+public class MicrowaveInfoDTO {
+    private Integer id;
+    private String name;
+    private Integer sectionId;
+    private Integer areaId;
+    private String address;
+    private String gateway;
+    private Integer online;
+    private Double rssi;
+    /** 配网状态(0 未配网,1 已配网) */
+    private Integer provStatus;
+    /** 微波状态(0 正常,1 异常) */
+    private Integer microStatus;
+    /** 设备软件版本号 */
+    private String swVersion;
+    /** 设备硬件版本号 */
+    private String hwVersion;
+    /** 光照传感器状态(0 正常,1 异常) */
+    private Integer lightSensorStatus;
+    private String updateTime;
+}

+ 19 - 0
src/main/java/com/welampiot/service/MicrowaveInfoService.java

@@ -0,0 +1,19 @@
+package com.welampiot.service;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.dto.MicrowaveInfoDTO;
+import com.welampiot.vo.MicrowaveInfoVO;
+
+import java.util.List;
+
+public interface MicrowaveInfoService {
+    List<MicrowaveInfoDTO> getMicrowaveListByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO);
+    Integer getMicrowaveTotalByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO);
+    Integer getMicrowaveOnlineTotalByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO);
+    void deleteMicrowaveDataById(Integer id);
+    Integer findMicrowaveCountByMicroDTO(MicrowaveInfoDTO microwaveInfoDTO);
+    void addMicrowaveData(MicrowaveInfoDTO microwaveInfoDTO);
+    void updateMicrowaveData(MicrowaveInfoDTO microwaveInfoDTO);
+    BaseResult<?> saveMicrowaveDataByMicrowaveVO(MicrowaveInfoVO microwaveInfoVO);
+    MicrowaveInfoDTO getMicrowaveDetailsById(Integer id);
+}

+ 110 - 0
src/main/java/com/welampiot/service/impl/MicrowaveInfoServiceImpl.java

@@ -0,0 +1,110 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dao.MicrowaveInfoDao;
+import com.welampiot.dto.MicrowaveInfoDTO;
+import com.welampiot.service.MicrowaveInfoService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.MicrowaveInfoVO;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class MicrowaveInfoServiceImpl implements MicrowaveInfoService {
+
+    @Autowired
+    private MicrowaveInfoDao microwaveInfoDao;
+
+    @Autowired
+    private ToolUtils toolUtils;
+
+    @Override
+    public List<MicrowaveInfoDTO> getMicrowaveListByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO) {
+        return microwaveInfoDao.getMicrowaveListByMicrowaveInfoVO(microwaveInfoVO);
+    }
+
+    @Override
+    public Integer getMicrowaveTotalByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO) {
+        return microwaveInfoDao.getMicrowaveTotalByMicrowaveInfoVO(microwaveInfoVO);
+    }
+
+    @Override
+    public Integer getMicrowaveOnlineTotalByMicrowaveInfoVO(MicrowaveInfoVO microwaveInfoVO) {
+        return microwaveInfoDao.getMicrowaveOnlineTotalByMicrowaveInfoVO(microwaveInfoVO);
+    }
+
+    @Override
+    public void deleteMicrowaveDataById(Integer id) {
+        microwaveInfoDao.deleteMicrowaveDataById(id);
+    }
+
+    @Override
+    public Integer findMicrowaveCountByMicroDTO(MicrowaveInfoDTO microwaveInfoDTO) {
+        return microwaveInfoDao.findMicrowaveCountByMicroDTO(microwaveInfoDTO);
+    }
+
+    @Override
+    public void addMicrowaveData(MicrowaveInfoDTO microwaveInfoDTO) {
+        microwaveInfoDao.addMicrowaveData(microwaveInfoDTO);
+    }
+
+    @Override
+    public void updateMicrowaveData(MicrowaveInfoDTO microwaveInfoDTO) {
+        microwaveInfoDao.updateMicrowaveData(microwaveInfoDTO);
+    }
+
+    @Override
+    public BaseResult<?> saveMicrowaveDataByMicrowaveVO(MicrowaveInfoVO microwaveInfoVO) {
+        BaseResult<?> baseResult = checkMicroData(microwaveInfoVO);
+        if (baseResult != null) return baseResult;
+
+        MicrowaveInfoDTO microwaveInfoDTO = new MicrowaveInfoDTO();
+        BeanUtils.copyProperties(microwaveInfoVO, microwaveInfoDTO);
+        if (microwaveInfoVO.getId() != null && microwaveInfoVO.getId() != 0) {
+            // 编辑
+            updateMicrowaveData(microwaveInfoDTO);
+        } else {
+            // 新增
+            addMicrowaveData(microwaveInfoDTO);
+        }
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, microwaveInfoVO.getVersion());
+    }
+
+    private BaseResult<?> checkMicroData(MicrowaveInfoVO microwaveInfoVO) {
+        Integer version = microwaveInfoVO.getVersion();
+        if (microwaveInfoVO.getAreaId() == null || microwaveInfoVO.getAreaId() == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR, version);
+        if (microwaveInfoVO.getSectionId() == null || microwaveInfoVO.getSectionId() == 0)
+            return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR, version);
+        if (microwaveInfoVO.getName() == null || microwaveInfoVO.getName().trim().isEmpty())
+            return toolUtils.response(InterfaceResultEnum.LACK_NAME_ERROR, version);
+        if (microwaveInfoVO.getAddress() == null || microwaveInfoVO.getAddress().trim().isEmpty())
+            return toolUtils.response(InterfaceResultEnum.LACK_ADDRESS_ERROR, version);
+        if (microwaveInfoVO.getGateway() == null || microwaveInfoVO.getGateway().trim().isEmpty())
+            return toolUtils.response(InterfaceResultEnum.LACK_NET_ADDRESS_ERROR, version);
+
+        MicrowaveInfoDTO microwaveInfoDTO1 = new MicrowaveInfoDTO();
+        microwaveInfoDTO1.setAreaId(microwaveInfoVO.getAreaId());
+        microwaveInfoDTO1.setSectionId(microwaveInfoVO.getSectionId());
+        microwaveInfoDTO1.setId(microwaveInfoVO.getId());
+        microwaveInfoDTO1.setName(microwaveInfoVO.getName());
+        if (findMicrowaveCountByMicroDTO(microwaveInfoDTO1) > 0)
+            return toolUtils.response(InterfaceResultEnum.DEV_NAME_UNIQUE_ERROR, version);
+        microwaveInfoDTO1 = new MicrowaveInfoDTO();
+        microwaveInfoDTO1.setAddress(microwaveInfoVO.getAddress());
+        microwaveInfoDTO1.setId(microwaveInfoVO.getId());
+        if (findMicrowaveCountByMicroDTO(microwaveInfoDTO1) > 0)
+            return toolUtils.response(InterfaceResultEnum.DEV_ADDRESS_UNIQUE_ERROR, version);
+
+        return null;
+    }
+
+    @Override
+    public MicrowaveInfoDTO getMicrowaveDetailsById(Integer id) {
+        return microwaveInfoDao.getMicrowaveDetailsById(id);
+    }
+}

+ 145 - 0
src/main/java/com/welampiot/utils/ToolUtils.java

@@ -14,6 +14,8 @@ import com.welampiot.dto.*;
 import com.welampiot.handle.MqttHandler;
 import com.welampiot.service.*;
 import com.welampiot.vo.DevEnumVO;
+import com.welampiot.vo.EventVO;
+import com.welampiot.vo.InductionConfigVO;
 import com.welampiot.vo.PanelConfigVO;
 import io.ipdata.client.Ipdata;
 import io.ipdata.client.error.IpdataException;
@@ -2445,6 +2447,149 @@ System.out.println(res);
         return 16;
     }
 
+    /**
+     * 设置事件
+     * @param netAddr   网关地址
+     * @param macAddr   设备mac地址
+     * @param eventType 事件类型( 1:串口雷达, 2: 高电平触发)
+     * @param eventID   事件ID,0-15
+     * @param perTimes  事件间隔,每几秒上报一次数据(s)
+     * @param addSpeed  偏移量
+     * @param groupAddr 分组地址,事件触发时,发送的分组地址
+     */
+    public boolean setEventData(String netAddr, String macAddr, Integer eventType, Integer eventID,
+                             Integer perTimes, Integer addSpeed, Integer groupAddr)
+    {
+        int seq = getSeq();
+        String cmd = "{\"Seq\":" + seq + ",\"CmdType\":\"SetTrigEvent\",\"DateTime\":\"" + getNowTime()
+                + "\",\"CmdData\":{\"Mac\":\"" + macAddr + "\",\"EventType\":" + eventType +
+                ",\"EventID\":" + eventID + ",\"PerTimes\":" + perTimes + ",\"AddSpeed\":" +
+                addSpeed + ",\"GroupAddr\":" + groupAddr + ",\"StartTime\":0,\"EndTime\":1440}}";
+        String sendTopic = "/MESHGW/commandIn/" + netAddr;
+        String backTopic = "/MESHGW/commandOut/" + netAddr;
+        String backResult = sendMqttCmd(sendTopic, cmd, backTopic);
+        return check2p4BackResult(backResult);
+    }
+
+    /**
+     * 获取事件配置
+     */
+    public EventVO getEventData(String netAddr, String macAddr) {
+        int seq = getSeq();
+        String cmd = "{\"Seq\":" + seq + ",\"CmdType\":\"GetTrigEvent\",\"DateTime\":\"" + getNowTime()
+                + "\",\"CmdData\":{\"Mac\":\"" + macAddr + "\"}}";
+        String sendTopic = "/MESHGW/commandIn/" + netAddr;
+        String backTopic = "/MESHGW/commandOut/" + netAddr;
+        String backResult = sendMqttCmd(sendTopic, cmd, backTopic);
+
+        EventVO eventVO = new EventVO();
+        eventVO.setEventType(1);
+        eventVO.setEventID(0);
+        eventVO.setPerTimes(0);
+        eventVO.setAddSpeed(0);
+        eventVO.setGroupAddr(0);
+        eventVO.setStartTime("00:00");
+        eventVO.setEndTime("24:00");
+
+        if (backResult.isEmpty()) return eventVO;
+        JSONObject jsonObject = JSONObject.parseObject(backResult);
+        if (!jsonObject.containsKey("CmdRsp")) return eventVO;
+        JSONObject cmdRsp = (JSONObject) jsonObject.get("CmdRsp");
+        if (cmdRsp.isEmpty()) return eventVO;
+        Integer eventType = cmdRsp.getInteger("EventType");
+        if (eventType != null) eventVO.setEventType(eventType);
+        Integer eventID = cmdRsp.getInteger("EventID");
+        if (eventID != null) eventVO.setEventID(eventID);
+        Integer perTimes = cmdRsp.getInteger("PerTimes");
+        if (perTimes != null) eventVO.setPerTimes(perTimes);
+        Integer addSpeed = cmdRsp.getInteger("AddSpeed");
+        if (addSpeed != null) eventVO.setAddSpeed(addSpeed);
+        Integer groupAddr = cmdRsp.getInteger("GroupAddr");
+        if (groupAddr != null) eventVO.setGroupAddr(groupAddr);
+        return eventVO;
+    }
+
+    /**
+     * 获取感应配置
+     */
+    public InductionConfigVO getInductionConfig(String netAddr, String macAddr) {
+        int seq = getSeq();
+        String cmd = "{\"Seq\":" + seq + ",\"CmdType\":\"GetMicroWave\",\"DateTime\":\"" + getNowTime()
+                + "\",\"CmdData\":{\"Mac\":\"" + macAddr + "\"}}";
+        String sendTopic = "/MESHGW/commandIn/" + netAddr;
+        String backTopic = "/MESHGW/commandOut/" + netAddr;
+        String backResult = sendMqttCmd(sendTopic, cmd, backTopic);
+
+        InductionConfigVO inductionConfigVO = new InductionConfigVO();
+        inductionConfigVO.setEnable(0);
+        inductionConfigVO.setSensitivity(1);
+        inductionConfigVO.setOnLight(0);
+        inductionConfigVO.setOffLight(0);
+
+
+        if (backResult.isEmpty()) return inductionConfigVO;
+        JSONObject jsonObject = JSONObject.parseObject(backResult);
+        if (!jsonObject.containsKey("CmdRsp")) return inductionConfigVO;
+        JSONObject cmdRsp = (JSONObject) jsonObject.get("CmdRsp");
+        if (cmdRsp.isEmpty()) return inductionConfigVO;
+        Integer enable = cmdRsp.getInteger("Enable");
+        if (enable != null) inductionConfigVO.setEnable(enable);
+        Integer sensitivity = cmdRsp.getInteger("Sensitivity");
+        if (sensitivity != null) inductionConfigVO.setSensitivity(sensitivity);
+        Integer onLight = cmdRsp.getInteger("OnLight");
+        if (onLight != null) inductionConfigVO.setOnLight(onLight);
+        Integer offLight = cmdRsp.getInteger("OffLight");
+        if (offLight != null) inductionConfigVO.setOffLight(offLight);
+        return inductionConfigVO;
+    }
+
+    /**
+     * 设置感应配置
+     */
+    public boolean setInductionConfig(String netAddr, String macAddr, Integer enable, Integer sensitivity,
+                                      Integer onLight, Integer offLight)
+    {
+        int seq = getSeq();
+        String cmd = "{\"Seq\":" + seq + ",\"CmdType\":\"SetMicroWave\",\"DateTime\":\"" + getNowTime()
+                + "\",\"CmdData\":{\"Mac\":\"" + macAddr + "\",\"Enable\":" + enable + ",\"Sensitivity\":" + sensitivity
+                + ",\"Onlight\":" + onLight + ",\"Offlight\":" + offLight + "}}";
+        String sendTopic = "/MESHGW/commandIn/" + netAddr;
+        String backTopic = "/MESHGW/commandOut/" + netAddr;
+        String backResult = sendMqttCmd(sendTopic, cmd, backTopic);
+        return check2p4BackResult(backResult);
+    }
+
+    /**
+     * 刷新数据
+     */
+    public boolean refreshData(String netAddr, String macAddr) {
+        int seq = getSeq();
+        String cmd = "{\"Seq\":" + seq + ",\"CmdType\":\"RealReport\",\"DateTime\":\"" + getNowTime() +
+                "\",\"CmdData\":{\"Mac\":\""+ macAddr +"\"}}";
+        String sendTopic = "/MESHGW/commandIn/" + netAddr;
+        String backTopic = "/MESHGW/commandOut/" + netAddr;
+        String backResult = sendMqttCmd(sendTopic, cmd, backTopic);
+        return check2p4BackResult(backResult);
+    }
+
+    /**
+     * 获取光照度
+     */
+    public Integer getIlluminanceValue(String netAddr, String macAddr) {
+        int seq = getSeq();
+        String cmd = "{\"Seq\":" + seq + ",\"CmdType\":\"GetIlluValue\",\"DateTime\":\"" + getNowTime() +
+                "\",\"CmdData\":{\"Mac\":\""+ macAddr +"\"}}";
+        String sendTopic = "/MESHGW/commandIn/" + netAddr;
+        String backTopic = "/MESHGW/commandOut/" + netAddr;
+        String backResult = sendMqttCmd(sendTopic, cmd, backTopic);
+        if (backResult.isEmpty()) return -1;
+        JSONObject jsonObject = JSONObject.parseObject(backResult);
+        if (!jsonObject.containsKey("CmdRsp")) return -1;
+        JSONObject cmdRsp = jsonObject.getJSONObject("CmdRsp");
+        if (cmdRsp.isEmpty() || !cmdRsp.containsKey("Illu")) return -1;
+        return cmdRsp.getInteger("Illu");
+    }
+
     public static void main(String[] args) {
         System.out.println(getPublicIp());
         System.out.println(formatNumber(0.0));

+ 1 - 0
src/main/java/com/welampiot/vo/BaseVO.java

@@ -14,6 +14,7 @@ public class BaseVO {
     private Integer online;
     private String username;
     private Integer version;
+    private Integer download;
     private List<Integer> sectionList;
 
     public void setPageAndCount(Integer page, Integer count) {

+ 17 - 0
src/main/java/com/welampiot/vo/EventVO.java

@@ -0,0 +1,17 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class EventVO extends BaseVO {
+    private Integer id;
+    private Integer eventType;
+    private Integer eventID;
+    private Integer perTimes;
+    private Integer addSpeed;
+    private Integer groupAddr;
+    private String startTime;
+    private String endTime;
+}

+ 19 - 0
src/main/java/com/welampiot/vo/InductionConfigVO.java

@@ -0,0 +1,19 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class InductionConfigVO extends BaseVO {
+    private Integer id;
+    /** 设备状态 1使能,0禁用 */
+    private Integer enable;
+    /** 灵敏度(1 高灵敏,0 低灵敏) */
+    private Integer sensitivity;
+    /** 微波使能照度值 */
+    private Integer onLight;
+    /** 微波禁用照度值 */
+    private Integer offLight;
+    private Integer light;
+}

+ 19 - 0
src/main/java/com/welampiot/vo/MicrowaveInfoVO.java

@@ -0,0 +1,19 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.MicrowaveInfoDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class MicrowaveInfoVO extends BaseVO {
+    private Integer id;
+    private String name;
+    private String address;
+    private String gateway;
+    private Integer total;
+    private Integer onlineTotal;
+    private List<MicrowaveInfoDTO> list;
+}

+ 129 - 0
src/main/resources/mapper/MicrowaveInfoMapper.xml

@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.welampiot.dao.MicrowaveInfoDao">
+
+    <select id="getMicrowaveListByMicrowaveInfoVO" resultType="com.welampiot.dto.MicrowaveInfoDTO">
+        select m.id,m.name,m.address,m.gateway,m.areaid as areaId,m.sectionid as sectionId,
+               m.online,m.sw_version as swVersion,m.hw_version as hwVersion,s.name as section
+               <choose>
+                   <when test="version == 2">
+                       ,gl.ru_name as area
+                   </when>
+                   <when test="version == 1">
+                       ,gl.english_name as area
+                   </when>
+                   <otherwise>
+                       ,gl.chinese_name as area
+                   </otherwise>
+               </choose>
+        from microwave_dev_info m
+        left join section s on m.sectionid = s.id
+        left join global_location gl on m.areaid = gl.id
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and m.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and m.areaid = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and m.sectionid = #{sectionId}
+        </if>
+        <if test="keyword != null and keyword != ''">
+            and (m.name like '%${keyword}%' or m.address like '%${keyword}%')
+        </if>
+        <if test="online != null and online == 1">
+            and m.online = 1
+        </if>
+        <if test="online != null and online == 0">
+            and m.online = 0
+        </if>
+        <if test="page != null and count != null">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <select id="getMicrowaveTotalByMicrowaveInfoVO" resultType="Integer">
+        select count(*)
+        from microwave_dev_info m
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and m.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and m.areaid = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and m.sectionid = #{sectionId}
+        </if>
+    </select>
+
+    <select id="getMicrowaveOnlineTotalByMicrowaveInfoVO" resultType="Integer">
+        select count(*)
+        from microwave_dev_info m
+        where m.online = 1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and m.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and m.areaid = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and m.sectionid = #{sectionId}
+        </if>
+    </select>
+
+    <insert id="addMicrowaveData" useGeneratedKeys="true" keyProperty="id" parameterType="com.welampiot.dto.MicrowaveInfoDTO">
+        insert into microwave_dev_info(`name`,address,gateway,areaid,sectionid)
+        values(#{name},#{address},#{gateway},#{areaId},#{sectionId})
+    </insert>
+
+    <update id="updateMicrowaveData" parameterType="com.welampiot.dto.MicrowaveInfoDTO">
+        update microwave_dev_info
+        set `name` = #{name},address = #{address},gateway = #{gateway},areaid = #{areaId},sectionid = #{sectionId}
+        where id = #{id}
+    </update>
+
+    <select id="findMicrowaveCount" resultType="Integer">
+        select count(*)
+        from microwave_dev_info m
+        where 1=1
+        <if test="areaId != null and areaId != 0">
+            and m.areaid = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and m.sectionid = #{sectionId}
+        </if>
+        <if test="name != null and name != ''">
+            and m.name = #{name}
+        </if>
+        <if test="address != null and address != ''">
+            and m.address = #{address}
+        </if>
+        <if test="id != null and id != 0">
+            and m.id != #{id}
+        </if>
+    </select>
+
+    <delete id="deleteMicrowaveDataById">
+        delete
+        from microwave_dev_info
+        where id = #{id}
+    </delete>
+
+    <select id="getMicrowaveDetailsById" resultType="com.welampiot.dto.MicrowaveInfoDTO">
+        select m.id,m.name,m.address,m.gateway
+        from microwave_dev_info m
+        where m.id = #{id}
+    </select>
+
+</mapper>