Bläddra i källkod

三种plc的调光,ase128位的加密,hmac-md5加密32位,http的网络请求

weclouds 2 år sedan
förälder
incheckning
25617003f8

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

@@ -191,6 +191,17 @@ public enum InterfaceResultEnum {
     LACK_LOCATION_INFO_ERROR("0380","请填写位置信息","Please fill in the location information","Пожалуйста, заполните анкету"),
     CONTROL_TYPE_ERROR("0381","控制器类型错误","Controller type error","Ошибка типа контроллера"),
     DEVICE_EXISTS_ERROR("0382","设备不存在","Device does not exist","Оборудования не существует"),
+    PLC_CALL_ERROR("0382","无此调用方","There is no such caller","без этого вызова"),
+    PLC_KEY_ERROR("0383","密钥错误","Key error","ошибка ключа"),
+    PLC_token_ERROR("0384","密钥错误","Failed to get token","Ошибка получения маркера"),
+    USER_EXISTS_ERROR("0385","用户不存在","User does not exist","пользователь не существует"),
+    USER_DISABLED_ERROR("0386","该用户已被禁用","The user has been disabled","Пользователь был запрещен"),
+    USER_LOGIN_ERROR("0387","登录失败","Login failed","Ошибка регистрации"),
+    LACK_UNKNOWN_ERROR("0388","未知错误","unknown error","Неизвестная ошибка"),
+    INVALID_TOKEN_ERROR("0389","无效的令牌","Invalid token","Неверный маркер"),
+    DEVICE_OFFLINE_ERROR("0390","设备已离线","Device is offline","Оборудование отключено"),
+    DEVICE_TIMEOUT_ERROR("0391","控制超时","Control timeout","Контроль за превышением времени"),
+    DEVICE_CONNECTED_ERROR("0392","设备连接异常","Abnormal device connection","Необычное подключение оборудования"),
     ;
     private String code;
     private String msgCn;

+ 16 - 0
src/main/java/com/welampiot/configuration/BaseMqttConfig.java

@@ -0,0 +1,16 @@
+package com.welampiot.configuration;
+
+import lombok.Data;
+import org.springframework.stereotype.Component;
+
+@Component
+@Data
+public class BaseMqttConfig {
+    protected String url;
+    protected String clientId;
+    protected String topics;
+    protected String username;
+    protected String password;
+    protected int timeout;
+    protected int keepalive;
+}

+ 51 - 51
src/main/java/com/welampiot/configuration/MqttConfig.java

@@ -5,55 +5,55 @@ import org.springframework.stereotype.Component;
 
 @Component
 @ConfigurationProperties(prefix = "welampiot.mqtt")
-public class MqttConfig {
-    private String url;
-    private String clientId;
-    private String topics;
-    private String username;
-    private String password;
-    private int timeout;
-    private int keepalive;
-
-    public String getUrl() {
-        return url;
-    }
-    public void setUrl(String url) {
-        this.url = url;
-    }
-    public String getUsername() {
-        return username;
-    }
-    public void setUsername(String username) {
-        this.username = username;
-    }
-    public String getPassword() {
-        return password;
-    }
-    public void setPassword(String password) {
-        this.password = password;
-    }
-    public String getClientId() {
-        return clientId;
-    }
-    public void setClientId(String clientId) {
-        this.clientId = clientId;
-    }
-    public String getTopics() {
-        return topics;
-    }
-    public void setTopics(String topics) {
-        this.topics = topics;
-    }
-    public int getTimeout() {
-        return timeout;
-    }
-    public void setTimeout(int timeout) {
-        this.timeout = timeout;
-    }
-    public int getKeepalive() {
-        return keepalive;
-    }
-    public void setKeepalive(int keepalive) {
-        this.keepalive = keepalive;
-    }
+public class MqttConfig extends BaseMqttConfig{
+//    private String url;
+//    private String clientId;
+//    private String topics;
+//    private String username;
+//    private String password;
+//    private int timeout;
+//    private int keepalive;
+//
+//    public String getUrl() {
+//        return url;
+//    }
+//    public void setUrl(String url) {
+//        this.url = url;
+//    }
+//    public String getUsername() {
+//        return username;
+//    }
+//    public void setUsername(String username) {
+//        this.username = username;
+//    }
+//    public String getPassword() {
+//        return password;
+//    }
+//    public void setPassword(String password) {
+//        this.password = password;
+//    }
+//    public String getClientId() {
+//        return clientId;
+//    }
+//    public void setClientId(String clientId) {
+//        this.clientId = clientId;
+//    }
+//    public String getTopics() {
+//        return topics;
+//    }
+//    public void setTopics(String topics) {
+//        this.topics = topics;
+//    }
+//    public int getTimeout() {
+//        return timeout;
+//    }
+//    public void setTimeout(int timeout) {
+//        this.timeout = timeout;
+//    }
+//    public int getKeepalive() {
+//        return keepalive;
+//    }
+//    public void setKeepalive(int keepalive) {
+//        this.keepalive = keepalive;
+//    }
 }

+ 10 - 0
src/main/java/com/welampiot/configuration/PlcMqttConfig.java

@@ -0,0 +1,10 @@
+package com.welampiot.configuration;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "plc.mqtt")
+public class PlcMqttConfig extends BaseMqttConfig{
+}

+ 14 - 0
src/main/java/com/welampiot/configuration/QuHuiPlc.java

@@ -0,0 +1,14 @@
+package com.welampiot.configuration;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "qihui.plc")
+@Data
+public class QuHuiPlc {
+    private String url;
+    private String clientId;
+    private String clientSecret;
+}

+ 20 - 0
src/main/java/com/welampiot/configuration/ZhongLightPlc.java

@@ -0,0 +1,20 @@
+package com.welampiot.configuration;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@Data
+@ConfigurationProperties(prefix = "zhonglight.plc")
+public class ZhongLightPlc {
+    private String zhongUrl;
+    private String operatorID;
+    private String operatorSecret;
+    private String sigSecret;
+    private String encryptKey;
+    private String iv;
+    private String zhongUserName;
+    private String zhongPassword;
+
+}

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 493 - 9
src/main/java/com/welampiot/controller/LampController.java


+ 6 - 0
src/main/java/com/welampiot/dto/LampInfoDTO.java

@@ -99,8 +99,14 @@ public class LampInfoDTO {
     private Integer devType;
     private String endDate;
     private Integer total;
+    private String lampCtrId;
     private List<Object> updateTimeList;
     private List<Object> dateList; // 日期列表
     private List<Object> energyList; // 用电量列表
     private List<Object> powerSaveList; // 省电量列表
+    public LampInfoDTO(){
+    }
+    public LampInfoDTO(Integer id){
+        this.id = id;
+    }
 }

+ 83 - 0
src/main/java/com/welampiot/utils/AESUtils.java

@@ -0,0 +1,83 @@
+package com.welampiot.utils;
+
+import org.apache.shiro.codec.Hex;
+import org.springframework.stereotype.Component;
+
+import javax.crypto.Cipher;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
+
+import sun.misc.BASE64Decoder;  //要java1.8
+import sun.misc.BASE64Encoder;
+
+
+@Component
+public class AESUtils {
+    /** 字符集名称 **/
+    public static final String charsetName = "utf-8";
+    /** 算法 **/
+    public static final String algorithm  = "AES";
+    /** 算法/模式/补码方式 **/
+    public static final String transformation  = "AES/CBC/PKCS5Padding";
+
+    /**
+     * 加密
+     * @param encryptKey 消息秘钥,AES加密密钥
+     * @param iv 秘钥初始化向量(偏移量)
+     * @param content 要加密的内容
+     * @return 返回base64编码的String
+     * @throws Exception
+     */
+    public static String encrypt(String encryptKey, String iv, String content) throws Exception {
+        byte[] raw = encryptKey.getBytes(charsetName);
+        SecretKeySpec skeySpec = new SecretKeySpec(raw, algorithm);
+        Cipher cipher = Cipher.getInstance(transformation);
+        IvParameterSpec ips = new IvParameterSpec(iv.getBytes());
+        cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ips);
+        byte[] encrypted = cipher.doFinal(content.getBytes());
+        return new BASE64Encoder().encode(encrypted);
+    }
+
+    /**
+     * 解密
+     * @param encryptKey 消息秘钥
+     * @param iv 秘钥初始化向量
+     * @param content 要解密的内容
+     * @return 返回原文
+     * @throws Exception
+     */
+    public static String decrypt(String encryptKey, String iv, String content) throws Exception {
+        byte[] raw = encryptKey.getBytes(charsetName);
+        SecretKeySpec skeySpec = new SecretKeySpec(raw, algorithm);
+        Cipher cipher = Cipher.getInstance(transformation);
+        IvParameterSpec ips = new IvParameterSpec(iv.getBytes());
+        cipher.init(Cipher.DECRYPT_MODE, skeySpec, ips);
+        byte[] encrypted1 = new BASE64Decoder().decodeBuffer(content);
+        byte[] original = cipher.doFinal(encrypted1);
+        String originalString = new String(original);
+        return originalString;
+    }
+
+
+    /**
+     * 生成32位HmacMD5加密数据
+     * @param data
+     * @param key
+     * @return
+     * @throws Exception
+     */
+    public static String encodeHmacMD5(byte[] data, byte[] key)throws Exception {
+        // 还原密钥
+        SecretKey secretKey = new SecretKeySpec(key, "HmacMD5");
+        // 实例化Mac
+        Mac mac = Mac.getInstance(secretKey.getAlgorithm());
+        // 初始化mac
+        mac.init(secretKey);
+        // 执行消息摘要
+        byte[] digest = mac.doFinal(data);
+        return new HexBinaryAdapter().marshal(digest);// 转为十六进制的字符串
+    }
+}

+ 260 - 2
src/main/java/com/welampiot/utils/ToolUtils.java

@@ -1,11 +1,14 @@
 package com.welampiot.utils;
 
+import com.alibaba.druid.support.json.JSONUtils;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.welampiot.common.BaseResult;
 import com.welampiot.common.DevInfoEnum;
 import com.welampiot.common.InterfaceResultEnum;
 import com.welampiot.common.LampControlTypeEnum;
 import com.welampiot.configuration.MqttConfig;
+import com.welampiot.configuration.PlcMqttConfig;
 import com.welampiot.dto.*;
 import com.welampiot.handle.MqttHandler;
 import com.welampiot.service.GlobalLocationService;
@@ -15,6 +18,7 @@ import com.welampiot.service.UserService;
 import com.welampiot.vo.DevEnumVO;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.poi.ss.formula.functions.T;
 import org.eclipse.paho.client.mqttv3.MqttClient;
 import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
 import org.eclipse.paho.client.mqttv3.MqttMessage;
@@ -29,8 +33,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
+import java.io.*;
 import java.lang.reflect.Field;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.text.DecimalFormat;
@@ -53,7 +59,8 @@ public class ToolUtils {
     private MqttHandler mqttHandler;
     @Autowired
     private LampPoleService lampPoleService;
-
+    @Autowired
+    private PlcMqttConfig plcMqttConfig;
     private static final String PATTERN = "^(?=.*[0-9])(?=.*[a-zA-Z]).{8,20}$";
     private static final String PATTERN_PHONE = "^1[3-9]\\d{9}$";
     private static final String PATTERN_EMAIL = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$";
@@ -326,6 +333,167 @@ public class ToolUtils {
         return res;
     }
 
+    /**
+     * 发送mqtt指令
+     * @param sendTopic  发送的topic
+     * @param cmdInfo   发送的指令内容
+     * @param resTopic  接收指令返回的topic
+     * @return
+     */
+    public String plcSendMqttCmd(String sendTopic,Object cmdInfo,String resTopic){
+        MqttClient client;
+        String res = "";
+
+        try {
+            try {
+                client=new MqttClient(plcMqttConfig.getUrl(),plcMqttConfig.getClientId()+"_"+(new Date()).getTime(),new MemoryPersistence());
+                MqttConnectOptions options=new MqttConnectOptions();
+                options.setCleanSession(true);
+                options.setUserName(plcMqttConfig.getUsername());
+                options.setPassword(plcMqttConfig.getPassword().toCharArray());
+                options.setConnectionTimeout(plcMqttConfig.getTimeout());
+                options.setKeepAliveInterval(plcMqttConfig.getKeepalive());
+                mqttHandler.setTopic(resTopic);
+
+                // 设置回调
+                client.setCallback(mqttHandler);
+
+                // 建立连接
+                client.connect(options);
+                //            MqttCustomerClient.setClient(client);
+                client.subscribe(resTopic);
+
+                // 消息发布所需参数
+                MqttMessage message;
+                if (cmdInfo instanceof String){
+                    message = new MqttMessage(((String) cmdInfo).getBytes());
+                }else {
+                    message = new MqttMessage((byte[]) cmdInfo);
+                }
+                message.setQos(0);
+                client.publish(sendTopic, message);
+                int in = 0;
+
+                while (true){
+                    Thread.sleep(1000);
+                    if (mqttHandler.getRes() != null && mqttHandler.getRes().length() != 0){
+                        res = mqttHandler.getRes();
+                        break;
+                    }
+                    in ++;
+                    if (in > 30) break;
+                }
+                client.disconnect();
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return res;
+    }
+
+    /**
+     * 发送mqtt指令
+     * @param sendTopic  发送的topic
+     * @param cmdInfo   发送的指令内容
+     * @param resTopic  接收指令返回的topic
+     * @param timeout  指令超时时间
+     * @return
+     */
+    public String plcSendMqttCmd(String sendTopic,String cmdInfo, String resTopic, Integer timeout){
+        MqttClient client;
+        String res = "";
+
+        try {
+            try {
+                client=new MqttClient(plcMqttConfig.getUrl(),plcMqttConfig.getClientId()+"_"+(new Date()).getTime(),new MemoryPersistence());
+                MqttConnectOptions options=new MqttConnectOptions();
+                options.setCleanSession(true);
+                options.setUserName(plcMqttConfig.getUsername());
+                options.setPassword(plcMqttConfig.getPassword().toCharArray());
+                options.setConnectionTimeout(plcMqttConfig.getTimeout());
+                options.setKeepAliveInterval(plcMqttConfig.getKeepalive());
+                mqttHandler.setTopic(resTopic);
+
+                // 设置回调
+                client.setCallback(mqttHandler);
+
+                // 建立连接
+                client.connect(options);
+                //            MqttCustomerClient.setClient(client);
+                client.subscribe(resTopic);
+
+                // 消息发布所需参数
+                MqttMessage message;
+                message = new MqttMessage(cmdInfo.getBytes());
+                message.setQos(0);
+                client.publish(sendTopic, message);
+                System.out.println("==send:"+sendTopic+"====res:"+resTopic);
+                int in = 0;
+                if (timeout > 0){
+                    while (true){
+                        System.out.println("==d====:"+in+"====");
+                        Thread.sleep(100);
+                        if (mqttHandler.getRes() != null && mqttHandler.getRes().length() != 0){
+                            res = mqttHandler.getRes();
+System.out.println(res);
+                            //原来的
+                            JSONObject oldObject = JSON.parseObject(cmdInfo);
+                            String oldDataType = oldObject.getObject("dataType", String.class);
+//                            String[] oldThirdIdArr = oldObject.getObject("thirdId",String.class).split("-");
+//                            String[] oldSnArr = oldThirdIdArr[0].split(":");
+//                            String oldSn = oldSnArr[1]; //设备地址
+//                            String[] oldNumberArr = oldThirdIdArr[1].split(":");
+//                            int oldNum = Integer.parseInt(oldNumberArr[1]); //设备灯序号
+                            //解析json
+                            JSONObject jsonObject = JSON.parseObject(res);
+                           String dataType = jsonObject.getObject("dataType", String.class);
+//                            String[] thirdIdArr = jsonObject.getObject("thirdId",String.class).split("-");
+//                            String[] snArr = thirdIdArr[0].split(":");
+//                            String sn = snArr[1]; //设备地址
+//                            String[] numberArr = thirdIdArr[1].split(":");
+//                            int num = Integer.parseInt(numberArr[1]); //设备灯序号
+
+                            //它是字符串
+                            if (dataType.equals("lightStatus") ){ //1.读取灯信息,2.调光的
+                                //原来的
+                                String[] oldThirdIdArr = oldObject.getObject("thirdId",String.class).split("-");
+                                String[] oldSnArr = oldThirdIdArr[0].split(":");
+                                String oldSn = oldSnArr[1]; //设备地址
+                                String[] oldNumberArr = oldThirdIdArr[1].split(":");
+                                int oldNum = Integer.parseInt(oldNumberArr[1]); //设备灯序号
+                                //解析json
+                                String[] thirdIdArr = jsonObject.getObject("thirdId",String.class).split("-");
+                                String[] snArr = thirdIdArr[0].split(":");
+                                String sn = snArr[1]; //设备地址
+                                String[] numberArr = thirdIdArr[1].split(":");
+                                int num = Integer.parseInt(numberArr[1]); //设备灯序号
+                                //类型相等
+                                System.out.println("====ddd:"+oldSn+"====sn:"+sn+"====ol:"+oldNum+"==nu:"+num);
+                                if ((oldDataType.equals("lightStatus") || oldDataType.equals("adjustLightController")) && oldSn.equals(sn) && (oldNum == num)){
+                                    //查看灯的信息
+                                    System.out.println("====ddd:"+res);
+                                    return res;
+                                }
+                            }
+
+                        }
+                        in ++;
+                        if (in > timeout) return null;
+                    }
+                }
+                client.disconnect();
+            }catch (Exception e){
+                System.out.println("==dd=="+e);
+                e.printStackTrace();
+            }
+        }catch (Exception e){
+            System.out.println(e);
+            e.printStackTrace();
+        }
+        return null;
+    }
     /**
      * 字节数组转16进制字符串
      * @param b 字节数组
@@ -895,4 +1063,94 @@ public class ToolUtils {
         }
         return protocolTypeStr;
     }
+
+    /* 向第三方请求post
+     *@param  request:请求方式
+     * @param  url:路径
+     * @param param:参数
+     * @return 返回类型字符串
+    */
+    public  String sendHttp(String request,String url, String param,Integer timeOut) throws IOException {
+        String result = "";
+        URL postUrl = new URL(url);
+        // 打开连接
+        HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();
+        // 设置是否向connection输出,因为这个是post请求,参数要放在
+        // http正文内,因此需要设为true
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+        // Set the post method. Default is GET
+        connection.setRequestMethod(request.toUpperCase());
+        // Post 请求不能使用缓存
+        connection.setUseCaches(false);
+        // URLConnection.setInstanceFollowRedirects是成员函数,仅作用于当前函数
+        connection.setInstanceFollowRedirects(true);
+        // 进行编码
+        connection.setRequestProperty("Content-Type","application/json;charset=utf-8");
+        // 连接,从postUrl.openConnection()至此的配置必须要在connect之前完成,
+        // 要注意的是connection.getOutputStream会隐含的进行connect。
+        connection.connect();
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        // 正文,正文内容其实跟get的URL中'?'后的参数字符串一致
+        // DataOutputStream.writeBytes将字符串中的16位的unicode字符以8位的字符形式写道流里面
+        out.writeBytes(param);
+        out.flush();
+        out.close(); // flush and close
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+                connection.getInputStream()));
+        String line;
+        while ((line = reader.readLine()) != null) {
+            result += line;
+        }
+        reader.close();
+        connection.disconnect();
+        return result;
+    }
+
+    /* 向第三方请求post
+     *@param  request:请求方式
+     * @param  url:路径
+     * @param param:参数
+     * @return 返回类型字符串
+     */
+    public  String sendHttp(String request,String url, String param,String token,String sessionId,Integer timeOut) throws IOException {
+        String result = "";
+        URL postUrl = new URL(url);
+        // 打开连接
+        HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();
+        // 设置是否向connection输出,因为这个是post请求,参数要放在
+        // http正文内,因此需要设为true
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+        // Set the post method. Default is GET
+        connection.setRequestMethod(request.toUpperCase());
+        // Post 请求不能使用缓存
+        connection.setUseCaches(false);
+        // URLConnection.setInstanceFollowRedirects是成员函数,仅作用于当前函数
+        connection.setInstanceFollowRedirects(true);
+        // 进行编码
+        connection.setRequestProperty("Content-Type","application/json;charset=utf-8");
+        connection.setRequestProperty("Authorization","Bearer "+token);
+        if (sessionId != null){
+            connection.setRequestProperty("SessionId"," "+sessionId);
+        }
+        // 连接,从postUrl.openConnection()至此的配置必须要在connect之前完成,
+        // 要注意的是connection.getOutputStream会隐含的进行connect。
+        connection.connect();
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        // 正文,正文内容其实跟get的URL中'?'后的参数字符串一致
+        // DataOutputStream.writeBytes将字符串中的16位的unicode字符以8位的字符形式写道流里面
+        out.writeBytes(param);
+        out.flush();
+        out.close(); // flush and close
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+                connection.getInputStream()));
+        String line;
+        while ((line = reader.readLine()) != null) {
+            result += line;
+        }
+        reader.close();
+        connection.disconnect();
+        return result;
+    }
 }

+ 16 - 0
src/main/java/com/welampiot/vo/ZhongLightPlcVO.java

@@ -0,0 +1,16 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+@Data
+public class ZhongLightPlcVO implements Serializable {
+    private String token;
+    private String projectId;
+    private String organizationId;
+    private String sessionId;
+    private String divisionId;
+    private Integer succCode;
+    private Integer errorCode;
+    private Integer times; //次数
+}

+ 5 - 4
src/main/resources/mapper/LampMapper.xml

@@ -209,7 +209,7 @@
         LI.gridPF,LI.used_energy_tonight as usedEnergyTonight,L.faultstatus as faultStatus,N.snr,N.rssi,AI.id as alarmId,
         AI.stralarmtype as alarmInfo,S.timezone,L.status as lampStatas,L.freqId,
         L.ratedpower as power,L.address as imei,N.simid,L.name,N.sw_version as solfVersion,
-        N.hw_version as hardVersion,L.install_date,L.expiration_date,L.mode
+        N.hw_version as hardVersion,L.install_date,L.expiration_date,L.mode,lamp_ctrl_id
         from lampinfo L
         left join section as S on S.id = L.sectionid
         left join global_location as GL on GL.id = S.pid
@@ -772,11 +772,12 @@
     >
         update lampinfo
         set
-        lighteness=#{light}
+        lighteness=#{lighteness}
         <if test="policyId != null">,policyid=#{policyId}</if>
         <if test="policyType != null">,policy_type=#{policyType}</if>
-        <if test="light > 0">,status=1</if>
-        <if test="light == 0">,status=0</if>
+        <if test="lighteness > 0">,status=1</if>
+        <if test="lighteness == 0">,status=0</if>
+        <if test="updateTime != null">,updatetime=#{updateTime}</if>
         where id = #{id}
     </update>
 

+ 29 - 0
src/main/resources/prod/application.yml

@@ -39,6 +39,35 @@ welampiot:
     password: admin
     timeout: 10
     keepalive: 20
+
+plc:
+  mqtt:
+    url: tcp://120.24.144.183:1883
+    clientId: plc_mqtt_client
+    topics: /#
+    username: gateway_plc
+    password: gwplc123456
+    timeout: 10
+    keepalive: 20
+
+qihui:
+  plc:
+    url: http://139.9.31.177:13389/openapi/
+    clientId: qh5ozm3DqD4DLJ5F
+    clientSecret: q1N1NFaMgiJXUGLM1fOVjWekcmsdyQ
+
+zhonglight: #中灯智慧科技(深圳)有限公司 zigbee
+  plc:
+    zhongUrl: http://www.cciot.top/app/
+    operatorID: MA5G0DCR3 #调用方标识符
+    operatorSecret: uGxdt8NP5DYY+qYD #调用方密钥
+    sigSecret: ikbgAEmjkVqpKzsg #签名密钥-md5
+    encryptKey: AoHh1WeNhNvjEaHr #AES加密密钥
+    iv: SH7SjuAuu3MbXs0v #AES初始向量(偏移量)
+    zhongUserName: zdzh1935 #用户名
+    zhongPassword: Zhld2021 #密码
+
+
 mybatis:
   mapper-locations: classpath:/mapper/*.xml
   check-config-location: true

+ 29 - 0
src/main/resources/test/application.yml

@@ -39,6 +39,35 @@ welampiot:
     password: admin
     timeout: 10
     keepalive: 20
+
+plc:  #力合微
+  mqtt:
+    url: tcp://120.24.144.183:1883
+    clientId: plc_mqtt_client
+    topics: /#
+    username: gateway_plc
+    password: gwplc123456
+    timeout: 10
+    keepalive: 20
+
+qihui: #广东启慧
+  plc:
+    url: http://139.9.31.177:13389/openapi/
+    clientId: qh5ozm3DqD4DLJ5F
+    clientSecret: q1N1NFaMgiJXUGLM1fOVjWekcmsdyQ
+
+zhonglight: #中灯智慧科技(深圳)有限公司 zigbee
+  plc:
+    zhongUrl: http://www.cciot.top/app/
+    operatorID: MA5G0DCR3 #调用方标识符
+    operatorSecret: uGxdt8NP5DYY+qYD #调用方密钥
+    sigSecret: ikbgAEmjkVqpKzsg #签名密钥-md5
+    encryptKey: AoHh1WeNhNvjEaHr #AES加密密钥
+    iv: SH7SjuAuu3MbXs0v #AES初始向量(偏移量)
+    zhongUserName: zdzh1935 #用户名
+    zhongPassword: Zhld2021 #密码
+
+
 mybatis:
   mapper-locations: classpath:/mapper/*.xml
   check-config-location: true