1
0

2 Commits 739f5180b8 ... 930102bc7f

Autor SHA1 Mensagem Data
  crazycat 930102bc7f Merge remote-tracking branch 'origin/CIS_V1.0' into CIS_V1.0 11 meses atrás
  crazycat 3d92518d3b 增加伺服电机 11 meses atrás

+ 1 - 0
src/main/java/com/welampiot/common/InterfaceResultEnum.java

@@ -6,6 +6,7 @@ public enum InterfaceResultEnum {
     PARAM_FAIL("0001","参数异常","Parameter abnormality","Параметры аномалии"),
     TOKEN_FAIL("0004","登录信息已过期,请重新登录","Parameter abnormality","Параметры аномалии"),
     LACK_PARAM_ERROR("0007","缺少必要参数","",""),
+    NOT_AUTH("0013","无权限操作","",""),
     DEVICE_NO_SUPPORT("0018","设备不支持","",""),
     USERNAME_PASSWORD_PARAM_ERROR("0101","用户名或密码错误","",""),
     SEND_CMD_TIME_OUT("0014","下发命令超时,请稍后重试!","",""),

+ 87 - 30
src/main/java/com/welampiot/common/LampControlTypeEnum.java

@@ -2,42 +2,96 @@ package com.welampiot.common;
 
 public enum LampControlTypeEnum {
 
-    WE_MA_10(0, "WE-MA-10"),
-    WE_MA_20(1, "WE-MA-20"),
-    WE_CON_10(2, "WE-CON-10"),
-    WE_CON_20(3, "WE-CON-20"),
-    WE_CON_P10(4, "WE-CON-P10"),
-    WE_CON_4G20(5, "WE-CON-4G20"),
-    WE_CON_4G11(6, "WE-CON-4G11"),
-    WE_CON_4G10(7, "WE-CON-4G10"),
-    WE_CON_P20(8, "WE-CON-P20"),
-    WE_CON_N20(9, "WE-CON-N20"),
-    WE_CON_N10(10, "WE-CON-N10"),
-    PGH_125_051A(11, "PGH-125-051A"),
-    LHS_120_HP18G0(12, "LHS-120-HP18G0"),
-    SZ10_R1A_M(13, "SZ10-R1A-M"),
-    PGH_060_046(14, "PGH-060-046"),
-    WE_MA_4G10(15, "WE-MA-4G10"),
-    WE_CON_ZB10(16, "WE-CON-ZB10"),
-    WE_CON_R20(17, "WE-CON-R20"),
-    WE_CON_R10(18, "WE-CON-R10"),
-    WE_MA_N30(19, "WE-MA-N30"),
-    WE_ZH_4GS(20, "WE-ZH-4GS"),
-    WE_CON_4GH10(21, "WE-CON-4GH10"),
-    WE_CON_4GH20(22, "WE-CON-4GH20"),
-    WE_CON_4G15(23, "WE-CON-4G15"),
-    WE_CON_B10(24, "WE-CON-B10"),
-    WE_CON_B20(24, "WE-CON-B20"),
-    WE_CON_PW10(26, "WE-CON-PW10"),
-    WE_CON_PW20(27, "WE-CON-PW20"),
-    WE_MA_B10(28, "WE-MA-B10"),
+    WE_MA_10(0, "WE-MA-10",false),
+    WE_MA_20(1, "WE-MA-20",false),
+    WE_CON_10(2, "WE-CON-10",false),
+    WE_CON_20(3, "WE-CON-20",false),
+    WE_CON_P10(4, "WE-CON-P10",false),
+    WE_CON_4G20(5, "WE-CON-4G20",true),
+    WE_CON_4G11(6, "WE-CON-4G11",false),
+    WE_CON_4G10(7, "WE-CON-4G10",false),
+    WE_CON_P20(8, "WE-CON-P20",true),
+    WE_CON_N20(9, "WE-CON-N20",true),
+    WE_CON_N10(10, "WE-CON-N10",false),
+    PGH_125_051A(11, "PGH-125-051A",false),
+    LHS_120_HP18G0(12, "LHS-120-HP18G0",false),
+    SZ10_R1A_M(13, "SZ10-R1A-M",false),
+    PGH_060_046(14, "PGH-060-046",false),
+    WE_MA_4G10(15, "WE-MA-4G10",false),
+    WE_CON_ZB10(16, "WE-CON-ZB10",false),
+    WE_CON_R20(17, "WE-CON-R20",true),
+    WE_CON_R10(18, "WE-CON-R10",false),
+    WE_MA_N30(19, "WE-MA-N30",false),
+    WE_ZH_4GS(20, "WE-ZH-4G10G",false),
+    WE_CON_4GH10(21, "WE-CON-4GH10",false),
+    WE_CON_4GH20(22, "WE-CON-4GH20",true),
+    WE_CON_4G15(23, "WE-CON-4G15",false),
+    WE_CON_B10(24, "WE-CON-B10",false),
+    WE_CON_B20(24, "WE-CON-B20",true),
+    WE_CON_PW10(26, "WE-CON-PW10",false),
+    WE_CON_PW20(27, "WE-CON-PW20",true),
+    WE_MA_B10(28, "WE-MA-B10",false),
+    WE_CON_N20_EX(29, "WE-CON-N20-EX",true),
+    WE_D100_48G(30, "WE-D100-48G",false),
+    WE_D150_48G(31, "WE-D150-48G",false),
+    WE_D250_48G(32, "WE-D250-48G",false),
+    WE_CON_N10_EX(33, "WE-CON-N10-EX",false),
+    WE_CON_4G30(34, "WE-CON-4G30",true),
+    WE_CON_4G31(35, "WE-CON-4G31",false),
+    WE_CH_P10(36, "WE-CH-P10",false),
+    WE_MA_N10(37, "WE-MA-N10",false),
+    WE_CON_R30(38, "WE-CON-R30",false),
+    WE_CON_R40(39, "WE-CON-R40",true),
+    WE_80_48G(40, "WE-80-48G",false),
+    WE_100_48G(41, "WE-100-48G",false),
+    WE_120_48G(42, "WE-120-48G",false),
+    WE_150_48G(43, "WE-150-48G",false),
+    WE_180_48G(44, "WE-180-48G",false),
+    WE_200_48G(45, "WE-200-48G",false),
+    WE_240_48G(46, "WE-240-48G",false),
+    WE_300_48G(47, "WE-300-48G",false),
+    WE_480_48G_D(48, "WE-480-48G-D",true),
+    WE_MA_M10P(49, "WE-MA-M10P",false),
+    WE_MA_M40(50, "WE-MA-M40",false),
+    WE_MA_M41(51, "WE-MA-M41",false),
+    WE_MPPT_4G(52, "WE-MPPT-4G",false),
+    WE_MESH_LORAWAN(53, "WE-MESH-LORAWAN",false),
+    WE_MA_P10(54, "WE-MA-P10",false),
+    WE_SOLAR_4G_H(55, "WE-SOLAR-4G-H",false),
+    WE_CON_ZB30(56, "WE-CON-ZB30",false),
+    WE_30_48G(57, "WE-30-48G",false),
+    WE_50_48G(58, "WE-50-48G",false),
+    WE_60_48G(59, "WE-60-48G",false),
+    WE_75_48G(60, "WE-75-48G",false),
+    WE_30_48B(61, "WE-30-48B",false),
+    WE_50_48B(62, "WE-50-48B",false),
+    WE_60_48B(63, "WE-60-48B",false),
+    WE_75_48B(64, "WE-75-48B",false),
+    WE_80_48B(65, "WE-80-48B",false),
+    WE_100_48B(66, "WE-100-48B",false),
+    WE_120_48B(67, "WE-120-48B",false),
+    WE_150_48B(68, "WE-150-48B",false),
+    WE_180_48B(69, "WE-180-48B",false),
+    WE_200_48B(70, "WE-200-48B",false),
+    WE_240_48B(71, "WE-240-48B",false),
+    WE_300_48B(72, "WE-300-48B",false),
+    WE_70_48B_ZG(73, "WE-70-48B-ZG",false),
+    WE_ZH_BM21(74, "WE-ZH-BM21",false),
+    WE_SOLAR_24G_H(75, "WE-SOLAR-24G-H",false),
+    WE_ZH_BM22(76, "WE-ZH-BM22",false),
+    WE_MA_P40(77, "WE-MA-P40",true),
+    WE_MA_P30(78, "WE-MA-P30",false),
+    WE_200_48G_D(79, "WE-200-48G-D",true),
+    WE_300_48G_D(80, "WE-300-48G-D",true),
     ;
     private final Integer id;
     private final String name;
+    private final boolean isDb;
 
-    LampControlTypeEnum(Integer id, String name) {
+    LampControlTypeEnum(Integer id, String name,boolean isDb) {
         this.id = id;
         this.name = name;
+        this.isDb = isDb;
     }
 
     public Integer getId() {
@@ -47,6 +101,9 @@ public enum LampControlTypeEnum {
     public String getName() {
         return name;
     }
+    public boolean getIsDb() {
+        return isDb;
+    }
 
     /**
      * 转为数据

+ 29 - 0
src/main/java/com/welampiot/controller/BaseController.java

@@ -1,12 +1,26 @@
 package com.welampiot.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dto.BenchUserInfoDTO;
 import com.welampiot.dto.UserDTO;
+import com.welampiot.exception.SectionAuthException;
 import com.welampiot.service.UserService;
+import com.welampiot.utils.ToolUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.PreDestroy;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -31,6 +45,10 @@ public class BaseController {
 
     @Autowired
     private UserService userService;
+    @Autowired
+    private UserDTO userDTO;
+    @Autowired
+    protected ToolUtils toolUtils;
 
     protected List<Integer> getSectionList(String username) {
         List<Integer> sectionList = new ArrayList<>();
@@ -57,4 +75,15 @@ public class BaseController {
     public void shutdown() {
         EXECUTOR_SERVICE.shutdown();
     }
+    protected void checkSectionAuth(Integer sectionId)throws Exception{
+        String zoneList = userDTO.getZoneList();
+        String[] split = zoneList.split(",");
+        List<String> strings = Arrays.asList(split);
+        if (split.length == 0 || !strings.contains(sectionId.toString())){
+            SectionAuthException exception = new SectionAuthException();
+            throw exception;
+        }
+    }
+
+
 }

+ 2 - 2
src/main/java/com/welampiot/controller/BasePlatformController.java

@@ -79,7 +79,7 @@ public class BasePlatformController {
     @RequestMapping(value = "/data", method = RequestMethod.POST)
     public BaseResult<?> data(HttpServletRequest request) {
         Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
-        List<?> sectionList = toolUtils.getSectionList(request);
+        List<Integer> sectionList = toolUtils.getSectionList(request);
         LampPoleInfoVO lampPoleDevCount = null;
         if (sectionList == null || sectionList.size() == 0){
             lampPoleDevCount = new LampPoleInfoVO();
@@ -136,7 +136,7 @@ public class BasePlatformController {
     public BaseResult<?> lampPoleData(HttpServletRequest request) {
         Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
         String username = (String) toolUtils.getRequestContent(request, "username", 2);
-        List<?> sectionList = toolUtils.getSectionList(request);
+        List<Integer> sectionList = toolUtils.getSectionList(request);
         LampPoleInfoVO lampPoleDevCount = null;
         if (sectionList == null || sectionList.size() == 0){
             lampPoleDevCount = new LampPoleInfoVO();

+ 65 - 0
src/main/java/com/welampiot/controller/ServoClickController.java

@@ -0,0 +1,65 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dto.ServoClickDTO;
+import com.welampiot.service.ServoClickService;
+import com.welampiot.utils.ServoClick;
+import com.welampiot.vo.ServoClickVO;
+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("/servoClick")
+public class ServoClickController extends BaseController {
+    @Autowired
+    private ServoClickService servoClickService;
+
+    // 获取设备列表
+    @RequestMapping(value = "/getList", method = RequestMethod.POST)
+    private BaseResult<?> getSceneList(ServoClickVO servoClickVO) {
+        Integer version = servoClickVO.getVersion();
+        List<Integer> sectionList = getSectionList(servoClickVO.getUsername());
+        servoClickVO.setSectionList(sectionList);
+        servoClickVO.setPageAndCount(servoClickVO.getPage(), servoClickVO.getCount());
+        List<ServoClickDTO> servoClickListByVO = servoClickService.getServoClickListByVO(servoClickVO);
+        Integer total = servoClickService.getServoClickTotalByVO(servoClickVO);
+        ServoClickVO servoClickVO1 = new ServoClickVO();
+        servoClickVO1.setTotal(total);
+        servoClickVO1.setList(servoClickListByVO);
+        servoClickVO1.setControlType(null);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, servoClickVO1);
+    }
+
+    // 获取设备详情
+    @RequestMapping(value = "/details", method = RequestMethod.POST)
+    private BaseResult<?> details(ServoClickVO servoClickVO) {
+        Integer version = servoClickVO.getVersion();
+        if (servoClickVO.getId() == null || servoClickVO.getId() == 0) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        ServoClickDTO servoClickDetailsById = servoClickService.getServoClickDetailsById(servoClickVO.getId());
+        if (servoClickDetailsById == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, servoClickDetailsById);
+    }
+
+    // 设备控制
+    @RequestMapping(value = "/deviceControl", method = RequestMethod.POST)
+    private BaseResult<?> deviceControl(ServoClickVO servoClickVO) {
+        Integer version = servoClickVO.getVersion();
+        if (servoClickVO.getId() == null || servoClickVO.getId() == 0 || servoClickVO.getControlType() == 0) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+
+        ServoClickDTO servoClickDetailsById = servoClickService.getServoClickDetailsById(servoClickVO.getId());
+        if (servoClickDetailsById == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        boolean b = ServoClick.deviceControl(servoClickDetailsById, servoClickVO.getControlType());
+        if (b){
+            return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version);
+        }else {
+            return toolUtils.response(InterfaceResultEnum.COMMAND_FAIL, version);
+        }
+    }
+}

+ 13 - 0
src/main/java/com/welampiot/dao/ServoClickDao.java

@@ -0,0 +1,13 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.ServoClickDTO;
+import com.welampiot.vo.ServoClickVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ServoClickDao {
+    List<ServoClickDTO> getServoClickListByVO(ServoClickVO servoClickVO);
+    Integer getServoClickTotalByVO(ServoClickVO servoClickVO);
+    ServoClickDTO getServoClickDetailsById(@Param("id")Integer id);
+}

+ 2 - 2
src/main/java/com/welampiot/dto/GlobalLocationDTO.java

@@ -48,9 +48,9 @@ public class GlobalLocationDTO implements Serializable {
 
     private Integer timeType;//时区类型
 
-    private Float longitude;//经度
+    private Double longitude;//经度
 
-    private Float latitude;//纬度
+    private Double latitude;//纬度
 
     private String name;
     private String name1;

+ 18 - 3
src/main/java/com/welampiot/dto/LampInfoDTO.java

@@ -1,8 +1,11 @@
 package com.welampiot.dto;
 
+import com.welampiot.common.LampControlTypeEnum;
 import lombok.Data;
+import org.apache.poi.ss.formula.functions.T;
 
 import java.util.List;
+import java.util.Objects;
 
 @Data
 public class LampInfoDTO {
@@ -18,7 +21,7 @@ public class LampInfoDTO {
     private String section;
     private Integer sectionId;
     private Integer timezone;
-    private Integer lighteness;
+    private Object lighteness;
     private Integer status;
     private Float gridVolt;
     private Float gridCurr;
@@ -62,8 +65,8 @@ public class LampInfoDTO {
     private Integer bindStatus;
     private Integer policyType;
     private Integer policyId;
-    private Float longitude;
-    private Float latitude;
+    private Double longitude;
+    private Double latitude;
     private Integer newFaultStatus;
     private String installDate;
     private String expirationDate;
@@ -115,6 +118,18 @@ public class LampInfoDTO {
     private String deviceId;
     public LampInfoDTO(){
     }
+    /**
+     * 判断灯控是否为双灯
+     * @return
+     */
+    public boolean isDbLamp(){
+        for (LampControlTypeEnum em :LampControlTypeEnum.values()) {
+            if (Objects.equals(em.getId(), this.controlType)){
+                return em.getIsDb();
+            }
+        }
+        return false;
+    }
     public LampInfoDTO(Integer id){
         this.id = id;
     }

+ 19 - 0
src/main/java/com/welampiot/dto/ServoClickDTO.java

@@ -0,0 +1,19 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+@Data
+public class ServoClickDTO {
+    private Integer id;
+    private String address; // 灯杆id
+    private String name; // 设备名称
+    private Integer online;  // 设备地址
+    private Integer serialPort; // 串口(0 3号串口,1 2号串口,2 1号串口)
+    private Integer lampPoleId; // 在线状态(0 离线,1 在线)
+    private String createTime; // 创建时间
+    private String installDate; // 安装时间
+    private String expirationDate; // 过期时间
+    private String cloudAddress;  // 云盒 序列号IMEI
+    private Integer cloudModel; // 云盒 型号(0 WE-GW-G100,1 WE-GW-G200,2 WE-GW-G40,3 WE-GW-G300,4 WE-XA-G20(云盒加4G双控设备),5 WE-GW-G260,6 WE-GW-G600)
+
+}

+ 13 - 0
src/main/java/com/welampiot/service/ServoClickService.java

@@ -0,0 +1,13 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.ServoClickDTO;
+import com.welampiot.vo.ServoClickVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ServoClickService {
+    List<ServoClickDTO> getServoClickListByVO(ServoClickVO servoClickVO);
+    Integer getServoClickTotalByVO(ServoClickVO servoClickVO);
+    ServoClickDTO getServoClickDetailsById(Integer id);
+}

+ 30 - 0
src/main/java/com/welampiot/service/impl/ServoClickServiceImpl.java

@@ -0,0 +1,30 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.ServoClickDao;
+import com.welampiot.dto.ServoClickDTO;
+import com.welampiot.service.ServoClickService;
+import com.welampiot.vo.ServoClickVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ServoClickServiceImpl implements ServoClickService {
+    @Autowired
+    private ServoClickDao servoClickDao;
+    @Override
+    public List<ServoClickDTO> getServoClickListByVO(ServoClickVO servoClickVO) {
+        return servoClickDao.getServoClickListByVO(servoClickVO);
+    }
+
+    @Override
+    public Integer getServoClickTotalByVO(ServoClickVO servoClickVO) {
+        return servoClickDao.getServoClickTotalByVO(servoClickVO);
+    }
+
+    @Override
+    public ServoClickDTO getServoClickDetailsById(Integer id) {
+        return servoClickDao.getServoClickDetailsById(id);
+    }
+}

+ 55 - 0
src/main/java/com/welampiot/utils/ServoClick.java

@@ -0,0 +1,55 @@
+package com.welampiot.utils;
+
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dto.ServoClickDTO;
+
+public class ServoClick {
+    public static String transIn = "/TransIn/";
+    public static String transOut = "/TransOut/";
+
+    public static String wage1 = "/WEGW";
+    public static String wage2 = "/WEGW2";
+    public static String wage3 = "/WEGW3";
+
+    /**
+     * 伺服控制
+     * @param servoClickDTO  伺服
+     * @param controlType 控制类型
+     * @return
+     */
+    public static boolean deviceControl(ServoClickDTO servoClickDTO,Integer controlType){
+
+        String sendTopic = "";
+        String backTopic = "";
+
+        if (servoClickDTO.getCloudModel() == 0){
+            sendTopic += wage1;
+        } else if (servoClickDTO.getCloudModel() == 1) {
+            sendTopic += wage2;
+        }else {
+            sendTopic += wage3;
+        }
+
+        sendTopic += transIn;
+        backTopic += transOut;
+
+        sendTopic += servoClickDTO.getCloudAddress();
+        backTopic += servoClickDTO.getCloudAddress();
+
+        String cmd = "";
+        if (controlType == 1){  // 一键上升
+            cmd = "0106092e00012b9f";
+        } else if (controlType == 2) {  // 一键下降
+            cmd = "0106092f00017a5f";
+        } else if (controlType == 3) {  // 步数上升
+            cmd = "0106093000014b99";
+        } else if (controlType == 4) {  // 步数下降
+            cmd = "0106093100011a59";
+        }else {
+            return false;
+        }
+
+        String s = ToolUtils.sendMqttCmdInfo(sendTopic, "0232"+cmd, backTopic);
+        return !s.isEmpty();
+    }
+}

+ 66 - 0
src/main/java/com/welampiot/utils/WebUtils.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.welampiot.configuration.ScreenConfig;
 import com.welampiot.dto.SystemConfigDto;
+import com.welampiot.dto.UserDTO;
 import com.welampiot.service.OperationLogService;
 import com.welampiot.service.SystemConfigService;
 import lombok.extern.slf4j.Slf4j;
@@ -13,6 +14,7 @@ import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.springframework.data.redis.core.StringRedisTemplate;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedReader;
@@ -26,6 +28,7 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
+import java.time.Duration;
 import java.util.*;
 
 @Slf4j
@@ -221,4 +224,67 @@ public class WebUtils
         BigDecimal two1 = new BigDecimal(n);
         return two1.setScale(c, RoundingMode.HALF_UP).doubleValue();
     }
+
+    /**
+     * 获取用户token
+     * @param userDTO
+     * @return
+     */
+    public static String getToken(UserDTO userDTO){
+        long timeMillis = System.currentTimeMillis();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String createTime = format.format(timeMillis);
+        return MD5Utils.encoderMD5(userDTO.getUsername()+userDTO.getPassword()+createTime+"64377%>~%¥%WeClouds");
+    }
+
+    /**
+     * 获取用户token
+     * @param userDTO
+     * @return
+     */
+    public static String getToken(UserDTO userDTO, StringRedisTemplate template){
+        String key = userDTO.getUsername()+"-status";
+
+        String token = "";
+        if (Boolean.TRUE.equals(template.hasKey(key))){
+            token = template.opsForValue().get(key);
+            template.expire(key, Duration.ofSeconds(2*3600));
+            template.expire(token,Duration.ofSeconds(2*3600+5));
+            System.out.println(token);
+        }else {
+            String nowTime = getNowTime();
+            token = MD5Utils.encoderMD5(userDTO.getUsername()+userDTO.getPassword()+nowTime);
+            template.opsForValue().set(key,token,Duration.ofSeconds(2*3600));
+            template.opsForValue().set(token,userDTO.getUsername(),Duration.ofSeconds(2*3600+5));
+        }
+        return token;
+    }
+
+    /**
+     * 获取当前时间
+     * @return 当前时间
+     */
+    public static String getNowTime() {
+        String createTime;
+        long timeMillis = System.currentTimeMillis();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        createTime = format.format(timeMillis);
+        return createTime;
+    }
+
+    /**
+     * 获取对应时区的时间
+     * @return 时间
+     */
+    public static String getTimeByTimezone(String time,Integer timezone) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            Date parse = format.parse(time);
+            long timeMillis = parse.getTime() + timezone*3600*1000;
+            String createTime = format.format(timeMillis);
+            return createTime;
+        }catch (Exception e){
+            return "";
+        }
+    }
 }

+ 81 - 0
src/main/java/com/welampiot/utils/lamp/WeLamp4G.java

@@ -0,0 +1,81 @@
+package com.welampiot.utils.lamp;
+
+import com.welampiot.utils.ToolUtils;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * 4G 控制器工具类
+ */
+@Component
+public class WeLamp4G {
+
+    public static String transIn = "/Lamp/TransIn/";
+    public static String transOut = "/Lamp/TransOut/";
+    /**
+     * 灯控调光
+     * @param address 灯控地址
+     * @param light 亮度值 0-100
+     * @param mode 通道值 0 A灯,1 B灯
+     * @return
+     */
+    public static boolean dimming(String address,Integer light,Integer mode){
+        String sendTopic = transIn+address;
+        String backTopic = transOut+address;
+        String cmd;
+        if (mode == 0){  // A 路
+            cmd = "0106DF0A";
+        }else {  // B 路
+            cmd = "0106DF0C";
+        }
+        String lightStr = "0000"+Integer.toHexString(light).toString();
+        lightStr = lightStr.substring(-4);
+        cmd += lightStr;
+        cmd += getCRC(cmd.getBytes());
+        String s = ToolUtils.sendMqttCmdInfo(sendTopic, "0232"+cmd, backTopic);
+        if (s.isEmpty()){
+            return false;
+        }else {
+            return true;
+        }
+    }
+    /**
+     * 计算modbus CRC16校验码
+     * @param bytes 需要计算的数据
+     * @return
+     */
+    public static String getCRC(byte[] bytes) {
+        // CRC寄存器全为1
+        int CRC = 0x0000ffff;
+        // 多项式校验值
+        int POLYNOMIAL = 0x0000a001;
+        int i, j;
+        for (i = 0; i < bytes.length; i++) {
+            CRC ^= ((int) bytes[i] & 0x000000ff);
+            for (j = 0; j < 8; j++) {
+                if ((CRC & 0x00000001) != 0) {
+                    CRC >>= 1;
+                    CRC ^= POLYNOMIAL;
+                } else {
+                    CRC >>= 1;
+                }
+            }
+        }
+        // 结果转换为16进制
+        String result = Integer.toHexString(CRC).toUpperCase();
+        if (result.length() != 4) {
+            StringBuffer sb = new StringBuffer("0000");
+            result = sb.replace(4 - result.length(), 4, result).toString();
+        }
+        //高位在前地位在后
+        //return result.substring(2, 4) + " " + result.substring(0, 2);
+        // 交换高低位,低位在前高位在后
+        return result.substring(2, 4)+result.substring(0, 2);
+    }
+}

+ 2 - 2
src/main/java/com/welampiot/vo/LampPoleVO.java

@@ -33,8 +33,8 @@ public class LampPoleVO implements Serializable {
     private Integer offset;
     private Map cloudBox; // 云盒
     private Integer createId;
-    private Float longitude;
-    private Float latitude;
+    private Double longitude;
+    private Double latitude;
     private Integer deviceCount; // 设备总数
     private Integer runCount; // 运行数
     private Integer faultCount; // 故障数

+ 14 - 0
src/main/java/com/welampiot/vo/ServoClickVO.java

@@ -0,0 +1,14 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.ServoClickDTO;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ServoClickVO extends BaseVO{
+    private Integer id;
+    private List<ServoClickDTO> list;
+    private Integer total;
+    private Integer controlType = 0;  // 设备控制类型 (1 一键上升,2 一键下级,3 步数上升,4 步数下级)
+}

+ 47 - 0
src/main/resources/mapper/ServoClickMapper.xml

@@ -0,0 +1,47 @@
+<?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.ServoClickDao">
+
+    <select id="getServoClickListByVO" resultType="ServoClickDTO">
+        select a.online,a.name,a.address,a.id
+        from servo_click a
+        left join lamp_pole b on a.lamp_pole_id = b.id
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and b.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and b.sectionid = #{sectionId}
+        </if>
+        <if test="page >= 0 and count > 0">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <select id="getServoClickTotalByVO" resultType="int">
+        select count(*)
+        from servo_click a
+        left join lamp_pole b on a.lamp_pole_id = b.id
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and b.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and b.sectionid = #{sectionId}
+        </if>
+    </select>
+
+    <select id="getServoClickDetailsById" resultType="ServoClickDTO">
+        select a.online,a.name,a.address,a.id,a.lamp_pole_id as lampPoleId,a.serial_port as serialPort,
+        a.expiration_date as expirationDate,a.install_date as installDate,b.num as cloudAddress,b.model as cloudModel
+        from servo_click a
+        left join wifi b on a.lamp_pole_id = b.lamp_pole_id
+        where a.id=#{id}
+    </select>
+</mapper>